google_currency 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/Rakefile +49 -0
- data/google_currency.gemspec +26 -0
- data/spec/google_currency_spec.rb +73 -0
- data/spec/spec_helper.rb +2 -0
- metadata +15 -12
data/.gemtest
ADDED
File without changes
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/clean'
|
3
|
+
|
4
|
+
CLOBBER.include('.yardoc', 'doc')
|
5
|
+
|
6
|
+
def gemspec
|
7
|
+
@gemspec ||= begin
|
8
|
+
file = File.expand_path("../google_currency.gemspec", __FILE__)
|
9
|
+
eval(File.read(file), binding, file)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
begin
|
14
|
+
require 'rspec/core/rake_task'
|
15
|
+
RSpec::Core::RakeTask.new
|
16
|
+
rescue LoadError
|
17
|
+
task(:spec){abort "`gem install rspec` to run specs"}
|
18
|
+
end
|
19
|
+
task :default => :spec
|
20
|
+
task :test => :spec
|
21
|
+
|
22
|
+
begin
|
23
|
+
require 'yard'
|
24
|
+
YARD::Rake::YardocTask.new do |t|
|
25
|
+
t.options << "--files" << "CHANGELOG.md,LICENSE"
|
26
|
+
end
|
27
|
+
rescue LoadError
|
28
|
+
task(:yard){abort "`gem install yard` to generate documentation"}
|
29
|
+
end
|
30
|
+
|
31
|
+
begin
|
32
|
+
require 'rake/gempackagetask'
|
33
|
+
Rake::GemPackageTask.new(gemspec) do |pkg|
|
34
|
+
pkg.gem_spec = gemspec
|
35
|
+
end
|
36
|
+
task :gem => :gemspec
|
37
|
+
rescue LoadError
|
38
|
+
task(:gem){abort "`gem install rake` to package gems"}
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "Install the gem locally"
|
42
|
+
task :install => :gem do
|
43
|
+
sh "gem install pkg/#{gemspec.full_name}.gem"
|
44
|
+
end
|
45
|
+
|
46
|
+
desc "Validate the gemspec"
|
47
|
+
task :gemspec do
|
48
|
+
gemspec.validate
|
49
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "google_currency"
|
3
|
+
s.version = "1.2.0"
|
4
|
+
s.platform = Gem::Platform::RUBY
|
5
|
+
s.authors = ["Shane Emmons", "Donald Ball"]
|
6
|
+
s.email = ["semmons99+RubyMoney@gmail.com", "donald.ball@gmail.com"]
|
7
|
+
s.homepage = "http://rubymoney.github.com/google_currency"
|
8
|
+
s.summary = "Access the Google Currency exchange rate data."
|
9
|
+
s.description = "GoogleCurrency extends Money::Bank::Base and gives you access to the current Google Currency exchange rates."
|
10
|
+
|
11
|
+
s.required_rubygems_version = ">= 1.3.7"
|
12
|
+
|
13
|
+
s.add_development_dependency "rspec", ">= 2.0.0"
|
14
|
+
s.add_development_dependency "yard", ">= 0.5.8"
|
15
|
+
s.add_development_dependency "json", ">= 1.4.0"
|
16
|
+
|
17
|
+
s.add_dependency "money", "~> 3.5"
|
18
|
+
|
19
|
+
s.requirements << "json"
|
20
|
+
|
21
|
+
s.files = Dir.glob("{lib,spec}/**/*")
|
22
|
+
s.files += %w(LICENSE README.md CHANGELOG.md)
|
23
|
+
s.files += %w(Rakefile .gemtest google_currency.gemspec)
|
24
|
+
|
25
|
+
s.require_path = "lib"
|
26
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
require 'money'
|
4
|
+
require 'money/bank/google_currency'
|
5
|
+
|
6
|
+
describe "GoogleCurrency" do
|
7
|
+
before :each do
|
8
|
+
@bank = Money::Bank::GoogleCurrency.new
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#get_google_rate" do
|
12
|
+
it "should work for USD->USD" do
|
13
|
+
@bank.get_google_rate('USD', 'USD').should == 1.0
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should work for usd->usd" do
|
17
|
+
@bank.get_google_rate('usd', 'usd').should == 1.0
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should work for Currency.wrap(:USD)->Currency.wrap(:USD)" do
|
21
|
+
@bank.get_google_rate(Money::Currency.wrap(:USD),
|
22
|
+
Money::Currency.wrap(:USD)).should == 1.0
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should raise an UnknownCurrency error for an unknown currency" do
|
26
|
+
lambda{@bank.get_google_rate('USD', 'BATMAN')}.should raise_error(Money::Currency::UnknownCurrency)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should raise and UnknownRate error for a known currency but unknown rate" do
|
30
|
+
lambda{@bank.get_google_rate('USD', 'ALL')}.should raise_error(Money::Bank::UnknownRate)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#get_rate" do
|
35
|
+
it "should use #fetch_rate when rate is unknown" do
|
36
|
+
@bank.should_receive(:fetch_rate).once
|
37
|
+
@bank.get_rate('USD', 'USD')
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should not use #fetch_rate when rate is known" do
|
41
|
+
@bank.get_rate('USD', 'USD')
|
42
|
+
@bank.should_not_receive(:fetch_rate)
|
43
|
+
@bank.get_rate('USD', 'USD')
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should return the correct rate" do
|
47
|
+
@bank.get_rate('USD', 'USD').should == 1.0
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should store the rate for faster retreival" do
|
51
|
+
@bank.get_rate('USD', 'EUR')
|
52
|
+
@bank.rates.should include('USD_TO_EUR')
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "#flush_rates" do
|
57
|
+
it "should empty @rates" do
|
58
|
+
@bank.get_rate('USD', 'EUR')
|
59
|
+
@bank.flush_rates
|
60
|
+
@bank.rates.should == {}
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "#flush_rate" do
|
65
|
+
it "should remove a specific rate from @rates" do
|
66
|
+
@bank.get_rate('USD', 'EUR')
|
67
|
+
@bank.get_rate('USD', 'JPY')
|
68
|
+
@bank.flush_rate('USD', 'EUR')
|
69
|
+
@bank.rates.should include('USD_TO_JPY')
|
70
|
+
@bank.rates.should_not include('USD_TO_EUR')
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google_currency
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 1.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 1.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Shane Emmons
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-02-
|
19
|
+
date: 2011-02-18 00:00:00 -05:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -90,22 +90,25 @@ executables: []
|
|
90
90
|
|
91
91
|
extensions: []
|
92
92
|
|
93
|
-
extra_rdoc_files:
|
94
|
-
|
95
|
-
- README.md
|
96
|
-
- CHANGELOG.md
|
93
|
+
extra_rdoc_files: []
|
94
|
+
|
97
95
|
files:
|
98
96
|
- lib/money/bank/google_currency.rb
|
97
|
+
- spec/google_currency_spec.rb
|
98
|
+
- spec/spec_helper.rb
|
99
99
|
- LICENSE
|
100
100
|
- README.md
|
101
101
|
- CHANGELOG.md
|
102
|
+
- Rakefile
|
103
|
+
- .gemtest
|
104
|
+
- google_currency.gemspec
|
102
105
|
has_rdoc: true
|
103
106
|
homepage: http://rubymoney.github.com/google_currency
|
104
107
|
licenses: []
|
105
108
|
|
106
109
|
post_install_message:
|
107
|
-
rdoc_options:
|
108
|
-
|
110
|
+
rdoc_options: []
|
111
|
+
|
109
112
|
require_paths:
|
110
113
|
- lib
|
111
114
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -131,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
134
|
requirements:
|
132
135
|
- json
|
133
136
|
rubyforge_project:
|
134
|
-
rubygems_version: 1.5.
|
137
|
+
rubygems_version: 1.5.2
|
135
138
|
signing_key:
|
136
139
|
specification_version: 3
|
137
140
|
summary: Access the Google Currency exchange rate data.
|