mongoid_money_field 4.0.3 → 4.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 68b91a0a645063515a24f3902bae7efafde69eca
4
- data.tar.gz: 7b81ad337aba37b89186fc969035d3144ac0e1e1
3
+ metadata.gz: 478cb23feb9e6ecc86ca4f9d91cc09aee5325b99
4
+ data.tar.gz: 3b1f1728f032f34aeb8dc312d62979c8e335491f
5
5
  SHA512:
6
- metadata.gz: 41cc884779f49497d340d467f71753ba304a7f39278a08d28c34b407c19427eec00d8b624466f83b5a8f86373ed37197bc2f25f818063b66efa17decd3877b42
7
- data.tar.gz: 6cef48ad9a76dbd7e12617328750a12a0ed2938ece93930284c37ffc84099aaf2ee992f877f29441b13e6d8e4544da6d05abcfa4cbee55343e467260bbe780ff
6
+ metadata.gz: f0aa2e2b1f542d7b9f8b0e93bd932faad35f40a3542d1f6bd01b5eec2ed83953c8c32b8269282b57b71ad9bfc4d14fc6ed511968d3443899d439e105e2027025
7
+ data.tar.gz: 64702f48ee82d3a78ece7868b2ff26748d942bd2a5bf13160fda39e5a99dff721dc761c2bb91e27653625e4a9c6f7470e0a30273a50651825fe71cfb54232dd8
data/.travis.yml CHANGED
@@ -1,12 +1,6 @@
1
1
  language: ruby
2
2
  services: mongodb
3
- gemfile:
4
- #- gemfiles/money4-mongoid3.gemfile
5
- #- gemfiles/money4-mongoid31.gemfile
6
- - gemfiles/money50-mongoid3.gemfile
7
- #- gemfiles/money50-mongoid31.gemfile
8
- - gemfiles/money51-mongoid3.gemfile
9
- - gemfiles/money51-mongoid31.gemfile
3
+
10
4
  rvm:
11
5
  - 1.9.3
12
6
  - rbx-19mode
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mongoid_money_field (4.0.1)
4
+ mongoid_money_field (4.0.3)
5
5
  monetize
6
6
  money (~> 6.1.0.beta1)
7
7
  mongoid (>= 3.0.0)
@@ -171,4 +171,8 @@ end
171
171
 
172
172
  if Object.const_defined?("SimpleForm")
173
173
  require "mongoid_money_field/simple_form/money_input"
174
- end
174
+ end
175
+
176
+ if Object.const_defined?("RailsAdmin")
177
+ require "mongoid_money_field/rails_admin"
178
+ end
@@ -0,0 +1,46 @@
1
+ require 'rails_admin/adapters/mongoid'
2
+ require 'rails_admin/config/fields/types/string'
3
+ module RailsAdmin
4
+ module Adapters
5
+ module Mongoid
6
+ alias_method :type_lookup_without_money, :type_lookup
7
+ def type_lookup(name, field)
8
+ if field.type.to_s == 'Money' || field.type.class.name == 'MoneyType'
9
+ { :type => :money_field }
10
+ else
11
+ type_lookup_without_money(name, field)
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+ module Config
18
+ module Fields
19
+ module Types
20
+ class MoneyField < RailsAdmin::Config::Fields::Types::String
21
+ # Register field type for the type loader
22
+ RailsAdmin::Config::Fields::Types::register(self)
23
+
24
+ register_instance_option :pretty_value do
25
+ ret = if value.class.name == 'Hash'
26
+ value.stringify_keys!
27
+ if value['cents']
28
+ "%.2f" % ::Money.new(value['cents'], value['currency_iso']).to_f
29
+ else
30
+ value
31
+ end
32
+ elsif value.respond_to?(:cents)
33
+ "%.2f" % value.to_f
34
+ else
35
+ value
36
+ end
37
+ end
38
+
39
+ register_instance_option :formatted_value do
40
+ pretty_value
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -1,3 +1,3 @@
1
1
  module MongoidMoneyField
2
- VERSION = "4.0.3"
2
+ VERSION = "4.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_money_field
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.3
4
+ version: 4.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gleb Tv
@@ -168,14 +168,9 @@ files:
168
168
  - LICENSE.txt
169
169
  - README.rdoc
170
170
  - Rakefile
171
- - gemfiles/money4-mongoid3.gemfile
172
- - gemfiles/money4-mongoid31.gemfile
173
- - gemfiles/money50-mongoid3.gemfile
174
- - gemfiles/money50-mongoid31.gemfile
175
- - gemfiles/money51-mongoid3.gemfile
176
- - gemfiles/money51-mongoid31.gemfile
177
171
  - lib/mongoid_money_field.rb
178
172
  - lib/mongoid_money_field/field.rb
173
+ - lib/mongoid_money_field/rails_admin.rb
179
174
  - lib/mongoid_money_field/simple_form/money_input.rb
180
175
  - lib/mongoid_money_field/version.rb
181
176
  - mongoid_money_field.gemspec
@@ -1,12 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- gem 'mongoid', '~> 3.0.0'
4
- gem "money", "~> 4.0.2"
5
-
6
- gem "rspec", "~> 2.12.0"
7
- gem "rdoc", "~> 3.12"
8
- gem "bundler", ">= 1.1.0"
9
- gem "jeweler", "~> 1.8.3"
10
- gem "simplecov", '>= 0.4.0', :require => false
11
- gem "database_cleaner", "~> 0.9.0"
12
- gem "mongoid-rspec"
@@ -1,12 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- gem 'mongoid', '~> 3.1.0'
4
- gem "money", "~> 4.0.2"
5
-
6
- gem "rake"
7
- gem "bundler", "~> 1.3.4"
8
- gem "rspec", "~> 2.13.0"
9
- gem "rdoc", "~> 4.0.1"
10
- gem "simplecov", "~> 0.7.1", require: false
11
- gem "database_cleaner", "~> 0.9.1"
12
- gem "mongoid-rspec"
@@ -1,12 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- gem 'mongoid', '~> 3.0.0'
4
- gem "money", "~> 5.0.0"
5
-
6
- gem "rspec", "~> 2.12.0"
7
- gem "rdoc", "~> 3.12"
8
- gem "bundler", ">= 1.1.0"
9
- gem "jeweler", "~> 1.8.3"
10
- gem "simplecov", '>= 0.4.0', :require => false
11
- gem "database_cleaner", "~> 0.9.0"
12
- gem "mongoid-rspec"
@@ -1,12 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- gem 'mongoid', '~> 3.1.0'
4
- gem "money", "~> 5.0.0"
5
-
6
- gem "rake"
7
- gem "bundler", "~> 1.3.4"
8
- gem "rspec", "~> 2.13.0"
9
- gem "rdoc", "~> 4.0.1"
10
- gem "simplecov", "~> 0.7.1", require: false
11
- gem "database_cleaner", "~> 0.9.1"
12
- gem "mongoid-rspec"
@@ -1,12 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- gem 'mongoid', '~> 3.0.0'
4
- gem "money", "~> 5.1.1"
5
-
6
- gem "rspec", "~> 2.12.0"
7
- gem "rdoc", "~> 3.12"
8
- gem "bundler", ">= 1.1.0"
9
- gem "jeweler", "~> 1.8.3"
10
- gem "simplecov", '>= 0.4.0', :require => false
11
- gem "database_cleaner", "~> 0.9.0"
12
- gem "mongoid-rspec"
@@ -1,12 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- gem 'mongoid', '~> 3.1.0'
4
- gem "money", "~> 5.1.1"
5
-
6
- gem "rake"
7
- gem "bundler", "~> 1.3.4"
8
- gem "rspec", "~> 2.13.0"
9
- gem "rdoc", "~> 4.0.1"
10
- gem "simplecov", "~> 0.7.1", require: false
11
- gem "database_cleaner", "~> 0.9.1"
12
- gem "mongoid-rspec"