exchange 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/Gemfile +17 -8
  2. data/Gemfile.lock +12 -6
  3. data/LICENSE.txt +1 -1
  4. data/README.rdoc +15 -12
  5. data/VERSION +1 -1
  6. data/exchange.gemspec +13 -23
  7. data/lib/core_extensions/conversability.rb +5 -4
  8. data/lib/exchange.rb +6 -11
  9. data/lib/exchange/base.rb +19 -0
  10. data/lib/exchange/cache/base.rb +57 -32
  11. data/lib/exchange/cache/file.rb +41 -45
  12. data/lib/exchange/cache/memcached.rb +28 -29
  13. data/lib/exchange/cache/no_cache.rb +4 -24
  14. data/lib/exchange/cache/rails.rb +26 -26
  15. data/lib/exchange/cache/redis.rb +30 -33
  16. data/lib/exchange/configuration.rb +167 -73
  17. data/lib/exchange/currency.rb +61 -30
  18. data/lib/exchange/external_api.rb +2 -0
  19. data/lib/exchange/external_api/base.rb +11 -5
  20. data/lib/exchange/external_api/call.rb +10 -7
  21. data/lib/exchange/external_api/currency_bot.rb +9 -5
  22. data/lib/exchange/external_api/ecb.rb +29 -13
  23. data/lib/exchange/external_api/json.rb +22 -0
  24. data/lib/exchange/external_api/xavier_media.rb +6 -5
  25. data/lib/exchange/external_api/xml.rb +22 -0
  26. data/lib/exchange/gem_loader.rb +35 -0
  27. data/lib/exchange/helper.rb +22 -15
  28. data/lib/exchange/iso_4217.rb +55 -44
  29. data/spec/core_extensions/conversability_spec.rb +2 -2
  30. data/spec/exchange/cache/base_spec.rb +7 -7
  31. data/spec/exchange/cache/file_spec.rb +19 -18
  32. data/spec/exchange/cache/memcached_spec.rb +29 -26
  33. data/spec/exchange/cache/no_cache_spec.rb +12 -6
  34. data/spec/exchange/cache/rails_spec.rb +13 -9
  35. data/spec/exchange/cache/redis_spec.rb +24 -24
  36. data/spec/exchange/configuration_spec.rb +38 -30
  37. data/spec/exchange/currency_spec.rb +33 -21
  38. data/spec/exchange/external_api/base_spec.rb +3 -1
  39. data/spec/exchange/external_api/call_spec.rb +5 -1
  40. data/spec/exchange/external_api/currency_bot_spec.rb +5 -1
  41. data/spec/exchange/external_api/ecb_spec.rb +9 -5
  42. data/spec/exchange/external_api/xavier_media_spec.rb +5 -1
  43. data/spec/exchange/gem_loader_spec.rb +29 -0
  44. data/spec/spec_helper.rb +1 -1
  45. metadata +12 -87
@@ -2,7 +2,11 @@ require 'spec_helper'
2
2
 
3
3
  describe "Exchange::ExternalAPI::XavierMedia" do
4
4
  before(:all) do
5
- Exchange::Configuration.cache = false
5
+ Exchange.configuration = Exchange::Configuration.new { |c|
6
+ c.cache = {
7
+ :subclass => :no_cache
8
+ }
9
+ }
6
10
  end
7
11
  describe "updating rates" do
8
12
  subject { Exchange::ExternalAPI::XavierMedia.new }
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Exchange::Gemloader" do
4
+
5
+ describe "initializing with a gem name" do
6
+ subject { Exchange::GemLoader.new('some_gem') }
7
+ it "should assign the gem name" do
8
+ subject.instance_variable_get('@gem').should == 'some_gem'
9
+ end
10
+ end
11
+
12
+ describe "loading the gem" do
13
+ context "with the gem being bundled" do
14
+ subject { Exchange::GemLoader.new('dalli') }
15
+ it "should not fail" do
16
+ lambda { subject.try_load }.should_not raise_error
17
+ defined?(Dalli).should be_true
18
+ end
19
+ end
20
+ context "with the gem not being bundled" do
21
+ subject { Exchange::GemLoader.new('blabla') }
22
+ it "should fail" do
23
+ lambda { subject.try_load }.should raise_error(Exchange::GemLoader::GemNotFoundError, "You specified blabla to be used with Exchange, yet it is not loadable. Please install blabla to be able to use it with Exchange")
24
+ defined?(Blabla).should be_false
25
+ end
26
+ end
27
+ end
28
+
29
+ end
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
4
4
  require 'rubygems'
5
5
  require 'bundler'
6
6
  begin
7
- Bundler.setup(:default, :development)
7
+ Bundler.setup(:default, :test)
8
8
  rescue Bundler::BundlerError => e
9
9
  $stderr.puts e.message
10
10
  $stderr.puts "Run `bundle install` to install missing gems"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exchange
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,81 +9,17 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-02 00:00:00.000000000 Z
12
+ date: 2012-10-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: nokogiri
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: 1.5.0
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: 1.5.0
30
- - !ruby/object:Gem::Dependency
31
- name: json
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: 1.6.5
38
- type: :runtime
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: 1.6.5
46
- - !ruby/object:Gem::Dependency
47
- name: memcached
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: 1.3.0
54
- type: :runtime
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: 1.3.0
62
- - !ruby/object:Gem::Dependency
63
- name: redis
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: 2.2.0
70
- type: :runtime
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: 2.2.0
78
- - !ruby/object:Gem::Dependency
79
- name: shoulda
15
+ name: exchange
80
16
  requirement: !ruby/object:Gem::Requirement
81
17
  none: false
82
18
  requirements:
83
19
  - - ! '>='
84
20
  - !ruby/object:Gem::Version
85
21
  version: '0'
86
- type: :development
22
+ type: :runtime
87
23
  prerelease: false
88
24
  version_requirements: !ruby/object:Gem::Requirement
89
25
  none: false
@@ -112,7 +48,7 @@ dependencies:
112
48
  requirement: !ruby/object:Gem::Requirement
113
49
  none: false
114
50
  requirements:
115
- - - ! '>'
51
+ - - ! '>='
116
52
  - !ruby/object:Gem::Version
117
53
  version: 1.0.0
118
54
  type: :development
@@ -120,7 +56,7 @@ dependencies:
120
56
  version_requirements: !ruby/object:Gem::Requirement
121
57
  none: false
122
58
  requirements:
123
- - - ! '>'
59
+ - - ! '>='
124
60
  - !ruby/object:Gem::Version
125
61
  version: 1.0.0
126
62
  - !ruby/object:Gem::Dependency
@@ -139,22 +75,6 @@ dependencies:
139
75
  - - ~>
140
76
  - !ruby/object:Gem::Version
141
77
  version: 1.8.3
142
- - !ruby/object:Gem::Dependency
143
- name: rspec
144
- requirement: !ruby/object:Gem::Requirement
145
- none: false
146
- requirements:
147
- - - ! '>='
148
- - !ruby/object:Gem::Version
149
- version: '0'
150
- type: :development
151
- prerelease: false
152
- version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
- requirements:
155
- - - ! '>='
156
- - !ruby/object:Gem::Version
157
- version: '0'
158
78
  description: ! "The Exchange Gem gives you easy access to currency functions directly
159
79
  on your Numbers. Imagine a conversion as easy as \n 1.eur.to_usd\n or even better
160
80
  \n 1.eur.to_usd(:at => Time.now - 84600)\n which gets you an exchange at the
@@ -180,6 +100,7 @@ files:
180
100
  - iso4217.yml
181
101
  - lib/core_extensions/conversability.rb
182
102
  - lib/exchange.rb
103
+ - lib/exchange/base.rb
183
104
  - lib/exchange/cache.rb
184
105
  - lib/exchange/cache/base.rb
185
106
  - lib/exchange/cache/file.rb
@@ -194,7 +115,10 @@ files:
194
115
  - lib/exchange/external_api/call.rb
195
116
  - lib/exchange/external_api/currency_bot.rb
196
117
  - lib/exchange/external_api/ecb.rb
118
+ - lib/exchange/external_api/json.rb
197
119
  - lib/exchange/external_api/xavier_media.rb
120
+ - lib/exchange/external_api/xml.rb
121
+ - lib/exchange/gem_loader.rb
198
122
  - lib/exchange/helper.rb
199
123
  - lib/exchange/iso_4217.rb
200
124
  - spec/core_extensions/conversability_spec.rb
@@ -211,6 +135,7 @@ files:
211
135
  - spec/exchange/external_api/currency_bot_spec.rb
212
136
  - spec/exchange/external_api/ecb_spec.rb
213
137
  - spec/exchange/external_api/xavier_media_spec.rb
138
+ - spec/exchange/gem_loader_spec.rb
214
139
  - spec/exchange/helper_spec.rb
215
140
  - spec/exchange/iso_4217_spec.rb
216
141
  - spec/spec_helper.rb
@@ -235,7 +160,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
235
160
  version: '0'
236
161
  segments:
237
162
  - 0
238
- hash: -1271993619830329119
163
+ hash: 595056188354575082
239
164
  required_rubygems_version: !ruby/object:Gem::Requirement
240
165
  none: false
241
166
  requirements: