activesupport 3.2.22.5 → 4.0.0.beta1

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.

Files changed (214) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +325 -136
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +4 -2
  5. data/lib/active_support.rb +8 -21
  6. data/lib/active_support/backtrace_cleaner.rb +33 -25
  7. data/lib/active_support/basic_object.rb +7 -17
  8. data/lib/active_support/benchmarkable.rb +19 -15
  9. data/lib/active_support/buffered_logger.rb +9 -113
  10. data/lib/active_support/cache.rb +203 -171
  11. data/lib/active_support/cache/file_store.rb +12 -12
  12. data/lib/active_support/cache/mem_cache_store.rb +24 -30
  13. data/lib/active_support/cache/memory_store.rb +2 -0
  14. data/lib/active_support/callbacks.rb +195 -247
  15. data/lib/active_support/concern.rb +16 -23
  16. data/lib/active_support/concurrency/latch.rb +27 -0
  17. data/lib/active_support/configurable.rb +69 -12
  18. data/lib/active_support/core_ext.rb +1 -0
  19. data/lib/active_support/core_ext/array.rb +0 -1
  20. data/lib/active_support/core_ext/array/access.rb +17 -9
  21. data/lib/active_support/core_ext/array/conversions.rb +113 -55
  22. data/lib/active_support/core_ext/array/extract_options.rb +2 -2
  23. data/lib/active_support/core_ext/array/grouping.rb +21 -22
  24. data/lib/active_support/core_ext/array/uniq_by.rb +12 -9
  25. data/lib/active_support/core_ext/array/wrap.rb +11 -14
  26. data/lib/active_support/core_ext/big_decimal/conversions.rb +7 -24
  27. data/lib/active_support/core_ext/class/attribute.rb +12 -8
  28. data/lib/active_support/core_ext/class/attribute_accessors.rb +14 -12
  29. data/lib/active_support/core_ext/class/delegating_attributes.rb +15 -19
  30. data/lib/active_support/core_ext/class/subclasses.rb +11 -5
  31. data/lib/active_support/core_ext/date.rb +6 -0
  32. data/lib/active_support/core_ext/date/calculations.rb +34 -188
  33. data/lib/active_support/core_ext/date/conversions.rb +16 -38
  34. data/lib/active_support/core_ext/date/infinite_comparable.rb +5 -0
  35. data/lib/active_support/core_ext/date/zones.rb +25 -2
  36. data/lib/active_support/core_ext/date_and_time/calculations.rb +232 -0
  37. data/lib/active_support/core_ext/date_time.rb +5 -0
  38. data/lib/active_support/core_ext/date_time/acts_like.rb +0 -1
  39. data/lib/active_support/core_ext/date_time/calculations.rb +73 -65
  40. data/lib/active_support/core_ext/date_time/conversions.rb +21 -33
  41. data/lib/active_support/core_ext/date_time/infinite_comparable.rb +5 -0
  42. data/lib/active_support/core_ext/date_time/zones.rb +11 -8
  43. data/lib/active_support/core_ext/enumerable.rb +26 -73
  44. data/lib/active_support/core_ext/file.rb +0 -1
  45. data/lib/active_support/core_ext/file/atomic.rb +27 -11
  46. data/lib/active_support/core_ext/hash.rb +0 -1
  47. data/lib/active_support/core_ext/hash/conversions.rb +145 -79
  48. data/lib/active_support/core_ext/hash/deep_merge.rb +14 -8
  49. data/lib/active_support/core_ext/hash/diff.rb +5 -4
  50. data/lib/active_support/core_ext/hash/except.rb +1 -9
  51. data/lib/active_support/core_ext/hash/indifferent_access.rb +4 -5
  52. data/lib/active_support/core_ext/hash/keys.rb +108 -24
  53. data/lib/active_support/core_ext/hash/reverse_merge.rb +2 -3
  54. data/lib/active_support/core_ext/hash/slice.rb +12 -12
  55. data/lib/active_support/core_ext/infinite_comparable.rb +35 -0
  56. data/lib/active_support/core_ext/integer/inflections.rb +13 -1
  57. data/lib/active_support/core_ext/integer/time.rb +17 -12
  58. data/lib/active_support/core_ext/kernel/debugger.rb +2 -2
  59. data/lib/active_support/core_ext/kernel/reporting.rb +36 -22
  60. data/lib/active_support/core_ext/kernel/singleton_class.rb +0 -7
  61. data/lib/active_support/core_ext/load_error.rb +7 -5
  62. data/lib/active_support/core_ext/logger.rb +7 -23
  63. data/lib/active_support/core_ext/marshal.rb +19 -0
  64. data/lib/active_support/core_ext/module.rb +1 -3
  65. data/lib/active_support/core_ext/module/aliasing.rb +8 -9
  66. data/lib/active_support/core_ext/module/anonymous.rb +2 -7
  67. data/lib/active_support/core_ext/module/attr_internal.rb +0 -1
  68. data/lib/active_support/core_ext/module/attribute_accessors.rb +12 -10
  69. data/lib/active_support/core_ext/module/delegation.rb +57 -40
  70. data/lib/active_support/core_ext/module/deprecation.rb +19 -3
  71. data/lib/active_support/core_ext/module/introspection.rb +17 -27
  72. data/lib/active_support/core_ext/module/qualified_const.rb +8 -20
  73. data/lib/active_support/core_ext/module/remove_method.rb +1 -5
  74. data/lib/active_support/core_ext/numeric.rb +2 -0
  75. data/lib/active_support/core_ext/numeric/conversions.rb +135 -0
  76. data/lib/active_support/core_ext/numeric/infinite_comparable.rb +9 -0
  77. data/lib/active_support/core_ext/numeric/time.rb +6 -6
  78. data/lib/active_support/core_ext/object.rb +1 -0
  79. data/lib/active_support/core_ext/object/acts_like.rb +4 -4
  80. data/lib/active_support/core_ext/object/blank.rb +7 -23
  81. data/lib/active_support/core_ext/object/deep_dup.rb +46 -0
  82. data/lib/active_support/core_ext/object/duplicable.rb +1 -30
  83. data/lib/active_support/core_ext/object/inclusion.rb +6 -6
  84. data/lib/active_support/core_ext/object/instance_variables.rb +7 -12
  85. data/lib/active_support/core_ext/object/to_json.rb +8 -0
  86. data/lib/active_support/core_ext/object/to_param.rb +5 -2
  87. data/lib/active_support/core_ext/object/try.rb +46 -25
  88. data/lib/active_support/core_ext/object/with_options.rb +7 -8
  89. data/lib/active_support/core_ext/proc.rb +3 -0
  90. data/lib/active_support/core_ext/range.rb +0 -2
  91. data/lib/active_support/core_ext/range/conversions.rb +0 -2
  92. data/lib/active_support/core_ext/range/include_range.rb +1 -1
  93. data/lib/active_support/core_ext/range/overlaps.rb +1 -1
  94. data/lib/active_support/core_ext/string.rb +2 -2
  95. data/lib/active_support/core_ext/string/access.rb +95 -90
  96. data/lib/active_support/core_ext/string/conversions.rb +29 -38
  97. data/lib/active_support/core_ext/string/encoding.rb +6 -9
  98. data/lib/active_support/core_ext/string/filters.rb +24 -18
  99. data/lib/active_support/core_ext/string/indent.rb +43 -0
  100. data/lib/active_support/core_ext/string/inflections.rb +70 -60
  101. data/lib/active_support/core_ext/string/inquiry.rb +2 -2
  102. data/lib/active_support/core_ext/string/multibyte.rb +41 -64
  103. data/lib/active_support/core_ext/string/output_safety.rb +59 -51
  104. data/lib/active_support/core_ext/string/zones.rb +13 -0
  105. data/lib/active_support/core_ext/struct.rb +6 -0
  106. data/lib/active_support/core_ext/thread.rb +74 -0
  107. data/lib/active_support/core_ext/time.rb +6 -0
  108. data/lib/active_support/core_ext/time/calculations.rb +105 -193
  109. data/lib/active_support/core_ext/time/conversions.rb +27 -51
  110. data/lib/active_support/core_ext/time/infinite_comparable.rb +5 -0
  111. data/lib/active_support/core_ext/time/marshal.rb +0 -27
  112. data/lib/active_support/core_ext/time/zones.rb +27 -17
  113. data/lib/active_support/core_ext/uri.rb +13 -17
  114. data/lib/active_support/dependencies.rb +160 -141
  115. data/lib/active_support/dependencies/autoload.rb +47 -20
  116. data/lib/active_support/deprecation.rb +39 -14
  117. data/lib/active_support/deprecation/behaviors.rb +44 -30
  118. data/lib/active_support/deprecation/instance_delegator.rb +24 -0
  119. data/lib/active_support/deprecation/method_wrappers.rb +33 -18
  120. data/lib/active_support/deprecation/proxy_wrappers.rb +58 -13
  121. data/lib/active_support/deprecation/reporting.rb +40 -11
  122. data/lib/active_support/descendants_tracker.rb +34 -19
  123. data/lib/active_support/duration.rb +6 -8
  124. data/lib/active_support/file_update_checker.rb +63 -47
  125. data/lib/active_support/gzip.rb +11 -5
  126. data/lib/active_support/hash_with_indifferent_access.rb +112 -37
  127. data/lib/active_support/i18n.rb +4 -0
  128. data/lib/active_support/i18n_railtie.rb +5 -22
  129. data/lib/active_support/inflections.rb +14 -12
  130. data/lib/active_support/inflector/inflections.rb +108 -71
  131. data/lib/active_support/inflector/methods.rb +181 -160
  132. data/lib/active_support/inflector/transliterate.rb +16 -17
  133. data/lib/active_support/json/decoding.rb +18 -17
  134. data/lib/active_support/json/encoding.rb +93 -39
  135. data/lib/active_support/json/variable.rb +10 -1
  136. data/lib/active_support/key_generator.rb +75 -0
  137. data/lib/active_support/lazy_load_hooks.rb +21 -19
  138. data/lib/active_support/locale/en.yml +100 -3
  139. data/lib/active_support/log_subscriber.rb +56 -36
  140. data/lib/active_support/log_subscriber/test_helper.rb +18 -15
  141. data/lib/active_support/logger.rb +57 -0
  142. data/lib/active_support/logger_silence.rb +24 -0
  143. data/lib/active_support/message_encryptor.rb +32 -29
  144. data/lib/active_support/message_verifier.rb +8 -14
  145. data/lib/active_support/multibyte.rb +5 -28
  146. data/lib/active_support/multibyte/chars.rb +80 -333
  147. data/lib/active_support/multibyte/unicode.rb +74 -64
  148. data/lib/active_support/notifications.rb +57 -25
  149. data/lib/active_support/notifications/fanout.rb +105 -18
  150. data/lib/active_support/notifications/instrumenter.rb +32 -13
  151. data/lib/active_support/number_helper.rb +636 -0
  152. data/lib/active_support/ordered_hash.rb +8 -190
  153. data/lib/active_support/ordered_options.rb +21 -23
  154. data/lib/active_support/proxy_object.rb +13 -0
  155. data/lib/active_support/rails.rb +27 -0
  156. data/lib/active_support/railtie.rb +12 -32
  157. data/lib/active_support/rescuable.rb +9 -4
  158. data/lib/active_support/string_inquirer.rb +13 -8
  159. data/lib/active_support/tagged_logging.rb +51 -73
  160. data/lib/active_support/test_case.rb +46 -17
  161. data/lib/active_support/testing/assertions.rb +56 -26
  162. data/lib/active_support/testing/autorun.rb +5 -0
  163. data/lib/active_support/testing/constant_lookup.rb +52 -0
  164. data/lib/active_support/testing/declarative.rb +1 -1
  165. data/lib/active_support/testing/deprecation.rb +0 -19
  166. data/lib/active_support/testing/isolation.rb +25 -58
  167. data/lib/active_support/testing/pending.rb +5 -43
  168. data/lib/active_support/testing/setup_and_teardown.rb +6 -92
  169. data/lib/active_support/testing/tagged_logging.rb +25 -0
  170. data/lib/active_support/time.rb +6 -21
  171. data/lib/active_support/time_with_zone.rb +78 -43
  172. data/lib/active_support/values/time_zone.rb +77 -58
  173. data/lib/active_support/values/unicode_tables.dat +0 -0
  174. data/lib/active_support/version.rb +4 -4
  175. data/lib/active_support/xml_mini.rb +35 -17
  176. data/lib/active_support/xml_mini/jdom.rb +9 -17
  177. data/lib/active_support/xml_mini/libxml.rb +1 -2
  178. data/lib/active_support/xml_mini/libxmlsax.rb +1 -2
  179. data/lib/active_support/xml_mini/nokogiri.rb +1 -2
  180. data/lib/active_support/xml_mini/nokogirisax.rb +1 -2
  181. data/lib/active_support/xml_mini/rexml.rb +6 -8
  182. metadata +107 -77
  183. data/lib/active_support/base64.rb +0 -54
  184. data/lib/active_support/core_ext/array/random_access.rb +0 -30
  185. data/lib/active_support/core_ext/date/freeze.rb +0 -33
  186. data/lib/active_support/core_ext/exception.rb +0 -3
  187. data/lib/active_support/core_ext/file/path.rb +0 -5
  188. data/lib/active_support/core_ext/float.rb +0 -1
  189. data/lib/active_support/core_ext/float/rounding.rb +0 -19
  190. data/lib/active_support/core_ext/hash/deep_dup.rb +0 -18
  191. data/lib/active_support/core_ext/io.rb +0 -15
  192. data/lib/active_support/core_ext/module/method_names.rb +0 -14
  193. data/lib/active_support/core_ext/module/synchronization.rb +0 -45
  194. data/lib/active_support/core_ext/process.rb +0 -1
  195. data/lib/active_support/core_ext/process/daemon.rb +0 -23
  196. data/lib/active_support/core_ext/range/blockless_step.rb +0 -29
  197. data/lib/active_support/core_ext/range/cover.rb +0 -3
  198. data/lib/active_support/core_ext/rexml.rb +0 -46
  199. data/lib/active_support/core_ext/string/interpolation.rb +0 -2
  200. data/lib/active_support/core_ext/time/publicize_conversion_methods.rb +0 -10
  201. data/lib/active_support/memoizable.rb +0 -116
  202. data/lib/active_support/multibyte/exceptions.rb +0 -8
  203. data/lib/active_support/multibyte/utils.rb +0 -60
  204. data/lib/active_support/ruby/shim.rb +0 -22
  205. data/lib/active_support/security_utils.rb +0 -27
  206. data/lib/active_support/testing/mochaing.rb +0 -7
  207. data/lib/active_support/testing/performance.rb +0 -317
  208. data/lib/active_support/testing/performance/jruby.rb +0 -115
  209. data/lib/active_support/testing/performance/rubinius.rb +0 -113
  210. data/lib/active_support/testing/performance/ruby.rb +0 -152
  211. data/lib/active_support/testing/performance/ruby/mri.rb +0 -57
  212. data/lib/active_support/testing/performance/ruby/yarv.rb +0 -57
  213. data/lib/active_support/time/autoload.rb +0 -5
  214. data/lib/active_support/whiny_nil.rb +0 -24
@@ -1,54 +0,0 @@
1
- require 'active_support/deprecation'
2
-
3
- begin
4
- require 'base64'
5
- rescue LoadError
6
- # The Base64 module isn't available in earlier versions of Ruby 1.9.
7
- module Base64
8
- # Encodes a string to its base 64 representation. Each 60 characters of
9
- # output is separated by a newline character.
10
- #
11
- # ActiveSupport::Base64.encode64("Original unencoded string")
12
- # # => "T3JpZ2luYWwgdW5lbmNvZGVkIHN0cmluZw==\n"
13
- def self.encode64(data)
14
- [data].pack("m")
15
- end
16
-
17
- # Decodes a base 64 encoded string to its original representation.
18
- #
19
- # ActiveSupport::Base64.decode64("T3JpZ2luYWwgdW5lbmNvZGVkIHN0cmluZw==")
20
- # # => "Original unencoded string"
21
- def self.decode64(data)
22
- data.unpack("m").first
23
- end
24
- end
25
- end
26
-
27
- unless Base64.respond_to?(:strict_encode64)
28
- # Included in Ruby 1.9
29
- def Base64.strict_encode64(value)
30
- encode64(value).gsub(/\n/, '')
31
- end
32
- end
33
-
34
- module ActiveSupport
35
- module Base64
36
- def self.encode64(value)
37
- ActiveSupport::Deprecation.warn "ActiveSupport::Base64.encode64 " \
38
- "is deprecated. Use Base64.encode64 instead", caller
39
- ::Base64.encode64(value)
40
- end
41
-
42
- def self.decode64(value)
43
- ActiveSupport::Deprecation.warn "ActiveSupport::Base64.decode64 " \
44
- "is deprecated. Use Base64.decode64 instead", caller
45
- ::Base64.decode64(value)
46
- end
47
-
48
- def self.encode64s(value)
49
- ActiveSupport::Deprecation.warn "ActiveSupport::Base64.encode64s " \
50
- "is deprecated. Use Base64.strict_encode64 instead", caller
51
- ::Base64.strict_encode64(value)
52
- end
53
- end
54
- end
@@ -1,30 +0,0 @@
1
- class Array
2
- # Backport of Array#sample based on Marc-Andre Lafortune's https://github.com/marcandre/backports/
3
- # Returns a random element or +n+ random elements from the array.
4
- # If the array is empty and +n+ is nil, returns <tt>nil</tt>.
5
- # If +n+ is passed and its value is less than 0, it raises an +ArgumentError+ exception.
6
- # If the value of +n+ is equal or greater than 0 it returns <tt>[]</tt>.
7
- #
8
- # [1,2,3,4,5,6].sample # => 4
9
- # [1,2,3,4,5,6].sample(3) # => [2, 4, 5]
10
- # [1,2,3,4,5,6].sample(-3) # => ArgumentError: negative array size
11
- # [].sample # => nil
12
- # [].sample(3) # => []
13
- def sample(n=nil)
14
- return self[Kernel.rand(size)] if n.nil?
15
- n = n.to_int
16
- rescue Exception => e
17
- raise TypeError, "Coercion error: #{n.inspect}.to_int => Integer failed:\n(#{e.message})"
18
- else
19
- raise TypeError, "Coercion error: obj.to_int did NOT return an Integer (was #{n.class})" unless n.kind_of? Integer
20
- raise ArgumentError, "negative array size" if n < 0
21
- n = size if n > size
22
- result = Array.new(self)
23
- n.times do |i|
24
- r = i + Kernel.rand(size - i)
25
- result[i], result[r] = result[r], result[i]
26
- end
27
- result[n..size] = []
28
- result
29
- end unless method_defined? :sample
30
- end
@@ -1,33 +0,0 @@
1
- # Date memoizes some instance methods using metaprogramming to wrap
2
- # the methods with one that caches the result in an instance variable.
3
- #
4
- # If a Date is frozen but the memoized method hasn't been called, the
5
- # first call will result in a frozen object error since the memo
6
- # instance variable is uninitialized.
7
- #
8
- # Work around by eagerly memoizing before the first freeze.
9
- #
10
- # Ruby 1.9 uses a preinitialized instance variable so it's unaffected.
11
- # This hack is as close as we can get to feature detection:
12
- if RUBY_VERSION < '1.9'
13
- require 'date'
14
- begin
15
- ::Date.today.freeze.jd
16
- rescue => frozen_object_error
17
- if frozen_object_error.message =~ /frozen/
18
- class Date #:nodoc:
19
- def freeze
20
- unless frozen?
21
- self.class.private_instance_methods(false).each do |m|
22
- if m.to_s =~ /\A__\d+__\Z/
23
- instance_variable_set(:"@#{m}", [send(m)])
24
- end
25
- end
26
- end
27
-
28
- super
29
- end
30
- end
31
- end
32
- end
33
- end
@@ -1,3 +0,0 @@
1
- module ActiveSupport
2
- FrozenObjectError = RUBY_VERSION < '1.9' ? TypeError : RuntimeError
3
- end
@@ -1,5 +0,0 @@
1
- class File
2
- unless File.allocate.respond_to?(:to_path)
3
- alias to_path path
4
- end
5
- end
@@ -1 +0,0 @@
1
- require 'active_support/core_ext/float/rounding'
@@ -1,19 +0,0 @@
1
- class Float
2
- alias precisionless_round round
3
- private :precisionless_round
4
-
5
- # Rounds the float with the specified precision.
6
- #
7
- # x = 1.337
8
- # x.round # => 1
9
- # x.round(1) # => 1.3
10
- # x.round(2) # => 1.34
11
- def round(precision = nil)
12
- if precision
13
- magnitude = 10.0 ** precision
14
- (self * magnitude).round / magnitude
15
- else
16
- precisionless_round
17
- end
18
- end
19
- end if RUBY_VERSION < '1.9'
@@ -1,18 +0,0 @@
1
- class Hash
2
- # Returns a deep copy of hash.
3
- #
4
- # hash = { :a => { :b => 'b' } }
5
- # dup = hash.deep_dup
6
- # dup[:a][:c] = 'c'
7
- #
8
- # hash[:a][:c] #=> nil
9
- # dup[:a][:c] #=> "c"
10
- def deep_dup
11
- duplicate = self.dup
12
- duplicate.each_pair do |k,v|
13
- tv = duplicate[k]
14
- duplicate[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.deep_dup : v
15
- end
16
- duplicate
17
- end
18
- end
@@ -1,15 +0,0 @@
1
- if RUBY_VERSION < '1.9.2'
2
-
3
- # :stopdoc:
4
- class IO
5
- def self.binread(name, length = nil, offset = nil)
6
- return File.read name unless length || offset
7
- File.open(name, 'rb') { |f|
8
- f.seek offset if offset
9
- f.read length
10
- }
11
- end
12
- end
13
- # :startdoc:
14
-
15
- end
@@ -1,14 +0,0 @@
1
- class Module
2
- if instance_methods[0].is_a?(Symbol)
3
- def instance_method_names(*args)
4
- instance_methods(*args).map(&:to_s)
5
- end
6
-
7
- def method_names(*args)
8
- methods(*args).map(&:to_s)
9
- end
10
- else
11
- alias_method :instance_method_names, :instance_methods
12
- alias_method :method_names, :methods
13
- end
14
- end
@@ -1,45 +0,0 @@
1
- require 'thread'
2
- require 'active_support/core_ext/module/aliasing'
3
- require 'active_support/core_ext/array/extract_options'
4
- require 'active_support/core_ext/module/deprecation'
5
-
6
- class Module
7
- # Synchronize access around a method, delegating synchronization to a
8
- # particular mutex. A mutex (either a Mutex, or any object that responds to
9
- # #synchronize and yields to a block) must be provided as a final :with option.
10
- # The :with option should be a symbol or string, and can represent a method,
11
- # constant, or instance or class variable.
12
- # Example:
13
- # class SharedCache
14
- # @@lock = Mutex.new
15
- # def expire
16
- # ...
17
- # end
18
- # synchronize :expire, :with => :@@lock
19
- # end
20
- def synchronize(*methods)
21
- options = methods.extract_options!
22
- unless options.is_a?(Hash) && with = options[:with]
23
- raise ArgumentError, "Synchronization needs a mutex. Supply an options hash with a :with key as the last argument (e.g. synchronize :hello, :with => :@mutex)."
24
- end
25
-
26
- methods.each do |method|
27
- aliased_method, punctuation = method.to_s.sub(/([?!=])$/, ''), $1
28
-
29
- if method_defined?("#{aliased_method}_without_synchronization#{punctuation}")
30
- raise ArgumentError, "#{method} is already synchronized. Double synchronization is not currently supported."
31
- end
32
-
33
- module_eval(<<-EOS, __FILE__, __LINE__ + 1)
34
- def #{aliased_method}_with_synchronization#{punctuation}(*args, &block) # def expire_with_synchronization(*args, &block)
35
- #{with}.synchronize do # @@lock.synchronize do
36
- #{aliased_method}_without_synchronization#{punctuation}(*args, &block) # expire_without_synchronization(*args, &block)
37
- end # end
38
- end # end
39
- EOS
40
-
41
- alias_method_chain method, :synchronization
42
- end
43
- end
44
- deprecate :synchronize
45
- end
@@ -1 +0,0 @@
1
- require 'active_support/core_ext/process/daemon'
@@ -1,23 +0,0 @@
1
- module Process
2
- def self.daemon(nochdir = nil, noclose = nil)
3
- exit if fork # Parent exits, child continues.
4
- Process.setsid # Become session leader.
5
- exit if fork # Zap session leader. See [1].
6
-
7
- unless nochdir
8
- Dir.chdir "/" # Release old working directory.
9
- end
10
-
11
- File.umask 0000 # Ensure sensible umask. Adjust as needed.
12
-
13
- unless noclose
14
- STDIN.reopen "/dev/null" # Free file descriptors and
15
- STDOUT.reopen "/dev/null", "a" # point them somewhere sensible.
16
- STDERR.reopen '/dev/null', 'a'
17
- end
18
-
19
- trap("TERM") { exit }
20
-
21
- return 0
22
- end unless respond_to?(:daemon)
23
- end
@@ -1,29 +0,0 @@
1
- require 'active_support/core_ext/module/aliasing'
2
-
3
- class Range
4
- begin
5
- (1..2).step
6
- # Range#step doesn't return an Enumerator
7
- rescue LocalJumpError
8
- # Return an array when step is called without a block.
9
- def step_with_blockless(*args, &block)
10
- if block_given?
11
- step_without_blockless(*args, &block)
12
- else
13
- array = []
14
- step_without_blockless(*args) { |step| array << step }
15
- array
16
- end
17
- end
18
- else
19
- def step_with_blockless(*args, &block) #:nodoc:
20
- if block_given?
21
- step_without_blockless(*args, &block)
22
- else
23
- step_without_blockless(*args).to_a
24
- end
25
- end
26
- end
27
-
28
- alias_method_chain :step, :blockless
29
- end
@@ -1,3 +0,0 @@
1
- class Range
2
- alias_method(:cover?, :include?) unless instance_methods.include?(:cover?)
3
- end
@@ -1,46 +0,0 @@
1
- require 'active_support/core_ext/kernel/reporting'
2
-
3
- # Fixes the rexml vulnerability disclosed at:
4
- # http://www.ruby-lang.org/en/news/2008/08/23/dos-vulnerability-in-rexml/
5
- # This fix is identical to rexml-expansion-fix version 1.0.1.
6
- #
7
- # We still need to distribute this fix because albeit the REXML
8
- # in recent 1.8.7s is patched, it wasn't in early patchlevels.
9
- require 'rexml/rexml'
10
-
11
- # Earlier versions of rexml defined REXML::Version, newer ones REXML::VERSION
12
- unless (defined?(REXML::VERSION) ? REXML::VERSION : REXML::Version) > "3.1.7.2"
13
- silence_warnings { require 'rexml/document' }
14
-
15
- # REXML in 1.8.7 has the patch but early patchlevels didn't update Version from 3.1.7.2.
16
- unless REXML::Document.respond_to?(:entity_expansion_limit=)
17
- silence_warnings { require 'rexml/entity' }
18
-
19
- module REXML #:nodoc:
20
- class Entity < Child #:nodoc:
21
- undef_method :unnormalized
22
- def unnormalized
23
- document.record_entity_expansion! if document
24
- v = value()
25
- return nil if v.nil?
26
- @unnormalized = Text::unnormalize(v, parent)
27
- @unnormalized
28
- end
29
- end
30
- class Document < Element #:nodoc:
31
- @@entity_expansion_limit = 10_000
32
- def self.entity_expansion_limit= val
33
- @@entity_expansion_limit = val
34
- end
35
-
36
- def record_entity_expansion!
37
- @number_of_expansions ||= 0
38
- @number_of_expansions += 1
39
- if @number_of_expansions > @@entity_expansion_limit
40
- raise "Number of entity expansions exceeded, processing aborted."
41
- end
42
- end
43
- end
44
- end
45
- end
46
- end
@@ -1,2 +0,0 @@
1
- require 'active_support/i18n'
2
- require 'i18n/core_ext/string/interpolate'
@@ -1,10 +0,0 @@
1
- require 'date'
2
-
3
- class Time
4
- # Ruby 1.8-cvs and early 1.9 series define private Time#to_date
5
- %w(to_date to_datetime).each do |method|
6
- if private_instance_methods.include?(method) || private_instance_methods.include?(method.to_sym)
7
- public method
8
- end
9
- end
10
- end
@@ -1,116 +0,0 @@
1
- require 'active_support/core_ext/kernel/singleton_class'
2
- require 'active_support/core_ext/module/aliasing'
3
- require 'active_support/deprecation'
4
-
5
- module ActiveSupport
6
- module Memoizable
7
- def self.extended(base)
8
- ActiveSupport::Deprecation.warn "ActiveSupport::Memoizable is deprecated and will be removed in future releases," \
9
- "simply use Ruby memoization pattern instead.", caller
10
- super
11
- end
12
-
13
- def self.memoized_ivar_for(symbol)
14
- "@_memoized_#{symbol.to_s.sub(/\?\Z/, '_query').sub(/!\Z/, '_bang')}".to_sym
15
- end
16
-
17
- module InstanceMethods
18
- def self.included(base)
19
- base.class_eval do
20
- unless base.method_defined?(:freeze_without_memoizable)
21
- alias_method_chain :freeze, :memoizable
22
- end
23
- end
24
- end
25
-
26
- def freeze_with_memoizable
27
- memoize_all unless frozen?
28
- freeze_without_memoizable
29
- end
30
-
31
- def memoize_all
32
- prime_cache ".*"
33
- end
34
-
35
- def unmemoize_all
36
- flush_cache ".*"
37
- end
38
-
39
- def prime_cache(*syms)
40
- syms.each do |sym|
41
- methods.each do |m|
42
- if m.to_s =~ /^_unmemoized_(#{sym})/
43
- if method(m).arity == 0
44
- __send__($1)
45
- else
46
- ivar = ActiveSupport::Memoizable.memoized_ivar_for($1)
47
- instance_variable_set(ivar, {})
48
- end
49
- end
50
- end
51
- end
52
- end
53
-
54
- def flush_cache(*syms)
55
- syms.each do |sym|
56
- (methods + private_methods + protected_methods).each do |m|
57
- if m.to_s =~ /^_unmemoized_(#{sym.to_s.gsub(/\?\Z/, '\?')})/
58
- ivar = ActiveSupport::Memoizable.memoized_ivar_for($1)
59
- instance_variable_get(ivar).clear if instance_variable_defined?(ivar)
60
- end
61
- end
62
- end
63
- end
64
- end
65
-
66
- def memoize(*symbols)
67
- symbols.each do |symbol|
68
- original_method = :"_unmemoized_#{symbol}"
69
- memoized_ivar = ActiveSupport::Memoizable.memoized_ivar_for(symbol)
70
-
71
- class_eval <<-EOS, __FILE__, __LINE__ + 1
72
- include InstanceMethods # include InstanceMethods
73
- #
74
- if method_defined?(:#{original_method}) # if method_defined?(:_unmemoized_mime_type)
75
- raise "Already memoized #{symbol}" # raise "Already memoized mime_type"
76
- end # end
77
- alias #{original_method} #{symbol} # alias _unmemoized_mime_type mime_type
78
- #
79
- if instance_method(:#{symbol}).arity == 0 # if instance_method(:mime_type).arity == 0
80
- def #{symbol}(reload = false) # def mime_type(reload = false)
81
- if reload || !defined?(#{memoized_ivar}) || #{memoized_ivar}.empty? # if reload || !defined?(@_memoized_mime_type) || @_memoized_mime_type.empty?
82
- #{memoized_ivar} = [#{original_method}] # @_memoized_mime_type = [_unmemoized_mime_type]
83
- end # end
84
- #{memoized_ivar}[0] # @_memoized_mime_type[0]
85
- end # end
86
- else # else
87
- def #{symbol}(*args) # def mime_type(*args)
88
- #{memoized_ivar} ||= {} unless frozen? # @_memoized_mime_type ||= {} unless frozen?
89
- args_length = method(:#{original_method}).arity # args_length = method(:_unmemoized_mime_type).arity
90
- if args.length == args_length + 1 && # if args.length == args_length + 1 &&
91
- (args.last == true || args.last == :reload) # (args.last == true || args.last == :reload)
92
- reload = args.pop # reload = args.pop
93
- end # end
94
- #
95
- if defined?(#{memoized_ivar}) && #{memoized_ivar} # if defined?(@_memoized_mime_type) && @_memoized_mime_type
96
- if !reload && #{memoized_ivar}.has_key?(args) # if !reload && @_memoized_mime_type.has_key?(args)
97
- #{memoized_ivar}[args] # @_memoized_mime_type[args]
98
- elsif #{memoized_ivar} # elsif @_memoized_mime_type
99
- #{memoized_ivar}[args] = #{original_method}(*args) # @_memoized_mime_type[args] = _unmemoized_mime_type(*args)
100
- end # end
101
- else # else
102
- #{original_method}(*args) # _unmemoized_mime_type(*args)
103
- end # end
104
- end # end
105
- end # end
106
- #
107
- if private_method_defined?(#{original_method.inspect}) # if private_method_defined?(:_unmemoized_mime_type)
108
- private #{symbol.inspect} # private :mime_type
109
- elsif protected_method_defined?(#{original_method.inspect}) # elsif protected_method_defined?(:_unmemoized_mime_type)
110
- protected #{symbol.inspect} # protected :mime_type
111
- end # end
112
- EOS
113
- end
114
- end
115
- end
116
- end