fxpotato 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 96bf1466205c0392c90b1ba4756c74b9a54d674f
4
- data.tar.gz: 8db3edee83c0397ed6802bcdaf0d5242e74e4449
3
+ metadata.gz: 4dc221a4fe6ed20600d9588fec08eb89c9fc587a
4
+ data.tar.gz: e5e02f7941cdc9a2321a57238cc92e4edbc471fc
5
5
  SHA512:
6
- metadata.gz: d334930ca7e6a9c78bed5abbf01aea3ecd4475d6109ae5626c9f67d563a998a924809b99011eb14eea2068f126c9c265833be9ec54a052d5a150f3c9181d44ad
7
- data.tar.gz: 34a0381d4baf8ad59f18143e075fbcc5e51ca1e47383411124fc3827d9eb7f311a1b855c22c99eae1dc710e466508e73e131b8497a7ae01adf709ea9747192be
6
+ metadata.gz: 1bc64f9b24257b055faea693b8a752ad31c7064348e910d788c25fc6c89d4667d0d269677e03edaa324c29754d2dae87fa658e0b2eeaa754f7df33e3a23a6929
7
+ data.tar.gz: 61d2c2c95b29822e01fc9d917f473ab5ed7e54fda7d72efc233b58c751ed69d97808f754fe14191ce09b46ae51e611ef3393694255b37c8ed5bd9cd62182a39a
data/Dockerfile CHANGED
@@ -15,4 +15,4 @@ RUN bundle install
15
15
 
16
16
  COPY . /usr/src/app/
17
17
 
18
- CMD bundle exec cucumber features && rake test
18
+ CMD rake test
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'bundler/gem_tasks'
2
2
  require 'rake/testtask'
3
3
  require 'fxpotato'
4
4
 
5
- Rake::TestTask.new(:test) do |t|
5
+ Rake::TestTask.new(:unit_test) do |t|
6
6
  t.libs << 'test'
7
7
  t.libs << 'lib'
8
8
  t.test_files = FileList['test/**/*_test.rb']
@@ -25,7 +25,12 @@ end
25
25
 
26
26
  desc "Build, test, bump version, and release in a container"
27
27
  task :docker_release do
28
- sh %{ docker build --force-rm -t fx-potato . && docker run --rm fx-potato bundle exec cucumber features && rake test && gem bump && rake release }
28
+ sh %{ docker build --force-rm -t fx-potato . && docker run --rm fx-potato rake test && gem bump && rake release }
29
29
  end
30
30
 
31
- task :default => :test
31
+ desc "Run feature and unit tests"
32
+ task :test => :unit_test do
33
+ sh %{ bundle exec cucumber features }
34
+ end
35
+
36
+ task :default => :unit_test
data/lib/fxpotato/cli.rb CHANGED
@@ -1,12 +1,14 @@
1
1
  require 'thor'
2
2
  require 'fxpotato'
3
+ require 'date'
3
4
 
4
5
  module FxPotato
5
6
  class CLI < Thor
6
7
  desc "getrate BASE TARGET", "Gets the foreign exchange rate for the given currencies on the chosen date."
7
- method_option :date, :aliases => "-d"
8
+ method_option :date, :aliases => "-d", :desc => "A specific date to get the rate for, e.g. -d 2017-05-29"
8
9
  def getrate(base, target)
9
- puts FxPotato.at(options[:date] || Date.today, base, target)
10
+ date = options[:date] || Date.today
11
+ puts "Exchange rate from #{base} to #{target} on #{date}: #{FxPotato.at(date, base, target)}"
10
12
  end
11
13
  end
12
14
  end
@@ -1,3 +1,3 @@
1
1
  module FxPotato
2
- VERSION = '0.2.5'
2
+ VERSION = '0.2.6'
3
3
  end
@@ -15,7 +15,8 @@ module FxPotato
15
15
 
16
16
  def find(date, currency)
17
17
  query = "//Cube[@time=\'#{date.to_s}\']//Cube[@currency=\'#{currency}\']"
18
- @data.at_xpath(query)["rate"].to_f
18
+ result = @data.at_xpath(query)
19
+ result ? result["rate"].to_f : nil
19
20
  end
20
21
  end
21
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fxpotato
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Liam Stupid Name Humphreys