activesupport 3.0.4 → 3.0.5.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activesupport might be problematic. Click here for more details.

@@ -5,6 +5,10 @@ module ActiveSupport
5
5
  # A convenient wrapper for the zlib standard library that allows compression/decompression of strings with gzip.
6
6
  module Gzip
7
7
  class Stream < StringIO
8
+ def initialize(*)
9
+ super
10
+ set_encoding "BINARY" if "".encoding_aware?
11
+ end
8
12
  def close; rewind; end
9
13
  end
10
14
 
@@ -24,9 +24,24 @@ module I18n
24
24
  end
25
25
  end
26
26
 
27
- # Set the i18n configuration only after initialization since a lot of
27
+ # Set the i18n configuration after initialization since a lot of
28
28
  # configuration is still usually done in application initializers.
29
29
  config.after_initialize do |app|
30
+ I18n::Railtie.initialize_i18n(app)
31
+ end
32
+
33
+ # Trigger i18n config before any eager loading has happened
34
+ # so it's ready if any classes require it when eager loaded
35
+ config.before_eager_load do |app|
36
+ I18n::Railtie.initialize_i18n(app)
37
+ end
38
+
39
+ protected
40
+
41
+ # Setup i18n configuration
42
+ def self.initialize_i18n(app)
43
+ return if @i18n_inited
44
+
30
45
  fallbacks = app.config.i18n.delete(:fallbacks)
31
46
 
32
47
  app.config.i18n.each do |setting, value|
@@ -44,9 +59,9 @@ module I18n
44
59
 
45
60
  reloader.paths.concat I18n.load_path
46
61
  reloader.execute_if_updated
47
- end
48
62
 
49
- protected
63
+ @i18n_inited = true
64
+ end
50
65
 
51
66
  def self.include_fallbacks_module
52
67
  I18n.backend.class.send(:include, I18n::Backend::Fallbacks)
@@ -78,4 +93,4 @@ module I18n
78
93
  end
79
94
  end
80
95
  end
81
- end
96
+ end
@@ -4,10 +4,12 @@ module ActiveSupport
4
4
  inflect.plural(/s$/i, 's')
5
5
  inflect.plural(/(ax|test)is$/i, '\1es')
6
6
  inflect.plural(/(octop|vir)us$/i, '\1i')
7
+ inflect.plural(/(octop|vir)i$/i, '\1i')
7
8
  inflect.plural(/(alias|status)$/i, '\1es')
8
9
  inflect.plural(/(bu)s$/i, '\1ses')
9
10
  inflect.plural(/(buffal|tomat)o$/i, '\1oes')
10
11
  inflect.plural(/([ti])um$/i, '\1a')
12
+ inflect.plural(/([ti])a$/i, '\1a')
11
13
  inflect.plural(/sis$/i, 'ses')
12
14
  inflect.plural(/(?:([^f])fe|([lr])f)$/i, '\1\2ves')
13
15
  inflect.plural(/(hive)$/i, '\1s')
@@ -15,7 +17,9 @@ module ActiveSupport
15
17
  inflect.plural(/(x|ch|ss|sh)$/i, '\1es')
16
18
  inflect.plural(/(matr|vert|ind)(?:ix|ex)$/i, '\1ices')
17
19
  inflect.plural(/([m|l])ouse$/i, '\1ice')
20
+ inflect.plural(/([m|l])ice$/i, '\1ice')
18
21
  inflect.plural(/^(ox)$/i, '\1en')
22
+ inflect.plural(/^(oxen)$/i, '\1')
19
23
  inflect.plural(/(quiz)$/i, '\1zes')
20
24
 
21
25
  inflect.singular(/s$/i, '')
@@ -26,7 +26,11 @@ module ActiveSupport
26
26
  when nil
27
27
  nil
28
28
  when DATE_REGEX
29
- DateTime.parse(data)
29
+ begin
30
+ DateTime.parse(data)
31
+ rescue ArgumentError
32
+ data
33
+ end
30
34
  when Array
31
35
  data.map! { |d| convert_dates_from(d) }
32
36
  when Hash
@@ -23,7 +23,11 @@ module ActiveSupport
23
23
  when nil
24
24
  nil
25
25
  when DATE_REGEX
26
- DateTime.parse(data)
26
+ begin
27
+ DateTime.parse(data)
28
+ rescue ArgumentError
29
+ data
30
+ end
27
31
  when Array
28
32
  data.map! { |d| convert_dates_from(d) }
29
33
  when Hash
@@ -29,7 +29,7 @@ module ActiveSupport
29
29
  quoting = char
30
30
  pos = scanner.pos
31
31
  elsif quoting == char
32
- if json[pos..scanner.pos-2] =~ DATE_REGEX
32
+ if valid_date?(json[pos..scanner.pos-2])
33
33
  # found a date, track the exact positions of the quotes so we can
34
34
  # overwrite them with spaces later.
35
35
  times << pos << scanner.pos
@@ -83,6 +83,16 @@ module ActiveSupport
83
83
  output
84
84
  end
85
85
  end
86
+
87
+ private
88
+ def valid_date?(date_string)
89
+ begin
90
+ date_string =~ DATE_REGEX && DateTime.parse(date_string)
91
+ rescue ArgumentError
92
+ false
93
+ end
94
+ end
95
+
86
96
  end
87
97
  end
88
98
  end
@@ -23,7 +23,7 @@ module ActiveSupport
23
23
 
24
24
  module JSON
25
25
  # matches YAML-formatted dates
26
- DATE_REGEX = /^(?:\d{4}-\d{2}-\d{2}|\d{4}-\d{1,2}-\d{1,2}[ \t]+\d{1,2}:\d{2}:\d{2}(\.[0-9]*)?(([ \t]*)Z|[-+]\d{2}?(:\d{2})?))$/
26
+ DATE_REGEX = /^(?:\d{4}-\d{2}-\d{2}|\d{4}-\d{1,2}-\d{1,2}[T \t]+\d{1,2}:\d{2}:\d{2}(\.[0-9]*)?(([ \t]*)Z|[-+]\d{2}?(:\d{2})?))$/
27
27
 
28
28
  # Dumps object in JSON (JavaScript Object Notation). See www.json.org for more info.
29
29
  def self.encode(value, options = nil)
@@ -401,7 +401,7 @@ begin
401
401
  Mode = RubyProf::GC_TIME if RubyProf.const_defined?(:GC_TIME)
402
402
 
403
403
  # Ruby 1.9 with GC::Profiler
404
- if GC.respond_to?(:total_time)
404
+ if defined?(GC::Profiler) && GC::Profiler.respond_to?(:total_time)
405
405
  def measure
406
406
  GC::Profiler.total_time
407
407
  end
@@ -2,8 +2,8 @@ module ActiveSupport
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 3
4
4
  MINOR = 0
5
- TINY = 4
6
- PRE = nil
5
+ TINY = 5
6
+ PRE = "rc1"
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
9
9
  end
metadata CHANGED
@@ -1,13 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activesupport
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
5
- prerelease: false
4
+ hash: 15424095
5
+ prerelease: 6
6
6
  segments:
7
7
  - 3
8
8
  - 0
9
- - 4
10
- version: 3.0.4
9
+ - 5
10
+ - rc
11
+ - 1
12
+ version: 3.0.5.rc1
11
13
  platform: ruby
12
14
  authors:
13
15
  - David Heinemeier Hansson
@@ -15,7 +17,7 @@ autorequire:
15
17
  bindir: bin
16
18
  cert_chain: []
17
19
 
18
- date: 2011-02-09 00:00:00 +13:00
20
+ date: 2011-02-22 00:00:00 -08:00
19
21
  default_executable:
20
22
  dependencies: []
21
23
 
@@ -260,16 +262,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
260
262
  required_rubygems_version: !ruby/object:Gem::Requirement
261
263
  none: false
262
264
  requirements:
263
- - - ">="
265
+ - - ">"
264
266
  - !ruby/object:Gem::Version
265
- hash: 3
267
+ hash: 25
266
268
  segments:
267
- - 0
268
- version: "0"
269
+ - 1
270
+ - 3
271
+ - 1
272
+ version: 1.3.1
269
273
  requirements: []
270
274
 
271
275
  rubyforge_project: activesupport
272
- rubygems_version: 1.3.7
276
+ rubygems_version: 1.5.2
273
277
  signing_key:
274
278
  specification_version: 3
275
279
  summary: A toolkit of support libraries and Ruby core extensions extracted from the Rails framework.