economy 4.0.2.2 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +5 -5
  4. data/Rakefile +1 -3
  5. data/lib/economy.rb +2 -0
  6. data/lib/economy/cache.rb +3 -3
  7. data/lib/economy/configuration.rb +1 -1
  8. data/lib/economy/money.rb +6 -3
  9. data/lib/economy/version.rb +1 -1
  10. data/lib/generators/economy/install/install_generator.rb +6 -6
  11. data/lib/generators/economy/install/templates/{migration.rb → create_exchanges.rb} +0 -0
  12. data/lib/generators/economy/install/templates/{initializer.rb → economy.rb} +0 -0
  13. data/lib/generators/economy/install/templates/{configuration.yml → redis.yml} +0 -0
  14. metadata +20 -136
  15. data/test/dummy/Rakefile +0 -5
  16. data/test/dummy/app/assets/javascripts/application.js +0 -13
  17. data/test/dummy/app/assets/stylesheets/application.css +0 -15
  18. data/test/dummy/app/controllers/application_controller.rb +0 -5
  19. data/test/dummy/app/helpers/application_helper.rb +0 -2
  20. data/test/dummy/app/models/plan.rb +0 -5
  21. data/test/dummy/app/models/product.rb +0 -5
  22. data/test/dummy/app/views/layouts/application.html.erb +0 -12
  23. data/test/dummy/bin/bundle +0 -4
  24. data/test/dummy/bin/rails +0 -5
  25. data/test/dummy/bin/rake +0 -5
  26. data/test/dummy/bin/setup +0 -30
  27. data/test/dummy/config.ru +0 -4
  28. data/test/dummy/config/application.rb +0 -25
  29. data/test/dummy/config/boot.rb +0 -5
  30. data/test/dummy/config/database.yml +0 -10
  31. data/test/dummy/config/database.yml.travis +0 -3
  32. data/test/dummy/config/environment.rb +0 -5
  33. data/test/dummy/config/environments/development.rb +0 -41
  34. data/test/dummy/config/environments/production.rb +0 -79
  35. data/test/dummy/config/environments/test.rb +0 -42
  36. data/test/dummy/config/initializers/assets.rb +0 -11
  37. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  38. data/test/dummy/config/initializers/cookies_serializer.rb +0 -3
  39. data/test/dummy/config/initializers/economy.rb +0 -19
  40. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  41. data/test/dummy/config/initializers/inflections.rb +0 -16
  42. data/test/dummy/config/initializers/mime_types.rb +0 -4
  43. data/test/dummy/config/initializers/session_store.rb +0 -3
  44. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  45. data/test/dummy/config/locales/en.yml +0 -23
  46. data/test/dummy/config/redis.yml +0 -9
  47. data/test/dummy/config/routes.rb +0 -56
  48. data/test/dummy/config/secrets.yml +0 -22
  49. data/test/dummy/db/migrate/20161115135521_create_exchanges.rb +0 -14
  50. data/test/dummy/db/migrate/20161115145905_create_products.rb +0 -10
  51. data/test/dummy/db/migrate/20161115150024_create_plans.rb +0 -11
  52. data/test/dummy/db/schema.rb +0 -45
  53. data/test/dummy/log/development.log +0 -224
  54. data/test/dummy/log/test.log +0 -4988
  55. data/test/dummy/public/404.html +0 -61
  56. data/test/dummy/public/422.html +0 -61
  57. data/test/dummy/public/500.html +0 -60
  58. data/test/dummy/public/favicon.ico +0 -0
  59. data/test/fixtures/yahoo/multiple.json +0 -29
  60. data/test/fixtures/yahoo/single.json +0 -18
  61. data/test/fixtures/yahoo/unknown.json +0 -18
  62. data/test/generator_test.rb +0 -20
  63. data/test/money_test.rb +0 -142
  64. data/test/rate_test.rb +0 -60
  65. data/test/record_test.rb +0 -60
  66. data/test/support/money_helper.rb +0 -30
  67. data/test/support/rate_helper.rb +0 -16
  68. data/test/task_test.rb +0 -22
  69. data/test/test_helper.rb +0 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 604ef31f6b464eba0d5b4d8c8a454df35fd71702
4
- data.tar.gz: 8a1a64a988d2512cd3d9153a9fb546423a4f9119
3
+ metadata.gz: 62a2ca99ccecd9937ba2d6615de139271b036c69
4
+ data.tar.gz: a9cd3831673d998374028c65446e9d46a30d82ef
5
5
  SHA512:
6
- metadata.gz: 10e15710522822f0a16ce3593d062f8fdcf3fe8f0a17bcb42726c3bc5b05c35d14b961bf275115c007f16ced00368facfc68eabf5350d82902d365de410923f9
7
- data.tar.gz: eb8348a59397084bea84f35228b26b70dbe7d2128f0a2043b40fa9de4f1cce8f4456fa9e633ce006f42ecc3db932669f58d3139870eb373cbff1bcc83edaf8ae
6
+ metadata.gz: 25a6321fbe47283b149a902aeb3b9238dcfc58fbb1c1f6c4239ee88e33522cb23594f92a492871d09610fcef44c9a6523dd60ddf0c0975d3cd1b4a0a84a099a2
7
+ data.tar.gz: c1545860209426cdd85756b05c90e55fa03e8d390c167a03fbd79356d304c7818933cb5ee214e1c4aaa96afea85981be13b0f7b19379820b3e3804242fbdcab5
@@ -1,4 +1,4 @@
1
- Copyright 2016 Mathías Montossi
1
+ Copyright 2017 Museways
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/economy.svg)](http://badge.fury.io/rb/economy)
2
- [![Code Climate](https://codeclimate.com/github/mmontossi/economy/badges/gpa.svg)](https://codeclimate.com/github/mmontossi/economy)
3
- [![Build Status](https://travis-ci.org/mmontossi/economy.svg)](https://travis-ci.org/mmontossi/economy)
4
- [![Dependency Status](https://gemnasium.com/mmontossi/economy.svg)](https://gemnasium.com/mmontossi/economy)
2
+ [![Code Climate](https://codeclimate.com/github/museways/economy/badges/gpa.svg)](https://codeclimate.com/github/museways/economy)
3
+ [![Build Status](https://travis-ci.org/museways/economy.svg)](https://travis-ci.org/museways/economy)
4
+ [![Dependency Status](https://gemnasium.com/museways/economy.svg)](https://gemnasium.com/museways/economy)
5
5
 
6
6
  # Economy
7
7
 
@@ -140,11 +140,11 @@ NOTE: You probably want to put the rake task into a cronjob.
140
140
 
141
141
  Any issue, pull request, comment of any kind is more than welcome!
142
142
 
143
- I will mainly ensure compatibility to PostgreSQL, AWS, Redis, Elasticsearch, FreeBSD and Memcached
143
+ I will mainly ensure compatibility to Rails, AWS, PostgreSQL, Redis, Elasticsearch and FreeBSD
144
144
 
145
145
  ## Credits
146
146
 
147
- This gem is maintained and funded by [mmontossi](https://github.com/mmontossi).
147
+ This gem is maintained and funded by [museways](https://github.com/museways).
148
148
 
149
149
  ## License
150
150
 
data/Rakefile CHANGED
@@ -4,16 +4,14 @@ rescue LoadError
4
4
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
5
  end
6
6
 
7
- Bundler::GemHelper.install_tasks
7
+ require 'bundler/gem_tasks'
8
8
 
9
9
  require 'rake/testtask'
10
10
 
11
11
  Rake::TestTask.new(:test) do |t|
12
- t.libs << 'lib'
13
12
  t.libs << 'test'
14
13
  t.pattern = 'test/**/*_test.rb'
15
14
  t.verbose = false
16
- t.warning = false
17
15
  end
18
16
 
19
17
  task default: :test
@@ -1,3 +1,5 @@
1
+ require 'net/http'
2
+
1
3
  require 'economy/extensions/active_record/base'
2
4
  require 'economy/rates/base'
3
5
  require 'economy/rates/yahoo'
@@ -14,13 +14,13 @@ module Economy
14
14
  end
15
15
 
16
16
  def method_missing(name, *args, &block)
17
- client.public_send name, *args, &block
17
+ redis.public_send name, *args, &block
18
18
  end
19
19
 
20
20
  private
21
21
 
22
- def client
23
- @client ||= begin
22
+ def redis
23
+ @redis ||= begin
24
24
  require 'redis'
25
25
  Redis.new YAML.load_file("#{Rails.root}/config/redis.yml")[Rails.env]
26
26
  end
@@ -1,7 +1,7 @@
1
1
  module Economy
2
2
  class Configuration
3
3
 
4
- attr_accessor :client, :rates, :default_currency
4
+ attr_accessor :rates, :default_currency
5
5
 
6
6
  def add_currency(*args)
7
7
  Economy.currencies.add *args
@@ -59,7 +59,7 @@ module Economy
59
59
  other = other.exchange_to(currency)
60
60
  amount <=> other.amount
61
61
  else
62
- raise "Only Numeric 0 and Money can be compared with Money"
62
+ raise "Can't compare #{other.class.name} with Money"
63
63
  end
64
64
  end
65
65
 
@@ -82,7 +82,10 @@ module Economy
82
82
  end
83
83
 
84
84
  def *(value)
85
- if value.is_a?(Numeric)
85
+ case value
86
+ when Money
87
+ amount * value.exchange_to(currency).amount
88
+ when Numeric
86
89
  Money.new (amount * value), currency
87
90
  else
88
91
  raise "Can't multiply Money by #{value.class.name}"
@@ -136,7 +139,7 @@ module Economy
136
139
  if rate = Economy.rate(currency, new_currency)
137
140
  Money.new (amount * BigDecimal(rate)), new_currency
138
141
  else
139
- raise "Exchange #{currency.iso_code} => #{new_currency.iso_code} not found"
142
+ raise "Rate #{currency.iso_code} => #{new_currency.iso_code} not found"
140
143
  end
141
144
  else
142
145
  self
@@ -1,5 +1,5 @@
1
1
  module Economy
2
2
 
3
- VERSION = '4.0.2.2'
3
+ VERSION = '5.1.0'
4
4
 
5
5
  end
@@ -7,16 +7,16 @@ module Economy
7
7
 
8
8
  source_root File.expand_path('../templates', __FILE__)
9
9
 
10
- def create_initializer_file
11
- copy_file 'initializer.rb', 'config/initializers/economy.rb'
10
+ def add_economy_file
11
+ copy_file 'economy.rb', 'config/initializers/economy.rb'
12
12
  end
13
13
 
14
- def create_configuration_file
15
- copy_file 'configuration.yml', 'config/redis.yml'
14
+ def add_redis_file
15
+ copy_file 'redis.yml', 'config/redis.yml'
16
16
  end
17
17
 
18
- def create_migration_file
19
- migration_template 'migration.rb', 'db/migrate/create_exchanges.rb'
18
+ def add_create_exchanges_file
19
+ migration_template 'create_exchanges.rb', 'db/migrate/create_exchanges.rb'
20
20
  end
21
21
 
22
22
  def self.next_migration_number(path)
metadata CHANGED
@@ -1,80 +1,74 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: economy
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.2.2
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mmontossi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-14 00:00:00.000000000 Z
11
+ date: 2017-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 4.2.0
20
- - - "<"
17
+ - - "~>"
21
18
  - !ruby/object:Gem::Version
22
- version: 4.3.0
19
+ version: '5.1'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: 4.2.0
30
- - - "<"
24
+ - - "~>"
31
25
  - !ruby/object:Gem::Version
32
- version: 4.3.0
26
+ version: '5.1'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: redis
35
29
  requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
37
31
  - - "~>"
38
32
  - !ruby/object:Gem::Version
39
- version: '3.2'
33
+ version: '4.0'
40
34
  type: :runtime
41
35
  prerelease: false
42
36
  version_requirements: !ruby/object:Gem::Requirement
43
37
  requirements:
44
38
  - - "~>"
45
39
  - !ruby/object:Gem::Version
46
- version: '3.2'
40
+ version: '4.0'
47
41
  - !ruby/object:Gem::Dependency
48
42
  name: pg
49
43
  requirement: !ruby/object:Gem::Requirement
50
44
  requirements:
51
45
  - - "~>"
52
46
  - !ruby/object:Gem::Version
53
- version: '0.18'
47
+ version: '0.21'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
51
  requirements:
58
52
  - - "~>"
59
53
  - !ruby/object:Gem::Version
60
- version: '0.18'
54
+ version: '0.21'
61
55
  - !ruby/object:Gem::Dependency
62
56
  name: mocha
63
57
  requirement: !ruby/object:Gem::Requirement
64
58
  requirements:
65
59
  - - "~>"
66
60
  - !ruby/object:Gem::Version
67
- version: '1.1'
61
+ version: '1.2'
68
62
  type: :development
69
63
  prerelease: false
70
64
  version_requirements: !ruby/object:Gem::Requirement
71
65
  requirements:
72
66
  - - "~>"
73
67
  - !ruby/object:Gem::Version
74
- version: '1.1'
68
+ version: '1.2'
75
69
  description: High performance multicurrency money for rails.
76
70
  email:
77
- - mmontossi@gmail.com
71
+ - hi@museways.com
78
72
  executables: []
79
73
  extensions: []
80
74
  extra_rdoc_files: []
@@ -96,66 +90,11 @@ files:
96
90
  - lib/economy/rates/yahoo.rb
97
91
  - lib/economy/version.rb
98
92
  - lib/generators/economy/install/install_generator.rb
99
- - lib/generators/economy/install/templates/configuration.yml
100
- - lib/generators/economy/install/templates/initializer.rb
101
- - lib/generators/economy/install/templates/migration.rb
93
+ - lib/generators/economy/install/templates/create_exchanges.rb
94
+ - lib/generators/economy/install/templates/economy.rb
95
+ - lib/generators/economy/install/templates/redis.yml
102
96
  - lib/tasks/economy.rake
103
- - test/dummy/Rakefile
104
- - test/dummy/app/assets/javascripts/application.js
105
- - test/dummy/app/assets/stylesheets/application.css
106
- - test/dummy/app/controllers/application_controller.rb
107
- - test/dummy/app/helpers/application_helper.rb
108
- - test/dummy/app/models/plan.rb
109
- - test/dummy/app/models/product.rb
110
- - test/dummy/app/views/layouts/application.html.erb
111
- - test/dummy/bin/bundle
112
- - test/dummy/bin/rails
113
- - test/dummy/bin/rake
114
- - test/dummy/bin/setup
115
- - test/dummy/config.ru
116
- - test/dummy/config/application.rb
117
- - test/dummy/config/boot.rb
118
- - test/dummy/config/database.yml
119
- - test/dummy/config/database.yml.travis
120
- - test/dummy/config/environment.rb
121
- - test/dummy/config/environments/development.rb
122
- - test/dummy/config/environments/production.rb
123
- - test/dummy/config/environments/test.rb
124
- - test/dummy/config/initializers/assets.rb
125
- - test/dummy/config/initializers/backtrace_silencers.rb
126
- - test/dummy/config/initializers/cookies_serializer.rb
127
- - test/dummy/config/initializers/economy.rb
128
- - test/dummy/config/initializers/filter_parameter_logging.rb
129
- - test/dummy/config/initializers/inflections.rb
130
- - test/dummy/config/initializers/mime_types.rb
131
- - test/dummy/config/initializers/session_store.rb
132
- - test/dummy/config/initializers/wrap_parameters.rb
133
- - test/dummy/config/locales/en.yml
134
- - test/dummy/config/redis.yml
135
- - test/dummy/config/routes.rb
136
- - test/dummy/config/secrets.yml
137
- - test/dummy/db/migrate/20161115135521_create_exchanges.rb
138
- - test/dummy/db/migrate/20161115145905_create_products.rb
139
- - test/dummy/db/migrate/20161115150024_create_plans.rb
140
- - test/dummy/db/schema.rb
141
- - test/dummy/log/development.log
142
- - test/dummy/log/test.log
143
- - test/dummy/public/404.html
144
- - test/dummy/public/422.html
145
- - test/dummy/public/500.html
146
- - test/dummy/public/favicon.ico
147
- - test/fixtures/yahoo/multiple.json
148
- - test/fixtures/yahoo/single.json
149
- - test/fixtures/yahoo/unknown.json
150
- - test/generator_test.rb
151
- - test/money_test.rb
152
- - test/rate_test.rb
153
- - test/record_test.rb
154
- - test/support/money_helper.rb
155
- - test/support/rate_helper.rb
156
- - test/task_test.rb
157
- - test/test_helper.rb
158
- homepage: https://github.com/mmontossi/economy
97
+ homepage: https://github.com/museways/economy
159
98
  licenses:
160
99
  - MIT
161
100
  metadata: {}
@@ -167,7 +106,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
167
106
  requirements:
168
107
  - - ">="
169
108
  - !ruby/object:Gem::Version
170
- version: 2.0.0
109
+ version: '0'
171
110
  required_rubygems_version: !ruby/object:Gem::Requirement
172
111
  requirements:
173
112
  - - ">="
@@ -175,63 +114,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
114
  version: '0'
176
115
  requirements: []
177
116
  rubyforge_project:
178
- rubygems_version: 2.5.1
117
+ rubygems_version: 2.6.13
179
118
  signing_key:
180
119
  specification_version: 4
181
120
  summary: Economy for Rails
182
- test_files:
183
- - test/dummy/app/assets/javascripts/application.js
184
- - test/dummy/app/assets/stylesheets/application.css
185
- - test/dummy/app/controllers/application_controller.rb
186
- - test/dummy/app/helpers/application_helper.rb
187
- - test/dummy/app/models/plan.rb
188
- - test/dummy/app/models/product.rb
189
- - test/dummy/app/views/layouts/application.html.erb
190
- - test/dummy/bin/bundle
191
- - test/dummy/bin/rails
192
- - test/dummy/bin/rake
193
- - test/dummy/bin/setup
194
- - test/dummy/config/application.rb
195
- - test/dummy/config/boot.rb
196
- - test/dummy/config/database.yml
197
- - test/dummy/config/database.yml.travis
198
- - test/dummy/config/environment.rb
199
- - test/dummy/config/environments/development.rb
200
- - test/dummy/config/environments/production.rb
201
- - test/dummy/config/environments/test.rb
202
- - test/dummy/config/initializers/assets.rb
203
- - test/dummy/config/initializers/backtrace_silencers.rb
204
- - test/dummy/config/initializers/cookies_serializer.rb
205
- - test/dummy/config/initializers/economy.rb
206
- - test/dummy/config/initializers/filter_parameter_logging.rb
207
- - test/dummy/config/initializers/inflections.rb
208
- - test/dummy/config/initializers/mime_types.rb
209
- - test/dummy/config/initializers/session_store.rb
210
- - test/dummy/config/initializers/wrap_parameters.rb
211
- - test/dummy/config/locales/en.yml
212
- - test/dummy/config/redis.yml
213
- - test/dummy/config/routes.rb
214
- - test/dummy/config/secrets.yml
215
- - test/dummy/config.ru
216
- - test/dummy/db/migrate/20161115135521_create_exchanges.rb
217
- - test/dummy/db/migrate/20161115145905_create_products.rb
218
- - test/dummy/db/migrate/20161115150024_create_plans.rb
219
- - test/dummy/db/schema.rb
220
- - test/dummy/log/development.log
221
- - test/dummy/log/test.log
222
- - test/dummy/public/404.html
223
- - test/dummy/public/422.html
224
- - test/dummy/public/500.html
225
- - test/dummy/public/favicon.ico
226
- - test/dummy/Rakefile
227
- - test/fixtures/yahoo/multiple.json
228
- - test/fixtures/yahoo/single.json
229
- - test/fixtures/yahoo/unknown.json
230
- - test/generator_test.rb
231
- - test/money_test.rb
232
- - test/rate_test.rb
233
- - test/record_test.rb
234
- - test/support/money_helper.rb
235
- - test/support/rate_helper.rb
236
- - test/task_test.rb
237
- - test/test_helper.rb
121
+ test_files: []
@@ -1,5 +0,0 @@
1
- # Add your own tasks in files placed in lib/tasks ending in .rake,
2
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
-
4
- require File.expand_path('../config/application', __FILE__)
5
- Rails.application.load_tasks
@@ -1,13 +0,0 @@
1
- // This is a manifest file that'll be compiled into application.js, which will include all the files
2
- // listed below.
3
- //
4
- // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
- //
7
- // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // compiled file.
9
- //
10
- // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
- // about supported directives.
12
- //
13
- //= require_tree .
@@ -1,15 +0,0 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
- * compiled file so the styles you add here take precedence over styles defined in any styles
10
- * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
- * file per style scope.
12
- *
13
- *= require_tree .
14
- *= require_self
15
- */
@@ -1,5 +0,0 @@
1
- class ApplicationController < ActionController::Base
2
- # Prevent CSRF attacks by raising an exception.
3
- # For APIs, you may want to use :null_session instead.
4
- protect_from_forgery with: :exception
5
- end