delocalize 0.2.6 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. data/MIT-LICENSE +1 -1
  2. data/README.markdown +8 -11
  3. data/Rakefile +8 -12
  4. data/VERSION +1 -1
  5. data/lib/delocalize.rb +7 -2
  6. data/lib/delocalize/i18n_ext.rb +2 -0
  7. data/lib/delocalize/rails_ext/action_view.rb +3 -1
  8. data/lib/delocalize/rails_ext/active_record.rb +23 -14
  9. data/lib/delocalize/rails_ext/time_zone.rb +1 -1
  10. data/lib/delocalize/railtie.rb +15 -0
  11. data/test/database.yml +3 -0
  12. data/test/delocalize_test.rb +25 -43
  13. data/test/test_helper.rb +9 -9
  14. metadata +59 -83
  15. data/init.rb +0 -1
  16. data/lib/delocalize/rails_ext.rb +0 -3
  17. data/tasks/distribution.rb +0 -21
  18. data/tasks/documentation.rb +0 -8
  19. data/tasks/testing.rb +0 -7
  20. data/test/rails2_app/app/controllers/application_controller.rb +0 -10
  21. data/test/rails2_app/config/boot.rb +0 -110
  22. data/test/rails2_app/config/environment.rb +0 -17
  23. data/test/rails2_app/config/environments/test.rb +0 -28
  24. data/test/rails2_app/config/initializers/new_rails_defaults.rb +0 -21
  25. data/test/rails2_app/config/initializers/session_store.rb +0 -15
  26. data/test/rails2_app/config/routes.rb +0 -4
  27. data/test/rails3.1_app/app/controllers/application_controller.rb +0 -3
  28. data/test/rails3.1_app/app/helpers/application_helper.rb +0 -2
  29. data/test/rails3.1_app/config/application.rb +0 -44
  30. data/test/rails3.1_app/config/boot.rb +0 -13
  31. data/test/rails3.1_app/config/environment.rb +0 -5
  32. data/test/rails3.1_app/config/environments/test.rb +0 -35
  33. data/test/rails3_app/app/controllers/application_controller.rb +0 -3
  34. data/test/rails3_app/app/helpers/application_helper.rb +0 -2
  35. data/test/rails3_app/config/application.rb +0 -44
  36. data/test/rails3_app/config/boot.rb +0 -13
  37. data/test/rails3_app/config/environment.rb +0 -5
  38. data/test/rails3_app/config/environments/test.rb +0 -35
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Clemens Kofler
1
+ Copyright (c) 2009-2011 Clemens Kofler and contributors
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
@@ -1,33 +1,30 @@
1
1
  delocalize
2
2
  ==========
3
3
 
4
+ [![Build Status](https://secure.travis-ci.org/clemens/delocalize.png)](http://travis-ci.org/clemens/delocalize)
5
+
4
6
  delocalize provides localized date/time and number parsing functionality for Rails.
5
7
 
6
8
  Installation
7
9
  ------------
8
10
 
9
- You can use delocalize either as a gem (preferred) or as a Rails plugin.
11
+ You can use delocalize as a gem (preferred). Using delocalize as a Rails plugin has been discontinued and is no supported. If you want/need to use delocalize as a gem (I really don't see a reason why you'd want to), consider using the `0-2-stable` branch.
10
12
 
11
13
  ### Rails 3
12
14
 
13
- To use the gem version, put the following gem requirement in your `Gemfile`:
15
+ To use delocalize, put the following gem requirement in your `Gemfile`:
14
16
 
15
17
  gem "delocalize"
16
18
 
17
- To install it as a plugin, fire up your terminal, go to your Rails app and type:
18
-
19
- $ ruby rails plugin install git://github.com/clemens/delocalize.git
20
-
21
19
  ### Rails 2
22
20
 
23
- To use the gem version, put the following gem requirement in your `environment.rb`:
21
+ Note: Support for Rails 2 has been discontinued. This version is only considered stable for Rails 3. If you need Rails 2 support, please use the `0.2.x` versions or the `0-2-stable` branch respectively.
24
22
 
25
- config.gem "delocalize", :source => 'http://gemcutter.org'
26
-
27
- To install it as a plugin, fire up your terminal, go to your Rails app and type:
23
+ To use delocalize, put the following gem requirement in your `environment.rb`:
28
24
 
29
- $ ruby script/plugin install git://github.com/clemens/delocalize.git
25
+ config.gem "delocalize", :source => 'http://gemcutter.org'
30
26
 
27
+ In Rails 2.3, alternatively, you can use it with Bundler. See http://gembundler.com/rails23.html for instructions.
31
28
 
32
29
  What does it do? And how do I use it?
33
30
  --------------------------------------
data/Rakefile CHANGED
@@ -1,18 +1,14 @@
1
1
  require 'rake'
2
2
  require 'rake/testtask'
3
- require 'rake/rdoctask'
3
+ require 'rdoc/task'
4
4
 
5
- require File.expand_path(File.join(File.dirname(__FILE__), 'tasks/distribution'))
6
- require File.expand_path(File.join(File.dirname(__FILE__), 'tasks/documentation'))
7
- require File.expand_path(File.join(File.dirname(__FILE__), 'tasks/testing'))
5
+ desc 'Test the delocalize gem.'
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << 'lib'
8
+ t.libs << 'test'
9
+ t.pattern = 'test/delocalize_test.rb'
10
+ t.verbose = true
11
+ end
8
12
 
9
13
  desc 'Default: run unit tests.'
10
14
  task :default => :test
11
-
12
- desc 'Run unit tests against Rails 2 and 3.'
13
- task :test_all do
14
- puts "\n * Running tests against Rails 2...\n\n"
15
- sh "rake test"
16
- puts "\n * Running tests against Rails 3...\n\n"
17
- sh "rake test RAILS_VERSION=3"
18
- end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.6
1
+ 0.3.0
@@ -1,4 +1,9 @@
1
1
  require 'delocalize/ruby_ext'
2
2
  require 'delocalize/i18n_ext'
3
- require 'delocalize/rails_ext'
4
- require 'delocalize/localized_date_time_parser'
3
+ require 'delocalize/localized_date_time_parser'
4
+
5
+ if defined?(Rails::Railtie)
6
+ require 'delocalize/railtie'
7
+ elsif defined?(Rails::Initializer)
8
+ raise "This version of delocalize is only compatible with Rails 3.0 or newer"
9
+ end
@@ -1,3 +1,5 @@
1
+ require 'active_support/core_ext/module/attribute_accessors'
2
+
1
3
  module I18n
2
4
  mattr_accessor :enable_delocalization
3
5
  I18n.enable_delocalization = true
@@ -1,3 +1,5 @@
1
+ require 'action_view'
2
+
1
3
  # TODO: also override other methods like to_check_box_tag since they might contain numeric values?
2
4
  # ActionView needs some patching too
3
5
 
@@ -25,7 +27,7 @@ ActionView::Helpers::InstanceTag.class_eval do
25
27
  hidden_for_integer = field_type == 'hidden' && column.type == :integer
26
28
 
27
29
  # the number will be formatted only if it has no errors
28
- if object.respond_to?(:errors) && !object.errors[method_name].try(:any?)
30
+ if object.respond_to?(:errors) && !Array(object.errors[method_name]).try(:any?)
29
31
  # we don't format integer hidden fields because this breaks nested_attributes
30
32
  options[:value] = number_with_precision(value, opts) unless hidden_for_integer
31
33
  end
@@ -1,3 +1,5 @@
1
+ require 'active_record'
2
+
1
3
  require 'active_record/connection_adapters/abstract/schema_definitions'
2
4
  begin
3
5
  require 'active_record/connection_adapters/column'
@@ -30,20 +32,6 @@ ActiveRecord::Base.class_eval do
30
32
  end
31
33
  alias_method_chain :write_attribute, :localization
32
34
 
33
- # ugh
34
- def self.define_write_method_for_time_zone_conversion(attr_name)
35
- method_body = <<-EOV
36
- def #{attr_name}=(time)
37
- unless time.acts_like?(:time)
38
- time = time.is_a?(String) ? (I18n.delocalization_enabled? ? Time.zone.parse_localized(time) : Time.zone.parse(time)) : time.to_time rescue time
39
- end
40
- time = time.in_time_zone rescue nil if time
41
- write_attribute(:#{attr_name}, time)
42
- end
43
- EOV
44
- evaluate_attribute_method attr_name, method_body, "#{attr_name}="
45
- end
46
-
47
35
  def convert_number_column_value_with_localization(value)
48
36
  value = convert_number_column_value_without_localization(value)
49
37
  value = Numeric.parse_localized(value) if I18n.delocalization_enabled?
@@ -69,3 +57,24 @@ ActiveRecord::Base.class_eval do
69
57
  old != value
70
58
  end
71
59
  end
60
+
61
+ ActiveRecord::Base.instance_eval do
62
+ def define_method_attribute=(attr_name)
63
+ if create_time_zone_conversion_attribute?(attr_name, columns_hash[attr_name])
64
+ method_body, line = <<-EOV, __LINE__ + 1
65
+ def #{attr_name}=(original_time)
66
+ time = original_time
67
+ unless time.acts_like?(:time)
68
+ time = time.is_a?(String) ? (I18n.delocalization_enabled? ? Time.zone.parse_localized(time) : Time.zone.parse(time)) : time.to_time rescue time
69
+ end
70
+ time = time.in_time_zone rescue nil if time
71
+ write_attribute(:#{attr_name}, original_time)
72
+ @attributes_cache["#{attr_name}"] = time
73
+ end
74
+ EOV
75
+ generated_attribute_methods.module_eval(method_body, __FILE__, line)
76
+ else
77
+ super
78
+ end
79
+ end
80
+ end
@@ -4,4 +4,4 @@ ActiveSupport::TimeZone.class_eval do
4
4
  def parse_localized(time_with_zone)
5
5
  Delocalize::LocalizedDateTimeParser.parse(time_with_zone, self.class)
6
6
  end
7
- end
7
+ end
@@ -0,0 +1,15 @@
1
+ module Delocalize
2
+ class Railtie < Rails::Railtie
3
+ initializer "delocalize" do |app|
4
+ ActiveSupport.on_load :active_record do
5
+ require 'delocalize/rails_ext/active_record'
6
+ end
7
+
8
+ ActiveSupport.on_load :action_view do
9
+ require 'delocalize/rails_ext/action_view'
10
+ end
11
+
12
+ require 'delocalize/rails_ext/time_zone'
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ test:
2
+ adapter: sqlite3
3
+ database: ":memory:"
@@ -1,10 +1,13 @@
1
1
  # encoding: utf-8
2
2
 
3
- require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
3
+ require 'test_helper'
4
+ require 'active_record/test_case'
5
+ require 'action_view/test_case'
4
6
 
5
7
  class DelocalizeActiveRecordTest < ActiveRecord::TestCase
6
8
  def setup
7
9
  Time.zone = 'Berlin' # make sure everything works as expected with TimeWithZone
10
+ Timecop.freeze(Time.zone.local(2009, 3, 1, 12, 0))
8
11
  @product = Product.new
9
12
  end
10
13
 
@@ -34,7 +37,7 @@ class DelocalizeActiveRecordTest < ActiveRecord::TestCase
34
37
  end
35
38
 
36
39
  test "delocalizes localized datetime with year" do
37
- time = Time.gm(2009, 3, 1, 11, 0, 0).in_time_zone
40
+ time = Time.zone.local(2009, 3, 1, 12, 0, 0)
38
41
 
39
42
  @product.published_at = 'Sonntag, 1. März 2009, 12:00 Uhr'
40
43
  assert_equal time, @product.published_at
@@ -44,7 +47,7 @@ class DelocalizeActiveRecordTest < ActiveRecord::TestCase
44
47
  end
45
48
 
46
49
  test "delocalizes localized datetime without year" do
47
- time = Time.gm(Date.today.year, 3, 1, 11, 0, 0).in_time_zone
50
+ time = Time.zone.local(Date.today.year, 3, 1, 12, 0, 0)
48
51
 
49
52
  @product.published_at = '1. März, 12:00 Uhr'
50
53
  assert_equal time, @product.published_at
@@ -53,15 +56,15 @@ class DelocalizeActiveRecordTest < ActiveRecord::TestCase
53
56
  # TODO can I somehow do this smarter? or should I use another zone w/o DST?
54
57
  if Time.current.dst?
55
58
  test "delocalizes localized time (DST)" do
56
- now = Time.current
57
- time = Time.gm(now.year, now.month, now.day, 7, 0, 0).in_time_zone
59
+ now = Date.today
60
+ time = Time.zone.local(now.year, now.month, now.day, 9, 0, 0)
58
61
  @product.cant_think_of_a_sensible_time_field = '09:00 Uhr'
59
62
  assert_equal time, @product.cant_think_of_a_sensible_time_field
60
63
  end
61
64
  else
62
65
  test "delocalizes localized time (non-DST)" do
63
- now = Time.current
64
- time = Time.gm(now.year, now.month, now.day, 7, 0, 0).in_time_zone
66
+ now = Date.today
67
+ time = Time.zone.local(now.year, now.month, now.day, 8, 0, 0)
65
68
  @product.cant_think_of_a_sensible_time_field = '08:00 Uhr'
66
69
  assert_equal time, @product.cant_think_of_a_sensible_time_field
67
70
  end
@@ -74,39 +77,20 @@ class DelocalizeActiveRecordTest < ActiveRecord::TestCase
74
77
  assert_equal date, @product.released_on_before_type_cast
75
78
  end
76
79
 
77
- # TODO can I somehow do this smarter? or should I use another zone w/o DST?
78
- if Time.current.dst?
79
- test "uses default parse if format isn't found (DST)" do
80
- date = Date.civil(2009, 10, 19)
81
-
82
- @product.released_on = '2009/10/19'
83
- assert_equal date, @product.released_on
84
-
85
- time = Time.gm(2009, 3, 1, 11, 0, 0).in_time_zone
86
- @product.published_at = '2009/03/01 12:00'
87
- assert_equal time, @product.published_at
88
-
89
- now = Time.current
90
- time = Time.gm(now.year, now.month, now.day, 7, 0, 0).in_time_zone
91
- @product.cant_think_of_a_sensible_time_field = '09:00'
92
- assert_equal time, @product.cant_think_of_a_sensible_time_field
93
- end
94
- else
95
- test "uses default parse if format isn't found (non-DST)" do
96
- date = Date.civil(2009, 10, 19)
80
+ test "uses default parse if format isn't found (non-DST)" do
81
+ date = Date.civil(2009, 10, 19)
97
82
 
98
- @product.released_on = '2009/10/19'
99
- assert_equal date, @product.released_on
83
+ @product.released_on = '2009/10/19'
84
+ assert_equal date, @product.released_on
100
85
 
101
- time = Time.gm(2009, 3, 1, 11, 0, 0).in_time_zone
102
- @product.published_at = '2009/03/01 12:00'
103
- assert_equal time, @product.published_at
86
+ time = Time.zone.local(2009, 3, 1, 12, 0, 0)
87
+ @product.published_at = '2009/03/01 12:00'
88
+ assert_equal time, @product.published_at
104
89
 
105
- now = Time.current
106
- time = Time.gm(now.year, now.month, now.day, 7, 0, 0).in_time_zone
107
- @product.cant_think_of_a_sensible_time_field = '08:00'
108
- assert_equal time, @product.cant_think_of_a_sensible_time_field
109
- end
90
+ now = Time.current
91
+ time = Time.zone.local(now.year, now.month, now.day, 8, 0, 0)
92
+ @product.cant_think_of_a_sensible_time_field = '08:00'
93
+ assert_equal time, @product.cant_think_of_a_sensible_time_field
110
94
  end
111
95
 
112
96
  test "should return nil if the input is empty or invalid" do
@@ -221,7 +205,7 @@ class DelocalizeActionViewTest < ActionView::TestCase
221
205
  end
222
206
 
223
207
  test "shows text field using formatted date and time" do
224
- @product.published_at = Time.local(2009, 3, 1, 12, 0, 0)
208
+ @product.published_at = Time.zone.local(2009, 3, 1, 12, 0, 0)
225
209
  # careful - leading whitespace with %e
226
210
  assert_dom_equal '<input id="product_published_at" name="product[published_at]" size="30" type="text" value="Sonntag, 1. März 2009, 12:00 Uhr" />',
227
211
  text_field(:product, :published_at)
@@ -234,14 +218,14 @@ class DelocalizeActionViewTest < ActionView::TestCase
234
218
  end
235
219
 
236
220
  test "shows text field using formatted date and time with format" do
237
- @product.published_at = Time.local(2009, 3, 1, 12, 0, 0)
221
+ @product.published_at = Time.zone.local(2009, 3, 1, 12, 0, 0)
238
222
  # careful - leading whitespace with %e
239
223
  assert_dom_equal '<input id="product_published_at" name="product[published_at]" size="30" type="text" value=" 1. März, 12:00 Uhr" />',
240
224
  text_field(:product, :published_at, :format => :short)
241
225
  end
242
226
 
243
227
  test "shows text field using formatted time with format" do
244
- @product.cant_think_of_a_sensible_time_field = Time.local(2009, 3, 1, 9, 0, 0)
228
+ @product.cant_think_of_a_sensible_time_field = Time.zone.local(2009, 3, 1, 9, 0, 0)
245
229
  assert_dom_equal '<input id="product_cant_think_of_a_sensible_time_field" name="product[cant_think_of_a_sensible_time_field]" size="30" type="text" value="09:00 Uhr" />',
246
230
  text_field(:product, :cant_think_of_a_sensible_time_field, :format => :time)
247
231
  end
@@ -274,11 +258,9 @@ class DelocalizeActionViewTest < ActionView::TestCase
274
258
  end
275
259
 
276
260
  test "doesn't convert the value if field has errors" do
277
- error_class = Rails.version =~ /^3/ ? 'field_with_errors' : 'fieldWithErrors'
278
-
279
261
  @product = ProductWithValidation.new(:price => 'this is not a number')
280
262
  @product.valid?
281
- assert_dom_equal %(<div class="#{error_class}"><input id="product_price" name="product[price]" size="30" type="text" value="this is not a number" /></div>),
263
+ assert_dom_equal %(<div class="field_with_errors"><input id="product_price" name="product[price]" size="30" type="text" value="this is not a number" /></div>),
282
264
  text_field(:product, :price)
283
265
  end
284
266
 
@@ -1,15 +1,15 @@
1
1
  # encoding: utf-8
2
2
 
3
- ENV["RAILS_ENV"] = "test"
4
- rails_version = ENV["RAILS_VERSION"] || 2
3
+ require 'rubygems'
4
+ require 'bundler'
5
5
 
6
- if rails_version.to_i == 2
7
- require File.expand_path(File.join(File.dirname(__FILE__), "rails2_app/config/environment"))
8
- require 'test_help'
9
- else
10
- require File.expand_path(File.join(File.dirname(__FILE__), "rails#{rails_version}_app/config/environment"))
11
- require 'rails/test_help'
12
- end
6
+ Bundler.require(:default, :development)
7
+
8
+ require 'test/unit'
9
+
10
+ require 'delocalize/rails_ext/action_view'
11
+ require 'delocalize/rails_ext/active_record'
12
+ require 'delocalize/rails_ext/time_zone'
13
13
 
14
14
  I18n.backend.store_translations :de, {
15
15
  :date => {
metadata CHANGED
@@ -1,126 +1,102 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: delocalize
3
- version: !ruby/object:Gem::Version
4
- hash: 27
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 2
9
- - 6
10
- version: 0.2.6
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Clemens Kofler
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-05-26 00:00:00 Z
19
- dependencies: []
20
-
12
+ date: 2011-10-25 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: &2156597040 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2156597040
25
+ - !ruby/object:Gem::Dependency
26
+ name: sqlite3
27
+ requirement: &2156596420 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 1.3.4
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *2156596420
36
+ - !ruby/object:Gem::Dependency
37
+ name: timecop
38
+ requirement: &2156595740 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 0.3.5
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *2156595740
21
47
  description: Delocalize is a tool for parsing localized dates/times and numbers.
22
48
  email: clemens@railway.at
23
49
  executables: []
24
-
25
50
  extensions: []
26
-
27
- extra_rdoc_files:
51
+ extra_rdoc_files:
28
52
  - README.markdown
29
- files:
53
+ files:
30
54
  - MIT-LICENSE
31
55
  - Rakefile
32
56
  - VERSION
33
- - init.rb
34
57
  - lib/delocalize.rb
35
58
  - lib/delocalize/i18n_ext.rb
36
59
  - lib/delocalize/localized_date_time_parser.rb
37
60
  - lib/delocalize/localized_numeric_parser.rb
38
- - lib/delocalize/rails_ext.rb
39
61
  - lib/delocalize/rails_ext/action_view.rb
40
62
  - lib/delocalize/rails_ext/active_record.rb
41
63
  - lib/delocalize/rails_ext/time_zone.rb
64
+ - lib/delocalize/railtie.rb
42
65
  - lib/delocalize/ruby_ext.rb
43
66
  - lib/delocalize/ruby_ext/date.rb
44
67
  - lib/delocalize/ruby_ext/datetime.rb
45
68
  - lib/delocalize/ruby_ext/numeric.rb
46
69
  - lib/delocalize/ruby_ext/time.rb
47
- - tasks/distribution.rb
48
- - tasks/documentation.rb
49
- - tasks/testing.rb
50
70
  - README.markdown
71
+ - test/database.yml
51
72
  - test/delocalize_test.rb
52
- - test/rails2_app/app/controllers/application_controller.rb
53
- - test/rails2_app/config/boot.rb
54
- - test/rails2_app/config/environment.rb
55
- - test/rails2_app/config/environments/test.rb
56
- - test/rails2_app/config/initializers/new_rails_defaults.rb
57
- - test/rails2_app/config/initializers/session_store.rb
58
- - test/rails2_app/config/routes.rb
59
- - test/rails3.1_app/app/controllers/application_controller.rb
60
- - test/rails3.1_app/app/helpers/application_helper.rb
61
- - test/rails3.1_app/config/application.rb
62
- - test/rails3.1_app/config/boot.rb
63
- - test/rails3.1_app/config/environment.rb
64
- - test/rails3.1_app/config/environments/test.rb
65
- - test/rails3_app/app/controllers/application_controller.rb
66
- - test/rails3_app/app/helpers/application_helper.rb
67
- - test/rails3_app/config/application.rb
68
- - test/rails3_app/config/boot.rb
69
- - test/rails3_app/config/environment.rb
70
- - test/rails3_app/config/environments/test.rb
71
73
  - test/test_helper.rb
72
74
  homepage: http://github.com/clemens/delocalize
73
75
  licenses: []
74
-
75
76
  post_install_message:
76
- rdoc_options: []
77
-
78
- require_paths:
77
+ rdoc_options:
78
+ - --charset=UTF-8
79
+ require_paths:
79
80
  - lib
80
- required_ruby_version: !ruby/object:Gem::Requirement
81
+ required_ruby_version: !ruby/object:Gem::Requirement
81
82
  none: false
82
- requirements:
83
- - - ">="
84
- - !ruby/object:Gem::Version
85
- hash: 3
86
- segments:
87
- - 0
88
- version: "0"
89
- required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
88
  none: false
91
- requirements:
92
- - - ">="
93
- - !ruby/object:Gem::Version
94
- hash: 3
95
- segments:
96
- - 0
97
- version: "0"
89
+ requirements:
90
+ - - ! '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
98
93
  requirements: []
99
-
100
94
  rubyforge_project:
101
- rubygems_version: 1.7.2
95
+ rubygems_version: 1.8.10
102
96
  signing_key:
103
97
  specification_version: 3
104
98
  summary: Localized date/time and number parsing
105
- test_files:
99
+ test_files:
100
+ - test/database.yml
106
101
  - test/delocalize_test.rb
107
- - test/rails2_app/app/controllers/application_controller.rb
108
- - test/rails2_app/config/boot.rb
109
- - test/rails2_app/config/environment.rb
110
- - test/rails2_app/config/environments/test.rb
111
- - test/rails2_app/config/initializers/new_rails_defaults.rb
112
- - test/rails2_app/config/initializers/session_store.rb
113
- - test/rails2_app/config/routes.rb
114
- - test/rails3.1_app/app/controllers/application_controller.rb
115
- - test/rails3.1_app/app/helpers/application_helper.rb
116
- - test/rails3.1_app/config/application.rb
117
- - test/rails3.1_app/config/boot.rb
118
- - test/rails3.1_app/config/environment.rb
119
- - test/rails3.1_app/config/environments/test.rb
120
- - test/rails3_app/app/controllers/application_controller.rb
121
- - test/rails3_app/app/helpers/application_helper.rb
122
- - test/rails3_app/config/application.rb
123
- - test/rails3_app/config/boot.rb
124
- - test/rails3_app/config/environment.rb
125
- - test/rails3_app/config/environments/test.rb
126
102
  - test/test_helper.rb
data/init.rb DELETED
@@ -1 +0,0 @@
1
- require 'delocalize'
@@ -1,3 +0,0 @@
1
- require 'delocalize/rails_ext/active_record'
2
- require 'delocalize/rails_ext/action_view'
3
- require 'delocalize/rails_ext/time_zone'
@@ -1,21 +0,0 @@
1
- begin
2
- require 'jeweler'
3
- Jeweler::Tasks.new do |s|
4
- s.name = "delocalize"
5
- s.summary = "Localized date/time and number parsing"
6
- s.email = "clemens@railway.at"
7
- s.homepage = "http://github.com/clemens/delocalize"
8
- s.description = "Delocalize is a tool for parsing localized dates/times and numbers."
9
- s.authors = ["Clemens Kofler"]
10
- s.files = FileList["init.rb",
11
- "lib/**/*.rb",
12
- "MIT-LICENSE",
13
- "Rakefile",
14
- "README",
15
- "tasks/**/*.rb",
16
- "VERSION"]
17
- s.test_files = FileList["test/**/*.rb"]
18
- end
19
- rescue LoadError
20
- puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
21
- end
@@ -1,8 +0,0 @@
1
- desc 'Generate documentation for the delocalize plugin.'
2
- Rake::RDocTask.new(:rdoc) do |rdoc|
3
- rdoc.rdoc_dir = 'rdoc'
4
- rdoc.title = 'Delocalize'
5
- rdoc.options << '--line-numbers' << '--inline-source'
6
- rdoc.rdoc_files.include('README')
7
- rdoc.rdoc_files.include('lib/**/*.rb')
8
- end
@@ -1,7 +0,0 @@
1
- desc 'Test the delocalize plugin.'
2
- Rake::TestTask.new(:test) do |t|
3
- t.libs << 'lib'
4
- t.libs << 'test'
5
- t.pattern = 'test/**/*_test.rb'
6
- t.verbose = true
7
- end
@@ -1,10 +0,0 @@
1
- # Filters added to this controller apply to all controllers in the application.
2
- # Likewise, all the methods added will be available for all controllers.
3
-
4
- class ApplicationController < ActionController::Base
5
- helper :all # include all helpers, all the time
6
- protect_from_forgery # See ActionController::RequestForgeryProtection for details
7
-
8
- # Scrub sensitive parameters from your log
9
- filter_parameter_logging :password
10
- end
@@ -1,110 +0,0 @@
1
- # Don't change this file!
2
- # Configure your app in config/environment.rb and config/environments/*.rb
3
-
4
- RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
5
-
6
- module Rails
7
- class << self
8
- def boot!
9
- unless booted?
10
- preinitialize
11
- pick_boot.run
12
- end
13
- end
14
-
15
- def booted?
16
- defined? Rails::Initializer
17
- end
18
-
19
- def pick_boot
20
- (vendor_rails? ? VendorBoot : GemBoot).new
21
- end
22
-
23
- def vendor_rails?
24
- File.exist?("#{RAILS_ROOT}/vendor/rails")
25
- end
26
-
27
- def preinitialize
28
- load(preinitializer_path) if File.exist?(preinitializer_path)
29
- end
30
-
31
- def preinitializer_path
32
- "#{RAILS_ROOT}/config/preinitializer.rb"
33
- end
34
- end
35
-
36
- class Boot
37
- def run
38
- load_initializer
39
- Rails::Initializer.run(:set_load_path)
40
- end
41
- end
42
-
43
- class VendorBoot < Boot
44
- def load_initializer
45
- require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
46
- Rails::Initializer.run(:install_gem_spec_stubs)
47
- Rails::GemDependency.add_frozen_gem_path
48
- end
49
- end
50
-
51
- class GemBoot < Boot
52
- def load_initializer
53
- self.class.load_rubygems
54
- load_rails_gem
55
- require 'initializer'
56
- end
57
-
58
- def load_rails_gem
59
- if version = self.class.gem_version
60
- gem 'rails', version
61
- else
62
- gem 'rails'
63
- end
64
- rescue Gem::LoadError => load_error
65
- $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
66
- exit 1
67
- end
68
-
69
- class << self
70
- def rubygems_version
71
- Gem::RubyGemsVersion rescue nil
72
- end
73
-
74
- def gem_version
75
- if defined? RAILS_GEM_VERSION
76
- RAILS_GEM_VERSION
77
- elsif ENV.include?('RAILS_GEM_VERSION')
78
- ENV['RAILS_GEM_VERSION']
79
- else
80
- parse_gem_version(read_environment_rb)
81
- end
82
- end
83
-
84
- def load_rubygems
85
- min_version = '1.3.2'
86
- require 'rubygems'
87
- unless rubygems_version >= min_version
88
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
89
- exit 1
90
- end
91
-
92
- rescue LoadError
93
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
94
- exit 1
95
- end
96
-
97
- def parse_gem_version(text)
98
- $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
99
- end
100
-
101
- private
102
- def read_environment_rb
103
- File.read("#{RAILS_ROOT}/config/environment.rb")
104
- end
105
- end
106
- end
107
- end
108
-
109
- # All that for this:
110
- Rails.boot!
@@ -1,17 +0,0 @@
1
- # Be sure to restart your server when you modify this file
2
-
3
- # Specifies gem version of Rails to use when vendor/rails is not present
4
- RAILS_GEM_VERSION = '2.3.11' unless defined? RAILS_GEM_VERSION
5
-
6
- # Bootstrap the Rails environment, frameworks, and default configuration
7
- require File.join(File.dirname(__FILE__), 'boot')
8
-
9
- Rails::Initializer.run do |config|
10
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
11
- # Run "rake -D time" for a list of tasks for finding time zone names.
12
- # config.time_zone = 'UTC'
13
-
14
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
15
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
16
- # config.i18n.default_locale = :en
17
- end
@@ -1,28 +0,0 @@
1
- # Settings specified here will take precedence over those in config/environment.rb
2
-
3
- # The test environment is used exclusively to run your application's
4
- # test suite. You never need to work with it otherwise. Remember that
5
- # your test database is "scratch space" for the test suite and is wiped
6
- # and recreated between test runs. Don't rely on the data there!
7
- config.cache_classes = true
8
-
9
- # Log error messages when you accidentally call methods on nil.
10
- config.whiny_nils = true
11
-
12
- # Show full error reports and disable caching
13
- config.action_controller.consider_all_requests_local = true
14
- config.action_controller.perform_caching = false
15
- config.action_view.cache_template_loading = true
16
-
17
- # Disable request forgery protection in test environment
18
- config.action_controller.allow_forgery_protection = false
19
-
20
- # Tell Action Mailer not to deliver emails to the real world.
21
- # The :test delivery method accumulates sent emails in the
22
- # ActionMailer::Base.deliveries array.
23
- config.action_mailer.delivery_method = :test
24
-
25
- # Use SQL instead of Active Record's schema dumper when creating the test database.
26
- # This is necessary if your schema can't be completely dumped by the schema dumper,
27
- # like if you have constraints or database-specific column types
28
- # config.active_record.schema_format = :sql
@@ -1,21 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # These settings change the behavior of Rails 2 apps and will be defaults
4
- # for Rails 3. You can remove this initializer when Rails 3 is released.
5
-
6
- if defined?(ActiveRecord)
7
- # Include Active Record class name as root for JSON serialized output.
8
- ActiveRecord::Base.include_root_in_json = true
9
-
10
- # Store the full class name (including module namespace) in STI type column.
11
- ActiveRecord::Base.store_full_sti_class = true
12
- end
13
-
14
- ActionController::Routing.generate_best_match = false
15
-
16
- # Use ISO 8601 format for JSON serialized times and dates.
17
- ActiveSupport.use_standard_json_time_format = true
18
-
19
- # Don't escape HTML entities in JSON, leave that for the #json_escape helper.
20
- # if you're including raw json in an HTML page.
21
- ActiveSupport.escape_html_entities_in_json = false
@@ -1,15 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Your secret key for verifying cookie session data integrity.
4
- # If you change this key, all old sessions will become invalid!
5
- # Make sure the secret is at least 30 characters and all random,
6
- # no regular words or you'll be exposed to dictionary attacks.
7
- ActionController::Base.session = {
8
- :key => '_rails_app_session',
9
- :secret => '89e8147901a0d7c221ac130e0ded3eeab6dab4a97127255909f08fedaae371918b41dec9d4d75c5b27a55c3772d43c2b6a3cbac232c5cc2ce4b8ec22242f5e60'
10
- }
11
-
12
- # Use the database for sessions instead of the cookie-based default,
13
- # which shouldn't be used to store highly confidential information
14
- # (create the session table with "rake db:sessions:create")
15
- # ActionController::Base.session_store = :active_record_store
@@ -1,4 +0,0 @@
1
- ActionController::Routing::Routes.draw do |map|
2
- map.connect ':controller/:action/:id'
3
- map.connect ':controller/:action/:id.:format'
4
- end
@@ -1,3 +0,0 @@
1
- class ApplicationController < ActionController::Base
2
- protect_from_forgery
3
- end
@@ -1,2 +0,0 @@
1
- module ApplicationHelper
2
- end
@@ -1,44 +0,0 @@
1
- require File.expand_path('../boot', __FILE__)
2
-
3
- require 'rails/all'
4
-
5
- # If you have a Gemfile, require the gems listed there, including any gems
6
- # you've limited to :test, :development, or :production.
7
- Bundler.require(:default, Rails.env) if defined?(Bundler)
8
-
9
- module Rails3App
10
- class Application < Rails::Application
11
- # Settings in config/environments/* take precedence over those specified here.
12
- # Application configuration should go into files in config/initializers
13
- # -- all .rb files in that directory are automatically loaded.
14
-
15
- # Custom directories with classes and modules you want to be autoloadable.
16
- # config.autoload_paths += %W(#{config.root}/extras)
17
-
18
- # Only load the plugins named here, in the order given (default is alphabetical).
19
- # :all can be used as a placeholder for all plugins not explicitly named.
20
- # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
21
-
22
- # Activate observers that should always be running.
23
- # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
24
-
25
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
26
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
27
- # config.time_zone = 'Central Time (US & Canada)'
28
-
29
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
30
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
31
- # config.i18n.default_locale = :de
32
-
33
- # JavaScript files you want as :defaults (application.js is always included).
34
- # config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
35
-
36
- config.paths.config.database = File.expand_path(File.dirname(__FILE__) + '../../../database.yml')
37
-
38
- # Configure the default encoding used in templates for Ruby 1.9.
39
- config.encoding = "utf-8"
40
-
41
- # Configure sensitive parameters which will be filtered from the log file.
42
- config.filter_parameters += [:password]
43
- end
44
- end
@@ -1,13 +0,0 @@
1
- require 'rubygems'
2
-
3
- # Set up gems listed in the Gemfile.
4
- gemfile = File.expand_path('../../Gemfile', __FILE__)
5
- begin
6
- ENV['BUNDLE_GEMFILE'] = gemfile
7
- require 'bundler'
8
- Bundler.setup
9
- rescue Bundler::GemNotFound => e
10
- STDERR.puts e.message
11
- STDERR.puts "Try running `bundle install`."
12
- exit!
13
- end if File.exist?(gemfile)
@@ -1,5 +0,0 @@
1
- # Load the rails application
2
- require File.expand_path('../application', __FILE__)
3
-
4
- # Initialize the rails application
5
- Rails3App::Application.initialize!
@@ -1,35 +0,0 @@
1
- Rails3App::Application.configure do
2
- # Settings specified here will take precedence over those in config/environment.rb
3
-
4
- # The test environment is used exclusively to run your application's
5
- # test suite. You never need to work with it otherwise. Remember that
6
- # your test database is "scratch space" for the test suite and is wiped
7
- # and recreated between test runs. Don't rely on the data there!
8
- config.cache_classes = true
9
-
10
- # Log error messages when you accidentally call methods on nil.
11
- config.whiny_nils = true
12
-
13
- # Show full error reports and disable caching
14
- config.consider_all_requests_local = true
15
- config.action_controller.perform_caching = false
16
-
17
- # Raise exceptions instead of rendering exception templates
18
- config.action_dispatch.show_exceptions = false
19
-
20
- # Disable request forgery protection in test environment
21
- config.action_controller.allow_forgery_protection = false
22
-
23
- # Tell Action Mailer not to deliver emails to the real world.
24
- # The :test delivery method accumulates sent emails in the
25
- # ActionMailer::Base.deliveries array.
26
- config.action_mailer.delivery_method = :test
27
-
28
- # Use SQL instead of Active Record's schema dumper when creating the test database.
29
- # This is necessary if your schema can't be completely dumped by the schema dumper,
30
- # like if you have constraints or database-specific column types
31
- # config.active_record.schema_format = :sql
32
-
33
- # Print deprecation notices to the stderr
34
- config.active_support.deprecation = :stderr
35
- end
@@ -1,3 +0,0 @@
1
- class ApplicationController < ActionController::Base
2
- protect_from_forgery
3
- end
@@ -1,2 +0,0 @@
1
- module ApplicationHelper
2
- end
@@ -1,44 +0,0 @@
1
- require File.expand_path('../boot', __FILE__)
2
-
3
- require 'rails/all'
4
-
5
- # If you have a Gemfile, require the gems listed there, including any gems
6
- # you've limited to :test, :development, or :production.
7
- Bundler.require(:default, Rails.env) if defined?(Bundler)
8
-
9
- module Rails3App
10
- class Application < Rails::Application
11
- # Settings in config/environments/* take precedence over those specified here.
12
- # Application configuration should go into files in config/initializers
13
- # -- all .rb files in that directory are automatically loaded.
14
-
15
- # Custom directories with classes and modules you want to be autoloadable.
16
- # config.autoload_paths += %W(#{config.root}/extras)
17
-
18
- # Only load the plugins named here, in the order given (default is alphabetical).
19
- # :all can be used as a placeholder for all plugins not explicitly named.
20
- # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
21
-
22
- # Activate observers that should always be running.
23
- # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
24
-
25
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
26
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
27
- # config.time_zone = 'Central Time (US & Canada)'
28
-
29
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
30
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
31
- # config.i18n.default_locale = :de
32
-
33
- # JavaScript files you want as :defaults (application.js is always included).
34
- # config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
35
-
36
- config.paths.config.database = File.expand_path(File.dirname(__FILE__) + '../../../database.yml')
37
-
38
- # Configure the default encoding used in templates for Ruby 1.9.
39
- config.encoding = "utf-8"
40
-
41
- # Configure sensitive parameters which will be filtered from the log file.
42
- config.filter_parameters += [:password]
43
- end
44
- end
@@ -1,13 +0,0 @@
1
- require 'rubygems'
2
-
3
- # Set up gems listed in the Gemfile.
4
- gemfile = File.expand_path('../../Gemfile', __FILE__)
5
- begin
6
- ENV['BUNDLE_GEMFILE'] = gemfile
7
- require 'bundler'
8
- Bundler.setup
9
- rescue Bundler::GemNotFound => e
10
- STDERR.puts e.message
11
- STDERR.puts "Try running `bundle install`."
12
- exit!
13
- end if File.exist?(gemfile)
@@ -1,5 +0,0 @@
1
- # Load the rails application
2
- require File.expand_path('../application', __FILE__)
3
-
4
- # Initialize the rails application
5
- Rails3App::Application.initialize!
@@ -1,35 +0,0 @@
1
- Rails3App::Application.configure do
2
- # Settings specified here will take precedence over those in config/environment.rb
3
-
4
- # The test environment is used exclusively to run your application's
5
- # test suite. You never need to work with it otherwise. Remember that
6
- # your test database is "scratch space" for the test suite and is wiped
7
- # and recreated between test runs. Don't rely on the data there!
8
- config.cache_classes = true
9
-
10
- # Log error messages when you accidentally call methods on nil.
11
- config.whiny_nils = true
12
-
13
- # Show full error reports and disable caching
14
- config.consider_all_requests_local = true
15
- config.action_controller.perform_caching = false
16
-
17
- # Raise exceptions instead of rendering exception templates
18
- config.action_dispatch.show_exceptions = false
19
-
20
- # Disable request forgery protection in test environment
21
- config.action_controller.allow_forgery_protection = false
22
-
23
- # Tell Action Mailer not to deliver emails to the real world.
24
- # The :test delivery method accumulates sent emails in the
25
- # ActionMailer::Base.deliveries array.
26
- config.action_mailer.delivery_method = :test
27
-
28
- # Use SQL instead of Active Record's schema dumper when creating the test database.
29
- # This is necessary if your schema can't be completely dumped by the schema dumper,
30
- # like if you have constraints or database-specific column types
31
- # config.active_record.schema_format = :sql
32
-
33
- # Print deprecation notices to the stderr
34
- config.active_support.deprecation = :stderr
35
- end