activesupport 3.2.22.5 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +364 -135
- data/MIT-LICENSE +1 -1
- data/README.rdoc +6 -4
- data/lib/active_support/backtrace_cleaner.rb +33 -25
- data/lib/active_support/basic_object.rb +7 -17
- data/lib/active_support/benchmarkable.rb +19 -15
- data/lib/active_support/buffered_logger.rb +9 -113
- data/lib/active_support/cache/file_store.rb +14 -14
- data/lib/active_support/cache/mem_cache_store.rb +24 -30
- data/lib/active_support/cache/memory_store.rb +2 -0
- data/lib/active_support/cache/strategy/local_cache.rb +48 -37
- data/lib/active_support/cache.rb +228 -183
- data/lib/active_support/callbacks.rb +201 -253
- data/lib/active_support/concern.rb +16 -23
- data/lib/active_support/concurrency/latch.rb +27 -0
- data/lib/active_support/configurable.rb +69 -12
- data/lib/active_support/core_ext/array/access.rb +17 -9
- data/lib/active_support/core_ext/array/conversions.rb +115 -55
- data/lib/active_support/core_ext/array/extract_options.rb +2 -2
- data/lib/active_support/core_ext/array/grouping.rb +21 -22
- data/lib/active_support/core_ext/array/uniq_by.rb +12 -9
- data/lib/active_support/core_ext/array/wrap.rb +13 -16
- data/lib/active_support/core_ext/array.rb +0 -1
- data/lib/active_support/core_ext/benchmark.rb +7 -0
- data/lib/active_support/core_ext/big_decimal/conversions.rb +8 -24
- data/lib/active_support/core_ext/class/attribute.rb +40 -32
- data/lib/active_support/core_ext/class/attribute_accessors.rb +14 -12
- data/lib/active_support/core_ext/class/delegating_attributes.rb +15 -19
- data/lib/active_support/core_ext/class/subclasses.rb +11 -5
- data/lib/active_support/core_ext/date/calculations.rb +44 -187
- data/lib/active_support/core_ext/date/conversions.rb +16 -38
- data/lib/active_support/core_ext/date/zones.rb +25 -2
- data/lib/active_support/core_ext/date.rb +5 -0
- data/lib/active_support/core_ext/date_and_time/calculations.rb +232 -0
- data/lib/active_support/core_ext/date_time/acts_like.rb +0 -1
- data/lib/active_support/core_ext/date_time/calculations.rb +77 -62
- data/lib/active_support/core_ext/date_time/conversions.rb +21 -33
- data/lib/active_support/core_ext/date_time/zones.rb +11 -8
- data/lib/active_support/core_ext/date_time.rb +4 -0
- data/lib/active_support/core_ext/enumerable.rb +26 -73
- data/lib/active_support/core_ext/file/atomic.rb +27 -11
- data/lib/active_support/core_ext/file.rb +0 -1
- data/lib/active_support/core_ext/hash/conversions.rb +145 -79
- data/lib/active_support/core_ext/hash/deep_merge.rb +14 -8
- data/lib/active_support/core_ext/hash/diff.rb +5 -4
- data/lib/active_support/core_ext/hash/except.rb +1 -9
- data/lib/active_support/core_ext/hash/indifferent_access.rb +4 -5
- data/lib/active_support/core_ext/hash/keys.rb +108 -24
- data/lib/active_support/core_ext/hash/reverse_merge.rb +2 -3
- data/lib/active_support/core_ext/hash/slice.rb +12 -12
- data/lib/active_support/core_ext/hash.rb +0 -1
- data/lib/active_support/core_ext/integer/inflections.rb +13 -1
- data/lib/active_support/core_ext/integer/time.rb +17 -12
- data/lib/active_support/core_ext/kernel/debugger.rb +2 -2
- data/lib/active_support/core_ext/kernel/reporting.rb +36 -22
- data/lib/active_support/core_ext/kernel/singleton_class.rb +0 -7
- data/lib/active_support/core_ext/load_error.rb +7 -5
- data/lib/active_support/core_ext/logger.rb +7 -23
- data/lib/active_support/core_ext/marshal.rb +21 -0
- data/lib/active_support/core_ext/module/aliasing.rb +8 -9
- data/lib/active_support/core_ext/module/anonymous.rb +2 -7
- data/lib/active_support/core_ext/module/attr_internal.rb +0 -1
- data/lib/active_support/core_ext/module/attribute_accessors.rb +12 -10
- data/lib/active_support/core_ext/module/delegation.rb +92 -49
- data/lib/active_support/core_ext/module/deprecation.rb +19 -3
- data/lib/active_support/core_ext/module/introspection.rb +17 -27
- data/lib/active_support/core_ext/module/qualified_const.rb +8 -20
- data/lib/active_support/core_ext/module/remove_method.rb +1 -5
- data/lib/active_support/core_ext/module.rb +1 -3
- data/lib/active_support/core_ext/numeric/conversions.rb +135 -0
- data/lib/active_support/core_ext/numeric/time.rb +6 -6
- data/lib/active_support/core_ext/numeric.rb +1 -0
- data/lib/active_support/core_ext/object/acts_like.rb +4 -4
- data/lib/active_support/core_ext/object/blank.rb +7 -23
- data/lib/active_support/core_ext/object/deep_dup.rb +46 -0
- data/lib/active_support/core_ext/object/duplicable.rb +1 -30
- data/lib/active_support/core_ext/object/inclusion.rb +8 -7
- data/lib/active_support/core_ext/object/instance_variables.rb +7 -12
- data/lib/active_support/core_ext/object/to_json.rb +8 -0
- data/lib/active_support/core_ext/object/to_param.rb +5 -2
- data/lib/active_support/core_ext/object/try.rb +46 -25
- data/lib/active_support/core_ext/object/with_options.rb +7 -8
- data/lib/active_support/core_ext/object.rb +1 -0
- data/lib/active_support/core_ext/proc.rb +3 -0
- data/lib/active_support/core_ext/range/conversions.rb +0 -2
- data/lib/active_support/core_ext/range/include_range.rb +3 -1
- data/lib/active_support/core_ext/range/overlaps.rb +1 -1
- data/lib/active_support/core_ext/range.rb +0 -2
- data/lib/active_support/core_ext/string/access.rb +95 -90
- data/lib/active_support/core_ext/string/conversions.rb +27 -38
- data/lib/active_support/core_ext/string/encoding.rb +6 -9
- data/lib/active_support/core_ext/string/filters.rb +24 -18
- data/lib/active_support/core_ext/string/indent.rb +43 -0
- data/lib/active_support/core_ext/string/inflections.rb +70 -60
- data/lib/active_support/core_ext/string/inquiry.rb +2 -2
- data/lib/active_support/core_ext/string/multibyte.rb +41 -64
- data/lib/active_support/core_ext/string/output_safety.rb +59 -51
- data/lib/active_support/core_ext/string/zones.rb +13 -0
- data/lib/active_support/core_ext/string.rb +2 -3
- data/lib/active_support/core_ext/struct.rb +6 -0
- data/lib/active_support/core_ext/thread.rb +74 -0
- data/lib/active_support/core_ext/time/calculations.rb +108 -184
- data/lib/active_support/core_ext/time/conversions.rb +27 -51
- data/lib/active_support/core_ext/time/marshal.rb +0 -27
- data/lib/active_support/core_ext/time/zones.rb +27 -17
- data/lib/active_support/core_ext/time.rb +5 -0
- data/lib/active_support/core_ext/uri.rb +13 -17
- data/lib/active_support/core_ext.rb +3 -2
- data/lib/active_support/dependencies/autoload.rb +47 -20
- data/lib/active_support/dependencies.rb +160 -141
- data/lib/active_support/deprecation/behaviors.rb +44 -30
- data/lib/active_support/deprecation/instance_delegator.rb +24 -0
- data/lib/active_support/deprecation/method_wrappers.rb +33 -18
- data/lib/active_support/deprecation/proxy_wrappers.rb +58 -13
- data/lib/active_support/deprecation/reporting.rb +40 -11
- data/lib/active_support/deprecation.rb +39 -14
- data/lib/active_support/descendants_tracker.rb +34 -19
- data/lib/active_support/duration.rb +6 -8
- data/lib/active_support/file_update_checker.rb +63 -47
- data/lib/active_support/gzip.rb +11 -5
- data/lib/active_support/hash_with_indifferent_access.rb +127 -42
- data/lib/active_support/i18n.rb +4 -0
- data/lib/active_support/i18n_railtie.rb +5 -22
- data/lib/active_support/inflections.rb +14 -12
- data/lib/active_support/inflector/inflections.rb +108 -71
- data/lib/active_support/inflector/methods.rb +181 -160
- data/lib/active_support/inflector/transliterate.rb +16 -17
- data/lib/active_support/json/decoding.rb +18 -17
- data/lib/active_support/json/encoding.rb +93 -39
- data/lib/active_support/json/variable.rb +10 -1
- data/lib/active_support/key_generator.rb +75 -0
- data/lib/active_support/lazy_load_hooks.rb +21 -19
- data/lib/active_support/locale/en.yml +100 -3
- data/lib/active_support/log_subscriber/test_helper.rb +18 -15
- data/lib/active_support/log_subscriber.rb +35 -52
- data/lib/active_support/logger.rb +57 -0
- data/lib/active_support/logger_silence.rb +24 -0
- data/lib/active_support/message_encryptor.rb +38 -35
- data/lib/active_support/message_verifier.rb +9 -15
- data/lib/active_support/multibyte/chars.rb +80 -333
- data/lib/active_support/multibyte/unicode.rb +74 -64
- data/lib/active_support/multibyte.rb +5 -28
- data/lib/active_support/notifications/fanout.rb +112 -18
- data/lib/active_support/notifications/instrumenter.rb +33 -14
- data/lib/active_support/notifications.rb +79 -26
- data/lib/active_support/number_helper.rb +637 -0
- data/lib/active_support/ordered_hash.rb +8 -190
- data/lib/active_support/ordered_options.rb +21 -23
- data/lib/active_support/per_thread_registry.rb +52 -0
- data/lib/active_support/proxy_object.rb +13 -0
- data/lib/active_support/rails.rb +27 -0
- data/lib/active_support/railtie.rb +12 -32
- data/lib/active_support/rescuable.rb +9 -4
- data/lib/active_support/string_inquirer.rb +13 -8
- data/lib/active_support/subscriber.rb +93 -0
- data/lib/active_support/tagged_logging.rb +51 -73
- data/lib/active_support/test_case.rb +46 -17
- data/lib/active_support/testing/assertions.rb +56 -26
- data/lib/active_support/testing/autorun.rb +5 -0
- data/lib/active_support/testing/constant_lookup.rb +54 -0
- data/lib/active_support/testing/declarative.rb +1 -1
- data/lib/active_support/testing/deprecation.rb +0 -19
- data/lib/active_support/testing/isolation.rb +29 -58
- data/lib/active_support/testing/pending.rb +5 -43
- data/lib/active_support/testing/setup_and_teardown.rb +6 -92
- data/lib/active_support/testing/tagged_logging.rb +25 -0
- data/lib/active_support/time.rb +6 -21
- data/lib/active_support/time_with_zone.rb +80 -43
- data/lib/active_support/values/time_zone.rb +81 -60
- data/lib/active_support/values/unicode_tables.dat +0 -0
- data/lib/active_support/version.rb +7 -6
- data/lib/active_support/xml_mini/jdom.rb +9 -11
- data/lib/active_support/xml_mini/libxml.rb +1 -2
- data/lib/active_support/xml_mini/libxmlsax.rb +2 -3
- data/lib/active_support/xml_mini/nokogiri.rb +1 -2
- data/lib/active_support/xml_mini/nokogirisax.rb +2 -3
- data/lib/active_support/xml_mini/rexml.rb +6 -8
- data/lib/active_support/xml_mini.rb +35 -17
- data/lib/active_support.rb +8 -21
- metadata +104 -72
- data/lib/active_support/base64.rb +0 -54
- data/lib/active_support/core_ext/array/random_access.rb +0 -30
- data/lib/active_support/core_ext/date/freeze.rb +0 -33
- data/lib/active_support/core_ext/exception.rb +0 -3
- data/lib/active_support/core_ext/file/path.rb +0 -5
- data/lib/active_support/core_ext/float/rounding.rb +0 -19
- data/lib/active_support/core_ext/float.rb +0 -1
- data/lib/active_support/core_ext/hash/deep_dup.rb +0 -18
- data/lib/active_support/core_ext/io.rb +0 -15
- data/lib/active_support/core_ext/module/method_names.rb +0 -14
- data/lib/active_support/core_ext/module/synchronization.rb +0 -45
- data/lib/active_support/core_ext/process/daemon.rb +0 -23
- data/lib/active_support/core_ext/process.rb +0 -1
- data/lib/active_support/core_ext/range/blockless_step.rb +0 -29
- data/lib/active_support/core_ext/range/cover.rb +0 -3
- data/lib/active_support/core_ext/rexml.rb +0 -46
- data/lib/active_support/core_ext/string/interpolation.rb +0 -2
- data/lib/active_support/core_ext/string/xchar.rb +0 -18
- data/lib/active_support/core_ext/time/publicize_conversion_methods.rb +0 -10
- data/lib/active_support/memoizable.rb +0 -116
- data/lib/active_support/multibyte/exceptions.rb +0 -8
- data/lib/active_support/multibyte/utils.rb +0 -60
- data/lib/active_support/ruby/shim.rb +0 -22
- data/lib/active_support/security_utils.rb +0 -27
- data/lib/active_support/testing/mochaing.rb +0 -7
- data/lib/active_support/testing/performance/jruby.rb +0 -115
- data/lib/active_support/testing/performance/rubinius.rb +0 -113
- data/lib/active_support/testing/performance/ruby/mri.rb +0 -57
- data/lib/active_support/testing/performance/ruby/yarv.rb +0 -57
- data/lib/active_support/testing/performance/ruby.rb +0 -152
- data/lib/active_support/testing/performance.rb +0 -317
- data/lib/active_support/time/autoload.rb +0 -5
- data/lib/active_support/whiny_nil.rb +0 -24
metadata
CHANGED
|
@@ -1,49 +1,91 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activesupport
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 4.0.0
|
|
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:
|
|
11
|
+
date: 2013-06-25 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.6'
|
|
20
|
-
- -
|
|
20
|
+
- - '>='
|
|
21
21
|
- !ruby/object:Gem::Version
|
|
22
22
|
version: 0.6.4
|
|
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.6'
|
|
30
|
-
- -
|
|
30
|
+
- - '>='
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
32
|
version: 0.6.4
|
|
33
33
|
- !ruby/object:Gem::Dependency
|
|
34
34
|
name: multi_json
|
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
|
-
- -
|
|
37
|
+
- - ~>
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '1.
|
|
39
|
+
version: '1.3'
|
|
40
40
|
type: :runtime
|
|
41
41
|
prerelease: false
|
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
|
43
43
|
requirements:
|
|
44
|
-
- -
|
|
44
|
+
- - ~>
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: '1.
|
|
46
|
+
version: '1.3'
|
|
47
|
+
- !ruby/object:Gem::Dependency
|
|
48
|
+
name: tzinfo
|
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ~>
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: 0.3.37
|
|
54
|
+
type: :runtime
|
|
55
|
+
prerelease: false
|
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - ~>
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: 0.3.37
|
|
61
|
+
- !ruby/object:Gem::Dependency
|
|
62
|
+
name: minitest
|
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - ~>
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '4.2'
|
|
68
|
+
type: :runtime
|
|
69
|
+
prerelease: false
|
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - ~>
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '4.2'
|
|
75
|
+
- !ruby/object:Gem::Dependency
|
|
76
|
+
name: thread_safe
|
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - ~>
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: '0.1'
|
|
82
|
+
type: :runtime
|
|
83
|
+
prerelease: false
|
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - ~>
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '0.1'
|
|
47
89
|
description: A toolkit of support libraries and Ruby core extensions extracted from
|
|
48
90
|
the Rails framework. Rich support for multibyte strings, internationalization, time
|
|
49
91
|
zones, and testing.
|
|
@@ -55,60 +97,53 @@ files:
|
|
|
55
97
|
- CHANGELOG.md
|
|
56
98
|
- MIT-LICENSE
|
|
57
99
|
- README.rdoc
|
|
58
|
-
- lib/active_support.rb
|
|
59
100
|
- lib/active_support/all.rb
|
|
60
101
|
- lib/active_support/backtrace_cleaner.rb
|
|
61
|
-
- lib/active_support/base64.rb
|
|
62
102
|
- lib/active_support/basic_object.rb
|
|
63
103
|
- lib/active_support/benchmarkable.rb
|
|
64
104
|
- lib/active_support/buffered_logger.rb
|
|
65
105
|
- lib/active_support/builder.rb
|
|
66
|
-
- lib/active_support/cache.rb
|
|
67
106
|
- lib/active_support/cache/file_store.rb
|
|
68
107
|
- lib/active_support/cache/mem_cache_store.rb
|
|
69
108
|
- lib/active_support/cache/memory_store.rb
|
|
70
109
|
- lib/active_support/cache/null_store.rb
|
|
71
110
|
- lib/active_support/cache/strategy/local_cache.rb
|
|
111
|
+
- lib/active_support/cache.rb
|
|
72
112
|
- lib/active_support/callbacks.rb
|
|
73
113
|
- lib/active_support/concern.rb
|
|
114
|
+
- lib/active_support/concurrency/latch.rb
|
|
74
115
|
- lib/active_support/configurable.rb
|
|
75
|
-
- lib/active_support/core_ext.rb
|
|
76
|
-
- lib/active_support/core_ext/array.rb
|
|
77
116
|
- lib/active_support/core_ext/array/access.rb
|
|
78
117
|
- lib/active_support/core_ext/array/conversions.rb
|
|
79
118
|
- lib/active_support/core_ext/array/extract_options.rb
|
|
80
119
|
- lib/active_support/core_ext/array/grouping.rb
|
|
81
120
|
- lib/active_support/core_ext/array/prepend_and_append.rb
|
|
82
|
-
- lib/active_support/core_ext/array/random_access.rb
|
|
83
121
|
- lib/active_support/core_ext/array/uniq_by.rb
|
|
84
122
|
- lib/active_support/core_ext/array/wrap.rb
|
|
123
|
+
- lib/active_support/core_ext/array.rb
|
|
85
124
|
- lib/active_support/core_ext/benchmark.rb
|
|
86
|
-
- lib/active_support/core_ext/big_decimal.rb
|
|
87
125
|
- lib/active_support/core_ext/big_decimal/conversions.rb
|
|
88
|
-
- lib/active_support/core_ext/
|
|
126
|
+
- lib/active_support/core_ext/big_decimal.rb
|
|
89
127
|
- lib/active_support/core_ext/class/attribute.rb
|
|
90
128
|
- lib/active_support/core_ext/class/attribute_accessors.rb
|
|
91
129
|
- lib/active_support/core_ext/class/delegating_attributes.rb
|
|
92
130
|
- lib/active_support/core_ext/class/subclasses.rb
|
|
131
|
+
- lib/active_support/core_ext/class.rb
|
|
93
132
|
- lib/active_support/core_ext/date/acts_like.rb
|
|
94
133
|
- lib/active_support/core_ext/date/calculations.rb
|
|
95
134
|
- lib/active_support/core_ext/date/conversions.rb
|
|
96
|
-
- lib/active_support/core_ext/date/freeze.rb
|
|
97
135
|
- lib/active_support/core_ext/date/zones.rb
|
|
136
|
+
- lib/active_support/core_ext/date.rb
|
|
137
|
+
- lib/active_support/core_ext/date_and_time/calculations.rb
|
|
98
138
|
- lib/active_support/core_ext/date_time/acts_like.rb
|
|
99
139
|
- lib/active_support/core_ext/date_time/calculations.rb
|
|
100
140
|
- lib/active_support/core_ext/date_time/conversions.rb
|
|
101
141
|
- lib/active_support/core_ext/date_time/zones.rb
|
|
142
|
+
- lib/active_support/core_ext/date_time.rb
|
|
102
143
|
- lib/active_support/core_ext/enumerable.rb
|
|
103
|
-
- lib/active_support/core_ext/exception.rb
|
|
104
|
-
- lib/active_support/core_ext/file.rb
|
|
105
144
|
- lib/active_support/core_ext/file/atomic.rb
|
|
106
|
-
- lib/active_support/core_ext/file
|
|
107
|
-
- lib/active_support/core_ext/float.rb
|
|
108
|
-
- lib/active_support/core_ext/float/rounding.rb
|
|
109
|
-
- lib/active_support/core_ext/hash.rb
|
|
145
|
+
- lib/active_support/core_ext/file.rb
|
|
110
146
|
- lib/active_support/core_ext/hash/conversions.rb
|
|
111
|
-
- lib/active_support/core_ext/hash/deep_dup.rb
|
|
112
147
|
- lib/active_support/core_ext/hash/deep_merge.rb
|
|
113
148
|
- lib/active_support/core_ext/hash/diff.rb
|
|
114
149
|
- lib/active_support/core_ext/hash/except.rb
|
|
@@ -116,19 +151,19 @@ files:
|
|
|
116
151
|
- lib/active_support/core_ext/hash/keys.rb
|
|
117
152
|
- lib/active_support/core_ext/hash/reverse_merge.rb
|
|
118
153
|
- lib/active_support/core_ext/hash/slice.rb
|
|
119
|
-
- lib/active_support/core_ext/
|
|
154
|
+
- lib/active_support/core_ext/hash.rb
|
|
120
155
|
- lib/active_support/core_ext/integer/inflections.rb
|
|
121
156
|
- lib/active_support/core_ext/integer/multiple.rb
|
|
122
157
|
- lib/active_support/core_ext/integer/time.rb
|
|
123
|
-
- lib/active_support/core_ext/
|
|
124
|
-
- lib/active_support/core_ext/kernel.rb
|
|
158
|
+
- lib/active_support/core_ext/integer.rb
|
|
125
159
|
- lib/active_support/core_ext/kernel/agnostics.rb
|
|
126
160
|
- lib/active_support/core_ext/kernel/debugger.rb
|
|
127
161
|
- lib/active_support/core_ext/kernel/reporting.rb
|
|
128
162
|
- lib/active_support/core_ext/kernel/singleton_class.rb
|
|
163
|
+
- lib/active_support/core_ext/kernel.rb
|
|
129
164
|
- lib/active_support/core_ext/load_error.rb
|
|
130
165
|
- lib/active_support/core_ext/logger.rb
|
|
131
|
-
- lib/active_support/core_ext/
|
|
166
|
+
- lib/active_support/core_ext/marshal.rb
|
|
132
167
|
- lib/active_support/core_ext/module/aliasing.rb
|
|
133
168
|
- lib/active_support/core_ext/module/anonymous.rb
|
|
134
169
|
- lib/active_support/core_ext/module/attr_internal.rb
|
|
@@ -136,19 +171,19 @@ files:
|
|
|
136
171
|
- lib/active_support/core_ext/module/delegation.rb
|
|
137
172
|
- lib/active_support/core_ext/module/deprecation.rb
|
|
138
173
|
- lib/active_support/core_ext/module/introspection.rb
|
|
139
|
-
- lib/active_support/core_ext/module/method_names.rb
|
|
140
174
|
- lib/active_support/core_ext/module/qualified_const.rb
|
|
141
175
|
- lib/active_support/core_ext/module/reachable.rb
|
|
142
176
|
- lib/active_support/core_ext/module/remove_method.rb
|
|
143
|
-
- lib/active_support/core_ext/module
|
|
177
|
+
- lib/active_support/core_ext/module.rb
|
|
144
178
|
- lib/active_support/core_ext/name_error.rb
|
|
145
|
-
- lib/active_support/core_ext/numeric.rb
|
|
146
179
|
- lib/active_support/core_ext/numeric/bytes.rb
|
|
180
|
+
- lib/active_support/core_ext/numeric/conversions.rb
|
|
147
181
|
- lib/active_support/core_ext/numeric/time.rb
|
|
148
|
-
- lib/active_support/core_ext/
|
|
182
|
+
- lib/active_support/core_ext/numeric.rb
|
|
149
183
|
- lib/active_support/core_ext/object/acts_like.rb
|
|
150
184
|
- lib/active_support/core_ext/object/blank.rb
|
|
151
185
|
- lib/active_support/core_ext/object/conversions.rb
|
|
186
|
+
- lib/active_support/core_ext/object/deep_dup.rb
|
|
152
187
|
- lib/active_support/core_ext/object/duplicable.rb
|
|
153
188
|
- lib/active_support/core_ext/object/inclusion.rb
|
|
154
189
|
- lib/active_support/core_ext/object/instance_variables.rb
|
|
@@ -157,46 +192,46 @@ files:
|
|
|
157
192
|
- lib/active_support/core_ext/object/to_query.rb
|
|
158
193
|
- lib/active_support/core_ext/object/try.rb
|
|
159
194
|
- lib/active_support/core_ext/object/with_options.rb
|
|
195
|
+
- lib/active_support/core_ext/object.rb
|
|
160
196
|
- lib/active_support/core_ext/proc.rb
|
|
161
|
-
- lib/active_support/core_ext/process.rb
|
|
162
|
-
- lib/active_support/core_ext/process/daemon.rb
|
|
163
|
-
- lib/active_support/core_ext/range.rb
|
|
164
|
-
- lib/active_support/core_ext/range/blockless_step.rb
|
|
165
197
|
- lib/active_support/core_ext/range/conversions.rb
|
|
166
|
-
- lib/active_support/core_ext/range/cover.rb
|
|
167
198
|
- lib/active_support/core_ext/range/include_range.rb
|
|
168
199
|
- lib/active_support/core_ext/range/overlaps.rb
|
|
200
|
+
- lib/active_support/core_ext/range.rb
|
|
169
201
|
- lib/active_support/core_ext/regexp.rb
|
|
170
|
-
- lib/active_support/core_ext/rexml.rb
|
|
171
|
-
- lib/active_support/core_ext/string.rb
|
|
172
202
|
- lib/active_support/core_ext/string/access.rb
|
|
173
203
|
- lib/active_support/core_ext/string/behavior.rb
|
|
174
204
|
- lib/active_support/core_ext/string/conversions.rb
|
|
175
205
|
- lib/active_support/core_ext/string/encoding.rb
|
|
176
206
|
- lib/active_support/core_ext/string/exclude.rb
|
|
177
207
|
- lib/active_support/core_ext/string/filters.rb
|
|
208
|
+
- lib/active_support/core_ext/string/indent.rb
|
|
178
209
|
- lib/active_support/core_ext/string/inflections.rb
|
|
179
210
|
- lib/active_support/core_ext/string/inquiry.rb
|
|
180
|
-
- lib/active_support/core_ext/string/interpolation.rb
|
|
181
211
|
- lib/active_support/core_ext/string/multibyte.rb
|
|
182
212
|
- lib/active_support/core_ext/string/output_safety.rb
|
|
183
213
|
- lib/active_support/core_ext/string/starts_ends_with.rb
|
|
184
214
|
- lib/active_support/core_ext/string/strip.rb
|
|
185
|
-
- lib/active_support/core_ext/string/
|
|
215
|
+
- lib/active_support/core_ext/string/zones.rb
|
|
216
|
+
- lib/active_support/core_ext/string.rb
|
|
217
|
+
- lib/active_support/core_ext/struct.rb
|
|
218
|
+
- lib/active_support/core_ext/thread.rb
|
|
186
219
|
- lib/active_support/core_ext/time/acts_like.rb
|
|
187
220
|
- lib/active_support/core_ext/time/calculations.rb
|
|
188
221
|
- lib/active_support/core_ext/time/conversions.rb
|
|
189
222
|
- lib/active_support/core_ext/time/marshal.rb
|
|
190
|
-
- lib/active_support/core_ext/time/publicize_conversion_methods.rb
|
|
191
223
|
- lib/active_support/core_ext/time/zones.rb
|
|
224
|
+
- lib/active_support/core_ext/time.rb
|
|
192
225
|
- lib/active_support/core_ext/uri.rb
|
|
193
|
-
- lib/active_support/
|
|
226
|
+
- lib/active_support/core_ext.rb
|
|
194
227
|
- lib/active_support/dependencies/autoload.rb
|
|
195
|
-
- lib/active_support/
|
|
228
|
+
- lib/active_support/dependencies.rb
|
|
196
229
|
- lib/active_support/deprecation/behaviors.rb
|
|
230
|
+
- lib/active_support/deprecation/instance_delegator.rb
|
|
197
231
|
- lib/active_support/deprecation/method_wrappers.rb
|
|
198
232
|
- lib/active_support/deprecation/proxy_wrappers.rb
|
|
199
233
|
- lib/active_support/deprecation/reporting.rb
|
|
234
|
+
- lib/active_support/deprecation.rb
|
|
200
235
|
- lib/active_support/descendants_tracker.rb
|
|
201
236
|
- lib/active_support/duration.rb
|
|
202
237
|
- lib/active_support/file_update_checker.rb
|
|
@@ -206,92 +241,89 @@ files:
|
|
|
206
241
|
- lib/active_support/i18n.rb
|
|
207
242
|
- lib/active_support/i18n_railtie.rb
|
|
208
243
|
- lib/active_support/inflections.rb
|
|
209
|
-
- lib/active_support/inflector.rb
|
|
210
244
|
- lib/active_support/inflector/inflections.rb
|
|
211
245
|
- lib/active_support/inflector/methods.rb
|
|
212
246
|
- lib/active_support/inflector/transliterate.rb
|
|
213
|
-
- lib/active_support/
|
|
247
|
+
- lib/active_support/inflector.rb
|
|
214
248
|
- lib/active_support/json/decoding.rb
|
|
215
249
|
- lib/active_support/json/encoding.rb
|
|
216
250
|
- lib/active_support/json/variable.rb
|
|
251
|
+
- lib/active_support/json.rb
|
|
252
|
+
- lib/active_support/key_generator.rb
|
|
217
253
|
- lib/active_support/lazy_load_hooks.rb
|
|
218
254
|
- lib/active_support/locale/en.yml
|
|
219
|
-
- lib/active_support/log_subscriber.rb
|
|
220
255
|
- lib/active_support/log_subscriber/test_helper.rb
|
|
221
|
-
- lib/active_support/
|
|
256
|
+
- lib/active_support/log_subscriber.rb
|
|
257
|
+
- lib/active_support/logger.rb
|
|
258
|
+
- lib/active_support/logger_silence.rb
|
|
222
259
|
- lib/active_support/message_encryptor.rb
|
|
223
260
|
- lib/active_support/message_verifier.rb
|
|
224
|
-
- lib/active_support/multibyte.rb
|
|
225
261
|
- lib/active_support/multibyte/chars.rb
|
|
226
|
-
- lib/active_support/multibyte/exceptions.rb
|
|
227
262
|
- lib/active_support/multibyte/unicode.rb
|
|
228
|
-
- lib/active_support/multibyte
|
|
229
|
-
- lib/active_support/notifications.rb
|
|
263
|
+
- lib/active_support/multibyte.rb
|
|
230
264
|
- lib/active_support/notifications/fanout.rb
|
|
231
265
|
- lib/active_support/notifications/instrumenter.rb
|
|
266
|
+
- lib/active_support/notifications.rb
|
|
267
|
+
- lib/active_support/number_helper.rb
|
|
232
268
|
- lib/active_support/option_merger.rb
|
|
233
269
|
- lib/active_support/ordered_hash.rb
|
|
234
270
|
- lib/active_support/ordered_options.rb
|
|
271
|
+
- lib/active_support/per_thread_registry.rb
|
|
272
|
+
- lib/active_support/proxy_object.rb
|
|
273
|
+
- lib/active_support/rails.rb
|
|
235
274
|
- lib/active_support/railtie.rb
|
|
236
275
|
- lib/active_support/rescuable.rb
|
|
237
|
-
- lib/active_support/ruby/shim.rb
|
|
238
|
-
- lib/active_support/security_utils.rb
|
|
239
276
|
- lib/active_support/string_inquirer.rb
|
|
277
|
+
- lib/active_support/subscriber.rb
|
|
240
278
|
- lib/active_support/tagged_logging.rb
|
|
241
279
|
- lib/active_support/test_case.rb
|
|
242
280
|
- lib/active_support/testing/assertions.rb
|
|
281
|
+
- lib/active_support/testing/autorun.rb
|
|
282
|
+
- lib/active_support/testing/constant_lookup.rb
|
|
243
283
|
- lib/active_support/testing/declarative.rb
|
|
244
284
|
- lib/active_support/testing/deprecation.rb
|
|
245
285
|
- lib/active_support/testing/isolation.rb
|
|
246
|
-
- lib/active_support/testing/mochaing.rb
|
|
247
286
|
- lib/active_support/testing/pending.rb
|
|
248
|
-
- lib/active_support/testing/performance.rb
|
|
249
|
-
- lib/active_support/testing/performance/jruby.rb
|
|
250
|
-
- lib/active_support/testing/performance/rubinius.rb
|
|
251
|
-
- lib/active_support/testing/performance/ruby.rb
|
|
252
|
-
- lib/active_support/testing/performance/ruby/mri.rb
|
|
253
|
-
- lib/active_support/testing/performance/ruby/yarv.rb
|
|
254
287
|
- lib/active_support/testing/setup_and_teardown.rb
|
|
288
|
+
- lib/active_support/testing/tagged_logging.rb
|
|
255
289
|
- lib/active_support/time.rb
|
|
256
|
-
- lib/active_support/time/autoload.rb
|
|
257
290
|
- lib/active_support/time_with_zone.rb
|
|
258
291
|
- lib/active_support/values/time_zone.rb
|
|
259
292
|
- lib/active_support/values/unicode_tables.dat
|
|
260
293
|
- lib/active_support/version.rb
|
|
261
|
-
- lib/active_support/whiny_nil.rb
|
|
262
|
-
- lib/active_support/xml_mini.rb
|
|
263
294
|
- lib/active_support/xml_mini/jdom.rb
|
|
264
295
|
- lib/active_support/xml_mini/libxml.rb
|
|
265
296
|
- lib/active_support/xml_mini/libxmlsax.rb
|
|
266
297
|
- lib/active_support/xml_mini/nokogiri.rb
|
|
267
298
|
- lib/active_support/xml_mini/nokogirisax.rb
|
|
268
299
|
- lib/active_support/xml_mini/rexml.rb
|
|
300
|
+
- lib/active_support/xml_mini.rb
|
|
301
|
+
- lib/active_support.rb
|
|
269
302
|
homepage: http://www.rubyonrails.org
|
|
270
303
|
licenses:
|
|
271
304
|
- MIT
|
|
272
305
|
metadata: {}
|
|
273
306
|
post_install_message:
|
|
274
307
|
rdoc_options:
|
|
275
|
-
-
|
|
308
|
+
- --encoding
|
|
276
309
|
- UTF-8
|
|
277
310
|
require_paths:
|
|
278
311
|
- lib
|
|
279
312
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
280
313
|
requirements:
|
|
281
|
-
- -
|
|
314
|
+
- - '>='
|
|
282
315
|
- !ruby/object:Gem::Version
|
|
283
|
-
version: 1.
|
|
316
|
+
version: 1.9.3
|
|
284
317
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
285
318
|
requirements:
|
|
286
|
-
- -
|
|
319
|
+
- - '>='
|
|
287
320
|
- !ruby/object:Gem::Version
|
|
288
321
|
version: '0'
|
|
289
322
|
requirements: []
|
|
290
323
|
rubyforge_project:
|
|
291
|
-
rubygems_version: 2.
|
|
324
|
+
rubygems_version: 2.0.2
|
|
292
325
|
signing_key:
|
|
293
326
|
specification_version: 4
|
|
294
327
|
summary: A toolkit of support libraries and Ruby core extensions extracted from the
|
|
295
328
|
Rails framework.
|
|
296
329
|
test_files: []
|
|
297
|
-
has_rdoc:
|
|
@@ -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,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 +0,0 @@
|
|
|
1
|
-
require 'active_support/core_ext/float/rounding'
|
|
@@ -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,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 +0,0 @@
|
|
|
1
|
-
require 'active_support/core_ext/process/daemon'
|