activesupport 3.1.0 → 3.1.1.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.

data/CHANGELOG CHANGED
@@ -1,4 +1,10 @@
1
- *Rails 3.1.0 (unreleased)*
1
+ *Rails 3.1.1 (unreleased)*
2
+
3
+ * Fixed performance issue where TimeZone lookups would require tzinfo each time [Tim Lucas]
4
+
5
+ * ActiveSupport::OrderedHash is now marked as extractable when using Array#extract_options! [Prem Sichanugrist]
6
+
7
+ *Rails 3.1.0 (August 30, 2011)*
2
8
 
3
9
  * ActiveSupport::Dependencies#load and ActiveSupport::Dependencies#require now
4
10
  return the value from `super` [Aaron Patterson]
@@ -29,8 +29,11 @@ class BigDecimal
29
29
  coder.represent_scalar(nil, YAML_MAPPING[string] || string)
30
30
  end
31
31
 
32
- def to_d
33
- self
32
+ # Backport this method if it doesn't exist
33
+ unless method_defined?(:to_d)
34
+ def to_d
35
+ self
36
+ end
34
37
  end
35
38
 
36
39
  DEFAULT_STRING_FORMAT = 'F'
@@ -95,7 +95,7 @@ class Hash
95
95
  case value.class.to_s
96
96
  when 'Hash'
97
97
  if value['type'] == 'array'
98
- _, entries = Array.wrap(value.detect { |k,v| k != 'type' })
98
+ _, entries = Array.wrap(value.detect { |k,v| not v.is_a?(String) })
99
99
  if entries.nil? || (c = value['__content__'] && c.blank?)
100
100
  []
101
101
  else
@@ -55,9 +55,31 @@ class Time
55
55
  utc? && alternate_utc_string || ActiveSupport::TimeZone.seconds_to_utc_offset(utc_offset, colon)
56
56
  end
57
57
 
58
+ # Converts a Time object to a Date, dropping hour, minute, and second precision.
59
+ #
60
+ # my_time = Time.now # => Mon Nov 12 22:59:51 -0500 2007
61
+ # my_time.to_date # => Mon, 12 Nov 2007
62
+ #
63
+ # your_time = Time.parse("1/13/2009 1:13:03 P.M.") # => Tue Jan 13 13:13:03 -0500 2009
64
+ # your_time.to_date # => Tue, 13 Jan 2009
65
+ def to_date
66
+ ::Date.new(year, month, day)
67
+ end unless method_defined?(:to_date)
68
+
58
69
  # A method to keep Time, Date and DateTime instances interchangeable on conversions.
59
70
  # In this case, it simply returns +self+.
60
71
  def to_time
61
72
  self
62
73
  end unless method_defined?(:to_time)
74
+
75
+ # Converts a Time instance to a Ruby DateTime instance, preserving UTC offset.
76
+ #
77
+ # my_time = Time.now # => Mon Nov 12 23:04:21 -0500 2007
78
+ # my_time.to_datetime # => Mon, 12 Nov 2007 23:04:21 -0500
79
+ #
80
+ # your_time = Time.parse("1/13/2009 1:13:03 P.M.") # => Tue Jan 13 13:13:03 -0500 2009
81
+ # your_time.to_datetime # => Tue, 13 Jan 2009 13:13:03 -0500
82
+ def to_datetime
83
+ ::DateTime.civil(year, month, day, hour, min, sec, Rational(utc_offset, 86400))
84
+ end unless method_defined?(:to_datetime)
63
85
  end
@@ -1,5 +1,4 @@
1
1
  require "active_support"
2
- require "rails"
3
2
  require "active_support/file_update_checker"
4
3
  require "active_support/core_ext/array/wrap"
5
4
 
@@ -38,6 +37,8 @@ module I18n
38
37
 
39
38
  protected
40
39
 
40
+ @i18n_inited = false
41
+
41
42
  # Setup i18n configuration
42
43
  def self.initialize_i18n(app)
43
44
  return if @i18n_inited
@@ -18,8 +18,8 @@ module ActiveSupport
18
18
  # Developer.all
19
19
  # wait
20
20
  # assert_equal 1, @logger.logged(:debug).size
21
- # assert_match /Developer Load/, @logger.logged(:debug).last
22
- # assert_match /SELECT \* FROM "developers"/, @logger.logged(:debug).last
21
+ # assert_match(/Developer Load/, @logger.logged(:debug).last)
22
+ # assert_match(/SELECT \* FROM "developers"/, @logger.logged(:debug).last)
23
23
  # end
24
24
  # end
25
25
  #
@@ -47,6 +47,11 @@ module ActiveSupport
47
47
  self
48
48
  end
49
49
 
50
+ # Returns true to make sure that this hash is extractable via <tt>Array#extract_options!</tt>
51
+ def extractable_options?
52
+ true
53
+ end
54
+
50
55
  # Hash is ordered in Ruby 1.9!
51
56
  if RUBY_VERSION < '1.9'
52
57
 
@@ -1,5 +1,4 @@
1
1
  require "active_support"
2
- require "rails"
3
2
  require "active_support/i18n_railtie"
4
3
 
5
4
  module ActiveSupport
@@ -12,7 +12,7 @@ module ActiveSupport
12
12
  #
13
13
  # Time.zone = 'Eastern Time (US & Canada)' # => 'Eastern Time (US & Canada)'
14
14
  # Time.zone.local(2007, 2, 10, 15, 30, 45) # => Sat, 10 Feb 2007 15:30:45 EST -05:00
15
- # Time.zone.parse('2007-02-01 15:30:45') # => Sat, 10 Feb 2007 15:30:45 EST -05:00
15
+ # Time.zone.parse('2007-02-10 15:30:45') # => Sat, 10 Feb 2007 15:30:45 EST -05:00
16
16
  # Time.zone.at(1170361845) # => Sat, 10 Feb 2007 15:30:45 EST -05:00
17
17
  # Time.zone.now # => Sun, 18 May 2008 13:07:55 EDT -04:00
18
18
  # Time.utc(2007, 2, 10, 20, 30, 45).in_time_zone # => Sat, 10 Feb 2007 15:30:45 EST -05:00
@@ -373,7 +373,7 @@ module ActiveSupport
373
373
  protected
374
374
 
375
375
  def require_tzinfo
376
- require 'tzinfo'
376
+ require 'tzinfo' unless defined?(::TZInfo)
377
377
  rescue LoadError
378
378
  $stderr.puts "You don't have tzinfo installed in your application. Please add it to your Gemfile and run bundle install"
379
379
  raise
@@ -2,8 +2,8 @@ module ActiveSupport
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 3
4
4
  MINOR = 1
5
- TINY = 0
6
- PRE = nil
5
+ TINY = 1
6
+ PRE = "rc1"
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
9
9
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activesupport
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
5
- prerelease:
4
+ hash: 977940594
5
+ prerelease: true
6
6
  segments:
7
7
  - 3
8
8
  - 1
9
- - 0
10
- version: 3.1.0
9
+ - 1
10
+ - rc1
11
+ version: 3.1.1.rc1
11
12
  platform: ruby
12
13
  authors:
13
14
  - David Heinemeier Hansson
@@ -15,7 +16,8 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2011-08-31 00:00:00 Z
19
+ date: 2011-09-14 00:00:00 -07:00
20
+ default_executable:
19
21
  dependencies:
20
22
  - !ruby/object:Gem::Dependency
21
23
  name: multi_json
@@ -254,6 +256,7 @@ files:
254
256
  - lib/active_support/xml_mini/rexml.rb
255
257
  - lib/active_support/xml_mini.rb
256
258
  - lib/active_support.rb
259
+ has_rdoc: true
257
260
  homepage: http://www.rubyonrails.org
258
261
  licenses: []
259
262
 
@@ -276,16 +279,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
276
279
  required_rubygems_version: !ruby/object:Gem::Requirement
277
280
  none: false
278
281
  requirements:
279
- - - ">="
282
+ - - ">"
280
283
  - !ruby/object:Gem::Version
281
- hash: 3
284
+ hash: 25
282
285
  segments:
283
- - 0
284
- version: "0"
286
+ - 1
287
+ - 3
288
+ - 1
289
+ version: 1.3.1
285
290
  requirements: []
286
291
 
287
292
  rubyforge_project:
288
- rubygems_version: 1.8.8
293
+ rubygems_version: 1.3.7
289
294
  signing_key:
290
295
  specification_version: 3
291
296
  summary: A toolkit of support libraries and Ruby core extensions extracted from the Rails framework.