activesupport 5.0.7.2 → 5.1.7
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activesupport might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +464 -694
- data/MIT-LICENSE +1 -1
- data/README.rdoc +1 -1
- data/lib/active_support.rb +8 -4
- data/lib/active_support/all.rb +3 -3
- data/lib/active_support/array_inquirer.rb +7 -5
- data/lib/active_support/backtrace_cleaner.rb +4 -4
- data/lib/active_support/benchmarkable.rb +3 -3
- data/lib/active_support/builder.rb +1 -1
- data/lib/active_support/cache.rb +41 -48
- data/lib/active_support/cache/file_store.rb +11 -20
- data/lib/active_support/cache/mem_cache_store.rb +30 -40
- data/lib/active_support/cache/memory_store.rb +13 -13
- data/lib/active_support/cache/null_store.rb +4 -4
- data/lib/active_support/cache/strategy/local_cache.rb +13 -22
- data/lib/active_support/cache/strategy/local_cache_middleware.rb +4 -5
- data/lib/active_support/callbacks.rb +649 -584
- data/lib/active_support/concurrency/load_interlock_aware_monitor.rb +17 -0
- data/lib/active_support/concurrency/share_lock.rb +20 -21
- data/lib/active_support/configurable.rb +5 -5
- data/lib/active_support/core_ext.rb +1 -2
- data/lib/active_support/core_ext/array.rb +7 -7
- data/lib/active_support/core_ext/array/access.rb +1 -1
- data/lib/active_support/core_ext/array/conversions.rb +15 -15
- data/lib/active_support/core_ext/array/grouping.rb +1 -1
- data/lib/active_support/core_ext/array/inquiry.rb +1 -1
- data/lib/active_support/core_ext/array/prepend_and_append.rb +1 -1
- data/lib/active_support/core_ext/benchmark.rb +1 -1
- data/lib/active_support/core_ext/big_decimal.rb +1 -1
- data/lib/active_support/core_ext/big_decimal/conversions.rb +4 -6
- data/lib/active_support/core_ext/class.rb +2 -2
- data/lib/active_support/core_ext/class/attribute.rb +5 -5
- data/lib/active_support/core_ext/class/attribute_accessors.rb +1 -1
- data/lib/active_support/core_ext/class/subclasses.rb +18 -4
- data/lib/active_support/core_ext/date.rb +5 -5
- data/lib/active_support/core_ext/date/acts_like.rb +1 -1
- data/lib/active_support/core_ext/date/blank.rb +1 -1
- data/lib/active_support/core_ext/date/calculations.rb +8 -8
- data/lib/active_support/core_ext/date/conversions.rb +12 -12
- data/lib/active_support/core_ext/date/zones.rb +2 -2
- data/lib/active_support/core_ext/date_and_time/calculations.rb +27 -22
- data/lib/active_support/core_ext/date_and_time/compatibility.rb +1 -1
- data/lib/active_support/core_ext/date_and_time/zones.rb +7 -8
- data/lib/active_support/core_ext/date_time.rb +5 -5
- data/lib/active_support/core_ext/date_time/acts_like.rb +2 -2
- data/lib/active_support/core_ext/date_time/blank.rb +1 -1
- data/lib/active_support/core_ext/date_time/calculations.rb +20 -10
- data/lib/active_support/core_ext/date_time/compatibility.rb +2 -2
- data/lib/active_support/core_ext/date_time/conversions.rb +12 -12
- data/lib/active_support/core_ext/digest/uuid.rb +4 -4
- data/lib/active_support/core_ext/enumerable.rb +23 -12
- data/lib/active_support/core_ext/file.rb +1 -1
- data/lib/active_support/core_ext/file/atomic.rb +4 -4
- data/lib/active_support/core_ext/hash.rb +9 -9
- data/lib/active_support/core_ext/hash/compact.rb +12 -9
- data/lib/active_support/core_ext/hash/conversions.rb +36 -37
- data/lib/active_support/core_ext/hash/indifferent_access.rb +1 -2
- data/lib/active_support/core_ext/hash/keys.rb +6 -6
- data/lib/active_support/core_ext/hash/reverse_merge.rb +1 -1
- data/lib/active_support/core_ext/hash/slice.rb +4 -4
- data/lib/active_support/core_ext/hash/transform_values.rb +1 -0
- data/lib/active_support/core_ext/integer.rb +3 -3
- data/lib/active_support/core_ext/integer/inflections.rb +1 -1
- data/lib/active_support/core_ext/integer/time.rb +2 -2
- data/lib/active_support/core_ext/kernel.rb +4 -4
- data/lib/active_support/core_ext/kernel/concern.rb +1 -1
- data/lib/active_support/core_ext/kernel/reporting.rb +1 -1
- data/lib/active_support/core_ext/load_error.rb +1 -18
- data/lib/active_support/core_ext/module.rb +11 -12
- data/lib/active_support/core_ext/module/aliasing.rb +3 -48
- data/lib/active_support/core_ext/module/attr_internal.rb +4 -4
- data/lib/active_support/core_ext/module/attribute_accessors.rb +11 -5
- data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +20 -13
- data/lib/active_support/core_ext/module/concerning.rb +1 -1
- data/lib/active_support/core_ext/module/delegation.rb +85 -16
- data/lib/active_support/core_ext/module/introspection.rb +3 -11
- data/lib/active_support/core_ext/module/reachable.rb +2 -2
- data/lib/active_support/core_ext/numeric.rb +4 -4
- data/lib/active_support/core_ext/numeric/conversions.rb +3 -9
- data/lib/active_support/core_ext/numeric/inquiry.rb +21 -21
- data/lib/active_support/core_ext/numeric/time.rb +5 -5
- data/lib/active_support/core_ext/object.rb +12 -12
- data/lib/active_support/core_ext/object/blank.rb +3 -1
- data/lib/active_support/core_ext/object/conversions.rb +4 -4
- data/lib/active_support/core_ext/object/deep_dup.rb +1 -1
- data/lib/active_support/core_ext/object/duplicable.rb +34 -4
- data/lib/active_support/core_ext/object/inclusion.rb +1 -1
- data/lib/active_support/core_ext/object/json.rb +26 -12
- data/lib/active_support/core_ext/object/to_param.rb +1 -1
- data/lib/active_support/core_ext/object/to_query.rb +8 -5
- data/lib/active_support/core_ext/object/try.rb +1 -1
- data/lib/active_support/core_ext/object/with_options.rb +12 -1
- data/lib/active_support/core_ext/range.rb +4 -4
- data/lib/active_support/core_ext/range/conversions.rb +1 -1
- data/lib/active_support/core_ext/regexp.rb +4 -0
- data/lib/active_support/core_ext/securerandom.rb +3 -3
- data/lib/active_support/core_ext/string.rb +13 -13
- data/lib/active_support/core_ext/string/access.rb +6 -6
- data/lib/active_support/core_ext/string/conversions.rb +2 -2
- data/lib/active_support/core_ext/string/filters.rb +3 -3
- data/lib/active_support/core_ext/string/indent.rb +4 -4
- data/lib/active_support/core_ext/string/inflections.rb +10 -14
- data/lib/active_support/core_ext/string/inquiry.rb +1 -1
- data/lib/active_support/core_ext/string/multibyte.rb +1 -1
- data/lib/active_support/core_ext/string/output_safety.rb +19 -20
- data/lib/active_support/core_ext/string/strip.rb +1 -1
- data/lib/active_support/core_ext/string/zones.rb +2 -2
- data/lib/active_support/core_ext/time.rb +5 -5
- data/lib/active_support/core_ext/time/acts_like.rb +1 -1
- data/lib/active_support/core_ext/time/calculations.rb +46 -29
- data/lib/active_support/core_ext/time/conversions.rb +15 -12
- data/lib/active_support/core_ext/time/zones.rb +3 -3
- data/lib/active_support/core_ext/uri.rb +2 -2
- data/lib/active_support/dependencies.rb +45 -46
- data/lib/active_support/dependencies/interlock.rb +1 -1
- data/lib/active_support/deprecation.rb +9 -8
- data/lib/active_support/deprecation/behaviors.rb +3 -3
- data/lib/active_support/deprecation/constant_accessor.rb +50 -0
- data/lib/active_support/deprecation/instance_delegator.rb +2 -2
- data/lib/active_support/deprecation/method_wrappers.rb +10 -3
- data/lib/active_support/deprecation/proxy_wrappers.rb +6 -4
- data/lib/active_support/deprecation/reporting.rb +7 -7
- data/lib/active_support/duration.rb +221 -28
- data/lib/active_support/duration/iso8601_parser.rb +66 -65
- data/lib/active_support/duration/iso8601_serializer.rb +11 -9
- data/lib/active_support/evented_file_update_checker.rb +59 -55
- data/lib/active_support/execution_wrapper.rb +3 -3
- data/lib/active_support/executor.rb +1 -1
- data/lib/active_support/file_update_checker.rb +54 -50
- data/lib/active_support/gem_version.rb +2 -2
- data/lib/active_support/gzip.rb +4 -4
- data/lib/active_support/hash_with_indifferent_access.rb +40 -28
- data/lib/active_support/i18n.rb +5 -5
- data/lib/active_support/i18n_railtie.rb +14 -9
- data/lib/active_support/inflections.rb +11 -11
- data/lib/active_support/inflector.rb +5 -5
- data/lib/active_support/inflector/inflections.rb +11 -9
- data/lib/active_support/inflector/methods.rb +52 -51
- data/lib/active_support/inflector/transliterate.rb +8 -11
- data/lib/active_support/json.rb +2 -2
- data/lib/active_support/json/decoding.rb +3 -3
- data/lib/active_support/json/encoding.rb +8 -7
- data/lib/active_support/key_generator.rb +17 -17
- data/lib/active_support/lazy_load_hooks.rb +2 -2
- data/lib/active_support/log_subscriber.rb +9 -7
- data/lib/active_support/log_subscriber/test_helper.rb +9 -9
- data/lib/active_support/logger.rb +3 -3
- data/lib/active_support/logger_silence.rb +3 -3
- data/lib/active_support/logger_thread_safe_level.rb +1 -1
- data/lib/active_support/message_encryptor.rb +77 -35
- data/lib/active_support/message_verifier.rb +7 -7
- data/lib/active_support/multibyte.rb +2 -2
- data/lib/active_support/multibyte/chars.rb +23 -21
- data/lib/active_support/multibyte/unicode.rb +68 -89
- data/lib/active_support/notifications.rb +7 -5
- data/lib/active_support/notifications/fanout.rb +3 -3
- data/lib/active_support/notifications/instrumenter.rb +5 -5
- data/lib/active_support/number_helper.rb +5 -4
- data/lib/active_support/number_helper/number_converter.rb +11 -11
- data/lib/active_support/number_helper/number_to_currency_converter.rb +3 -3
- data/lib/active_support/number_helper/number_to_delimited_converter.rb +1 -2
- data/lib/active_support/number_helper/number_to_human_converter.rb +8 -10
- data/lib/active_support/number_helper/number_to_human_size_converter.rb +6 -11
- data/lib/active_support/number_helper/number_to_percentage_converter.rb +1 -1
- data/lib/active_support/number_helper/number_to_phone_converter.rb +1 -3
- data/lib/active_support/number_helper/number_to_rounded_converter.rb +12 -32
- data/lib/active_support/number_helper/rounding_helper.rb +64 -0
- data/lib/active_support/option_merger.rb +1 -1
- data/lib/active_support/ordered_hash.rb +3 -3
- data/lib/active_support/ordered_options.rb +6 -4
- data/lib/active_support/per_thread_registry.rb +5 -5
- data/lib/active_support/rails.rb +12 -6
- data/lib/active_support/railtie.rb +3 -3
- data/lib/active_support/reloader.rb +1 -1
- data/lib/active_support/rescuable.rb +6 -6
- data/lib/active_support/security_utils.rb +1 -1
- data/lib/active_support/string_inquirer.rb +8 -2
- data/lib/active_support/subscriber.rb +9 -5
- data/lib/active_support/tagged_logging.rb +4 -4
- data/lib/active_support/test_case.rb +12 -29
- data/lib/active_support/testing/assertions.rb +100 -2
- data/lib/active_support/testing/autorun.rb +2 -2
- data/lib/active_support/testing/constant_lookup.rb +0 -1
- data/lib/active_support/testing/declarative.rb +1 -1
- data/lib/active_support/testing/deprecation.rb +3 -2
- data/lib/active_support/testing/isolation.rb +15 -22
- data/lib/active_support/testing/method_call_assertions.rb +1 -1
- data/lib/active_support/testing/setup_and_teardown.rb +2 -2
- data/lib/active_support/testing/stream.rb +28 -28
- data/lib/active_support/testing/tagged_logging.rb +1 -1
- data/lib/active_support/testing/time_helpers.rb +45 -11
- data/lib/active_support/time.rb +12 -12
- data/lib/active_support/time_with_zone.rb +16 -14
- data/lib/active_support/values/time_zone.rb +100 -31
- data/lib/active_support/values/unicode_tables.dat +0 -0
- data/lib/active_support/version.rb +1 -1
- data/lib/active_support/xml_mini.rb +34 -36
- data/lib/active_support/xml_mini/jdom.rb +112 -112
- data/lib/active_support/xml_mini/libxml.rb +12 -11
- data/lib/active_support/xml_mini/libxmlsax.rb +13 -14
- data/lib/active_support/xml_mini/nokogiri.rb +10 -10
- data/lib/active_support/xml_mini/nokogirisax.rb +12 -13
- data/lib/active_support/xml_mini/rexml.rb +9 -9
- metadata +8 -9
- data/lib/active_support/concurrency/latch.rb +0 -26
- data/lib/active_support/core_ext/kernel/debugger.rb +0 -3
- data/lib/active_support/core_ext/module/method_transplanting.rb +0 -3
- data/lib/active_support/core_ext/module/qualified_const.rb +0 -70
- data/lib/active_support/core_ext/struct.rb +0 -3
- data/lib/active_support/core_ext/time/marshal.rb +0 -3
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
1
|
+
require "active_support/duration"
|
2
|
+
require "active_support/core_ext/time/calculations"
|
3
|
+
require "active_support/core_ext/time/acts_like"
|
4
|
+
require "active_support/core_ext/date/calculations"
|
5
|
+
require "active_support/core_ext/date/acts_like"
|
6
6
|
|
7
7
|
class Numeric
|
8
8
|
# Enables the use of time calculations and declarations, like 45.minutes + 2.hours + 4.years.
|
@@ -1,14 +1,14 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
1
|
+
require "active_support/core_ext/object/acts_like"
|
2
|
+
require "active_support/core_ext/object/blank"
|
3
|
+
require "active_support/core_ext/object/duplicable"
|
4
|
+
require "active_support/core_ext/object/deep_dup"
|
5
|
+
require "active_support/core_ext/object/try"
|
6
|
+
require "active_support/core_ext/object/inclusion"
|
7
7
|
|
8
|
-
require
|
9
|
-
require
|
8
|
+
require "active_support/core_ext/object/conversions"
|
9
|
+
require "active_support/core_ext/object/instance_variables"
|
10
10
|
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
11
|
+
require "active_support/core_ext/object/json"
|
12
|
+
require "active_support/core_ext/object/to_param"
|
13
|
+
require "active_support/core_ext/object/to_query"
|
14
|
+
require "active_support/core_ext/object/with_options"
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "active_support/core_ext/regexp"
|
2
|
+
|
1
3
|
class Object
|
2
4
|
# An object is blank if it's false, empty, or a whitespace string.
|
3
5
|
# For example, +false+, '', ' ', +nil+, [], and {} are all blank.
|
@@ -115,7 +117,7 @@ class String
|
|
115
117
|
# The regexp that matches blank strings is expensive. For the case of empty
|
116
118
|
# strings we can speed up this method (~3.5x) with an empty? call. The
|
117
119
|
# penalty for the rest of strings is marginal.
|
118
|
-
empty? || BLANK_RE
|
120
|
+
empty? || BLANK_RE.match?(self)
|
119
121
|
end
|
120
122
|
end
|
121
123
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require "active_support/core_ext/object/to_param"
|
2
|
+
require "active_support/core_ext/object/to_query"
|
3
|
+
require "active_support/core_ext/array/conversions"
|
4
|
+
require "active_support/core_ext/hash/conversions"
|
@@ -74,7 +74,7 @@ end
|
|
74
74
|
class Symbol
|
75
75
|
begin
|
76
76
|
:symbol.dup # Ruby 2.4.x.
|
77
|
-
|
77
|
+
"symbol_from_string".to_sym.dup # Some symbols can't `dup` in Ruby 2.4.0.
|
78
78
|
rescue TypeError
|
79
79
|
|
80
80
|
# Symbols are not duplicable:
|
@@ -102,12 +102,12 @@ class Numeric
|
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
105
|
-
require
|
105
|
+
require "bigdecimal"
|
106
106
|
class BigDecimal
|
107
107
|
# BigDecimals are duplicable:
|
108
108
|
#
|
109
|
-
#
|
110
|
-
#
|
109
|
+
# BigDecimal.new("1.2").duplicable? # => true
|
110
|
+
# BigDecimal.new("1.2").dup # => #<BigDecimal:...,'0.12E1',18(18)>
|
111
111
|
def duplicable?
|
112
112
|
true
|
113
113
|
end
|
@@ -122,3 +122,33 @@ class Method
|
|
122
122
|
false
|
123
123
|
end
|
124
124
|
end
|
125
|
+
|
126
|
+
class Complex
|
127
|
+
begin
|
128
|
+
Complex(1).dup
|
129
|
+
rescue TypeError
|
130
|
+
|
131
|
+
# Complexes are not duplicable for RUBY_VERSION < 2.5.0:
|
132
|
+
#
|
133
|
+
# Complex(1).duplicable? # => false
|
134
|
+
# Complex(1).dup # => TypeError: can't copy Complex
|
135
|
+
def duplicable?
|
136
|
+
false
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
class Rational
|
142
|
+
begin
|
143
|
+
Rational(1).dup
|
144
|
+
rescue TypeError
|
145
|
+
|
146
|
+
# Rationals are not duplicable for RUBY_VERSION < 2.5.0:
|
147
|
+
#
|
148
|
+
# Rational(1).duplicable? # => false
|
149
|
+
# Rational(1).dup # => TypeError: can't copy Rational
|
150
|
+
def duplicable?
|
151
|
+
false
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
@@ -1,14 +1,16 @@
|
|
1
1
|
# Hack to load json gem first so we can overwrite its to_json.
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
2
|
+
require "json"
|
3
|
+
require "bigdecimal"
|
4
|
+
require "uri/generic"
|
5
|
+
require "pathname"
|
6
|
+
require "active_support/core_ext/big_decimal/conversions" # for #to_s
|
7
|
+
require "active_support/core_ext/hash/except"
|
8
|
+
require "active_support/core_ext/hash/slice"
|
9
|
+
require "active_support/core_ext/object/instance_variables"
|
10
|
+
require "time"
|
11
|
+
require "active_support/core_ext/time/conversions"
|
12
|
+
require "active_support/core_ext/date_time/conversions"
|
13
|
+
require "active_support/core_ext/date/conversions"
|
12
14
|
|
13
15
|
# The JSON gem adds a few modules to Ruby core classes containing :to_json definition, overwriting
|
14
16
|
# their default behavior. That said, we need to define the basic to_json method in all of them,
|
@@ -187,14 +189,26 @@ class DateTime
|
|
187
189
|
if ActiveSupport::JSON::Encoding.use_standard_json_time_format
|
188
190
|
xmlschema(ActiveSupport::JSON::Encoding.time_precision)
|
189
191
|
else
|
190
|
-
strftime(
|
192
|
+
strftime("%Y/%m/%d %H:%M:%S %z")
|
191
193
|
end
|
192
194
|
end
|
193
195
|
end
|
194
196
|
|
197
|
+
class URI::Generic #:nodoc:
|
198
|
+
def as_json(options = nil)
|
199
|
+
to_s
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
class Pathname #:nodoc:
|
204
|
+
def as_json(options = nil)
|
205
|
+
to_s
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
195
209
|
class Process::Status #:nodoc:
|
196
210
|
def as_json(options = nil)
|
197
|
-
{ :
|
211
|
+
{ exitstatus: exitstatus, pid: pid }
|
198
212
|
end
|
199
213
|
end
|
200
214
|
|
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require "active_support/core_ext/object/to_query"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "cgi"
|
2
2
|
|
3
3
|
class Object
|
4
4
|
# Alias of <tt>to_s</tt>.
|
@@ -38,7 +38,7 @@ class Array
|
|
38
38
|
# Calls <tt>to_param</tt> on all its elements and joins the result with
|
39
39
|
# slashes. This is used by <tt>url_for</tt> in Action Pack.
|
40
40
|
def to_param
|
41
|
-
collect(&:to_param).join
|
41
|
+
collect(&:to_param).join "/"
|
42
42
|
end
|
43
43
|
|
44
44
|
# Converts an array into a string suitable for use as a URL query string,
|
@@ -51,7 +51,7 @@ class Array
|
|
51
51
|
if empty?
|
52
52
|
nil.to_query(prefix)
|
53
53
|
else
|
54
|
-
collect { |value| value.to_query(prefix) }.join
|
54
|
+
collect { |value| value.to_query(prefix) }.join "&"
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -73,11 +73,14 @@ class Hash
|
|
73
73
|
#
|
74
74
|
# This method is also aliased as +to_param+.
|
75
75
|
def to_query(namespace = nil)
|
76
|
-
collect do |key, value|
|
76
|
+
query = collect do |key, value|
|
77
77
|
unless (value.is_a?(Hash) || value.is_a?(Array)) && value.empty?
|
78
78
|
value.to_query(namespace ? "#{namespace}[#{key}]" : key)
|
79
79
|
end
|
80
|
-
end.compact
|
80
|
+
end.compact
|
81
|
+
|
82
|
+
query.sort! unless namespace.to_s.include?("[]")
|
83
|
+
query.join("&")
|
81
84
|
end
|
82
85
|
|
83
86
|
alias_method :to_param, :to_query
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "active_support/option_merger"
|
2
2
|
|
3
3
|
class Object
|
4
4
|
# An elegant way to factor duplication out of options passed to a series of
|
@@ -62,6 +62,17 @@ class Object
|
|
62
62
|
#
|
63
63
|
# Hence the inherited default for `if` key is ignored.
|
64
64
|
#
|
65
|
+
# NOTE: You cannot call class methods implicitly inside of with_options.
|
66
|
+
# You can access these methods using the class name instead:
|
67
|
+
#
|
68
|
+
# class Phone < ActiveRecord::Base
|
69
|
+
# enum phone_number_type: [home: 0, office: 1, mobile: 2]
|
70
|
+
#
|
71
|
+
# with_options presence: true do
|
72
|
+
# validates :phone_number_type, inclusion: { in: Phone.phone_number_types.keys }
|
73
|
+
# end
|
74
|
+
# end
|
75
|
+
#
|
65
76
|
def with_options(options, &block)
|
66
77
|
option_merger = ActiveSupport::OptionMerger.new(self, options)
|
67
78
|
block.arity.zero? ? option_merger.instance_eval(&block) : block.call(option_merger)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require "active_support/core_ext/range/conversions"
|
2
|
+
require "active_support/core_ext/range/include_range"
|
3
|
+
require "active_support/core_ext/range/overlaps"
|
4
|
+
require "active_support/core_ext/range/each"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module ActiveSupport::RangeWithFormat
|
2
2
|
RANGE_FORMATS = {
|
3
|
-
:
|
3
|
+
db: Proc.new { |start, stop| "BETWEEN '#{start.to_s(:db)}' AND '#{stop.to_s(:db)}'" }
|
4
4
|
}
|
5
5
|
|
6
6
|
# Convert range to a formatted string. See RANGE_FORMATS for predefined formats.
|
@@ -1,12 +1,12 @@
|
|
1
|
-
require
|
1
|
+
require "securerandom"
|
2
2
|
|
3
3
|
module SecureRandom
|
4
|
-
BASE58_ALPHABET = (
|
4
|
+
BASE58_ALPHABET = ("0".."9").to_a + ("A".."Z").to_a + ("a".."z").to_a - ["0", "O", "I", "l"]
|
5
5
|
# SecureRandom.base58 generates a random base58 string.
|
6
6
|
#
|
7
7
|
# The argument _n_ specifies the length, of the random string to be generated.
|
8
8
|
#
|
9
|
-
# If _n_ is not specified or is nil
|
9
|
+
# If _n_ is not specified or is +nil+, 16 is assumed. It may be larger in the future.
|
10
10
|
#
|
11
11
|
# The result may contain alphanumeric characters except 0, O, I and l
|
12
12
|
#
|
@@ -1,13 +1,13 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
1
|
+
require "active_support/core_ext/string/conversions"
|
2
|
+
require "active_support/core_ext/string/filters"
|
3
|
+
require "active_support/core_ext/string/multibyte"
|
4
|
+
require "active_support/core_ext/string/starts_ends_with"
|
5
|
+
require "active_support/core_ext/string/inflections"
|
6
|
+
require "active_support/core_ext/string/access"
|
7
|
+
require "active_support/core_ext/string/behavior"
|
8
|
+
require "active_support/core_ext/string/output_safety"
|
9
|
+
require "active_support/core_ext/string/exclude"
|
10
|
+
require "active_support/core_ext/string/strip"
|
11
|
+
require "active_support/core_ext/string/inquiry"
|
12
|
+
require "active_support/core_ext/string/indent"
|
13
|
+
require "active_support/core_ext/string/zones"
|
@@ -3,7 +3,7 @@ class String
|
|
3
3
|
# position. The first character of the string is at position 0, the next at
|
4
4
|
# position 1, and so on. If a range is supplied, a substring containing
|
5
5
|
# characters at offsets given by the range is returned. In both cases, if an
|
6
|
-
# offset is negative, it is counted from the end of the string. Returns nil
|
6
|
+
# offset is negative, it is counted from the end of the string. Returns +nil+
|
7
7
|
# if the initial offset falls outside the string. Returns an empty string if
|
8
8
|
# the beginning of the range is greater than the end of the string.
|
9
9
|
#
|
@@ -17,7 +17,7 @@ class String
|
|
17
17
|
#
|
18
18
|
# If a Regexp is given, the matching portion of the string is returned.
|
19
19
|
# If a String is given, that given string is returned if it occurs in
|
20
|
-
# the string. In both cases, nil is returned if there is no match.
|
20
|
+
# the string. In both cases, +nil+ is returned if there is no match.
|
21
21
|
#
|
22
22
|
# str = "hello"
|
23
23
|
# str.at(/lo/) # => "lo"
|
@@ -74,9 +74,9 @@ class String
|
|
74
74
|
# str.first(6) # => "hello"
|
75
75
|
def first(limit = 1)
|
76
76
|
if limit == 0
|
77
|
-
|
77
|
+
""
|
78
78
|
elsif limit >= size
|
79
|
-
|
79
|
+
dup
|
80
80
|
else
|
81
81
|
to(limit - 1)
|
82
82
|
end
|
@@ -94,9 +94,9 @@ class String
|
|
94
94
|
# str.last(6) # => "hello"
|
95
95
|
def last(limit = 1)
|
96
96
|
if limit == 0
|
97
|
-
|
97
|
+
""
|
98
98
|
elsif limit >= size
|
99
|
-
|
99
|
+
dup
|
100
100
|
else
|
101
101
|
from(-limit)
|
102
102
|
end
|
@@ -17,7 +17,7 @@ class String
|
|
17
17
|
# str.squish! # => "foo bar boo"
|
18
18
|
# str # => "foo bar boo"
|
19
19
|
def squish!
|
20
|
-
gsub!(/[[:space:]]+/,
|
20
|
+
gsub!(/[[:space:]]+/, " ")
|
21
21
|
strip!
|
22
22
|
self
|
23
23
|
end
|
@@ -64,7 +64,7 @@ class String
|
|
64
64
|
def truncate(truncate_at, options = {})
|
65
65
|
return dup unless length > truncate_at
|
66
66
|
|
67
|
-
omission = options[:omission] ||
|
67
|
+
omission = options[:omission] || "..."
|
68
68
|
length_with_room_for_omission = truncate_at - omission.length
|
69
69
|
stop = \
|
70
70
|
if options[:separator]
|
@@ -94,7 +94,7 @@ class String
|
|
94
94
|
sep = options[:separator] || /\s+/
|
95
95
|
sep = Regexp.escape(sep.to_s) unless Regexp === sep
|
96
96
|
if self =~ /\A((?>.+?#{sep}){#{words_count - 1}}.+?)#{sep}.*/m
|
97
|
-
$1 + (options[:omission] ||
|
97
|
+
$1 + (options[:omission] || "...")
|
98
98
|
else
|
99
99
|
dup
|
100
100
|
end
|
@@ -2,8 +2,8 @@ class String
|
|
2
2
|
# Same as +indent+, except it indents the receiver in-place.
|
3
3
|
#
|
4
4
|
# Returns the indented string, or +nil+ if there was nothing to indent.
|
5
|
-
def indent!(amount, indent_string=nil, indent_empty_lines=false)
|
6
|
-
indent_string = indent_string || self[/^[ \t]/] ||
|
5
|
+
def indent!(amount, indent_string = nil, indent_empty_lines = false)
|
6
|
+
indent_string = indent_string || self[/^[ \t]/] || " "
|
7
7
|
re = indent_empty_lines ? /^/ : /^(?!$)/
|
8
8
|
gsub!(re, indent_string * amount)
|
9
9
|
end
|
@@ -37,7 +37,7 @@ class String
|
|
37
37
|
# "foo\n\nbar".indent(2) # => " foo\n\n bar"
|
38
38
|
# "foo\n\nbar".indent(2, nil, true) # => " foo\n \n bar"
|
39
39
|
#
|
40
|
-
def indent(amount, indent_string=nil, indent_empty_lines=false)
|
41
|
-
dup.tap {|_| _.indent!(amount, indent_string, indent_empty_lines)}
|
40
|
+
def indent(amount, indent_string = nil, indent_empty_lines = false)
|
41
|
+
dup.tap { |_| _.indent!(amount, indent_string, indent_empty_lines) }
|
42
42
|
end
|
43
43
|
end
|