money-rails 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +6 -0
- data/README.md +67 -7
- data/Rakefile +5 -0
- data/lib/money-rails.rb +5 -4
- data/lib/money-rails/active_record/monetizable.rb +20 -5
- data/lib/money-rails/helpers/action_view_extension.rb +36 -0
- data/lib/money-rails/hooks.rb +29 -0
- data/lib/money-rails/railtie.rb +3 -5
- data/lib/money-rails/version.rb +1 -1
- data/money-rails.gemspec +3 -4
- data/spec/active_record/monetizable_spec.rb +32 -1
- data/spec/dummy/app/models/product.rb +4 -1
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20120607210247_add_column_that_allows_nil.rb +5 -0
- data/spec/dummy/db/schema.rb +4 -3
- data/spec/dummy/db/structure.sql +17 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +44 -139
- data/spec/dummy/log/test.log +1714 -15710
- data/spec/helpers/action_view_extension_spec.rb +38 -0
- metadata +85 -129
- data/lib/money-rails/orms.rb +0 -29
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'MoneyRails::ActionViewExtension' do
|
4
|
+
describe '#currency_symbol' do
|
5
|
+
subject { helper.currency_symbol }
|
6
|
+
it { should be_a String }
|
7
|
+
it { should include Money.default_currency.symbol }
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#humanized_money' do
|
11
|
+
subject { helper.humanized_money Money.new(12500) }
|
12
|
+
it { should be_a String }
|
13
|
+
it { should_not include Money.default_currency.symbol }
|
14
|
+
it { should_not include Money.default_currency.decimal_mark }
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#humanized_money_with_symbol' do
|
18
|
+
subject { helper.humanized_money_with_symbol Money.new(12500) }
|
19
|
+
it { should be_a String }
|
20
|
+
it { should_not include Money.default_currency.decimal_mark }
|
21
|
+
it { should include Money.default_currency.symbol }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#money_without_cents' do
|
25
|
+
subject { helper.money_without_cents Money.new(12500) }
|
26
|
+
it { should be_a String }
|
27
|
+
it { should_not include Money.default_currency.symbol }
|
28
|
+
it { should_not include Money.default_currency.decimal_mark }
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#money_without_cents_and_with_symbol' do
|
32
|
+
subject { helper.money_without_cents_and_with_symbol Money.new(12500) }
|
33
|
+
it { should be_a String }
|
34
|
+
it { should_not include Money.default_currency.decimal_mark }
|
35
|
+
it { should include Money.default_currency.symbol }
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: money-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,11 +11,11 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-06-
|
14
|
+
date: 2012-06-22 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: money
|
18
|
-
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirement: &10552880 !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
21
|
- - ~>
|
@@ -23,15 +23,10 @@ dependencies:
|
|
23
23
|
version: 5.0.0
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
|
-
version_requirements:
|
27
|
-
none: false
|
28
|
-
requirements:
|
29
|
-
- - ~>
|
30
|
-
- !ruby/object:Gem::Version
|
31
|
-
version: 5.0.0
|
26
|
+
version_requirements: *10552880
|
32
27
|
- !ruby/object:Gem::Dependency
|
33
28
|
name: activesupport
|
34
|
-
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirement: &10552340 !ruby/object:Gem::Requirement
|
35
30
|
none: false
|
36
31
|
requirements:
|
37
32
|
- - ~>
|
@@ -39,15 +34,10 @@ dependencies:
|
|
39
34
|
version: '3.0'
|
40
35
|
type: :runtime
|
41
36
|
prerelease: false
|
42
|
-
version_requirements:
|
43
|
-
none: false
|
44
|
-
requirements:
|
45
|
-
- - ~>
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '3.0'
|
37
|
+
version_requirements: *10552340
|
48
38
|
- !ruby/object:Gem::Dependency
|
49
39
|
name: railties
|
50
|
-
requirement: !ruby/object:Gem::Requirement
|
40
|
+
requirement: &10551860 !ruby/object:Gem::Requirement
|
51
41
|
none: false
|
52
42
|
requirements:
|
53
43
|
- - ~>
|
@@ -55,92 +45,51 @@ dependencies:
|
|
55
45
|
version: '3.0'
|
56
46
|
type: :runtime
|
57
47
|
prerelease: false
|
58
|
-
version_requirements:
|
59
|
-
none: false
|
60
|
-
requirements:
|
61
|
-
- - ~>
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
version: '3.0'
|
48
|
+
version_requirements: *10551860
|
64
49
|
- !ruby/object:Gem::Dependency
|
65
50
|
name: rails
|
66
|
-
requirement: !ruby/object:Gem::Requirement
|
67
|
-
none: false
|
68
|
-
requirements:
|
69
|
-
- - ~>
|
70
|
-
- !ruby/object:Gem::Version
|
71
|
-
version: '3.0'
|
72
|
-
type: :development
|
73
|
-
prerelease: false
|
74
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirement: &10551360 !ruby/object:Gem::Requirement
|
75
52
|
none: false
|
76
53
|
requirements:
|
77
54
|
- - ~>
|
78
55
|
- !ruby/object:Gem::Version
|
79
56
|
version: '3.0'
|
80
|
-
- !ruby/object:Gem::Dependency
|
81
|
-
name: sqlite3
|
82
|
-
requirement: !ruby/object:Gem::Requirement
|
83
|
-
none: false
|
84
|
-
requirements:
|
85
|
-
- - ~>
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
version: 1.3.6
|
88
57
|
type: :development
|
89
58
|
prerelease: false
|
90
|
-
version_requirements:
|
91
|
-
none: false
|
92
|
-
requirements:
|
93
|
-
- - ~>
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version: 1.3.6
|
59
|
+
version_requirements: *10551360
|
96
60
|
- !ruby/object:Gem::Dependency
|
97
61
|
name: rspec
|
98
|
-
requirement: !ruby/object:Gem::Requirement
|
62
|
+
requirement: &10550860 !ruby/object:Gem::Requirement
|
99
63
|
none: false
|
100
64
|
requirements:
|
101
65
|
- - ~>
|
102
66
|
- !ruby/object:Gem::Version
|
103
|
-
version: 2.
|
67
|
+
version: '2.10'
|
104
68
|
type: :development
|
105
69
|
prerelease: false
|
106
|
-
version_requirements:
|
107
|
-
none: false
|
108
|
-
requirements:
|
109
|
-
- - ~>
|
110
|
-
- !ruby/object:Gem::Version
|
111
|
-
version: 2.9.0
|
70
|
+
version_requirements: *10550860
|
112
71
|
- !ruby/object:Gem::Dependency
|
113
72
|
name: rspec-rails
|
114
|
-
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirement: &10550360 !ruby/object:Gem::Requirement
|
115
74
|
none: false
|
116
75
|
requirements:
|
117
76
|
- - ~>
|
118
77
|
- !ruby/object:Gem::Version
|
119
|
-
version: 2.
|
78
|
+
version: '2.10'
|
120
79
|
type: :development
|
121
80
|
prerelease: false
|
122
|
-
version_requirements:
|
123
|
-
none: false
|
124
|
-
requirements:
|
125
|
-
- - ~>
|
126
|
-
- !ruby/object:Gem::Version
|
127
|
-
version: 2.9.0
|
81
|
+
version_requirements: *10550360
|
128
82
|
- !ruby/object:Gem::Dependency
|
129
83
|
name: guard-rspec
|
130
|
-
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirement: &10549880 !ruby/object:Gem::Requirement
|
131
85
|
none: false
|
132
86
|
requirements:
|
133
87
|
- - ~>
|
134
88
|
- !ruby/object:Gem::Version
|
135
|
-
version:
|
89
|
+
version: '1.1'
|
136
90
|
type: :development
|
137
91
|
prerelease: false
|
138
|
-
version_requirements:
|
139
|
-
none: false
|
140
|
-
requirements:
|
141
|
-
- - ~>
|
142
|
-
- !ruby/object:Gem::Version
|
143
|
-
version: 0.7.2
|
92
|
+
version_requirements: *10549880
|
144
93
|
description: This library provides integration of RubyMoney - Money gem with Rails
|
145
94
|
email:
|
146
95
|
- alup.rubymoney@gmail.com
|
@@ -148,60 +97,64 @@ executables: []
|
|
148
97
|
extensions: []
|
149
98
|
extra_rdoc_files: []
|
150
99
|
files:
|
151
|
-
- lib/money-rails.rb
|
152
|
-
- lib/money-rails/railtie.rb
|
100
|
+
- lib/money-rails/hooks.rb
|
153
101
|
- lib/money-rails/active_record/monetizable.rb
|
154
|
-
- lib/money-rails/version.rb
|
155
102
|
- lib/money-rails/configuration.rb
|
156
|
-
- lib/money-rails/
|
103
|
+
- lib/money-rails/version.rb
|
104
|
+
- lib/money-rails/helpers/action_view_extension.rb
|
105
|
+
- lib/money-rails/railtie.rb
|
106
|
+
- lib/money-rails.rb
|
157
107
|
- lib/generators/money_rails/initializer_generator.rb
|
158
108
|
- lib/generators/templates/money.rb
|
159
109
|
- spec/spec_helper.rb
|
160
110
|
- spec/active_record/monetizable_spec.rb
|
161
111
|
- spec/dummy/script/rails
|
162
|
-
- spec/dummy/
|
163
|
-
- spec/dummy/db/schema.rb
|
164
|
-
- spec/dummy/db/migrate/20120524052716_create_services.rb
|
112
|
+
- spec/dummy/db/migrate/20120528181002_create_transactions.rb
|
165
113
|
- spec/dummy/db/migrate/20120402080348_add_bonus_cents_to_product.rb
|
114
|
+
- spec/dummy/db/migrate/20120607210247_add_column_that_allows_nil.rb
|
166
115
|
- spec/dummy/db/migrate/20120528210103_create_dummy_products.rb
|
167
|
-
- spec/dummy/db/migrate/20120528181002_create_transactions.rb
|
168
116
|
- spec/dummy/db/migrate/20120331190108_create_products.rb
|
117
|
+
- spec/dummy/db/migrate/20120524052716_create_services.rb
|
118
|
+
- spec/dummy/db/structure.sql
|
119
|
+
- spec/dummy/db/schema.rb
|
169
120
|
- spec/dummy/db/test.sqlite3
|
170
121
|
- spec/dummy/db/development.sqlite3
|
171
122
|
- spec/dummy/README.rdoc
|
172
|
-
- spec/dummy/
|
173
|
-
- spec/dummy/
|
174
|
-
- spec/dummy/log/test.log
|
175
|
-
- spec/dummy/app/controllers/application_controller.rb
|
176
|
-
- spec/dummy/app/views/layouts/application.html.erb
|
177
|
-
- spec/dummy/app/helpers/application_helper.rb
|
178
|
-
- spec/dummy/app/models/transaction.rb
|
179
|
-
- spec/dummy/app/models/service.rb
|
180
|
-
- spec/dummy/app/models/product.rb
|
181
|
-
- spec/dummy/app/models/dummy_product.rb
|
182
|
-
- spec/dummy/app/assets/javascripts/application.js
|
183
|
-
- spec/dummy/app/assets/stylesheets/application.css
|
184
|
-
- spec/dummy/config/boot.rb
|
185
|
-
- spec/dummy/config/routes.rb
|
123
|
+
- spec/dummy/Rakefile
|
124
|
+
- spec/dummy/config/environment.rb
|
186
125
|
- spec/dummy/config/locales/en.yml
|
187
|
-
- spec/dummy/config/
|
188
|
-
- spec/dummy/config/application.rb
|
126
|
+
- spec/dummy/config/initializers/money.rb
|
189
127
|
- spec/dummy/config/initializers/mime_types.rb
|
128
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
190
129
|
- spec/dummy/config/initializers/backtrace_silencers.rb
|
191
|
-
- spec/dummy/config/initializers/money.rb
|
192
130
|
- spec/dummy/config/initializers/session_store.rb
|
193
|
-
- spec/dummy/config/initializers/inflections.rb
|
194
131
|
- spec/dummy/config/initializers/secret_token.rb
|
195
|
-
- spec/dummy/config/initializers/
|
196
|
-
- spec/dummy/config/
|
197
|
-
- spec/dummy/config/
|
132
|
+
- spec/dummy/config/initializers/inflections.rb
|
133
|
+
- spec/dummy/config/boot.rb
|
134
|
+
- spec/dummy/config/database.yml
|
135
|
+
- spec/dummy/config/routes.rb
|
198
136
|
- spec/dummy/config/environments/test.rb
|
137
|
+
- spec/dummy/config/environments/production.rb
|
199
138
|
- spec/dummy/config/environments/development.rb
|
200
|
-
- spec/dummy/
|
139
|
+
- spec/dummy/config/application.rb
|
140
|
+
- spec/dummy/app/assets/stylesheets/application.css
|
141
|
+
- spec/dummy/app/assets/javascripts/application.js
|
142
|
+
- spec/dummy/app/models/service.rb
|
143
|
+
- spec/dummy/app/models/product.rb
|
144
|
+
- spec/dummy/app/models/dummy_product.rb
|
145
|
+
- spec/dummy/app/models/transaction.rb
|
146
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
147
|
+
- spec/dummy/app/helpers/application_helper.rb
|
148
|
+
- spec/dummy/app/controllers/application_controller.rb
|
149
|
+
- spec/dummy/log/development.log
|
150
|
+
- spec/dummy/log/test.log
|
151
|
+
- spec/dummy/config.ru
|
152
|
+
- spec/dummy/public/500.html
|
201
153
|
- spec/dummy/public/404.html
|
202
154
|
- spec/dummy/public/favicon.ico
|
203
|
-
- spec/dummy/public/
|
155
|
+
- spec/dummy/public/422.html
|
204
156
|
- spec/configuration_spec.rb
|
157
|
+
- spec/helpers/action_view_extension_spec.rb
|
205
158
|
- CHANGELOG.md
|
206
159
|
- LICENSE
|
207
160
|
- README.md
|
@@ -228,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
228
181
|
version: '0'
|
229
182
|
requirements: []
|
230
183
|
rubyforge_project:
|
231
|
-
rubygems_version: 1.8.
|
184
|
+
rubygems_version: 1.8.11
|
232
185
|
signing_key:
|
233
186
|
specification_version: 3
|
234
187
|
summary: Money gem integration with Rails
|
@@ -236,47 +189,50 @@ test_files:
|
|
236
189
|
- spec/spec_helper.rb
|
237
190
|
- spec/active_record/monetizable_spec.rb
|
238
191
|
- spec/dummy/script/rails
|
239
|
-
- spec/dummy/
|
240
|
-
- spec/dummy/db/schema.rb
|
241
|
-
- spec/dummy/db/migrate/20120524052716_create_services.rb
|
192
|
+
- spec/dummy/db/migrate/20120528181002_create_transactions.rb
|
242
193
|
- spec/dummy/db/migrate/20120402080348_add_bonus_cents_to_product.rb
|
194
|
+
- spec/dummy/db/migrate/20120607210247_add_column_that_allows_nil.rb
|
243
195
|
- spec/dummy/db/migrate/20120528210103_create_dummy_products.rb
|
244
|
-
- spec/dummy/db/migrate/20120528181002_create_transactions.rb
|
245
196
|
- spec/dummy/db/migrate/20120331190108_create_products.rb
|
197
|
+
- spec/dummy/db/migrate/20120524052716_create_services.rb
|
198
|
+
- spec/dummy/db/structure.sql
|
199
|
+
- spec/dummy/db/schema.rb
|
246
200
|
- spec/dummy/db/test.sqlite3
|
247
201
|
- spec/dummy/db/development.sqlite3
|
248
202
|
- spec/dummy/README.rdoc
|
249
|
-
- spec/dummy/
|
250
|
-
- spec/dummy/
|
251
|
-
- spec/dummy/log/test.log
|
252
|
-
- spec/dummy/app/controllers/application_controller.rb
|
253
|
-
- spec/dummy/app/views/layouts/application.html.erb
|
254
|
-
- spec/dummy/app/helpers/application_helper.rb
|
255
|
-
- spec/dummy/app/models/transaction.rb
|
256
|
-
- spec/dummy/app/models/service.rb
|
257
|
-
- spec/dummy/app/models/product.rb
|
258
|
-
- spec/dummy/app/models/dummy_product.rb
|
259
|
-
- spec/dummy/app/assets/javascripts/application.js
|
260
|
-
- spec/dummy/app/assets/stylesheets/application.css
|
261
|
-
- spec/dummy/config/boot.rb
|
262
|
-
- spec/dummy/config/routes.rb
|
203
|
+
- spec/dummy/Rakefile
|
204
|
+
- spec/dummy/config/environment.rb
|
263
205
|
- spec/dummy/config/locales/en.yml
|
264
|
-
- spec/dummy/config/
|
265
|
-
- spec/dummy/config/application.rb
|
206
|
+
- spec/dummy/config/initializers/money.rb
|
266
207
|
- spec/dummy/config/initializers/mime_types.rb
|
208
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
267
209
|
- spec/dummy/config/initializers/backtrace_silencers.rb
|
268
|
-
- spec/dummy/config/initializers/money.rb
|
269
210
|
- spec/dummy/config/initializers/session_store.rb
|
270
|
-
- spec/dummy/config/initializers/inflections.rb
|
271
211
|
- spec/dummy/config/initializers/secret_token.rb
|
272
|
-
- spec/dummy/config/initializers/
|
273
|
-
- spec/dummy/config/
|
274
|
-
- spec/dummy/config/
|
212
|
+
- spec/dummy/config/initializers/inflections.rb
|
213
|
+
- spec/dummy/config/boot.rb
|
214
|
+
- spec/dummy/config/database.yml
|
215
|
+
- spec/dummy/config/routes.rb
|
275
216
|
- spec/dummy/config/environments/test.rb
|
217
|
+
- spec/dummy/config/environments/production.rb
|
276
218
|
- spec/dummy/config/environments/development.rb
|
277
|
-
- spec/dummy/
|
219
|
+
- spec/dummy/config/application.rb
|
220
|
+
- spec/dummy/app/assets/stylesheets/application.css
|
221
|
+
- spec/dummy/app/assets/javascripts/application.js
|
222
|
+
- spec/dummy/app/models/service.rb
|
223
|
+
- spec/dummy/app/models/product.rb
|
224
|
+
- spec/dummy/app/models/dummy_product.rb
|
225
|
+
- spec/dummy/app/models/transaction.rb
|
226
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
227
|
+
- spec/dummy/app/helpers/application_helper.rb
|
228
|
+
- spec/dummy/app/controllers/application_controller.rb
|
229
|
+
- spec/dummy/log/development.log
|
230
|
+
- spec/dummy/log/test.log
|
231
|
+
- spec/dummy/config.ru
|
232
|
+
- spec/dummy/public/500.html
|
278
233
|
- spec/dummy/public/404.html
|
279
234
|
- spec/dummy/public/favicon.ico
|
280
|
-
- spec/dummy/public/
|
235
|
+
- spec/dummy/public/422.html
|
281
236
|
- spec/configuration_spec.rb
|
237
|
+
- spec/helpers/action_view_extension_spec.rb
|
282
238
|
has_rdoc:
|
data/lib/money-rails/orms.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require "active_support/lazy_load_hooks"
|
2
|
-
|
3
|
-
# Thnx to Kristian Mandrup for the inspiration
|
4
|
-
# TODO: Include more ORMs/ODMs here
|
5
|
-
|
6
|
-
module MoneyRails
|
7
|
-
module Orms
|
8
|
-
def self.extend_for(name=:active_record)
|
9
|
-
case name.to_sym
|
10
|
-
when :active_record
|
11
|
-
if defined?(ActiveRecord::Base)
|
12
|
-
require "money-rails/active_record/monetizable"
|
13
|
-
|
14
|
-
# Lazy load extension
|
15
|
-
ActiveSupport.on_load :active_record do
|
16
|
-
include MoneyRails::ActiveRecord::Monetizable
|
17
|
-
end
|
18
|
-
end
|
19
|
-
else
|
20
|
-
raise ArgumentError, "ORM extension for #{name} is currently not supported."
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
# Return all supported ORMs
|
25
|
-
def self.supported
|
26
|
-
%w{active_record}
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|