This repository has been archived by the owner on Mar 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Code refactoring #2
Open
simonoff
wants to merge
4
commits into
matiaskorhonen:master
Choose a base branch
from
natify:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--no-doc | ||
--no-style | ||
--style-measure 99 | ||
--abc-max 18 | ||
--style-exclude spec/**/* | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
*.gem | ||
.bundle | ||
Gemfile.lock | ||
*.lock | ||
pkg/* | ||
doc/* | ||
coverage/* | ||
coverage/* | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
--colour | ||
--color | ||
--format documentation | ||
--require spec_helper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
AllCops: | ||
Include: | ||
- '**/Rakefile' | ||
Exclude: | ||
- 'spec/**/*' | ||
Style/LineLength: | ||
Max: 99 | ||
Style/FileName: | ||
Enabled: false | ||
Style/ModuleFunction: | ||
Enabled: false | ||
Style/Encoding: | ||
Enabled: false | ||
Documentation: | ||
Enabled: false | ||
Style/MethodLength: | ||
Max: 15 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Rubocop addition should have probably gone into a separate PR… However, I guess I can pull it in with this PR regardless… Could you change the config so that the style matches my earlier style in the gem (the main issue being that double quotes are proffered over single quotes). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What the reason of using double quotes over single? Do you know why double quotes is bad? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,18 @@ | ||
script: "bundle exec rake spec" | ||
language: ruby | ||
rvm: | ||
- 1.9.3 | ||
- 2.1.1 | ||
- 2.0.0 | ||
- 2.1 | ||
- ruby-head | ||
- jruby-19mode | ||
- rbx | ||
notifications: | ||
disable: true | ||
- rbx-2 | ||
gemfile: | ||
- money-5.1.gemfile | ||
- money-6.0.gemfile | ||
- money-head.gemfile | ||
- gemfiles/money_6.1.gemfile | ||
- gemfiles/money_6.2.gemfile | ||
- gemfiles/money_head.gemfile | ||
matrix: | ||
allow_failures: | ||
- gemfile: gemfiles/money-head.gemfile | ||
exclude: | ||
- rvm: 1.9.3 | ||
gemfile: money-5.1.gemfile | ||
- rvm: jruby-19mode | ||
gemfile: money-5.1.gemfile | ||
- rvm: rbx | ||
gemfile: money-5.1.gemfile | ||
- rvm: 1.9.3 | ||
gemfile: money-head.gemfile | ||
- rvm: jruby-19mode | ||
gemfile: money-head.gemfile | ||
- rvm: rbx | ||
gemfile: money-head.gemfile | ||
- rvm: ruby-head | ||
bundler_args: --without local_development | ||
script: | ||
- mkdir tmp | ||
- bundle exec rake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
appraise "money-6.0" do | ||
gem "money", "~> 6.0.0" | ||
end | ||
|
||
appraise "money-6.1" do | ||
gem "money", "~> 6.1.0" | ||
end | ||
|
||
appraise "money-6.2" do | ||
gem "money", "~> 6.2.0" | ||
end | ||
|
||
appraise "money-head" do | ||
gem "money", github: "RubyMoney/money" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,20 @@ | ||
source "http://rubygems.org" | ||
source 'https://rubygems.org' | ||
|
||
# Specify your gem's dependencies in nordea.gemspec | ||
gemspec | ||
|
||
group :test do | ||
gem 'simplecov', '>= 0.9.0', require: false | ||
gem 'coveralls', require: false | ||
end | ||
|
||
group :local_development do | ||
gem 'appraisal' | ||
gem 'terminal-notifier-guard', require: false if RUBY_PLATFORM.downcase.include?('darwin') | ||
gem 'guard', '>= 2.0.0' | ||
gem 'guard-rspec', '>= 4.3.1', require: false | ||
gem 'guard-bundler', require: false | ||
gem 'guard-preek', require: false | ||
gem 'guard-rubocop', require: false | ||
gem 'guard-reek', github: 'pericles/guard-reek', require: false | ||
gem 'pry' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
guard 'rspec', cmd: 'rspec' do | ||
watch(%r{^spec/.+_spec\.rb$}) | ||
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } | ||
watch('spec/spec_helper.rb') { 'spec' } | ||
end | ||
|
||
guard 'bundler' do | ||
watch('Gemfile') | ||
watch('nordea.gemspec') | ||
end | ||
|
||
guard :rubocop do | ||
watch(%r{.+\.rb$}) | ||
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) } | ||
end | ||
|
||
guard :preek, run_all_dir: 'lib' do | ||
watch(/^lib\/(.*).rb/) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
# encoding: UTF-8 | ||
require "bundler/gem_tasks" | ||
require 'bundler/gem_tasks' | ||
|
||
require "rake" | ||
require "rake/task" | ||
require 'rake' | ||
require 'rake/task' | ||
|
||
require "rspec/core" | ||
require "rspec/core/rake_task" | ||
require 'rspec/core' | ||
require 'rspec/core/rake_task' | ||
|
||
RSpec::Core::RakeTask.new(:spec) | ||
|
||
task :default => :spec | ||
task default: :spec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
NestedIterators: | ||
max_allowed_nesting: 2 | ||
UtilityFunction: | ||
enabled: false | ||
IrresponsibleModule: | ||
enabled: false | ||
DuplicateMethodCall: | ||
max_calls: 5 | ||
FeatureEnvy: | ||
enabled: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# This file was generated by Appraisal | ||
|
||
source "https://rubygems.org" | ||
|
||
gem "money", "~> 6.1.0" | ||
|
||
group :test do | ||
gem "simplecov", ">= 0.9.0", :require => false | ||
gem "coveralls", :require => false | ||
end | ||
|
||
group :local_development do | ||
gem "appraisal" | ||
gem "terminal-notifier-guard", :require => false | ||
gem "guard", ">= 2.0.0" | ||
gem "guard-rspec", ">= 4.3.1", :require => false | ||
gem "guard-bundler", :require => false | ||
gem "guard-preek", :require => false | ||
gem "guard-rubocop", :require => false | ||
gem "guard-reek", :github => "pericles/guard-reek", :require => false | ||
gem "pry" | ||
end | ||
|
||
gemspec :path => "../" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# This file was generated by Appraisal | ||
|
||
source "https://rubygems.org" | ||
|
||
gem "money", "~> 6.2.0" | ||
|
||
group :test do | ||
gem "simplecov", ">= 0.9.0", :require => false | ||
gem "coveralls", :require => false | ||
end | ||
|
||
group :local_development do | ||
gem "appraisal" | ||
gem "terminal-notifier-guard", :require => false | ||
gem "guard", ">= 2.0.0" | ||
gem "guard-rspec", ">= 4.3.1", :require => false | ||
gem "guard-bundler", :require => false | ||
gem "guard-preek", :require => false | ||
gem "guard-rubocop", :require => false | ||
gem "guard-reek", :github => "pericles/guard-reek", :require => false | ||
gem "pry" | ||
end | ||
|
||
gemspec :path => "../" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# This file was generated by Appraisal | ||
|
||
source "https://rubygems.org" | ||
|
||
gem "money", :github => "RubyMoney/money" | ||
|
||
group :test do | ||
gem "simplecov", ">= 0.9.0", :require => false | ||
gem "coveralls", :require => false | ||
end | ||
|
||
group :local_development do | ||
gem "appraisal" | ||
gem "terminal-notifier-guard", :require => false | ||
gem "guard", ">= 2.0.0" | ||
gem "guard-rspec", ">= 4.3.1", :require => false | ||
gem "guard-bundler", :require => false | ||
gem "guard-preek", :require => false | ||
gem "guard-rubocop", :require => false | ||
gem "guard-reek", :github => "pericles/guard-reek", :require => false | ||
gem "pry" | ||
end | ||
|
||
gemspec :path => "../" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,46 @@ | ||
require "nordea/bank" | ||
require "nordea/exchange_rates" | ||
require "nordea/version" | ||
require "tzinfo" | ||
require 'nordea/bank' | ||
require 'nordea/exchange_rates' | ||
require 'nordea/version' | ||
require 'tzinfo' | ||
|
||
# Ruby interface to the Nordea Bank exchange rate data. | ||
module Nordea | ||
# The default timezone, Europe/Helsinki | ||
TZ = TZInfo::Timezone.get("Europe/Helsinki") | ||
TZ = ::TZInfo::Timezone.get('Europe/Helsinki') | ||
extend self | ||
|
||
# Parses the datetime format used in the Nordea data. | ||
# | ||
# @example | ||
# Nordea.parse_time("20150101120056") #=> 2015-01-01 10:00:05 UTC | ||
# | ||
# @param [String] the datetime string (YYYYMMDDHHmmSS) | ||
# @return [Time] the string converted into a Time object | ||
def self.parse_time(datetime) | ||
time = Time.utc( datetime[0..3].to_i, | ||
datetime[4..5].to_i, | ||
datetime[6..7].to_i, | ||
datetime[8..9].to_i, | ||
datetime[10..11].to_i, | ||
datetime[11..12].to_i ) | ||
class << self | ||
# Parses the datetime format used in the Nordea data. | ||
# | ||
# @example | ||
# Nordea.parse_time("20150101120056") #=> 2015-01-01 10:00:05 UTC | ||
# | ||
# @param [String] the datetime string (YYYYMMDDHHmmSS) | ||
# @return [Time] the string converted into a Time object | ||
def parse_time(datetime) | ||
time = Time.utc(datetime[0..3].to_i, | ||
datetime[4..5].to_i, | ||
datetime[6..7].to_i, | ||
datetime[8..9].to_i, | ||
datetime[10..11].to_i, | ||
datetime[11..12].to_i) | ||
|
||
# Convert the local time to UTC time. | ||
TZ.local_to_utc(time) | ||
# Convert the local time to UTC time. | ||
TZ.local_to_utc(time) | ||
rescue | ||
nil | ||
end | ||
end | ||
|
||
# Parses the date format used in the Nordea data. | ||
# | ||
# @param [String] the date string (YYYYMMDD) | ||
# @return [Date] the string converted into a Date object | ||
def self.parse_date(date) | ||
Date.new(date[0..3].to_i, | ||
date[4..5].to_i, | ||
date[6..7].to_i) | ||
# Parses the date format used in the Nordea data. | ||
# | ||
# @param [String] the date string (YYYYMMDD) | ||
# @return [Date] the string converted into a Date object | ||
def parse_date(date) | ||
::Date.new(date[0..3].to_i, | ||
date[4..5].to_i, | ||
date[6..7].to_i) | ||
rescue | ||
nil | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's a .cane file and why should I merge it in with this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/square/cane