activesupport 4.2.0.beta3 → 4.2.0.beta4

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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 703dda1615155dd91e7e7ba42a186ba291b81ca9
4
- data.tar.gz: 5b082d317e6770ddcc2922eccbbb4e503f5a245e
3
+ metadata.gz: 977535bf869ab9b1cd7302daad1d884ba844fd04
4
+ data.tar.gz: 6ab3b58355d80563255e185ca657dc5667a741ec
5
5
  SHA512:
6
- metadata.gz: eefb467f487c7130ee6bef6defada1eadaece7854d2b5030f46bdef1b2ff8c2cd4b5163620d208838db40fc7337dfddfa2bf3716275ffd0669c513ff4287fe8d
7
- data.tar.gz: 881695a1fb2a41a60825c1994f0385a323af0d13b510e266f128f162ee59e1d382b9691bc896b419e83118b3158357918d54f492e1d105f4c171e293f43b58dd
6
+ metadata.gz: 059eb20ff7658055d192c7bbe278284ff5108a2af3f1cdbccce1ba191836e0ab5c1f4f24d6ea621eb9ede68c0f523760e6f93546c9fd3df937feaaef28712c4f
7
+ data.tar.gz: 5d6e3f0f0a07e827e67f48e4b9805d3f22f5bee08241205c6962d2a3e7d9c6d7524887e1e6052cbdfdd3c67b247afcae0b81504a10bf25b52b06dfca1f0714cf
@@ -1,3 +1,12 @@
1
+ * TimeWithZone#strftime now delegates every directive to Time#strftime except for '%Z',
2
+ it also now correctly handles escaped '%' characters placed just before time zone related directives.
3
+
4
+ *Pablo Herrero*
5
+
6
+ * Corrected Inflector#underscore handling of multiple successive acroynms.
7
+
8
+ *James Le Cuirot*
9
+
1
10
  * Delegation now works with ruby reserved words passed to `:to` option.
2
11
 
3
12
  Fixes #16956.
@@ -19,8 +28,8 @@
19
28
 
20
29
  *Joost Lubach*
21
30
 
22
- * Time#change can now change nanoseconds (:nsec) as a higher-precision
23
- alternative to microseconds (:usec).
31
+ * `Time#change` can now change nanoseconds (`:nsec`) as a higher-precision
32
+ alternative to microseconds (`:usec`).
24
33
 
25
34
  *Agis Anastasooulos*
26
35
 
@@ -35,14 +44,14 @@
35
44
 
36
45
  *Akira Matsuda*, *Godfrey Chan*
37
46
 
38
- * Fixed a bug in Inflector#underscore where acroynms in nested constant names
47
+ * Fixed a bug in `Inflector#underscore` where acroynms in nested constant names
39
48
  are incorrectly parsed as camelCase.
40
49
 
41
50
  Fixes #8015.
42
51
 
43
52
  *Fred Wu*, *Matthew Draper*
44
53
 
45
- * Make Time#change throw an exception if the :usec option is out of range and
54
+ * Make `Time#change` throw an exception if the `:usec` option is out of range and
46
55
  the time has an offset other than UTC or local.
47
56
 
48
57
  *Agis Anastasopoulos*
@@ -59,15 +68,15 @@
59
68
 
60
69
  *Guo Xiang Tan*
61
70
 
62
- * Added instance_eval version to Object#try, so you can do this:
71
+ * Added instance_eval version to Object#try and Object#try!, so you can do this:
63
72
 
64
- person.try { name.first }
73
+ person.try { name.first }
65
74
 
66
75
  instead of:
67
76
 
68
- person.try { |person| person.name.first }
77
+ person.try { |person| person.name.first }
69
78
 
70
- *DHH*
79
+ *DHH*, *Ari Pollak*
71
80
 
72
81
  * Fix the `ActiveSupport::Duration#instance_of?` method to return the right
73
82
  value with the class itself since it was previously delegated to the
@@ -75,12 +84,12 @@
75
84
 
76
85
  *Robin Dupret*
77
86
 
78
- * Fix rounding errors with #travel_to by resetting the usec on any passed time to zero, so we only travel
87
+ * Fix rounding errors with `#travel_to` by resetting the usec on any passed time to zero, so we only travel
79
88
  with per-second precision, not anything deeper than that.
80
89
 
81
90
  *DHH*
82
91
 
83
- * Fix DateTime comparison with DateTime::Infinity object.
92
+ * Fix DateTime comparison with `DateTime::Infinity` object.
84
93
 
85
94
  *Rafael Mendonça França*
86
95
 
@@ -318,8 +327,8 @@
318
327
  *Pavel Pravosud*
319
328
 
320
329
  * `HashWithIndifferentAccess` better respects `#to_hash` on objects it
321
- recieves. In particular, `.new`, `#update`, `#merge`, `#replace` all accept
322
- objects which respond to `#to_hash`, even if those objects are not Hashes
330
+ receives. In particular, `.new`, `#update`, `#merge`, and `#replace` accept
331
+ objects which respond to `#to_hash`, even if those objects are not hashes
323
332
  directly.
324
333
 
325
334
  *Peter Jaros*
@@ -78,18 +78,21 @@ module ActiveSupport
78
78
  # save
79
79
  # end
80
80
  def run_callbacks(kind, &block)
81
- cbs = send("_#{kind}_callbacks")
82
- if cbs.empty?
83
- yield if block_given?
81
+ send "_run_#{kind}_callbacks", &block
82
+ end
83
+
84
+ private
85
+
86
+ def _run_callbacks(callbacks, &block)
87
+ if callbacks.empty?
88
+ block.call if block
84
89
  else
85
- runner = cbs.compile
90
+ runner = callbacks.compile
86
91
  e = Filters::Environment.new(self, false, nil, block)
87
92
  runner.call(e).value
88
93
  end
89
94
  end
90
95
 
91
- private
92
-
93
96
  # A hook invoked every time a before callback is halted.
94
97
  # This can be overridden in AS::Callback implementors in order
95
98
  # to provide better debugging/logging.
@@ -556,7 +559,7 @@ module ActiveSupport
556
559
  # This is used internally to append, prepend and skip callbacks to the
557
560
  # CallbackChain.
558
561
  def __update_callbacks(name) #:nodoc:
559
- ([self] + ActiveSupport::DescendantsTracker.descendants(self)).reverse.each do |target|
562
+ ([self] + ActiveSupport::DescendantsTracker.descendants(self)).reverse_each do |target|
560
563
  chain = target.get_callbacks name
561
564
  yield target, chain.dup
562
565
  end
@@ -716,12 +719,21 @@ module ActiveSupport
716
719
  # define_callbacks :save, scope: [:name]
717
720
  #
718
721
  # would call <tt>Audit#save</tt>.
722
+ #
723
+ # NOTE: +method_name+ passed to `define_model_callbacks` must not end with
724
+ # `!`, `?` or `=`.
719
725
  def define_callbacks(*names)
720
726
  options = names.extract_options!
721
727
 
722
728
  names.each do |name|
723
729
  class_attribute "_#{name}_callbacks"
724
730
  set_callbacks name, CallbackChain.new(name, options)
731
+
732
+ module_eval <<-RUBY, __FILE__, __LINE__ + 1
733
+ def _run_#{name}_callbacks(&block)
734
+ _run_callbacks(_#{name}_callbacks, &block)
735
+ end
736
+ RUBY
725
737
  end
726
738
  end
727
739
 
@@ -20,7 +20,11 @@ class Array
20
20
  # %w( a b c d ).to(-2) # => ["a", "b", "c"]
21
21
  # %w( a b c ).to(-10) # => []
22
22
  def to(position)
23
- self[0..position]
23
+ if position >= 0
24
+ first position + 1
25
+ else
26
+ self[0..position]
27
+ end
24
28
  end
25
29
 
26
30
  # Equal to <tt>self[1]</tt>.
@@ -40,7 +40,7 @@ class File
40
40
  chown(old_stat.uid, old_stat.gid, file_name)
41
41
  # This operation will affect filesystem ACL's
42
42
  chmod(old_stat.mode, file_name)
43
- rescue Errno::EPERM
43
+ rescue Errno::EPERM, Errno::EACCES
44
44
  # Changing file ownership failed, moving on.
45
45
  end
46
46
  end
@@ -32,7 +32,7 @@ module Kernel
32
32
  # For compatibility
33
33
  def silence_stderr #:nodoc:
34
34
  ActiveSupport::Deprecation.warn(
35
- "#silence_stderr is deprecated and will be removed in the next release"
35
+ "`#silence_stderr` is deprecated and will be removed in the next release."
36
36
  ) #not thread-safe
37
37
  silence_stream(STDERR) { yield }
38
38
  end
@@ -87,7 +87,7 @@ module Kernel
87
87
  # stream # => "error\n"
88
88
  def capture(stream)
89
89
  ActiveSupport::Deprecation.warn(
90
- "#capture(stream) is deprecated and will be removed in the next release"
90
+ "`#capture(stream)` is deprecated and will be removed in the next release."
91
91
  ) #not thread-safe
92
92
  stream = stream.to_s
93
93
  captured_stream = Tempfile.new(stream)
@@ -113,7 +113,7 @@ module Kernel
113
113
  # This method is not thread-safe.
114
114
  def quietly
115
115
  ActiveSupport::Deprecation.warn(
116
- "#quietly is deprecated and will be removed in the next release"
116
+ "`#quietly` is deprecated and will be removed in the next release."
117
117
  ) #not thread-safe
118
118
  silence_stream(STDOUT) do
119
119
  silence_stream(STDERR) do
@@ -19,9 +19,9 @@ class Module
19
19
  # alias_method :foo_without_feature?, :foo?
20
20
  # alias_method :foo?, :foo_with_feature?
21
21
  #
22
- # so you can safely chain foo, foo?, and foo! with the same feature.
22
+ # so you can safely chain foo, foo?, foo! and/or foo= with the same feature.
23
23
  def alias_method_chain(target, feature)
24
- # Strip out punctuation on predicates or bang methods since
24
+ # Strip out punctuation on predicates, bang or writer methods since
25
25
  # e.g. target?_without_feature is not a valid method name.
26
26
  aliased_target, punctuation = target.to_s.sub(/([?!=])$/, ''), $1
27
27
  yield(aliased_target, punctuation) if block_given?
@@ -9,7 +9,23 @@ class Object
9
9
  #
10
10
  # instead of
11
11
  #
12
- # @person ? @person.name : nil
12
+ # @person.name if @person
13
+ #
14
+ # +try+ calls can be chained:
15
+ #
16
+ # @person.try(:spouse).try(:name)
17
+ #
18
+ # instead of
19
+ #
20
+ # @person.spouse.name if @person && @person.spouse
21
+ #
22
+ # +try+ will also return +nil+ if the receiver does not respond to the method:
23
+ #
24
+ # @person.try(:non_existing_method) #=> nil
25
+ #
26
+ # instead of
27
+ #
28
+ # @person.non_existing_method if @person.respond_to?(:non_existing_method) #=> nil
13
29
  #
14
30
  # +try+ returns +nil+ when called on +nil+ regardless of whether it responds
15
31
  # to the method:
@@ -24,7 +40,7 @@ class Object
24
40
  #
25
41
  # The number of arguments in the signature must match. If the object responds
26
42
  # to the method the call is attempted and +ArgumentError+ is still raised
27
- # otherwise.
43
+ # in case of argument mismatch.
28
44
  #
29
45
  # If +try+ is called without arguments it yields the receiver to a given
30
46
  # block unless it is +nil+:
@@ -38,28 +54,25 @@ class Object
38
54
  #
39
55
  # @person.try { upcase.truncate(50) }
40
56
  #
41
- # Please also note that +try+ is defined on +Object+, therefore it won't work
57
+ # Please also note that +try+ is defined on +Object+. Therefore, it won't work
42
58
  # with instances of classes that do not have +Object+ among their ancestors,
43
59
  # like direct subclasses of +BasicObject+. For example, using +try+ with
44
60
  # +SimpleDelegator+ will delegate +try+ to the target instead of calling it on
45
- # delegator itself.
61
+ # the delegator itself.
46
62
  def try(*a, &b)
63
+ try!(*a, &b) if a.empty? || respond_to?(a.first)
64
+ end
65
+
66
+ # Same as #try, but will raise a NoMethodError exception if the receiver is not +nil+ and
67
+ # does not implement the tried method.
68
+
69
+ def try!(*a, &b)
47
70
  if a.empty? && block_given?
48
71
  if b.arity.zero?
49
72
  instance_eval(&b)
50
73
  else
51
74
  yield self
52
75
  end
53
- else
54
- public_send(*a, &b) if respond_to?(a.first)
55
- end
56
- end
57
-
58
- # Same as #try, but will raise a NoMethodError exception if the receiving is not nil and
59
- # does not implement the tried method.
60
- def try!(*a, &b)
61
- if a.empty? && block_given?
62
- yield self
63
76
  else
64
77
  public_send(*a, &b)
65
78
  end
@@ -68,12 +81,12 @@ end
68
81
 
69
82
  class NilClass
70
83
  # Calling +try+ on +nil+ always returns +nil+.
71
- # It becomes specially helpful when navigating through associations that may return +nil+.
84
+ # It becomes especially helpful when navigating through associations that may return +nil+.
72
85
  #
73
86
  # nil.try(:name) # => nil
74
87
  #
75
88
  # Without +try+
76
- # @person && !@person.children.blank? && @person.children.first.name
89
+ # @person && @person.children.any? && @person.children.first.name
77
90
  #
78
91
  # With +try+
79
92
  # @person.try(:children).try(:first).try(:name)
@@ -47,7 +47,21 @@ class Object
47
47
  # end
48
48
  #
49
49
  # <tt>with_options</tt> can also be nested since the call is forwarded to its receiver.
50
- # Each nesting level will merge inherited defaults in addition to their own.
50
+ #
51
+ # NOTE: Each nesting level will merge inherited defaults in addition to their own.
52
+ #
53
+ # class Post < ActiveRecord::Base
54
+ # with_options if: :persisted?, length: { minimum: 50 } do
55
+ # validates :content, if: -> { content.present? }
56
+ # end
57
+ # end
58
+ #
59
+ # The code is equivalent to:
60
+ #
61
+ # validates :content, length: { minimum: 50 }, if: -> { content.present? }
62
+ #
63
+ # Hence the inherited default for `if` key is ignored.
64
+ #
51
65
  def with_options(options, &block)
52
66
  option_merger = ActiveSupport::OptionMerger.new(self, options)
53
67
  block.arity.zero? ? option_merger.instance_eval(&block) : block.call(option_merger)
@@ -150,7 +150,7 @@ module ActiveSupport #:nodoc:
150
150
  else
151
151
  if html_safe?
152
152
  new_safe_buffer = super
153
- new_safe_buffer.instance_eval { @html_safe = true }
153
+ new_safe_buffer.instance_variable_set :@html_safe, true
154
154
  new_safe_buffer
155
155
  else
156
156
  to_str[*args]
@@ -30,6 +30,10 @@ module ActiveSupport #:nodoc:
30
30
  mattr_accessor :loaded
31
31
  self.loaded = Set.new
32
32
 
33
+ # Stack of files being loaded.
34
+ mattr_accessor :loading
35
+ self.loading = []
36
+
33
37
  # Should we load files or require them?
34
38
  mattr_accessor :mechanism
35
39
  self.mechanism = ENV['NO_RELOAD'] ? :require : :load
@@ -317,6 +321,7 @@ module ActiveSupport #:nodoc:
317
321
  def clear
318
322
  log_call
319
323
  loaded.clear
324
+ loading.clear
320
325
  remove_unloadable_constants!
321
326
  end
322
327
 
@@ -329,6 +334,7 @@ module ActiveSupport #:nodoc:
329
334
  # Record that we've seen this file *before* loading it to avoid an
330
335
  # infinite loop with mutual dependencies.
331
336
  loaded << expanded
337
+ loading << expanded
332
338
 
333
339
  begin
334
340
  if load?
@@ -351,6 +357,8 @@ module ActiveSupport #:nodoc:
351
357
  rescue Exception
352
358
  loaded.delete expanded
353
359
  raise
360
+ ensure
361
+ loading.pop
354
362
  end
355
363
 
356
364
  # Record history *after* loading so first load gets warnings.
@@ -475,7 +483,7 @@ module ActiveSupport #:nodoc:
475
483
  expanded = File.expand_path(file_path)
476
484
  expanded.sub!(/\.rb\z/, '')
477
485
 
478
- if loaded.include?(expanded)
486
+ if loading.include?(expanded)
479
487
  raise "Circular dependency detected while autoloading constant #{qualified_name}"
480
488
  else
481
489
  require_or_load(expanded, qualified_name)
@@ -63,6 +63,10 @@ module ActiveSupport
63
63
  Duration === other && other.value.eql?(value)
64
64
  end
65
65
 
66
+ def hash
67
+ @value.hash
68
+ end
69
+
66
70
  def self.===(other) #:nodoc:
67
71
  other.is_a?(Duration)
68
72
  rescue ::NoMethodError
@@ -8,7 +8,7 @@ module ActiveSupport
8
8
  MAJOR = 4
9
9
  MINOR = 2
10
10
  TINY = 0
11
- PRE = "beta3"
11
+ PRE = "beta4"
12
12
 
13
13
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
14
14
  end
@@ -1,4 +1,5 @@
1
1
  require 'active_support/core_ext/hash/keys'
2
+ require 'active_support/core_ext/hash/reverse_merge'
2
3
 
3
4
  module ActiveSupport
4
5
  # Implements a hash where keys <tt>:foo</tt> and <tt>"foo"</tt> are considered
@@ -154,7 +154,7 @@ module ActiveSupport
154
154
  end
155
155
  end
156
156
 
157
- # Add uncountable words that shouldn't be attempted inflected.
157
+ # Specifies words that are uncountable and should not be inflected.
158
158
  #
159
159
  # uncountable 'money'
160
160
  # uncountable 'money', 'information'
@@ -90,8 +90,8 @@ module ActiveSupport
90
90
  # 'SSLError'.underscore.camelize # => "SslError"
91
91
  def underscore(camel_cased_word)
92
92
  return camel_cased_word unless camel_cased_word =~ /[A-Z-]|::/
93
- word = camel_cased_word.to_s.gsub('::', '/')
94
- word.gsub!(/(?:([A-Za-z\d])|\b)(#{inflections.acronym_regex})(?=\b|[^a-z])/) { "#{$1}#{$1 && '_'}#{$2.downcase}" }
93
+ word = camel_cased_word.to_s.gsub(/::/, '/')
94
+ word.gsub!(/(?:(?<=([A-Za-z\d]))|\b)(#{inflections.acronym_regex})(?=\b|[^a-z])/) { "#{$1 && '_'}#{$2.downcase}" }
95
95
  word.gsub!(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2')
96
96
  word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
97
97
  word.tr!("-", "_")
@@ -12,7 +12,7 @@ module ActiveSupport
12
12
 
13
13
  class << self
14
14
  # Parses a JSON string (JavaScript Object Notation) into a hash.
15
- # See www.json.org for more info.
15
+ # See http://www.json.org for more info.
16
16
  #
17
17
  # ActiveSupport::JSON.decode("{\"team\":\"rails\",\"players\":\"36\"}")
18
18
  # => {"team" => "rails", "players" => "36"}
@@ -13,7 +13,7 @@ module ActiveSupport
13
13
 
14
14
  module JSON
15
15
  # Dumps objects in JSON (JavaScript Object Notation).
16
- # See www.json.org for more info.
16
+ # See http://www.json.org for more info.
17
17
  #
18
18
  # ActiveSupport::JSON.encode({ team: 'rails', players: '36' })
19
19
  # # => "{\"team\":\"rails\",\"players\":\"36\"}"
@@ -131,7 +131,7 @@ module ActiveSupport
131
131
  "The JSON encoder in Rails 4.1 no longer supports encoding BigDecimals as JSON numbers. Instead, " \
132
132
  "the new encoder will always encode them as strings.\n\n" \
133
133
  "You are seeing this error because you are trying to check the value of the related configuration, " \
134
- "'active_support.encode_big_decimal_as_string'. If your application depends on this option, you should " \
134
+ "`active_support.encode_big_decimal_as_string`. If your application depends on this option, you should " \
135
135
  "add the 'activesupport-json_encoder' gem to your Gemfile. For now, this option will always be true. " \
136
136
  "In the future, it will be removed from Rails, so you should stop checking its value."
137
137
 
@@ -1,5 +1,6 @@
1
1
  require 'base64'
2
2
  require 'active_support/core_ext/object/blank'
3
+ require 'active_support/security_utils'
3
4
 
4
5
  module ActiveSupport
5
6
  # +MessageVerifier+ makes it easy to generate and verify messages which are
@@ -37,7 +38,7 @@ module ActiveSupport
37
38
  raise InvalidSignature if signed_message.blank?
38
39
 
39
40
  data, digest = signed_message.split("--")
40
- if data.present? && digest.present? && secure_compare(digest, generate_digest(data))
41
+ if data.present? && digest.present? && ActiveSupport::SecurityUtils.secure_compare(digest, generate_digest(data))
41
42
  begin
42
43
  @serializer.load(::Base64.strict_decode64(data))
43
44
  rescue ArgumentError => argument_error
@@ -55,17 +56,6 @@ module ActiveSupport
55
56
  end
56
57
 
57
58
  private
58
- # constant-time comparison algorithm to prevent timing attacks
59
- def secure_compare(a, b)
60
- return false unless a.bytesize == b.bytesize
61
-
62
- l = a.unpack "C#{a.bytesize}"
63
-
64
- res = 0
65
- b.each_byte { |byte| res |= byte ^ l.shift }
66
- res == 0
67
- end
68
-
69
59
  def generate_digest(data)
70
60
  require 'openssl' unless defined?(OpenSSL)
71
61
  OpenSSL::HMAC.hexdigest(OpenSSL::Digest.const_get(@digest).new, @secret, data)
@@ -272,12 +272,12 @@ module ActiveSupport
272
272
  # string containing an i18n scope where to find this hash. It
273
273
  # might have the following keys:
274
274
  # * *integers*: <tt>:unit</tt>, <tt>:ten</tt>,
275
- # *<tt>:hundred</tt>, <tt>:thousand</tt>, <tt>:million</tt>,
276
- # *<tt>:billion</tt>, <tt>:trillion</tt>,
277
- # *<tt>:quadrillion</tt>
275
+ # <tt>:hundred</tt>, <tt>:thousand</tt>, <tt>:million</tt>,
276
+ # <tt>:billion</tt>, <tt>:trillion</tt>,
277
+ # <tt>:quadrillion</tt>
278
278
  # * *fractionals*: <tt>:deci</tt>, <tt>:centi</tt>,
279
- # *<tt>:mili</tt>, <tt>:micro</tt>, <tt>:nano</tt>,
280
- # *<tt>:pico</tt>, <tt>:femto</tt>
279
+ # <tt>:mili</tt>, <tt>:micro</tt>, <tt>:nano</tt>,
280
+ # <tt>:pico</tt>, <tt>:femto</tt>
281
281
  # * <tt>:format</tt> - Sets the format of the output string
282
282
  # (defaults to "%n %u"). The field types are:
283
283
  # * %u - The quantifier (ex.: 'thousand')
@@ -13,7 +13,7 @@ module ActiveSupport
13
13
  end
14
14
 
15
15
  rounded_number = NumberToRoundedConverter.convert(number, options)
16
- format.gsub('%n', rounded_number).gsub('%u', options[:unit])
16
+ format.gsub(/%n/, rounded_number).gsub(/%u/, options[:unit])
17
17
  end
18
18
 
19
19
  private
@@ -5,7 +5,7 @@ module ActiveSupport
5
5
 
6
6
  def convert
7
7
  rounded_number = NumberToRoundedConverter.convert(number, options)
8
- options[:format].gsub('%n', rounded_number)
8
+ options[:format].gsub(/%n/, rounded_number)
9
9
  end
10
10
  end
11
11
  end
@@ -0,0 +1,20 @@
1
+ module ActiveSupport
2
+ module SecurityUtils
3
+ # Constant time string comparison.
4
+ #
5
+ # The values compared should be of fixed length, such as strings
6
+ # that have already been processed by HMAC. This should not be used
7
+ # on variable length plaintext strings because it could leak length info
8
+ # via timing attacks.
9
+ def secure_compare(a, b)
10
+ return false unless a.bytesize == b.bytesize
11
+
12
+ l = a.unpack "C#{a.bytesize}"
13
+
14
+ res = 0
15
+ b.each_byte { |byte| res |= byte ^ l.shift }
16
+ res == 0
17
+ end
18
+ module_function :secure_compare
19
+ end
20
+ end
@@ -25,7 +25,7 @@ module ActiveSupport
25
25
 
26
26
  if test_order.nil?
27
27
  ActiveSupport::Deprecation.warn "You did not specify a value for the " \
28
- "configuration option 'active_support.test_order'. In Rails 5.0, " \
28
+ "configuration option `active_support.test_order`. In Rails 5, " \
29
29
  "the default value of this option will change from `:sorted` to " \
30
30
  "`:random`.\n" \
31
31
  "To disable this warning and keep the current behavior, you can add " \
@@ -90,7 +90,7 @@ module ActiveSupport
90
90
  # Time.current # => Wed, 24 Nov 2004 01:04:44 EST -05:00
91
91
  # end
92
92
  # Time.current # => Sat, 09 Nov 2013 15:34:49 EST -05:00
93
- def travel_to(date_or_time, &block)
93
+ def travel_to(date_or_time)
94
94
  if date_or_time.is_a?(Date) && !date_or_time.is_a?(DateTime)
95
95
  now = date_or_time.midnight.to_time
96
96
  else
@@ -102,7 +102,7 @@ module ActiveSupport
102
102
 
103
103
  if block_given?
104
104
  begin
105
- block.call
105
+ yield
106
106
  ensure
107
107
  travel_back
108
108
  end
@@ -75,8 +75,8 @@ module ActiveSupport
75
75
 
76
76
  # Returns a <tt>Time.local()</tt> instance of the simultaneous time in your
77
77
  # system's <tt>ENV['TZ']</tt> zone.
78
- def localtime
79
- utc.respond_to?(:getlocal) ? utc.getlocal : utc.to_time.getlocal
78
+ def localtime(utc_offset = nil)
79
+ utc.respond_to?(:getlocal) ? utc.getlocal(utc_offset) : utc.to_time.getlocal(utc_offset)
80
80
  end
81
81
  alias_method :getlocal, :localtime
82
82
 
@@ -201,15 +201,11 @@ module ActiveSupport
201
201
  end
202
202
  alias_method :to_formatted_s, :to_s
203
203
 
204
- # Replaces <tt>%Z</tt> and <tt>%z</tt> directives with +zone+ and
205
- # +formatted_offset+, respectively, before passing to Time#strftime, so
206
- # that zone information is correct
204
+ # Replaces <tt>%Z</tt> directive with +zone before passing to Time#strftime,
205
+ # so that zone information is correct.
207
206
  def strftime(format)
208
- format = format.gsub('%Z', zone)
209
- .gsub('%z', formatted_offset(false))
210
- .gsub('%:z', formatted_offset(true))
211
- .gsub('%::z', formatted_offset(true) + ":00")
212
- time.strftime(format)
207
+ format = format.gsub(/((?:\A|[^%])(?:%%)*)%Z/, "\\1#{zone}")
208
+ getlocal(utc_offset).strftime(format)
213
209
  end
214
210
 
215
211
  # Use the time in UTC for comparisons.
@@ -184,7 +184,7 @@ module ActiveSupport
184
184
  }
185
185
 
186
186
  UTC_OFFSET_WITH_COLON = '%s%02d:%02d'
187
- UTC_OFFSET_WITHOUT_COLON = UTC_OFFSET_WITH_COLON.sub(':', '')
187
+ UTC_OFFSET_WITHOUT_COLON = UTC_OFFSET_WITH_COLON.tr(':', '')
188
188
 
189
189
  @lazy_zones_map = ThreadSafe::Cache.new
190
190
 
metadata CHANGED
@@ -1,95 +1,95 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activesupport
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0.beta3
4
+ version: 4.2.0.beta4
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-29 00:00:00.000000000 Z
11
+ date: 2014-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.7.0.beta1
20
- - - "<"
20
+ - - <
21
21
  - !ruby/object:Gem::Version
22
22
  version: '0.8'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ">="
27
+ - - '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: 0.7.0.beta1
30
- - - "<"
30
+ - - <
31
31
  - !ruby/object:Gem::Version
32
32
  version: '0.8'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: json
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - "~>"
37
+ - - ~>
38
38
  - !ruby/object:Gem::Version
39
39
  version: '1.7'
40
- - - ">="
40
+ - - '>='
41
41
  - !ruby/object:Gem::Version
42
42
  version: 1.7.7
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - "~>"
47
+ - - ~>
48
48
  - !ruby/object:Gem::Version
49
49
  version: '1.7'
50
- - - ">="
50
+ - - '>='
51
51
  - !ruby/object:Gem::Version
52
52
  version: 1.7.7
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: tzinfo
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
- - - "~>"
57
+ - - ~>
58
58
  - !ruby/object:Gem::Version
59
59
  version: '1.1'
60
60
  type: :runtime
61
61
  prerelease: false
62
62
  version_requirements: !ruby/object:Gem::Requirement
63
63
  requirements:
64
- - - "~>"
64
+ - - ~>
65
65
  - !ruby/object:Gem::Version
66
66
  version: '1.1'
67
67
  - !ruby/object:Gem::Dependency
68
68
  name: minitest
69
69
  requirement: !ruby/object:Gem::Requirement
70
70
  requirements:
71
- - - "~>"
71
+ - - ~>
72
72
  - !ruby/object:Gem::Version
73
73
  version: '5.1'
74
74
  type: :runtime
75
75
  prerelease: false
76
76
  version_requirements: !ruby/object:Gem::Requirement
77
77
  requirements:
78
- - - "~>"
78
+ - - ~>
79
79
  - !ruby/object:Gem::Version
80
80
  version: '5.1'
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: thread_safe
83
83
  requirement: !ruby/object:Gem::Requirement
84
84
  requirements:
85
- - - "~>"
85
+ - - ~>
86
86
  - !ruby/object:Gem::Version
87
87
  version: '0.1'
88
88
  type: :runtime
89
89
  prerelease: false
90
90
  version_requirements: !ruby/object:Gem::Requirement
91
91
  requirements:
92
- - - "~>"
92
+ - - ~>
93
93
  - !ruby/object:Gem::Version
94
94
  version: '0.1'
95
95
  description: A toolkit of support libraries and Ruby core extensions extracted from
@@ -291,6 +291,7 @@ files:
291
291
  - lib/active_support/rails.rb
292
292
  - lib/active_support/railtie.rb
293
293
  - lib/active_support/rescuable.rb
294
+ - lib/active_support/security_utils.rb
294
295
  - lib/active_support/string_inquirer.rb
295
296
  - lib/active_support/subscriber.rb
296
297
  - lib/active_support/tagged_logging.rb
@@ -322,23 +323,23 @@ licenses:
322
323
  metadata: {}
323
324
  post_install_message:
324
325
  rdoc_options:
325
- - "--encoding"
326
+ - --encoding
326
327
  - UTF-8
327
328
  require_paths:
328
329
  - lib
329
330
  required_ruby_version: !ruby/object:Gem::Requirement
330
331
  requirements:
331
- - - ">="
332
+ - - '>='
332
333
  - !ruby/object:Gem::Version
333
334
  version: 1.9.3
334
335
  required_rubygems_version: !ruby/object:Gem::Requirement
335
336
  requirements:
336
- - - ">"
337
+ - - '>'
337
338
  - !ruby/object:Gem::Version
338
339
  version: 1.3.1
339
340
  requirements: []
340
341
  rubyforge_project:
341
- rubygems_version: 2.2.2
342
+ rubygems_version: 2.2.1
342
343
  signing_key:
343
344
  specification_version: 4
344
345
  summary: A toolkit of support libraries and Ruby core extensions extracted from the