activesupport 3.1.0 → 5.0.0
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 +7 -0
- data/CHANGELOG.md +798 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +13 -7
- data/lib/active_support/array_inquirer.rb +44 -0
- data/lib/active_support/backtrace_cleaner.rb +38 -34
- data/lib/active_support/benchmarkable.rb +17 -28
- data/lib/active_support/cache/file_store.rb +85 -70
- data/lib/active_support/cache/mem_cache_store.rb +75 -66
- data/lib/active_support/cache/memory_store.rb +31 -23
- data/lib/active_support/cache/null_store.rb +41 -0
- data/lib/active_support/cache/strategy/local_cache.rb +73 -70
- data/lib/active_support/cache/strategy/local_cache_middleware.rb +44 -0
- data/lib/active_support/cache.rb +360 -294
- data/lib/active_support/callbacks.rb +563 -393
- data/lib/active_support/concern.rb +42 -34
- data/lib/active_support/concurrency/latch.rb +19 -0
- data/lib/active_support/concurrency/share_lock.rb +186 -0
- data/lib/active_support/configurable.rb +70 -12
- data/lib/active_support/core_ext/array/access.rb +53 -9
- data/lib/active_support/core_ext/array/conversions.rb +109 -62
- data/lib/active_support/core_ext/array/extract_options.rb +2 -2
- data/lib/active_support/core_ext/array/grouping.rb +39 -32
- data/lib/active_support/core_ext/array/inquiry.rb +17 -0
- data/lib/active_support/core_ext/array/prepend_and_append.rb +7 -0
- data/lib/active_support/core_ext/array/wrap.rb +16 -18
- data/lib/active_support/core_ext/array.rb +2 -2
- data/lib/active_support/core_ext/benchmark.rb +7 -0
- data/lib/active_support/core_ext/big_decimal/conversions.rb +8 -36
- data/lib/active_support/core_ext/class/attribute.rb +47 -34
- data/lib/active_support/core_ext/class/attribute_accessors.rb +4 -79
- data/lib/active_support/core_ext/class/subclasses.rb +12 -7
- data/lib/active_support/core_ext/class.rb +0 -3
- data/lib/active_support/core_ext/date/blank.rb +12 -0
- data/lib/active_support/core_ext/date/calculations.rb +57 -167
- data/lib/active_support/core_ext/date/conversions.rb +31 -42
- data/lib/active_support/core_ext/date/zones.rb +2 -10
- data/lib/active_support/core_ext/date.rb +5 -0
- data/lib/active_support/core_ext/date_and_time/calculations.rb +335 -0
- data/lib/active_support/core_ext/date_and_time/compatibility.rb +18 -0
- data/lib/active_support/core_ext/date_and_time/zones.rb +40 -0
- data/lib/active_support/core_ext/date_time/acts_like.rb +1 -0
- data/lib/active_support/core_ext/date_time/blank.rb +12 -0
- data/lib/active_support/core_ext/date_time/calculations.rb +132 -65
- data/lib/active_support/core_ext/date_time/compatibility.rb +5 -0
- data/lib/active_support/core_ext/date_time/conversions.rb +36 -34
- data/lib/active_support/core_ext/date_time.rb +5 -0
- data/lib/active_support/core_ext/digest/uuid.rb +51 -0
- data/lib/active_support/core_ext/enumerable.rb +81 -74
- data/lib/active_support/core_ext/file/atomic.rb +53 -26
- data/lib/active_support/core_ext/file.rb +0 -1
- data/lib/active_support/core_ext/hash/compact.rb +20 -0
- data/lib/active_support/core_ext/hash/conversions.rb +175 -70
- data/lib/active_support/core_ext/hash/deep_merge.rb +30 -8
- data/lib/active_support/core_ext/hash/except.rb +11 -12
- data/lib/active_support/core_ext/hash/indifferent_access.rb +7 -8
- data/lib/active_support/core_ext/hash/keys.rb +147 -24
- data/lib/active_support/core_ext/hash/reverse_merge.rb +2 -3
- data/lib/active_support/core_ext/hash/slice.rb +22 -14
- data/lib/active_support/core_ext/hash/transform_values.rb +29 -0
- data/lib/active_support/core_ext/hash.rb +2 -2
- data/lib/active_support/core_ext/integer/inflections.rb +13 -1
- data/lib/active_support/core_ext/integer/multiple.rb +4 -0
- data/lib/active_support/core_ext/integer/time.rb +12 -22
- data/lib/active_support/core_ext/kernel/agnostics.rb +2 -2
- data/lib/active_support/core_ext/kernel/concern.rb +12 -0
- data/lib/active_support/core_ext/kernel/debugger.rb +2 -15
- data/lib/active_support/core_ext/kernel/reporting.rb +12 -62
- data/lib/active_support/core_ext/kernel/singleton_class.rb +0 -7
- data/lib/active_support/core_ext/kernel.rb +2 -3
- data/lib/active_support/core_ext/load_error.rb +14 -7
- data/lib/active_support/core_ext/marshal.rb +22 -0
- data/lib/active_support/core_ext/module/aliasing.rb +16 -12
- data/lib/active_support/core_ext/module/anonymous.rb +12 -8
- data/lib/active_support/core_ext/module/attr_internal.rb +2 -5
- data/lib/active_support/core_ext/module/attribute_accessors.rb +165 -13
- data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +141 -0
- data/lib/active_support/core_ext/module/concerning.rb +135 -0
- data/lib/active_support/core_ext/module/delegation.rb +141 -68
- data/lib/active_support/core_ext/module/deprecation.rb +17 -3
- data/lib/active_support/core_ext/module/introspection.rb +9 -31
- data/lib/active_support/core_ext/module/method_transplanting.rb +3 -0
- data/lib/active_support/core_ext/module/qualified_const.rb +70 -0
- data/lib/active_support/core_ext/module/reachable.rb +1 -3
- data/lib/active_support/core_ext/module/remove_method.rb +24 -5
- data/lib/active_support/core_ext/module.rb +3 -3
- data/lib/active_support/core_ext/name_error.rb +15 -2
- data/lib/active_support/core_ext/numeric/bytes.rb +20 -0
- data/lib/active_support/core_ext/numeric/conversions.rb +145 -0
- data/lib/active_support/core_ext/numeric/inquiry.rb +26 -0
- data/lib/active_support/core_ext/numeric/time.rb +31 -36
- data/lib/active_support/core_ext/numeric.rb +2 -0
- data/lib/active_support/core_ext/object/acts_like.rb +4 -4
- data/lib/active_support/core_ext/object/blank.rb +52 -18
- data/lib/active_support/core_ext/object/deep_dup.rb +53 -0
- data/lib/active_support/core_ext/object/duplicable.rb +12 -20
- data/lib/active_support/core_ext/object/inclusion.rb +13 -1
- data/lib/active_support/core_ext/object/instance_variables.rb +7 -12
- data/lib/active_support/core_ext/object/json.rb +205 -0
- data/lib/active_support/core_ext/object/to_param.rb +1 -55
- data/lib/active_support/core_ext/object/to_query.rb +66 -9
- data/lib/active_support/core_ext/object/try.rb +124 -33
- data/lib/active_support/core_ext/object/with_options.rb +37 -11
- data/lib/active_support/core_ext/object.rb +2 -1
- data/lib/active_support/core_ext/range/conversions.rb +17 -7
- data/lib/active_support/core_ext/range/each.rb +21 -0
- data/lib/active_support/core_ext/range/include_range.rb +20 -18
- data/lib/active_support/core_ext/range/overlaps.rb +1 -1
- data/lib/active_support/core_ext/range.rb +1 -2
- data/lib/active_support/core_ext/securerandom.rb +23 -0
- data/lib/active_support/core_ext/string/access.rb +95 -90
- data/lib/active_support/core_ext/string/behavior.rb +1 -1
- data/lib/active_support/core_ext/string/conversions.rb +41 -38
- data/lib/active_support/core_ext/string/exclude.rb +6 -1
- data/lib/active_support/core_ext/string/filters.rb +70 -17
- data/lib/active_support/core_ext/string/indent.rb +43 -0
- data/lib/active_support/core_ext/string/inflections.rb +139 -59
- data/lib/active_support/core_ext/string/inquiry.rb +2 -2
- data/lib/active_support/core_ext/string/multibyte.rb +46 -65
- data/lib/active_support/core_ext/string/output_safety.rb +153 -56
- data/lib/active_support/core_ext/string/strip.rb +3 -6
- data/lib/active_support/core_ext/string/zones.rb +14 -0
- data/lib/active_support/core_ext/string.rb +2 -3
- data/lib/active_support/core_ext/struct.rb +3 -0
- data/lib/active_support/core_ext/time/calculations.rb +173 -173
- data/lib/active_support/core_ext/time/compatibility.rb +5 -0
- data/lib/active_support/core_ext/time/conversions.rb +33 -29
- data/lib/active_support/core_ext/time/marshal.rb +2 -56
- data/lib/active_support/core_ext/time/zones.rb +57 -32
- data/lib/active_support/core_ext/time.rb +5 -0
- data/lib/active_support/core_ext/uri.rb +13 -19
- data/lib/active_support/core_ext.rb +3 -2
- data/lib/active_support/dependencies/autoload.rb +47 -20
- data/lib/active_support/dependencies/interlock.rb +51 -0
- data/lib/active_support/dependencies.rb +315 -265
- data/lib/active_support/deprecation/behaviors.rb +71 -30
- data/lib/active_support/deprecation/instance_delegator.rb +24 -0
- data/lib/active_support/deprecation/method_wrappers.rb +59 -18
- data/lib/active_support/deprecation/proxy_wrappers.rb +82 -14
- data/lib/active_support/deprecation/reporting.rb +61 -14
- data/lib/active_support/deprecation.rb +38 -13
- data/lib/active_support/descendants_tracker.rb +34 -19
- data/lib/active_support/duration/iso8601_parser.rb +122 -0
- data/lib/active_support/duration/iso8601_serializer.rb +51 -0
- data/lib/active_support/duration.rb +85 -14
- data/lib/active_support/evented_file_update_checker.rb +194 -0
- data/lib/active_support/execution_wrapper.rb +117 -0
- data/lib/active_support/executor.rb +6 -0
- data/lib/active_support/file_update_checker.rb +138 -17
- data/lib/active_support/gem_version.rb +15 -0
- data/lib/active_support/gzip.rb +11 -5
- data/lib/active_support/hash_with_indifferent_access.rb +199 -49
- data/lib/active_support/i18n.rb +6 -2
- data/lib/active_support/i18n_railtie.rb +40 -21
- data/lib/active_support/inflections.rb +22 -13
- data/lib/active_support/inflector/inflections.rb +175 -144
- data/lib/active_support/inflector/methods.rb +328 -91
- data/lib/active_support/inflector/transliterate.rb +51 -37
- data/lib/active_support/json/decoding.rb +31 -22
- data/lib/active_support/json/encoding.rb +88 -248
- data/lib/active_support/key_generator.rb +71 -0
- data/lib/active_support/lazy_load_hooks.rb +27 -25
- data/lib/active_support/locale/en.yml +102 -3
- data/lib/active_support/log_subscriber/test_helper.rb +24 -21
- data/lib/active_support/log_subscriber.rb +36 -49
- data/lib/active_support/logger.rb +106 -0
- data/lib/active_support/logger_silence.rb +28 -0
- data/lib/active_support/logger_thread_safe_level.rb +31 -0
- data/lib/active_support/message_encryptor.rb +72 -36
- data/lib/active_support/message_verifier.rb +96 -24
- data/lib/active_support/multibyte/chars.rb +88 -333
- data/lib/active_support/multibyte/unicode.rb +156 -136
- data/lib/active_support/multibyte.rb +5 -28
- data/lib/active_support/notifications/fanout.rb +115 -19
- data/lib/active_support/notifications/instrumenter.rb +52 -15
- data/lib/active_support/notifications.rb +168 -33
- data/lib/active_support/number_helper/number_converter.rb +182 -0
- data/lib/active_support/number_helper/number_to_currency_converter.rb +44 -0
- data/lib/active_support/number_helper/number_to_delimited_converter.rb +28 -0
- data/lib/active_support/number_helper/number_to_human_converter.rb +68 -0
- data/lib/active_support/number_helper/number_to_human_size_converter.rb +62 -0
- data/lib/active_support/number_helper/number_to_percentage_converter.rb +12 -0
- data/lib/active_support/number_helper/number_to_phone_converter.rb +58 -0
- data/lib/active_support/number_helper/number_to_rounded_converter.rb +92 -0
- data/lib/active_support/number_helper.rb +368 -0
- data/lib/active_support/option_merger.rb +1 -1
- data/lib/active_support/ordered_hash.rb +18 -183
- data/lib/active_support/ordered_options.rb +44 -24
- data/lib/active_support/per_thread_registry.rb +58 -0
- data/lib/active_support/proxy_object.rb +13 -0
- data/lib/active_support/rails.rb +27 -0
- data/lib/active_support/railtie.rb +25 -34
- data/lib/active_support/reloader.rb +129 -0
- data/lib/active_support/rescuable.rb +98 -48
- data/lib/active_support/security_utils.rb +27 -0
- data/lib/active_support/string_inquirer.rb +14 -9
- data/lib/active_support/subscriber.rb +120 -0
- data/lib/active_support/tagged_logging.rb +78 -0
- data/lib/active_support/test_case.rb +69 -17
- data/lib/active_support/testing/assertions.rb +43 -41
- data/lib/active_support/testing/autorun.rb +12 -0
- data/lib/active_support/testing/constant_lookup.rb +50 -0
- data/lib/active_support/testing/declarative.rb +7 -21
- data/lib/active_support/testing/deprecation.rb +14 -33
- data/lib/active_support/testing/file_fixtures.rb +34 -0
- data/lib/active_support/testing/isolation.rb +53 -95
- data/lib/active_support/testing/method_call_assertions.rb +41 -0
- data/lib/active_support/testing/setup_and_teardown.rb +21 -82
- data/lib/active_support/testing/stream.rb +42 -0
- data/lib/active_support/testing/tagged_logging.rb +25 -0
- data/lib/active_support/testing/time_helpers.rb +134 -0
- data/lib/active_support/time.rb +6 -23
- data/lib/active_support/time_with_zone.rb +239 -92
- data/lib/active_support/values/time_zone.rb +236 -160
- data/lib/active_support/values/unicode_tables.dat +0 -0
- data/lib/active_support/version.rb +5 -7
- data/lib/active_support/xml_mini/jdom.rb +19 -13
- data/lib/active_support/xml_mini/libxml.rb +3 -4
- data/lib/active_support/xml_mini/libxmlsax.rb +2 -3
- data/lib/active_support/xml_mini/nokogiri.rb +3 -4
- data/lib/active_support/xml_mini/nokogirisax.rb +2 -3
- data/lib/active_support/xml_mini/rexml.rb +8 -10
- data/lib/active_support/xml_mini.rb +66 -34
- data/lib/active_support.rb +40 -23
- metadata +185 -134
- data/CHANGELOG +0 -1534
- data/lib/active_support/base64.rb +0 -42
- data/lib/active_support/basic_object.rb +0 -21
- data/lib/active_support/buffered_logger.rb +0 -137
- data/lib/active_support/cache/compressed_mem_cache_store.rb +0 -13
- data/lib/active_support/cache/synchronized_memory_store.rb +0 -11
- data/lib/active_support/core_ext/array/random_access.rb +0 -30
- data/lib/active_support/core_ext/array/uniq_by.rb +0 -16
- data/lib/active_support/core_ext/class/delegating_attributes.rb +0 -44
- data/lib/active_support/core_ext/class/inheritable_attributes.rb +0 -178
- data/lib/active_support/core_ext/date/freeze.rb +0 -31
- data/lib/active_support/core_ext/date_time/zones.rb +0 -21
- 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 -11
- data/lib/active_support/core_ext/hash/diff.rb +0 -13
- data/lib/active_support/core_ext/kernel/requires.rb +0 -28
- data/lib/active_support/core_ext/logger.rb +0 -81
- data/lib/active_support/core_ext/module/attr_accessor_with_default.rb +0 -31
- data/lib/active_support/core_ext/module/method_names.rb +0 -14
- data/lib/active_support/core_ext/module/synchronization.rb +0 -43
- data/lib/active_support/core_ext/object/to_json.rb +0 -19
- data/lib/active_support/core_ext/proc.rb +0 -14
- 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/encoding.rb +0 -11
- 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/file_watcher.rb +0 -36
- data/lib/active_support/json/variable.rb +0 -9
- data/lib/active_support/memoizable.rb +0 -105
- 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/secure_random.rb +0 -6
- data/lib/active_support/testing/mochaing.rb +0 -7
- data/lib/active_support/testing/pending.rb +0 -52
- 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 -60
@@ -1,42 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'base64'
|
3
|
-
rescue LoadError
|
4
|
-
end
|
5
|
-
|
6
|
-
module ActiveSupport
|
7
|
-
if defined? ::Base64
|
8
|
-
Base64 = ::Base64
|
9
|
-
else
|
10
|
-
# Base64 provides utility methods for encoding and de-coding binary data
|
11
|
-
# using a base 64 representation. A base 64 representation of binary data
|
12
|
-
# consists entirely of printable US-ASCII characters. The Base64 module
|
13
|
-
# is included in Ruby 1.8, but has been removed in Ruby 1.9.
|
14
|
-
module Base64
|
15
|
-
# Encodes a string to its base 64 representation. Each 60 characters of
|
16
|
-
# output is separated by a newline character.
|
17
|
-
#
|
18
|
-
# ActiveSupport::Base64.encode64("Original unencoded string")
|
19
|
-
# # => "T3JpZ2luYWwgdW5lbmNvZGVkIHN0cmluZw==\n"
|
20
|
-
def self.encode64(data)
|
21
|
-
[data].pack("m")
|
22
|
-
end
|
23
|
-
|
24
|
-
# Decodes a base 64 encoded string to its original representation.
|
25
|
-
#
|
26
|
-
# ActiveSupport::Base64.decode64("T3JpZ2luYWwgdW5lbmNvZGVkIHN0cmluZw==")
|
27
|
-
# # => "Original unencoded string"
|
28
|
-
def self.decode64(data)
|
29
|
-
data.unpack("m").first
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# Encodes the value as base64 without the newline breaks. This makes the base64 encoding readily usable as URL parameters
|
35
|
-
# or memcache keys without further processing.
|
36
|
-
#
|
37
|
-
# ActiveSupport::Base64.encode64s("Original unencoded string")
|
38
|
-
# # => "T3JpZ2luYWwgdW5lbmNvZGVkIHN0cmluZw=="
|
39
|
-
def Base64.encode64s(value)
|
40
|
-
encode64(value).gsub(/\n/, '')
|
41
|
-
end
|
42
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module ActiveSupport
|
2
|
-
if defined? ::BasicObject
|
3
|
-
# A class with no predefined methods that behaves similarly to Builder's
|
4
|
-
# BlankSlate. Used for proxy classes.
|
5
|
-
class BasicObject < ::BasicObject
|
6
|
-
undef_method :==
|
7
|
-
undef_method :equal?
|
8
|
-
|
9
|
-
# Let ActiveSupport::BasicObject at least raise exceptions.
|
10
|
-
def raise(*args)
|
11
|
-
::Object.send(:raise, *args)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
else
|
15
|
-
class BasicObject #:nodoc:
|
16
|
-
instance_methods.each do |m|
|
17
|
-
undef_method(m) if m.to_s !~ /(?:^__|^nil\?$|^send$|^object_id$)/
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,137 +0,0 @@
|
|
1
|
-
require 'thread'
|
2
|
-
require 'active_support/core_ext/class/attribute_accessors'
|
3
|
-
|
4
|
-
module ActiveSupport
|
5
|
-
# Inspired by the buffered logger idea by Ezra
|
6
|
-
class BufferedLogger
|
7
|
-
module Severity
|
8
|
-
DEBUG = 0
|
9
|
-
INFO = 1
|
10
|
-
WARN = 2
|
11
|
-
ERROR = 3
|
12
|
-
FATAL = 4
|
13
|
-
UNKNOWN = 5
|
14
|
-
end
|
15
|
-
include Severity
|
16
|
-
|
17
|
-
MAX_BUFFER_SIZE = 1000
|
18
|
-
|
19
|
-
##
|
20
|
-
# :singleton-method:
|
21
|
-
# Set to false to disable the silencer
|
22
|
-
cattr_accessor :silencer
|
23
|
-
self.silencer = true
|
24
|
-
|
25
|
-
# Silences the logger for the duration of the block.
|
26
|
-
def silence(temporary_level = ERROR)
|
27
|
-
if silencer
|
28
|
-
begin
|
29
|
-
old_logger_level, self.level = level, temporary_level
|
30
|
-
yield self
|
31
|
-
ensure
|
32
|
-
self.level = old_logger_level
|
33
|
-
end
|
34
|
-
else
|
35
|
-
yield self
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
attr_accessor :level
|
40
|
-
attr_reader :auto_flushing
|
41
|
-
|
42
|
-
def initialize(log, level = DEBUG)
|
43
|
-
@level = level
|
44
|
-
@buffer = Hash.new { |h,k| h[k] = [] }
|
45
|
-
@auto_flushing = 1
|
46
|
-
@guard = Mutex.new
|
47
|
-
|
48
|
-
if log.respond_to?(:write)
|
49
|
-
@log = log
|
50
|
-
elsif File.exist?(log)
|
51
|
-
@log = open_log(log, (File::WRONLY | File::APPEND))
|
52
|
-
else
|
53
|
-
FileUtils.mkdir_p(File.dirname(log))
|
54
|
-
@log = open_log(log, (File::WRONLY | File::APPEND | File::CREAT))
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def open_log(log, mode)
|
59
|
-
open(log, mode).tap do |open_log|
|
60
|
-
open_log.set_encoding(Encoding::BINARY) if open_log.respond_to?(:set_encoding)
|
61
|
-
open_log.sync = true
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def add(severity, message = nil, progname = nil, &block)
|
66
|
-
return if @level > severity
|
67
|
-
message = (message || (block && block.call) || progname).to_s
|
68
|
-
# If a newline is necessary then create a new message ending with a newline.
|
69
|
-
# Ensures that the original message is not mutated.
|
70
|
-
message = "#{message}\n" unless message[-1] == ?\n
|
71
|
-
buffer << message
|
72
|
-
auto_flush
|
73
|
-
message
|
74
|
-
end
|
75
|
-
|
76
|
-
# Dynamically add methods such as:
|
77
|
-
# def info
|
78
|
-
# def warn
|
79
|
-
# def debug
|
80
|
-
for severity in Severity.constants
|
81
|
-
class_eval <<-EOT, __FILE__, __LINE__ + 1
|
82
|
-
def #{severity.downcase}(message = nil, progname = nil, &block) # def debug(message = nil, progname = nil, &block)
|
83
|
-
add(#{severity}, message, progname, &block) # add(DEBUG, message, progname, &block)
|
84
|
-
end # end
|
85
|
-
|
86
|
-
def #{severity.downcase}? # def debug?
|
87
|
-
#{severity} >= @level # DEBUG >= @level
|
88
|
-
end # end
|
89
|
-
EOT
|
90
|
-
end
|
91
|
-
|
92
|
-
# Set the auto-flush period. Set to true to flush after every log message,
|
93
|
-
# to an integer to flush every N messages, or to false, nil, or zero to
|
94
|
-
# never auto-flush. If you turn auto-flushing off, be sure to regularly
|
95
|
-
# flush the log yourself -- it will eat up memory until you do.
|
96
|
-
def auto_flushing=(period)
|
97
|
-
@auto_flushing =
|
98
|
-
case period
|
99
|
-
when true; 1
|
100
|
-
when false, nil, 0; MAX_BUFFER_SIZE
|
101
|
-
when Integer; period
|
102
|
-
else raise ArgumentError, "Unrecognized auto_flushing period: #{period.inspect}"
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
def flush
|
107
|
-
@guard.synchronize do
|
108
|
-
buffer.each do |content|
|
109
|
-
@log.write(content)
|
110
|
-
end
|
111
|
-
|
112
|
-
# Important to do this even if buffer was empty or else @buffer will
|
113
|
-
# accumulate empty arrays for each request where nothing was logged.
|
114
|
-
clear_buffer
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
def close
|
119
|
-
flush
|
120
|
-
@log.close if @log.respond_to?(:close)
|
121
|
-
@log = nil
|
122
|
-
end
|
123
|
-
|
124
|
-
protected
|
125
|
-
def auto_flush
|
126
|
-
flush if buffer.size >= @auto_flushing
|
127
|
-
end
|
128
|
-
|
129
|
-
def buffer
|
130
|
-
@buffer[Thread.current]
|
131
|
-
end
|
132
|
-
|
133
|
-
def clear_buffer
|
134
|
-
@buffer.delete(Thread.current)
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module ActiveSupport
|
2
|
-
module Cache
|
3
|
-
class CompressedMemCacheStore < MemCacheStore
|
4
|
-
def initialize(*args)
|
5
|
-
ActiveSupport::Deprecation.warn('ActiveSupport::Cache::CompressedMemCacheStore has been deprecated in favor of ActiveSupport::Cache::MemCacheStore(:compress => true).', caller)
|
6
|
-
addresses = args.dup
|
7
|
-
options = addresses.extract_options!
|
8
|
-
args = addresses + [options.merge(:compress => true)]
|
9
|
-
super(*args)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
module ActiveSupport
|
2
|
-
module Cache
|
3
|
-
# Like MemoryStore, but thread-safe.
|
4
|
-
class SynchronizedMemoryStore < MemoryStore
|
5
|
-
def initialize(*args)
|
6
|
-
ActiveSupport::Deprecation.warn('ActiveSupport::Cache::SynchronizedMemoryStore has been deprecated in favor of ActiveSupport::Cache::MemoryStore.', caller)
|
7
|
-
super
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
11
|
-
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,16 +0,0 @@
|
|
1
|
-
class Array
|
2
|
-
# Returns an unique array based on the criteria given as a +Proc+.
|
3
|
-
#
|
4
|
-
# [1, 2, 3, 4].uniq_by { |i| i.odd? } # => [1, 2]
|
5
|
-
#
|
6
|
-
def uniq_by
|
7
|
-
hash, array = {}, []
|
8
|
-
each { |i| hash[yield(i)] ||= (array << i) }
|
9
|
-
array
|
10
|
-
end
|
11
|
-
|
12
|
-
# Same as uniq_by, but modifies self.
|
13
|
-
def uniq_by!
|
14
|
-
replace(uniq_by{ |i| yield(i) })
|
15
|
-
end
|
16
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'active_support/core_ext/object/blank'
|
2
|
-
require 'active_support/core_ext/array/extract_options'
|
3
|
-
require 'active_support/core_ext/kernel/singleton_class'
|
4
|
-
require 'active_support/core_ext/module/remove_method'
|
5
|
-
|
6
|
-
class Class
|
7
|
-
def superclass_delegating_accessor(name, options = {})
|
8
|
-
# Create private _name and _name= methods that can still be used if the public
|
9
|
-
# methods are overridden. This allows
|
10
|
-
_superclass_delegating_accessor("_#{name}")
|
11
|
-
|
12
|
-
# Generate the public methods name, name=, and name?
|
13
|
-
# These methods dispatch to the private _name, and _name= methods, making them
|
14
|
-
# overridable
|
15
|
-
singleton_class.send(:define_method, name) { send("_#{name}") }
|
16
|
-
singleton_class.send(:define_method, "#{name}?") { !!send("_#{name}") }
|
17
|
-
singleton_class.send(:define_method, "#{name}=") { |value| send("_#{name}=", value) }
|
18
|
-
|
19
|
-
# If an instance_reader is needed, generate methods for name and name= on the
|
20
|
-
# class itself, so instances will be able to see them
|
21
|
-
define_method(name) { send("_#{name}") } if options[:instance_reader] != false
|
22
|
-
define_method("#{name}?") { !!send("#{name}") } if options[:instance_reader] != false
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
# Take the object being set and store it in a method. This gives us automatic
|
28
|
-
# inheritance behavior, without having to store the object in an instance
|
29
|
-
# variable and look up the superclass chain manually.
|
30
|
-
def _stash_object_in_method(object, method, instance_reader = true)
|
31
|
-
singleton_class.remove_possible_method(method)
|
32
|
-
singleton_class.send(:define_method, method) { object }
|
33
|
-
remove_possible_method(method)
|
34
|
-
define_method(method) { object } if instance_reader
|
35
|
-
end
|
36
|
-
|
37
|
-
def _superclass_delegating_accessor(name, options = {})
|
38
|
-
singleton_class.send(:define_method, "#{name}=") do |value|
|
39
|
-
_stash_object_in_method(value, name, options[:instance_reader] != false)
|
40
|
-
end
|
41
|
-
send("#{name}=", nil)
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
@@ -1,178 +0,0 @@
|
|
1
|
-
require 'active_support/core_ext/object/duplicable'
|
2
|
-
require 'active_support/core_ext/array/extract_options'
|
3
|
-
require 'active_support/deprecation'
|
4
|
-
|
5
|
-
# Retained for backward compatibility. Methods are now included in Class.
|
6
|
-
module ClassInheritableAttributes # :nodoc:
|
7
|
-
DEPRECATION_WARNING_MESSAGE = "class_inheritable_attribute is deprecated, please use class_attribute method instead. Notice their behavior are slightly different, so refer to class_attribute documentation first"
|
8
|
-
end
|
9
|
-
|
10
|
-
# It is recommended to use <tt>class_attribute</tt> over methods defined in this file. Please
|
11
|
-
# refer to documentation for <tt>class_attribute</tt> for more information. Officially it is not
|
12
|
-
# deprecated but <tt>class_attribute</tt> is faster.
|
13
|
-
#
|
14
|
-
# Allows attributes to be shared within an inheritance hierarchy. Each descendant gets a copy of
|
15
|
-
# their parents' attributes, instead of just a pointer to the same. This means that the child can add elements
|
16
|
-
# to, for example, an array without those additions being shared with either their parent, siblings, or
|
17
|
-
# children. This is unlike the regular class-level attributes that are shared across the entire hierarchy.
|
18
|
-
#
|
19
|
-
# The copies of inheritable parent attributes are added to subclasses when they are created, via the
|
20
|
-
# +inherited+ hook.
|
21
|
-
#
|
22
|
-
# class Person
|
23
|
-
# class_inheritable_accessor :hair_colors
|
24
|
-
# end
|
25
|
-
#
|
26
|
-
# Person.hair_colors = [:brown, :black, :blonde, :red]
|
27
|
-
# Person.hair_colors # => [:brown, :black, :blonde, :red]
|
28
|
-
# Person.new.hair_colors # => [:brown, :black, :blonde, :red]
|
29
|
-
#
|
30
|
-
# To opt out of the instance writer method, pass :instance_writer => false.
|
31
|
-
# To opt out of the instance reader method, pass :instance_reader => false.
|
32
|
-
#
|
33
|
-
# class Person
|
34
|
-
# class_inheritable_accessor :hair_colors :instance_writer => false, :instance_reader => false
|
35
|
-
# end
|
36
|
-
#
|
37
|
-
# Person.new.hair_colors = [:brown] # => NoMethodError
|
38
|
-
# Person.new.hair_colors # => NoMethodError
|
39
|
-
class Class # :nodoc:
|
40
|
-
def class_inheritable_reader(*syms)
|
41
|
-
ActiveSupport::Deprecation.warn ClassInheritableAttributes::DEPRECATION_WARNING_MESSAGE
|
42
|
-
options = syms.extract_options!
|
43
|
-
syms.each do |sym|
|
44
|
-
next if sym.is_a?(Hash)
|
45
|
-
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
46
|
-
def self.#{sym} # def self.after_add
|
47
|
-
read_inheritable_attribute(:#{sym}) # read_inheritable_attribute(:after_add)
|
48
|
-
end # end
|
49
|
-
#
|
50
|
-
#{" #
|
51
|
-
def #{sym} # def after_add
|
52
|
-
self.class.#{sym} # self.class.after_add
|
53
|
-
end # end
|
54
|
-
" unless options[:instance_reader] == false } # # the reader above is generated unless options[:instance_reader] == false
|
55
|
-
EOS
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def class_inheritable_writer(*syms)
|
60
|
-
ActiveSupport::Deprecation.warn ClassInheritableAttributes::DEPRECATION_WARNING_MESSAGE
|
61
|
-
options = syms.extract_options!
|
62
|
-
syms.each do |sym|
|
63
|
-
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
64
|
-
def self.#{sym}=(obj) # def self.color=(obj)
|
65
|
-
write_inheritable_attribute(:#{sym}, obj) # write_inheritable_attribute(:color, obj)
|
66
|
-
end # end
|
67
|
-
#
|
68
|
-
#{" #
|
69
|
-
def #{sym}=(obj) # def color=(obj)
|
70
|
-
self.class.#{sym} = obj # self.class.color = obj
|
71
|
-
end # end
|
72
|
-
" unless options[:instance_writer] == false } # # the writer above is generated unless options[:instance_writer] == false
|
73
|
-
EOS
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def class_inheritable_array_writer(*syms)
|
78
|
-
ActiveSupport::Deprecation.warn ClassInheritableAttributes::DEPRECATION_WARNING_MESSAGE
|
79
|
-
options = syms.extract_options!
|
80
|
-
syms.each do |sym|
|
81
|
-
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
82
|
-
def self.#{sym}=(obj) # def self.levels=(obj)
|
83
|
-
write_inheritable_array(:#{sym}, obj) # write_inheritable_array(:levels, obj)
|
84
|
-
end # end
|
85
|
-
#
|
86
|
-
#{" #
|
87
|
-
def #{sym}=(obj) # def levels=(obj)
|
88
|
-
self.class.#{sym} = obj # self.class.levels = obj
|
89
|
-
end # end
|
90
|
-
" unless options[:instance_writer] == false } # # the writer above is generated unless options[:instance_writer] == false
|
91
|
-
EOS
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def class_inheritable_hash_writer(*syms)
|
96
|
-
ActiveSupport::Deprecation.warn ClassInheritableAttributes::DEPRECATION_WARNING_MESSAGE
|
97
|
-
options = syms.extract_options!
|
98
|
-
syms.each do |sym|
|
99
|
-
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
100
|
-
def self.#{sym}=(obj) # def self.nicknames=(obj)
|
101
|
-
write_inheritable_hash(:#{sym}, obj) # write_inheritable_hash(:nicknames, obj)
|
102
|
-
end # end
|
103
|
-
#
|
104
|
-
#{" #
|
105
|
-
def #{sym}=(obj) # def nicknames=(obj)
|
106
|
-
self.class.#{sym} = obj # self.class.nicknames = obj
|
107
|
-
end # end
|
108
|
-
" unless options[:instance_writer] == false } # # the writer above is generated unless options[:instance_writer] == false
|
109
|
-
EOS
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
def class_inheritable_accessor(*syms)
|
114
|
-
class_inheritable_reader(*syms)
|
115
|
-
class_inheritable_writer(*syms)
|
116
|
-
end
|
117
|
-
|
118
|
-
def class_inheritable_array(*syms)
|
119
|
-
class_inheritable_reader(*syms)
|
120
|
-
class_inheritable_array_writer(*syms)
|
121
|
-
end
|
122
|
-
|
123
|
-
def class_inheritable_hash(*syms)
|
124
|
-
class_inheritable_reader(*syms)
|
125
|
-
class_inheritable_hash_writer(*syms)
|
126
|
-
end
|
127
|
-
|
128
|
-
def inheritable_attributes
|
129
|
-
@inheritable_attributes ||= EMPTY_INHERITABLE_ATTRIBUTES
|
130
|
-
end
|
131
|
-
|
132
|
-
def write_inheritable_attribute(key, value)
|
133
|
-
if inheritable_attributes.equal?(EMPTY_INHERITABLE_ATTRIBUTES)
|
134
|
-
@inheritable_attributes = {}
|
135
|
-
end
|
136
|
-
inheritable_attributes[key] = value
|
137
|
-
end
|
138
|
-
|
139
|
-
def write_inheritable_array(key, elements)
|
140
|
-
write_inheritable_attribute(key, []) if read_inheritable_attribute(key).nil?
|
141
|
-
write_inheritable_attribute(key, read_inheritable_attribute(key) + elements)
|
142
|
-
end
|
143
|
-
|
144
|
-
def write_inheritable_hash(key, hash)
|
145
|
-
write_inheritable_attribute(key, {}) if read_inheritable_attribute(key).nil?
|
146
|
-
write_inheritable_attribute(key, read_inheritable_attribute(key).merge(hash))
|
147
|
-
end
|
148
|
-
|
149
|
-
def read_inheritable_attribute(key)
|
150
|
-
inheritable_attributes[key]
|
151
|
-
end
|
152
|
-
|
153
|
-
def reset_inheritable_attributes
|
154
|
-
ActiveSupport::Deprecation.warn ClassInheritableAttributes::DEPRECATION_WARNING_MESSAGE
|
155
|
-
@inheritable_attributes = EMPTY_INHERITABLE_ATTRIBUTES
|
156
|
-
end
|
157
|
-
|
158
|
-
private
|
159
|
-
# Prevent this constant from being created multiple times
|
160
|
-
EMPTY_INHERITABLE_ATTRIBUTES = {}.freeze
|
161
|
-
|
162
|
-
def inherited_with_inheritable_attributes(child)
|
163
|
-
inherited_without_inheritable_attributes(child) if respond_to?(:inherited_without_inheritable_attributes)
|
164
|
-
|
165
|
-
if inheritable_attributes.equal?(EMPTY_INHERITABLE_ATTRIBUTES)
|
166
|
-
new_inheritable_attributes = EMPTY_INHERITABLE_ATTRIBUTES
|
167
|
-
else
|
168
|
-
new_inheritable_attributes = Hash[inheritable_attributes.map do |(key, value)|
|
169
|
-
[key, value.duplicable? ? value.dup : value]
|
170
|
-
end]
|
171
|
-
end
|
172
|
-
|
173
|
-
child.instance_variable_set('@inheritable_attributes', new_inheritable_attributes)
|
174
|
-
end
|
175
|
-
|
176
|
-
alias inherited_without_inheritable_attributes inherited
|
177
|
-
alias inherited inherited_with_inheritable_attributes
|
178
|
-
end
|
@@ -1,31 +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 freezing.
|
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
|
-
self.class.private_instance_methods(false).each do |m|
|
21
|
-
if m.to_s =~ /\A__\d+__\Z/
|
22
|
-
instance_variable_set(:"@#{m}", [send(m)])
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
super
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'active_support/core_ext/time/zones'
|
2
|
-
|
3
|
-
class DateTime
|
4
|
-
# Returns the simultaneous time in <tt>Time.zone</tt>.
|
5
|
-
#
|
6
|
-
# Time.zone = 'Hawaii' # => 'Hawaii'
|
7
|
-
# DateTime.new(2000).in_time_zone # => Fri, 31 Dec 1999 14:00:00 HST -10:00
|
8
|
-
#
|
9
|
-
# This method is similar to Time#localtime, except that it uses <tt>Time.zone</tt> as the local zone
|
10
|
-
# instead of the operating system's time zone.
|
11
|
-
#
|
12
|
-
# You can also pass in a TimeZone instance or string that identifies a TimeZone as an argument,
|
13
|
-
# and the conversion will be based on that zone instead of <tt>Time.zone</tt>.
|
14
|
-
#
|
15
|
-
# DateTime.new(2000).in_time_zone('Alaska') # => Fri, 31 Dec 1999 15:00:00 AKST -09:00
|
16
|
-
def in_time_zone(zone = ::Time.zone)
|
17
|
-
return self unless zone
|
18
|
-
|
19
|
-
ActiveSupport::TimeWithZone.new(utc? ? self : getutc, ::Time.find_zone!(zone))
|
20
|
-
end
|
21
|
-
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,13 +0,0 @@
|
|
1
|
-
class Hash
|
2
|
-
# Returns a hash that represents the difference between two hashes.
|
3
|
-
#
|
4
|
-
# Examples:
|
5
|
-
#
|
6
|
-
# {1 => 2}.diff(1 => 2) # => {}
|
7
|
-
# {1 => 2}.diff(1 => 3) # => {1 => 2}
|
8
|
-
# {}.diff(1 => 2) # => {1 => 2}
|
9
|
-
# {1 => 2, 3 => 4}.diff(1 => 2) # => {3 => 4}
|
10
|
-
def diff(h2)
|
11
|
-
dup.delete_if { |k, v| h2[k] == v }.merge!(h2.dup.delete_if { |k, v| has_key?(k) })
|
12
|
-
end
|
13
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'active_support/core_ext/kernel/reporting'
|
2
|
-
require 'active_support/core_ext/module/deprecation'
|
3
|
-
|
4
|
-
module Kernel
|
5
|
-
# Require a library with fallback to RubyGems. Warnings during library
|
6
|
-
# loading are silenced to increase signal/noise for application warnings.
|
7
|
-
def require_library_or_gem(library_name)
|
8
|
-
silence_warnings do
|
9
|
-
begin
|
10
|
-
require library_name
|
11
|
-
rescue LoadError => cannot_require
|
12
|
-
# 1. Requiring the module is unsuccessful, maybe it's a gem and nobody required rubygems yet. Try.
|
13
|
-
begin
|
14
|
-
require 'rubygems'
|
15
|
-
rescue LoadError # => rubygems_not_installed
|
16
|
-
raise cannot_require
|
17
|
-
end
|
18
|
-
# 2. Rubygems is installed and loaded. Try to load the library again
|
19
|
-
begin
|
20
|
-
require library_name
|
21
|
-
rescue LoadError # => gem_not_installed
|
22
|
-
raise cannot_require
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
deprecate :require_library_or_gem
|
28
|
-
end
|