eu_central_bank 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ = eu_central_bank changelog
2
+
3
+ == 0.1.3 (December 18 2010)
4
+
5
+ * Fixed the gemspec bug
6
+
7
+ == 0.1.2 (December 15 2010)
8
+
9
+ * Clean up dependencies
10
+
11
+ == 0.1.1 (July 17 2010)
12
+
13
+ * Added the exchange_with method from money gem
14
+
15
+ == 0.1.0 (April 21 2010)
16
+
17
+ * Initial gem release
@@ -1,11 +1,12 @@
1
1
  require 'rubygems'
2
2
  require 'open-uri'
3
3
  require 'nokogiri'
4
+ gem 'money', '=3.1.5'
4
5
  require 'money'
5
6
 
6
7
  class InvalidCache < StandardError ; end
7
8
 
8
- class EuCentralBank < Money::VariableExchangeBank
9
+ class EuCentralBank < Money::Bank::VariableExchange
9
10
 
10
11
  ECB_RATES_URL = 'http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml'
11
12
  CURRENCIES = %w(USD JPY BGN CZK DKK EEK GBP HUF LTL LVL PLN RON SEK CHF NOK HRK RUB TRY AUD BRL CAD CNY HKD IDR INR KRW MXN MYR NZD PHP SGD THB ZAR)
metadata CHANGED
@@ -1,89 +1,88 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eu_central_bank
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Wong Liang Zan
14
+ - Shane Emmons
14
15
  autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-07-17 00:00:00 +08:00
19
+ date: 2010-12-18 00:00:00 +08:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
22
- name: rspec
23
+ name: nokogiri
23
24
  prerelease: false
24
25
  requirement: &id001 !ruby/object:Gem::Requirement
25
26
  none: false
26
27
  requirements:
27
28
  - - ">="
28
29
  - !ruby/object:Gem::Version
29
- hash: 27
30
+ hash: 5
30
31
  segments:
31
32
  - 1
32
- - 3
33
- - 0
34
- version: 1.3.0
35
- type: :development
33
+ - 4
34
+ - 1
35
+ version: 1.4.1
36
+ type: :runtime
36
37
  version_requirements: *id001
37
38
  - !ruby/object:Gem::Dependency
38
- name: rr
39
+ name: money
39
40
  prerelease: false
40
41
  requirement: &id002 !ruby/object:Gem::Requirement
41
42
  none: false
42
43
  requirements:
43
- - - ">="
44
+ - - "="
44
45
  - !ruby/object:Gem::Version
45
- hash: 33
46
+ hash: 9
46
47
  segments:
47
- - 0
48
- - 10
49
- - 11
50
- version: 0.10.11
51
- type: :development
48
+ - 3
49
+ - 1
50
+ - 5
51
+ version: 3.1.5
52
+ type: :runtime
52
53
  version_requirements: *id002
53
54
  - !ruby/object:Gem::Dependency
54
- name: shoulda
55
+ name: rspec
55
56
  prerelease: false
56
57
  requirement: &id003 !ruby/object:Gem::Requirement
57
58
  none: false
58
59
  requirements:
59
60
  - - ">="
60
61
  - !ruby/object:Gem::Version
61
- hash: 33
62
+ hash: 15
62
63
  segments:
63
64
  - 2
64
- - 10
65
- - 3
66
- version: 2.10.3
65
+ - 0
66
+ - 0
67
+ version: 2.0.0
67
68
  type: :development
68
69
  version_requirements: *id003
69
70
  - !ruby/object:Gem::Dependency
70
- name: nokogiri
71
+ name: rr
71
72
  prerelease: false
72
73
  requirement: &id004 !ruby/object:Gem::Requirement
73
74
  none: false
74
75
  requirements:
75
76
  - - ">="
76
77
  - !ruby/object:Gem::Version
77
- hash: 5
78
+ hash: 3
78
79
  segments:
79
- - 1
80
- - 4
81
- - 1
82
- version: 1.4.1
83
- type: :runtime
80
+ - 0
81
+ version: "0"
82
+ type: :development
84
83
  version_requirements: *id004
85
84
  - !ruby/object:Gem::Dependency
86
- name: money
85
+ name: shoulda
87
86
  prerelease: false
88
87
  requirement: &id005 !ruby/object:Gem::Requirement
89
88
  none: false
@@ -92,42 +91,31 @@ dependencies:
92
91
  - !ruby/object:Gem::Version
93
92
  hash: 3
94
93
  segments:
95
- - 2
96
- - 3
97
94
  - 0
98
- version: 2.3.0
99
- type: :runtime
95
+ version: "0"
96
+ type: :development
100
97
  version_requirements: *id005
101
98
  description: This gem reads exchange rates from the european central bank website. It uses it to calculates exchange rates. It is compatible with the money gem
102
- email: zan@liangzan.net
99
+ email:
100
+ - zan@liangzan.net
103
101
  executables: []
104
102
 
105
103
  extensions: []
106
104
 
107
- extra_rdoc_files:
108
- - LICENSE
109
- - README.rdoc
105
+ extra_rdoc_files: []
106
+
110
107
  files:
111
- - .document
112
- - .gitignore
108
+ - lib/eu_central_bank.rb
109
+ - CHANGELOG.rdoc
113
110
  - LICENSE
114
111
  - README.rdoc
115
- - Rakefile
116
- - VERSION
117
- - eu_central_bank.gemspec
118
- - lib/eu_central_bank.rb
119
- - spec/eu_central_bank_spec.rb
120
- - spec/exchange_rates.xml
121
- - spec/exchange_rates.yml
122
- - spec/spec.opts
123
- - spec/spec_helper.rb
124
112
  has_rdoc: true
125
- homepage: http://github.com/liangzan/eu_central_bank
113
+ homepage: http://github.com/RubyMoney/eu_central_bank
126
114
  licenses: []
127
115
 
128
116
  post_install_message:
129
- rdoc_options:
130
- - --charset=UTF-8
117
+ rdoc_options: []
118
+
131
119
  require_paths:
132
120
  - lib
133
121
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -144,10 +132,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
132
  requirements:
145
133
  - - ">="
146
134
  - !ruby/object:Gem::Version
147
- hash: 3
135
+ hash: 23
148
136
  segments:
149
- - 0
150
- version: "0"
137
+ - 1
138
+ - 3
139
+ - 6
140
+ version: 1.3.6
151
141
  requirements: []
152
142
 
153
143
  rubyforge_project:
@@ -155,6 +145,5 @@ rubygems_version: 1.3.7
155
145
  signing_key:
156
146
  specification_version: 3
157
147
  summary: Calculates exchange rates based on rates from european central bank. Money gem compatible.
158
- test_files:
159
- - spec/spec_helper.rb
160
- - spec/eu_central_bank_spec.rb
148
+ test_files: []
149
+
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
data/.gitignore DELETED
@@ -1,21 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC
data/Rakefile DELETED
@@ -1,49 +0,0 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "eu_central_bank"
8
- gem.summary = %Q{Calculates exchange rates based on rates from european central bank. Money gem compatible. }
9
- gem.description = %Q{This gem reads exchange rates from the european central bank website. It uses it to calculates exchange rates. It is compatible with the money gem}
10
- gem.email = "zan@liangzan.net"
11
- gem.homepage = "http://github.com/liangzan/eu_central_bank"
12
- gem.authors = ["Wong Liang Zan"]
13
- gem.add_development_dependency "rspec", ">= 1.3.0"
14
- gem.add_development_dependency "rr", ">= 0.10.11"
15
- gem.add_development_dependency "shoulda", ">= 2.10.3"
16
- gem.add_dependency "nokogiri", ">= 1.4.1"
17
- gem.add_dependency "money", ">= 2.3.0"
18
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
19
- end
20
- Jeweler::GemcutterTasks.new
21
- rescue LoadError
22
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
23
- end
24
-
25
- require 'spec/rake/spectask'
26
- Spec::Rake::SpecTask.new(:spec) do |spec|
27
- spec.libs << 'lib' << 'spec'
28
- spec.spec_files = FileList['spec/**/*_spec.rb']
29
- end
30
-
31
- Spec::Rake::SpecTask.new(:rcov) do |spec|
32
- spec.libs << 'lib' << 'spec'
33
- spec.pattern = 'spec/**/*_spec.rb'
34
- spec.rcov = true
35
- end
36
-
37
- task :spec => :check_dependencies
38
-
39
- task :default => :spec
40
-
41
- require 'rake/rdoctask'
42
- Rake::RDocTask.new do |rdoc|
43
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
-
45
- rdoc.rdoc_dir = 'rdoc'
46
- rdoc.title = "eu_central_bank #{version}"
47
- rdoc.rdoc_files.include('README*')
48
- rdoc.rdoc_files.include('lib/**/*.rb')
49
- end
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.1.1
@@ -1,69 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{eu_central_bank}
8
- s.version = "0.1.1"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Wong Liang Zan"]
12
- s.date = %q{2010-07-17}
13
- s.description = %q{This gem reads exchange rates from the european central bank website. It uses it to calculates exchange rates. It is compatible with the money gem}
14
- s.email = %q{zan@liangzan.net}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- ".document",
21
- ".gitignore",
22
- "LICENSE",
23
- "README.rdoc",
24
- "Rakefile",
25
- "VERSION",
26
- "eu_central_bank.gemspec",
27
- "lib/eu_central_bank.rb",
28
- "spec/eu_central_bank_spec.rb",
29
- "spec/exchange_rates.xml",
30
- "spec/exchange_rates.yml",
31
- "spec/spec.opts",
32
- "spec/spec_helper.rb"
33
- ]
34
- s.homepage = %q{http://github.com/liangzan/eu_central_bank}
35
- s.rdoc_options = ["--charset=UTF-8"]
36
- s.require_paths = ["lib"]
37
- s.rubygems_version = %q{1.3.7}
38
- s.summary = %q{Calculates exchange rates based on rates from european central bank. Money gem compatible.}
39
- s.test_files = [
40
- "spec/spec_helper.rb",
41
- "spec/eu_central_bank_spec.rb"
42
- ]
43
-
44
- if s.respond_to? :specification_version then
45
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
46
- s.specification_version = 3
47
-
48
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
- s.add_development_dependency(%q<rspec>, [">= 1.3.0"])
50
- s.add_development_dependency(%q<rr>, [">= 0.10.11"])
51
- s.add_development_dependency(%q<shoulda>, [">= 2.10.3"])
52
- s.add_runtime_dependency(%q<nokogiri>, [">= 1.4.1"])
53
- s.add_runtime_dependency(%q<money>, [">= 2.3.0"])
54
- else
55
- s.add_dependency(%q<rspec>, [">= 1.3.0"])
56
- s.add_dependency(%q<rr>, [">= 0.10.11"])
57
- s.add_dependency(%q<shoulda>, [">= 2.10.3"])
58
- s.add_dependency(%q<nokogiri>, [">= 1.4.1"])
59
- s.add_dependency(%q<money>, [">= 2.3.0"])
60
- end
61
- else
62
- s.add_dependency(%q<rspec>, [">= 1.3.0"])
63
- s.add_dependency(%q<rr>, [">= 0.10.11"])
64
- s.add_dependency(%q<shoulda>, [">= 2.10.3"])
65
- s.add_dependency(%q<nokogiri>, [">= 1.4.1"])
66
- s.add_dependency(%q<money>, [">= 2.3.0"])
67
- end
68
- end
69
-
@@ -1,57 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
- require 'yaml'
3
-
4
- describe "EuCentralBank" do
5
- before(:each) do
6
- @bank = EuCentralBank.new
7
- @cache_path = File.expand_path(File.dirname(__FILE__) + '/exchange_rates.xml')
8
- @yml_cache_path = File.expand_path(File.dirname(__FILE__) + '/exchange_rates.yml')
9
- @tmp_cache_path = File.expand_path(File.dirname(__FILE__) + '/tmp/exchange_rates.xml')
10
- end
11
-
12
- after(:each) do
13
- if File.exists? @tmp_cache_path
14
- File.delete @tmp_cache_path
15
- end
16
- end
17
-
18
- it "should save the xml file from ecb given a file path" do
19
- @bank.save_rates(@tmp_cache_path)
20
- File.exists?(@tmp_cache_path).should == true
21
- end
22
-
23
- it "should raise an error if an invalid path is given to save_rates" do
24
- lambda { @bank.save_rates(nil) }.should raise_exception
25
- end
26
-
27
- it "should update itself with exchange rates from ecb website" do
28
- stub(OpenURI::OpenRead).open(EuCentralBank::ECB_RATES_URL) {@cache_path}
29
- @bank.update_rates
30
- EuCentralBank::CURRENCIES.each do |currency|
31
- @bank.get_rate("EUR", currency).should > 0
32
- end
33
- end
34
-
35
- it "should update itself with exchange rates from cache" do
36
- @bank.update_rates(@cache_path)
37
- EuCentralBank::CURRENCIES.each do |currency|
38
- @bank.get_rate("EUR", currency).should > 0
39
- end
40
- end
41
-
42
- it "should return the correct exchange rates using exchange" do
43
- EXCHANGE_RATES = YAML.load_file(@yml_cache_path)
44
- @bank.update_rates(@cache_path)
45
- EuCentralBank::CURRENCIES.each do |currency|
46
- @bank.exchange(100, "EUR", currency).cents.should == (EXCHANGE_RATES["currencies"][currency].to_f * 100).floor
47
- end
48
- end
49
-
50
- it "should return the correct exchange rates using exchange_with" do
51
- EXCHANGE_RATES = YAML.load_file(@yml_cache_path)
52
- @bank.update_rates(@cache_path)
53
- EuCentralBank::CURRENCIES.each do |currency|
54
- @bank.exchange_with(Money.new(100, "EUR"), currency).cents.should == (EXCHANGE_RATES["currencies"][currency].to_f * 100).floor
55
- end
56
- end
57
- end
@@ -1,44 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <gesmes:Envelope xmlns:gesmes="http://www.gesmes.org/xml/2002-08-01" xmlns="http://www.ecb.int/vocabulary/2002-08-01/eurofxref">
3
- <gesmes:subject>Reference rates</gesmes:subject>
4
- <gesmes:Sender>
5
- <gesmes:name>European Central Bank</gesmes:name>
6
- </gesmes:Sender>
7
- <Cube>
8
- <Cube time='2010-04-20'>
9
- <Cube currency='USD' rate='1.3486'/>
10
- <Cube currency='JPY' rate='125.32'/>
11
- <Cube currency='BGN' rate='1.9558'/>
12
- <Cube currency='CZK' rate='25.309'/>
13
- <Cube currency='DKK' rate='7.4423'/>
14
- <Cube currency='EEK' rate='15.6466'/>
15
- <Cube currency='GBP' rate='0.87650'/>
16
- <Cube currency='HUF' rate='264.93'/>
17
- <Cube currency='LTL' rate='3.4528'/>
18
- <Cube currency='LVL' rate='0.7074'/>
19
- <Cube currency='PLN' rate='3.8861'/>
20
- <Cube currency='RON' rate='4.1470'/>
21
- <Cube currency='SEK' rate='9.6450'/>
22
- <Cube currency='CHF' rate='1.4334'/>
23
- <Cube currency='NOK' rate='7.9475'/>
24
- <Cube currency='HRK' rate='7.2542'/>
25
- <Cube currency='RUB' rate='39.2535'/>
26
- <Cube currency='TRY' rate='2.0064'/>
27
- <Cube currency='AUD' rate='1.4478'/>
28
- <Cube currency='BRL' rate='2.3576'/>
29
- <Cube currency='CAD' rate='1.3665'/>
30
- <Cube currency='CNY' rate='9.2047'/>
31
- <Cube currency='HKD' rate='10.4688'/>
32
- <Cube currency='IDR' rate='12141.23'/>
33
- <Cube currency='INR' rate='60.0060'/>
34
- <Cube currency='KRW' rate='1507.69'/>
35
- <Cube currency='MXN' rate='16.4647'/>
36
- <Cube currency='MYR' rate='4.3209'/>
37
- <Cube currency='NZD' rate='1.8961'/>
38
- <Cube currency='PHP' rate='60.094'/>
39
- <Cube currency='SGD' rate='1.8551'/>
40
- <Cube currency='THB' rate='43.374'/>
41
- <Cube currency='ZAR' rate='10.0235'/>
42
- </Cube>
43
- </Cube>
44
- </gesmes:Envelope>
@@ -1,34 +0,0 @@
1
- currencies:
2
- USD: 1.3486
3
- JPY: 125.32
4
- BGN: 1.9558
5
- CZK: 25.309
6
- DKK: 7.4423
7
- EEK: 15.6466
8
- GBP: 0.87650
9
- HUF: 264.93
10
- LTL: 3.4528
11
- LVL: 0.7074
12
- PLN: 3.8861
13
- RON: 4.1470
14
- SEK: 9.6450
15
- CHF: 1.4334
16
- NOK: 7.9475
17
- HRK: 7.2542
18
- RUB: 39.2535
19
- TRY: 2.0064
20
- AUD: 1.4478
21
- BRL: 2.3576
22
- CAD: 1.3665
23
- CNY: 9.2047
24
- HKD: 10.4688
25
- IDR: 12141.23
26
- INR: 60.0060
27
- KRW: 1507.69
28
- MXN: 16.4647
29
- MYR: 4.3209
30
- NZD: 1.8961
31
- PHP: 60.094
32
- SGD: 1.8551
33
- THB: 43.374
34
- ZAR: 10.0235
@@ -1 +0,0 @@
1
- --color
@@ -1,11 +0,0 @@
1
- $LOAD_PATH.unshift(File.dirname(__FILE__))
2
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
- require 'eu_central_bank'
4
- require 'spec'
5
- require 'spec/autorun'
6
- require 'shoulda'
7
- require 'rr'
8
-
9
- Spec::Runner.configure do |config|
10
- config.mock_with :rr
11
- end