delocalize 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README CHANGED
@@ -1,7 +1,7 @@
1
1
  delocalize
2
2
  ==========
3
3
 
4
- Highly experimental date/time and number parsing. Use at your own risk! ;-)
4
+ delocalize provides localized date/time and number parsing functionality for Rails.
5
5
 
6
6
  Installation
7
7
  ============
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
@@ -7,6 +7,10 @@ ActiveRecord::ConnectionAdapters::Column.class_eval do
7
7
  def time?
8
8
  klass == Time
9
9
  end
10
+
11
+ def decimal?
12
+ klass == BigDecimal
13
+ end
10
14
  end
11
15
 
12
16
  ActiveRecord::Base.class_eval do
@@ -16,6 +20,9 @@ ActiveRecord::Base.class_eval do
16
20
  value = Date.parse_localized(value)
17
21
  elsif column.time?
18
22
  value = Time.parse_localized(value)
23
+ elsif column.decimal?
24
+ value = convert_number_column_value_with_localization(value)
25
+ value = BigDecimal(value) if value.is_a?(String)
19
26
  end
20
27
  end
21
28
  write_attribute_without_localization(attr_name, value)
@@ -44,4 +51,4 @@ ActiveRecord::Base.class_eval do
44
51
  value
45
52
  end
46
53
  alias_method_chain :convert_number_column_value, :localization
47
- end
54
+ end
@@ -109,6 +109,13 @@ class DelocalizeActiveRecordTest < ActiveRecord::TestCase
109
109
  assert_equal -1299.99, @product.price
110
110
  end
111
111
  end
112
+
113
+ test "dirty attributes must detect changes in decimal columns" do
114
+ @product.price = 10
115
+ @product.save
116
+ @product.price = "10,34"
117
+ assert @product.price_changed?
118
+ end
112
119
  end
113
120
 
114
121
  class DelocalizeActionViewTest < ActionView::TestCase
@@ -205,4 +212,4 @@ class DelocalizeActionViewTest < ActionView::TestCase
205
212
  text_field(:product, :price, :value => "1.499,90")
206
213
  }
207
214
  end
208
- end
215
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delocalize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clemens Kofler
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-31 00:00:00 +01:00
12
+ date: 2009-12-25 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15