open_exchange_rates 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -0
- data/lib/open_exchange_rates/rates.rb +2 -2
- data/lib/open_exchange_rates/version.rb +1 -1
- data/open_exchange_rates.gemspec +1 -1
- data/test/{2012-05-10.json → assets/2012-05-10.json} +0 -0
- data/test/{latest.json → assets/latest.json} +0 -0
- data/test/rates_test.rb +17 -7
- metadata +9 -9
data/Rakefile
CHANGED
@@ -43,8 +43,8 @@ module OpenExchangeRates
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def parse_latest
|
46
|
-
@
|
47
|
-
@
|
46
|
+
@latest_parser ||= OpenExchangeRates::Parser.new
|
47
|
+
@latest_parser.parse(open(OpenExchangeRates::LATEST_URL))
|
48
48
|
end
|
49
49
|
|
50
50
|
def parse_on(date_string)
|
data/open_exchange_rates.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.email = ["vladocingel@gmail.com"]
|
7
7
|
gem.description = %q{Ruby library for Open Exchange Rates API - free / open source hourly-updated currency data for everybody}
|
8
8
|
gem.summary = %q{Ruby library for Open Exchange Rates API}
|
9
|
-
gem.homepage = ""
|
9
|
+
gem.homepage = "https://github.com/vlado/open_exchange_rates"
|
10
10
|
|
11
11
|
gem.files = `git ls-files`.split($\)
|
12
12
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
File without changes
|
File without changes
|
data/test/rates_test.rb
CHANGED
@@ -4,7 +4,7 @@ class TestOpenExchangeRates < Test::Unit::TestCase
|
|
4
4
|
|
5
5
|
def test_exchange_rate
|
6
6
|
fx = OpenExchangeRates::Rates.new
|
7
|
-
stub(fx).parse_latest { OpenExchangeRates::Parser.new.parse(
|
7
|
+
stub(fx).parse_latest { OpenExchangeRates::Parser.new.parse(open_asset("latest.json")) }
|
8
8
|
|
9
9
|
# 1 USD = 6.0995 HRK
|
10
10
|
# 1 USD = 1.026057 AUD
|
@@ -24,7 +24,7 @@ class TestOpenExchangeRates < Test::Unit::TestCase
|
|
24
24
|
|
25
25
|
def test_exchange_rate_on_specific_date
|
26
26
|
fx = OpenExchangeRates::Rates.new
|
27
|
-
stub(fx).parse_on { OpenExchangeRates::Parser.new.parse(
|
27
|
+
stub(fx).parse_on { OpenExchangeRates::Parser.new.parse(open_asset("2012-05-10.json")) }
|
28
28
|
|
29
29
|
# 1 USD = 5.80025 HRK
|
30
30
|
# 1 USD = 0.99458 AUD
|
@@ -44,7 +44,7 @@ class TestOpenExchangeRates < Test::Unit::TestCase
|
|
44
44
|
|
45
45
|
def test_convert
|
46
46
|
fx = OpenExchangeRates::Rates.new
|
47
|
-
stub(fx).parse_latest { OpenExchangeRates::Parser.new.parse(
|
47
|
+
stub(fx).parse_latest { OpenExchangeRates::Parser.new.parse(open_asset("latest.json")) }
|
48
48
|
|
49
49
|
# 1 USD = 6.0995 HRK
|
50
50
|
# 1 USD = 1.026057 AUD
|
@@ -57,7 +57,7 @@ class TestOpenExchangeRates < Test::Unit::TestCase
|
|
57
57
|
|
58
58
|
def test_convert_on_specific_date
|
59
59
|
fx = OpenExchangeRates::Rates.new
|
60
|
-
stub(fx).parse_on { OpenExchangeRates::Parser.new.parse(
|
60
|
+
stub(fx).parse_on { OpenExchangeRates::Parser.new.parse(open_asset("2012-05-10.json")) }
|
61
61
|
|
62
62
|
# 1 USD = 5.80025 HRK
|
63
63
|
# 1 USD = 0.99458 AUD
|
@@ -70,7 +70,7 @@ class TestOpenExchangeRates < Test::Unit::TestCase
|
|
70
70
|
|
71
71
|
def test_convert_if_from_option_is_missing
|
72
72
|
fx = OpenExchangeRates::Rates.new
|
73
|
-
stub(fx).parse_latest { OpenExchangeRates::Parser.new.parse(
|
73
|
+
stub(fx).parse_latest { OpenExchangeRates::Parser.new.parse(open_asset("latest.json")) }
|
74
74
|
|
75
75
|
# from defaults to base currency (USD)
|
76
76
|
# 1 USD = 6.0995 HRK
|
@@ -81,7 +81,7 @@ class TestOpenExchangeRates < Test::Unit::TestCase
|
|
81
81
|
|
82
82
|
def test_convert_if_to_option_is_missing
|
83
83
|
fx = OpenExchangeRates::Rates.new
|
84
|
-
stub(fx).parse_latest { OpenExchangeRates::Parser.new.parse(
|
84
|
+
stub(fx).parse_latest { OpenExchangeRates::Parser.new.parse(open_asset("latest.json")) }
|
85
85
|
|
86
86
|
# to defaults to base currency (USD)
|
87
87
|
# 1 USD = 6.0995 HRK
|
@@ -98,7 +98,7 @@ class TestOpenExchangeRates < Test::Unit::TestCase
|
|
98
98
|
assert_equal "USD", latest_rates.base
|
99
99
|
assert latest_rates.rates.is_a?(Hash)
|
100
100
|
|
101
|
-
stub(fx).parse_latest { OpenExchangeRates::Parser.new.parse(
|
101
|
+
stub(fx).parse_latest { OpenExchangeRates::Parser.new.parse(open_asset("latest.json")) }
|
102
102
|
|
103
103
|
# latest results are cached
|
104
104
|
cached_rates = fx.latest
|
@@ -153,4 +153,14 @@ class TestOpenExchangeRates < Test::Unit::TestCase
|
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
156
|
+
private
|
157
|
+
|
158
|
+
def assets_root
|
159
|
+
File.join(File.dirname(__FILE__), "assets")
|
160
|
+
end
|
161
|
+
|
162
|
+
def open_asset(filename)
|
163
|
+
File.open("#{assets_root}/#{filename}")
|
164
|
+
end
|
165
|
+
|
156
166
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: open_exchange_rates
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Vlado Cingel
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-06-
|
18
|
+
date: 2012-06-13 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: yajl-ruby
|
@@ -80,11 +80,11 @@ files:
|
|
80
80
|
- lib/open_exchange_rates/response.rb
|
81
81
|
- lib/open_exchange_rates/version.rb
|
82
82
|
- open_exchange_rates.gemspec
|
83
|
-
- test/2012-05-10.json
|
84
|
-
- test/latest.json
|
83
|
+
- test/assets/2012-05-10.json
|
84
|
+
- test/assets/latest.json
|
85
85
|
- test/rates_test.rb
|
86
86
|
- test/test_helper.rb
|
87
|
-
homepage:
|
87
|
+
homepage: https://github.com/vlado/open_exchange_rates
|
88
88
|
licenses: []
|
89
89
|
|
90
90
|
post_install_message:
|
@@ -118,8 +118,8 @@ signing_key:
|
|
118
118
|
specification_version: 3
|
119
119
|
summary: Ruby library for Open Exchange Rates API
|
120
120
|
test_files:
|
121
|
-
- test/2012-05-10.json
|
122
|
-
- test/latest.json
|
121
|
+
- test/assets/2012-05-10.json
|
122
|
+
- test/assets/latest.json
|
123
123
|
- test/rates_test.rb
|
124
124
|
- test/test_helper.rb
|
125
125
|
has_rdoc:
|