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,113 +0,0 @@
1
- require 'rubinius/agent'
2
-
3
- module ActiveSupport
4
- module Testing
5
- module Performance
6
- DEFAULTS.merge!(
7
- if ENV["BENCHMARK_TESTS"]
8
- {:metrics => [:wall_time, :memory, :objects, :gc_runs, :gc_time]}
9
- else
10
- { :metrics => [:wall_time],
11
- :formats => [:flat, :graph] }
12
- end).freeze
13
-
14
- protected
15
- def run_gc
16
- GC.run(true)
17
- end
18
-
19
- class Performer; end
20
-
21
- class Profiler < Performer
22
- def initialize(*args)
23
- super
24
- @supported = @metric.is_a?(Metrics::WallTime)
25
- end
26
-
27
- def run
28
- return unless @supported
29
-
30
- @profiler = Rubinius::Profiler::Instrumenter.new
31
-
32
- @total = time_with_block do
33
- @profiler.profile(false) do
34
- full_profile_options[:runs].to_i.times { run_test(@metric, :profile) }
35
- end
36
- end
37
- end
38
-
39
- def record
40
- return unless @supported
41
-
42
- if(full_profile_options[:formats].include?(:flat))
43
- create_path_and_open_file(:flat) do |file|
44
- @profiler.show(file)
45
- end
46
- end
47
-
48
- if(full_profile_options[:formats].include?(:graph))
49
- create_path_and_open_file(:graph) do |file|
50
- @profiler.show(file)
51
- end
52
- end
53
- end
54
-
55
- protected
56
- def create_path_and_open_file(printer_name)
57
- fname = "#{output_filename}_#{printer_name}.txt"
58
- FileUtils.mkdir_p(File.dirname(fname))
59
- File.open(fname, 'wb') do |file|
60
- yield(file)
61
- end
62
- end
63
- end
64
-
65
- module Metrics
66
- class Base
67
- attr_reader :loopback
68
-
69
- def profile
70
- yield
71
- end
72
-
73
- protected
74
- def with_gc_stats
75
- @loopback = Rubinius::Agent.loopback
76
- GC.run(true)
77
- yield
78
- end
79
- end
80
-
81
- class WallTime < Time
82
- def measure
83
- super
84
- end
85
- end
86
-
87
- class Memory < DigitalInformationUnit
88
- def measure
89
- loopback.get("system.memory.counter.bytes").last
90
- end
91
- end
92
-
93
- class Objects < Amount
94
- def measure
95
- loopback.get("system.memory.counter.objects").last
96
- end
97
- end
98
-
99
- class GcRuns < Amount
100
- def measure
101
- loopback.get("system.gc.full.count").last + loopback.get("system.gc.young.count").last
102
- end
103
- end
104
-
105
- class GcTime < Time
106
- def measure
107
- (loopback.get("system.gc.full.wallclock").last + loopback.get("system.gc.young.wallclock").last) / 1000.0
108
- end
109
- end
110
- end
111
- end
112
- end
113
- end
@@ -1,152 +0,0 @@
1
- begin
2
- require 'ruby-prof'
3
- rescue LoadError
4
- $stderr.puts 'Specify ruby-prof as application\'s dependency in Gemfile to run benchmarks.'
5
- exit
6
- end
7
-
8
- module ActiveSupport
9
- module Testing
10
- module Performance
11
- DEFAULTS.merge!(
12
- if ENV["BENCHMARK_TESTS"]
13
- { :metrics => [:wall_time, :memory, :objects, :gc_runs, :gc_time] }
14
- else
15
- { :min_percent => 0.01,
16
- :metrics => [:process_time, :memory, :objects],
17
- :formats => [:flat, :graph_html, :call_tree, :call_stack] }
18
- end).freeze
19
-
20
- protected
21
- def run_gc
22
- GC.start
23
- end
24
-
25
- class Profiler < Performer
26
- def initialize(*args)
27
- super
28
- @supported = @metric.measure_mode rescue false
29
- end
30
-
31
- def run
32
- return unless @supported
33
-
34
- RubyProf.measure_mode = @metric.measure_mode
35
- RubyProf.start
36
- RubyProf.pause
37
- full_profile_options[:runs].to_i.times { run_test(@metric, :profile) }
38
- @data = RubyProf.stop
39
- @total = @data.threads.sum(0) { |thread| thread.methods.max.total_time }
40
- end
41
-
42
- def record
43
- return unless @supported
44
-
45
- klasses = full_profile_options[:formats].map { |f| RubyProf.const_get("#{f.to_s.camelize}Printer") }.compact
46
-
47
- klasses.each do |klass|
48
- fname = output_filename(klass)
49
- FileUtils.mkdir_p(File.dirname(fname))
50
- File.open(fname, 'wb') do |file|
51
- klass.new(@data).print(file, full_profile_options.slice(:min_percent))
52
- end
53
- end
54
- end
55
-
56
- protected
57
- def output_filename(printer_class)
58
- suffix =
59
- case printer_class.name.demodulize
60
- when 'FlatPrinter'; 'flat.txt'
61
- when 'FlatPrinterWithLineNumbers'; 'flat_line_numbers.txt'
62
- when 'GraphPrinter'; 'graph.txt'
63
- when 'GraphHtmlPrinter'; 'graph.html'
64
- when 'GraphYamlPrinter'; 'graph.yml'
65
- when 'CallTreePrinter'; 'tree.txt'
66
- when 'CallStackPrinter'; 'stack.html'
67
- when 'DotPrinter'; 'graph.dot'
68
- else printer_class.name.sub(/Printer$/, '').underscore
69
- end
70
-
71
- "#{super()}_#{suffix}"
72
- end
73
- end
74
-
75
- module Metrics
76
- class Base
77
- def measure_mode
78
- self.class::Mode
79
- end
80
-
81
- def profile
82
- RubyProf.resume
83
- yield
84
- ensure
85
- RubyProf.pause
86
- end
87
-
88
- protected
89
- # overridden by each implementation
90
- def with_gc_stats
91
- yield
92
- end
93
- end
94
-
95
- class ProcessTime < Time
96
- Mode = RubyProf::PROCESS_TIME if RubyProf.const_defined?(:PROCESS_TIME)
97
-
98
- def measure
99
- RubyProf.measure_process_time
100
- end
101
- end
102
-
103
- class WallTime < Time
104
- Mode = RubyProf::WALL_TIME if RubyProf.const_defined?(:WALL_TIME)
105
-
106
- def measure
107
- RubyProf.measure_wall_time
108
- end
109
- end
110
-
111
- class CpuTime < Time
112
- Mode = RubyProf::CPU_TIME if RubyProf.const_defined?(:CPU_TIME)
113
-
114
- def initialize(*args)
115
- # FIXME: yeah my CPU is 2.33 GHz
116
- RubyProf.cpu_frequency = 2.33e9 unless RubyProf.cpu_frequency > 0
117
- super
118
- end
119
-
120
- def measure
121
- RubyProf.measure_cpu_time
122
- end
123
- end
124
-
125
- class Memory < DigitalInformationUnit
126
- Mode = RubyProf::MEMORY if RubyProf.const_defined?(:MEMORY)
127
- end
128
-
129
- class Objects < Amount
130
- Mode = RubyProf::ALLOCATIONS if RubyProf.const_defined?(:ALLOCATIONS)
131
- end
132
-
133
- class GcRuns < Amount
134
- Mode = RubyProf::GC_RUNS if RubyProf.const_defined?(:GC_RUNS)
135
- end
136
-
137
- class GcTime < Time
138
- Mode = RubyProf::GC_TIME if RubyProf.const_defined?(:GC_TIME)
139
- end
140
- end
141
- end
142
- end
143
- end
144
-
145
- if RUBY_VERSION.between?('1.9.2', '2.0.0')
146
- require 'active_support/testing/performance/ruby/yarv'
147
- elsif RUBY_VERSION.between?('1.8.6', '1.9')
148
- require 'active_support/testing/performance/ruby/mri'
149
- else
150
- $stderr.puts 'Update your ruby interpreter to be able to run benchmarks.'
151
- exit
152
- end
@@ -1,57 +0,0 @@
1
- module ActiveSupport
2
- module Testing
3
- module Performance
4
- module Metrics
5
- class Base
6
- protected
7
- # Ruby 1.8 + ruby-prof wrapper (enable/disable stats for Benchmarker)
8
- if GC.respond_to?(:enable_stats)
9
- def with_gc_stats
10
- GC.enable_stats
11
- GC.start
12
- yield
13
- ensure
14
- GC.disable_stats
15
- end
16
- end
17
- end
18
-
19
- class Memory < DigitalInformationUnit
20
- # Ruby 1.8 + ruby-prof wrapper
21
- if RubyProf.respond_to?(:measure_memory)
22
- def measure
23
- RubyProf.measure_memory
24
- end
25
- end
26
- end
27
-
28
- class Objects < Amount
29
- # Ruby 1.8 + ruby-prof wrapper
30
- if RubyProf.respond_to?(:measure_allocations)
31
- def measure
32
- RubyProf.measure_allocations
33
- end
34
- end
35
- end
36
-
37
- class GcRuns < Amount
38
- # Ruby 1.8 + ruby-prof wrapper
39
- if RubyProf.respond_to?(:measure_gc_runs)
40
- def measure
41
- RubyProf.measure_gc_runs
42
- end
43
- end
44
- end
45
-
46
- class GcTime < Time
47
- # Ruby 1.8 + ruby-prof wrapper
48
- if RubyProf.respond_to?(:measure_gc_time)
49
- def measure
50
- RubyProf.measure_gc_time / 1000.0 / 1000.0
51
- end
52
- end
53
- end
54
- end
55
- end
56
- end
57
- end
@@ -1,57 +0,0 @@
1
- module ActiveSupport
2
- module Testing
3
- module Performance
4
- module Metrics
5
- class Base
6
- protected
7
- # Ruby 1.9 with GC::Profiler
8
- if defined?(GC::Profiler)
9
- def with_gc_stats
10
- GC::Profiler.enable
11
- GC.start
12
- yield
13
- ensure
14
- GC::Profiler.disable
15
- end
16
- end
17
- end
18
-
19
- class Memory < DigitalInformationUnit
20
- # Ruby 1.9 + GCdata patch
21
- if GC.respond_to?(:malloc_allocated_size)
22
- def measure
23
- GC.malloc_allocated_size
24
- end
25
- end
26
- end
27
-
28
- class Objects < Amount
29
- # Ruby 1.9 + GCdata patch
30
- if GC.respond_to?(:malloc_allocations)
31
- def measure
32
- GC.malloc_allocations
33
- end
34
- end
35
- end
36
-
37
- class GcRuns < Amount
38
- # Ruby 1.9
39
- if GC.respond_to?(:count)
40
- def measure
41
- GC.count
42
- end
43
- end
44
- end
45
-
46
- class GcTime < Time
47
- # Ruby 1.9 with GC::Profiler
48
- if defined?(GC::Profiler) && GC::Profiler.respond_to?(:total_time)
49
- def measure
50
- GC::Profiler.total_time
51
- end
52
- end
53
- end
54
- end
55
- end
56
- end
57
- end
@@ -1,5 +0,0 @@
1
- module ActiveSupport
2
- autoload :Duration, 'active_support/duration'
3
- autoload :TimeWithZone, 'active_support/time_with_zone'
4
- autoload :TimeZone, 'active_support/values/time_zone'
5
- end
@@ -1,24 +0,0 @@
1
- require 'active_support/deprecation'
2
-
3
- # Extensions to +nil+ which allow for more helpful error messages for people who
4
- # are new to Rails.
5
- #
6
- # NilClass#id exists in Ruby 1.8 (though it is deprecated). Since +id+ is a fundamental
7
- # method of Active Record models NilClass#id is redefined as well to raise a RuntimeError
8
- # and warn the user. She probably wanted a model database identifier and the 4
9
- # returned by the original method could result in obscure bugs.
10
- #
11
- # The flag <tt>config.whiny_nils</tt> determines whether this feature is enabled.
12
- # By default it is on in development and test modes, and it is off in production
13
- # mode.
14
- class NilClass
15
- def self.add_whiner(klass)
16
- ActiveSupport::Deprecation.warn "NilClass.add_whiner is deprecated and this functionality is " \
17
- "removed from Rails versions as it affects Ruby 1.9 performance.", caller
18
- end
19
-
20
- # Raises a RuntimeError when you attempt to call +id+ on +nil+.
21
- def id
22
- raise RuntimeError, "Called id for nil, which would mistakenly be #{object_id} -- if you really wanted the id of nil, use object_id", caller
23
- end
24
- end