From a9128c543c38c3a358cd5e62c86b24f878dd9769 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 17 Sep 2018 04:11:09 +0200 Subject: [PATCH 1/5] =?UTF-8?q?Use=20ActiveSupport=E2=80=99s=20`#days`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Library/Homebrew/cleanup.rb | 10 +- Library/Homebrew/compat/cask/cmd/cleanup.rb | 3 - Library/Homebrew/global.rb | 1 + Library/Homebrew/test/cleanup_spec.rb | 8 +- .../lib/active_support/core_ext/array.rb | 9 + .../active_support/core_ext/array/access.rb | 92 +++ .../core_ext/array/conversions.rb | 213 ++++++ .../core_ext/array/extract_options.rb | 31 + .../active_support/core_ext/array/grouping.rb | 109 +++ .../active_support/core_ext/array/inquiry.rb | 19 + .../core_ext/array/prepend_and_append.rb | 9 + .../lib/active_support/core_ext/array/wrap.rb | 48 ++ .../lib/active_support/core_ext/benchmark.rb | 16 + .../active_support/core_ext/big_decimal.rb | 3 + .../core_ext/big_decimal/conversions.rb | 14 + .../lib/active_support/core_ext/class.rb | 4 + .../core_ext/class/attribute.rb | 146 ++++ .../core_ext/class/attribute_accessors.rb | 6 + .../core_ext/class/subclasses.rb | 54 ++ .../lib/active_support/core_ext/date.rb | 7 + .../active_support/core_ext/date/acts_like.rb | 10 + .../lib/active_support/core_ext/date/blank.rb | 14 + .../core_ext/date/calculations.rb | 145 ++++ .../core_ext/date/conversions.rb | 96 +++ .../lib/active_support/core_ext/date/zones.rb | 8 + .../core_ext/date_and_time/calculations.rb | 374 ++++++++++ .../core_ext/date_and_time/compatibility.rb | 16 + .../core_ext/date_and_time/zones.rb | 41 ++ .../lib/active_support/core_ext/date_time.rb | 7 + .../core_ext/date_time/acts_like.rb | 16 + .../core_ext/date_time/blank.rb | 14 + .../core_ext/date_time/calculations.rb | 211 ++++++ .../core_ext/date_time/compatibility.rb | 18 + .../core_ext/date_time/conversions.rb | 107 +++ .../active_support/core_ext/digest/uuid.rb | 53 ++ .../lib/active_support/core_ext/enumerable.rb | 164 +++++ .../lib/active_support/core_ext/file.rb | 3 + .../lib/active_support/core_ext/hash.rb | 11 + .../active_support/core_ext/hash/compact.rb | 29 + .../core_ext/hash/conversions.rb | 263 +++++++ .../active_support/core_ext/hash/except.rb | 24 + .../core_ext/hash/indifferent_access.rb | 24 + .../lib/active_support/core_ext/hash/keys.rb | 172 +++++ .../core_ext/hash/reverse_merge.rb | 25 + .../lib/active_support/core_ext/hash/slice.rb | 48 ++ .../core_ext/hash/transform_values.rb | 32 + .../lib/active_support/core_ext/integer.rb | 5 + .../core_ext/integer/inflections.rb | 31 + .../core_ext/integer/multiple.rb | 12 + .../active_support/core_ext/integer/time.rb | 22 + .../lib/active_support/core_ext/kernel.rb | 6 + .../core_ext/kernel/agnostics.rb | 13 + .../active_support/core_ext/kernel/concern.rb | 14 + .../core_ext/kernel/reporting.rb | 45 ++ .../core_ext/kernel/singleton_class.rb | 8 + .../lib/active_support/core_ext/load_error.rb | 9 + .../lib/active_support/core_ext/marshal.rb | 24 + .../lib/active_support/core_ext/module.rb | 14 + .../core_ext/module/aliasing.rb | 31 + .../core_ext/module/anonymous.rb | 30 + .../core_ext/module/attr_internal.rb | 38 + .../core_ext/module/attribute_accessors.rb | 215 ++++++ .../module/attribute_accessors_per_thread.rb | 150 ++++ .../core_ext/module/concerning.rb | 134 ++++ .../core_ext/module/delegation.rb | 287 ++++++++ .../core_ext/module/deprecation.rb | 25 + .../core_ext/module/introspection.rb | 62 ++ .../core_ext/module/reachable.rb | 11 + .../core_ext/module/redefine_method.rb | 49 ++ .../core_ext/module/remove_method.rb | 17 + .../lib/active_support/core_ext/name_error.rb | 38 + .../lib/active_support/core_ext/numeric.rb | 6 + .../active_support/core_ext/numeric/bytes.rb | 66 ++ .../core_ext/numeric/conversions.rb | 140 ++++ .../core_ext/numeric/inquiry.rb | 28 + .../active_support/core_ext/numeric/time.rb | 66 ++ .../lib/active_support/core_ext/object.rb | 16 + .../core_ext/object/acts_like.rb | 21 + .../core_ext/object/conversions.rb | 6 + .../core_ext/object/deep_dup.rb | 55 ++ .../core_ext/object/duplicable.rb | 156 ++++ .../core_ext/object/inclusion.rb | 29 + .../core_ext/object/instance_variables.rb | 30 + .../active_support/core_ext/object/json.rb | 227 ++++++ .../core_ext/object/to_param.rb | 3 + .../core_ext/object/to_query.rb | 89 +++ .../lib/active_support/core_ext/object/try.rb | 148 ++++ .../core_ext/object/with_options.rb | 82 +++ .../lib/active_support/core_ext/range.rb | 7 + .../core_ext/range/conversions.rb | 39 + .../lib/active_support/core_ext/range/each.rb | 25 + .../core_ext/range/include_range.rb | 25 + .../core_ext/range/include_time_with_zone.rb | 23 + .../active_support/core_ext/range/overlaps.rb | 10 + .../active_support/core_ext/securerandom.rb | 25 + .../lib/active_support/core_ext/string.rb | 15 + .../active_support/core_ext/string/access.rb | 106 +++ .../core_ext/string/behavior.rb | 8 + .../core_ext/string/conversions.rb | 59 ++ .../active_support/core_ext/string/exclude.rb | 13 + .../active_support/core_ext/string/filters.rb | 104 +++ .../active_support/core_ext/string/indent.rb | 45 ++ .../core_ext/string/inflections.rb | 254 +++++++ .../active_support/core_ext/string/inquiry.rb | 15 + .../core_ext/string/multibyte.rb | 57 ++ .../core_ext/string/output_safety.rb | 258 +++++++ .../core_ext/string/starts_ends_with.rb | 6 + .../active_support/core_ext/string/strip.rb | 25 + .../active_support/core_ext/string/zones.rb | 16 + .../lib/active_support/core_ext/time.rb | 7 + .../active_support/core_ext/time/acts_like.rb | 10 + .../core_ext/time/calculations.rb | 315 +++++++++ .../core_ext/time/compatibility.rb | 16 + .../core_ext/time/conversions.rb | 72 ++ .../lib/active_support/core_ext/time/zones.rb | 113 +++ .../lib/active_support/core_ext/uri.rb | 24 + .../lib/active_support/deprecation.rb | 46 ++ .../active_support/deprecation/behaviors.rb | 109 +++ .../deprecation/constant_accessor.rb | 52 ++ .../deprecation/instance_delegator.rb | 39 + .../deprecation/method_wrappers.rb | 77 ++ .../deprecation/proxy_wrappers.rb | 154 ++++ .../active_support/deprecation/reporting.rb | 114 +++ .../lib/active_support/duration.rb | 432 +++++++++++ .../lib/active_support/i18n.rb | 15 + .../lib/active_support/inflections.rb | 72 ++ .../active_support/inflector/inflections.rb | 260 +++++++ .../lib/active_support/inflector/methods.rb | 408 +++++++++++ .../active_support/inflector/transliterate.rb | 118 +++ .../lib/active_support/lazy_load_hooks.rb | 78 ++ .../lib/active_support/multibyte.rb | 23 + .../lib/active_support/notifications.rb | 216 ++++++ .../active_support/notifications/fanout.rb | 159 +++++ .../notifications/instrumenter.rb | 93 +++ .../lib/active_support/per_thread_registry.rb | 60 ++ .../lib/active_support/time.rb | 20 + .../lib/active_support/time_with_zone.rb | 551 +++++++++++++++ .../lib/active_support/values/time_zone.rb | 565 +++++++++++++++ .../lib/active_support/xml_mini.rb | 209 ++++++ .../lib/active_support/xml_mini/rexml.rb | 130 ++++ .../ruby/2.3.0/gems/i18n-1.1.0/lib/i18n.rb | 372 ++++++++++ .../2.3.0/gems/i18n-1.1.0/lib/i18n/backend.rb | 20 + .../gems/i18n-1.1.0/lib/i18n/backend/base.rb | 258 +++++++ .../gems/i18n-1.1.0/lib/i18n/backend/cache.rb | 116 +++ .../i18n-1.1.0/lib/i18n/backend/cascade.rb | 56 ++ .../gems/i18n-1.1.0/lib/i18n/backend/chain.rb | 99 +++ .../i18n-1.1.0/lib/i18n/backend/fallbacks.rb | 84 +++ .../i18n-1.1.0/lib/i18n/backend/flatten.rb | 115 +++ .../i18n-1.1.0/lib/i18n/backend/gettext.rb | 83 +++ .../i18n/backend/interpolation_compiler.rb | 123 ++++ .../i18n-1.1.0/lib/i18n/backend/key_value.rb | 180 +++++ .../i18n-1.1.0/lib/i18n/backend/memoize.rb | 48 ++ .../i18n-1.1.0/lib/i18n/backend/metadata.rb | 71 ++ .../lib/i18n/backend/pluralization.rb | 55 ++ .../i18n-1.1.0/lib/i18n/backend/simple.rb | 95 +++ .../lib/i18n/backend/transliterator.rb | 108 +++ .../2.3.0/gems/i18n-1.1.0/lib/i18n/config.rb | 149 ++++ .../gems/i18n-1.1.0/lib/i18n/exceptions.rb | 97 +++ .../i18n-1.1.0/lib/i18n/interpolate/ruby.rb | 37 + .../2.3.0/gems/i18n-1.1.0/lib/i18n/version.rb | 5 + .../gems/thread_safe-0.3.6/lib/thread_safe.rb | 65 ++ .../lib/thread_safe/cache.rb | 161 +++++ .../lib/thread_safe/mri_cache_backend.rb | 60 ++ .../non_concurrent_cache_backend.rb | 135 ++++ .../lib/thread_safe/synchronized_delegator.rb | 43 ++ .../lib/thread_safe/version.rb | 21 + .../2.3.0/gems/tzinfo-1.2.5/lib/tzinfo.rb | 40 ++ .../gems/tzinfo-1.2.5/lib/tzinfo/country.rb | 196 +++++ .../lib/tzinfo/country_index_definition.rb | 31 + .../tzinfo-1.2.5/lib/tzinfo/country_info.rb | 42 ++ .../lib/tzinfo/country_timezone.rb | 135 ++++ .../tzinfo-1.2.5/lib/tzinfo/data_source.rb | 190 +++++ .../tzinfo-1.2.5/lib/tzinfo/data_timezone.rb | 58 ++ .../lib/tzinfo/data_timezone_info.rb | 55 ++ .../tzinfo-1.2.5/lib/tzinfo/info_timezone.rb | 30 + .../lib/tzinfo/linked_timezone.rb | 63 ++ .../lib/tzinfo/linked_timezone_info.rb | 26 + .../lib/tzinfo/offset_rationals.rb | 77 ++ .../lib/tzinfo/ruby_core_support.rb | 146 ++++ .../lib/tzinfo/ruby_country_info.rb | 74 ++ .../lib/tzinfo/ruby_data_source.rb | 136 ++++ .../lib/tzinfo/time_or_datetime.rb | 340 +++++++++ .../gems/tzinfo-1.2.5/lib/tzinfo/timezone.rb | 669 ++++++++++++++++++ .../lib/tzinfo/timezone_definition.rb | 36 + .../lib/tzinfo/timezone_index_definition.rb | 54 ++ .../tzinfo-1.2.5/lib/tzinfo/timezone_info.rb | 30 + .../lib/tzinfo/timezone_offset.rb | 101 +++ .../lib/tzinfo/timezone_period.rb | 245 +++++++ .../tzinfo-1.2.5/lib/tzinfo/timezone_proxy.rb | 105 +++ .../lib/tzinfo/timezone_transition.rb | 130 ++++ .../tzinfo/timezone_transition_definition.rb | 104 +++ .../tzinfo/transition_data_timezone_info.rb | 274 +++++++ .../lib/tzinfo/zoneinfo_country_info.rb | 37 + .../lib/tzinfo/zoneinfo_data_source.rb | 488 +++++++++++++ .../lib/tzinfo/zoneinfo_timezone_info.rb | 296 ++++++++ 195 files changed, 17727 insertions(+), 14 deletions(-) create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/array.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/array/access.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/array/conversions.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/array/extract_options.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/array/grouping.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/array/inquiry.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/array/prepend_and_append.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/array/wrap.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/benchmark.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/big_decimal.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/big_decimal/conversions.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/class.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/class/attribute.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/class/attribute_accessors.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/class/subclasses.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date/acts_like.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date/blank.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date/calculations.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date/conversions.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date/zones.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_and_time/calculations.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_and_time/compatibility.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_and_time/zones.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_time.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_time/acts_like.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_time/blank.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_time/calculations.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_time/compatibility.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_time/conversions.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/digest/uuid.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/enumerable.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/file.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/compact.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/conversions.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/except.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/indifferent_access.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/keys.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/reverse_merge.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/slice.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/transform_values.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/integer.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/integer/inflections.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/integer/multiple.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/integer/time.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/kernel.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/kernel/agnostics.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/kernel/concern.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/kernel/reporting.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/kernel/singleton_class.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/load_error.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/marshal.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/aliasing.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/anonymous.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/attr_internal.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/attribute_accessors.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/concerning.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/delegation.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/deprecation.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/introspection.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/reachable.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/redefine_method.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/remove_method.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/name_error.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/numeric.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/numeric/bytes.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/numeric/conversions.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/numeric/inquiry.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/numeric/time.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/acts_like.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/conversions.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/deep_dup.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/duplicable.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/inclusion.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/instance_variables.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/json.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/to_param.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/to_query.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/try.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/with_options.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/range.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/range/conversions.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/range/each.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/range/include_range.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/range/include_time_with_zone.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/range/overlaps.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/securerandom.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/access.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/behavior.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/conversions.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/exclude.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/filters.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/indent.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/inflections.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/inquiry.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/multibyte.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/output_safety.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/starts_ends_with.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/strip.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/zones.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/time.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/time/acts_like.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/time/calculations.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/time/compatibility.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/time/conversions.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/time/zones.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/uri.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/deprecation.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/deprecation/behaviors.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/deprecation/constant_accessor.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/deprecation/instance_delegator.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/deprecation/method_wrappers.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/deprecation/proxy_wrappers.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/deprecation/reporting.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/duration.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/i18n.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/inflections.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/inflector/inflections.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/inflector/methods.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/inflector/transliterate.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/multibyte.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/notifications.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/notifications/fanout.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/notifications/instrumenter.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/per_thread_registry.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/time.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/time_with_zone.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/values/time_zone.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/xml_mini.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/xml_mini/rexml.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/base.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/cache.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/cascade.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/chain.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/fallbacks.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/flatten.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/gettext.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/interpolation_compiler.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/key_value.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/memoize.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/metadata.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/pluralization.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/simple.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/transliterator.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/config.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/exceptions.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/interpolate/ruby.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/version.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/thread_safe-0.3.6/lib/thread_safe.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/thread_safe-0.3.6/lib/thread_safe/cache.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/thread_safe-0.3.6/lib/thread_safe/mri_cache_backend.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/thread_safe-0.3.6/lib/thread_safe/non_concurrent_cache_backend.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/thread_safe-0.3.6/lib/thread_safe/synchronized_delegator.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/thread_safe-0.3.6/lib/thread_safe/version.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/country.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/country_index_definition.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/country_info.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/country_timezone.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/data_source.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/data_timezone.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/data_timezone_info.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/info_timezone.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/linked_timezone.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/linked_timezone_info.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/offset_rationals.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/ruby_core_support.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/ruby_country_info.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/ruby_data_source.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/time_or_datetime.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone_definition.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone_index_definition.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone_info.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone_offset.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone_period.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone_proxy.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone_transition.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone_transition_definition.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/transition_data_timezone_info.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/zoneinfo_country_info.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/zoneinfo_data_source.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/zoneinfo_timezone_info.rb diff --git a/Library/Homebrew/cleanup.rb b/Library/Homebrew/cleanup.rb index 25653a4818..d670a758d2 100644 --- a/Library/Homebrew/cleanup.rb +++ b/Library/Homebrew/cleanup.rb @@ -4,7 +4,7 @@ require "cask/cask_loader" require "set" module CleanupRefinement - LATEST_CASK_DAYS = 7 + LATEST_CASK_OUTDATED = 7.days.ago refine Enumerator do def parallel @@ -51,8 +51,7 @@ module CleanupRefinement return true if symlink? && !exist? - # TODO: Replace with ActiveSupport's `.days.ago`. - mtime < ((@time ||= Time.now) - days * 60 * 60 * 24) + mtime < days.days.ago end def stale?(scrub = false) @@ -124,10 +123,7 @@ module CleanupRefinement return true if scrub && !cask.versions.include?(cask.version) - if cask.version.latest? - # TODO: Replace with ActiveSupport's `.days.ago`. - return mtime < ((@time ||= Time.now) - LATEST_CASK_DAYS * 60 * 60 * 24) - end + return mtime < LATEST_CASK_OUTDATED if cask.version.latest? false end diff --git a/Library/Homebrew/compat/cask/cmd/cleanup.rb b/Library/Homebrew/compat/cask/cmd/cleanup.rb index 06ed45535c..f7f6d9082d 100644 --- a/Library/Homebrew/compat/cask/cmd/cleanup.rb +++ b/Library/Homebrew/compat/cask/cmd/cleanup.rb @@ -6,9 +6,6 @@ using CleanupRefinement module Cask class Cmd class Cleanup < AbstractCommand - OUTDATED_DAYS = 10 - OUTDATED_TIMESTAMP = Time.now - (60 * 60 * 24 * OUTDATED_DAYS) - def self.help "cleans up cached downloads and tracker symlinks" end diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb index 8319ed9bc0..2ca701c870 100644 --- a/Library/Homebrew/global.rb +++ b/Library/Homebrew/global.rb @@ -7,6 +7,7 @@ require "pp" require_relative "load_path" +require "active_support/core_ext/numeric/time" require "config" require "os" require "extend/ARGV" diff --git a/Library/Homebrew/test/cleanup_spec.rb b/Library/Homebrew/test/cleanup_spec.rb index 35eaa19269..d96d238256 100644 --- a/Library/Homebrew/test/cleanup_spec.rb +++ b/Library/Homebrew/test/cleanup_spec.rb @@ -16,7 +16,7 @@ describe CleanupRefinement do end it "returns true when path_modified_time < days_default" do - allow_any_instance_of(Pathname).to receive(:mtime).and_return(Time.now - 2 * 60 * 60 * 24) + allow_any_instance_of(Pathname).to receive(:mtime).and_return(2.days.ago) expect(path.prune?(1)).to be true end @@ -181,7 +181,7 @@ describe Homebrew::Cleanup do it "removes the download for the latest version after a week" do download = Cask::Cache.path/"#{cask.token}--#{cask.version}" - FileUtils.touch download, mtime: Time.now - 7 * 60 * 60 * 24 + FileUtils.touch download, mtime: 7.days.ago - 1.hour subject.cleanup_cask(cask) @@ -203,13 +203,13 @@ describe Homebrew::Cleanup do end it "cleans up logs if older than 14 days" do - allow_any_instance_of(Pathname).to receive(:mtime).and_return(Time.now - 15 * 60 * 60 * 24) + allow_any_instance_of(Pathname).to receive(:mtime).and_return(15.days.ago) subject.cleanup_logs expect(path).not_to exist end it "does not clean up logs less than 14 days old" do - allow_any_instance_of(Pathname).to receive(:mtime).and_return(Time.now - 2 * 60 * 60 * 24) + allow_any_instance_of(Pathname).to receive(:mtime).and_return(2.days.ago) subject.cleanup_logs expect(path).to exist end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/array.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/array.rb new file mode 100644 index 0000000000..6d83b76882 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/array.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require "active_support/core_ext/array/wrap" +require "active_support/core_ext/array/access" +require "active_support/core_ext/array/conversions" +require "active_support/core_ext/array/extract_options" +require "active_support/core_ext/array/grouping" +require "active_support/core_ext/array/prepend_and_append" +require "active_support/core_ext/array/inquiry" diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/array/access.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/array/access.rb new file mode 100644 index 0000000000..b7ff7a3907 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/array/access.rb @@ -0,0 +1,92 @@ +# frozen_string_literal: true + +class Array + # Returns the tail of the array from +position+. + # + # %w( a b c d ).from(0) # => ["a", "b", "c", "d"] + # %w( a b c d ).from(2) # => ["c", "d"] + # %w( a b c d ).from(10) # => [] + # %w().from(0) # => [] + # %w( a b c d ).from(-2) # => ["c", "d"] + # %w( a b c ).from(-10) # => [] + def from(position) + self[position, length] || [] + end + + # Returns the beginning of the array up to +position+. + # + # %w( a b c d ).to(0) # => ["a"] + # %w( a b c d ).to(2) # => ["a", "b", "c"] + # %w( a b c d ).to(10) # => ["a", "b", "c", "d"] + # %w().to(0) # => [] + # %w( a b c d ).to(-2) # => ["a", "b", "c"] + # %w( a b c ).to(-10) # => [] + def to(position) + if position >= 0 + take position + 1 + else + self[0..position] + end + end + + # Returns a copy of the Array without the specified elements. + # + # people = ["David", "Rafael", "Aaron", "Todd"] + # people.without "Aaron", "Todd" + # # => ["David", "Rafael"] + # + # Note: This is an optimization of Enumerable#without that uses Array#- + # instead of Array#reject for performance reasons. + def without(*elements) + self - elements + end + + # Equal to self[1]. + # + # %w( a b c d e ).second # => "b" + def second + self[1] + end + + # Equal to self[2]. + # + # %w( a b c d e ).third # => "c" + def third + self[2] + end + + # Equal to self[3]. + # + # %w( a b c d e ).fourth # => "d" + def fourth + self[3] + end + + # Equal to self[4]. + # + # %w( a b c d e ).fifth # => "e" + def fifth + self[4] + end + + # Equal to self[41]. Also known as accessing "the reddit". + # + # (1..42).to_a.forty_two # => 42 + def forty_two + self[41] + end + + # Equal to self[-3]. + # + # %w( a b c d e ).third_to_last # => "c" + def third_to_last + self[-3] + end + + # Equal to self[-2]. + # + # %w( a b c d e ).second_to_last # => "d" + def second_to_last + self[-2] + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/array/conversions.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/array/conversions.rb new file mode 100644 index 0000000000..ea688ed2ea --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/array/conversions.rb @@ -0,0 +1,213 @@ +# frozen_string_literal: true + +require "active_support/xml_mini" +require "active_support/core_ext/hash/keys" +require "active_support/core_ext/string/inflections" +require "active_support/core_ext/object/to_param" +require "active_support/core_ext/object/to_query" + +class Array + # Converts the array to a comma-separated sentence where the last element is + # joined by the connector word. + # + # You can pass the following options to change the default behavior. If you + # pass an option key that doesn't exist in the list below, it will raise an + # ArgumentError. + # + # ==== Options + # + # * :words_connector - The sign or word used to join the elements + # in arrays with two or more elements (default: ", "). + # * :two_words_connector - The sign or word used to join the elements + # in arrays with two elements (default: " and "). + # * :last_word_connector - The sign or word used to join the last element + # in arrays with three or more elements (default: ", and "). + # * :locale - If +i18n+ is available, you can set a locale and use + # the connector options defined on the 'support.array' namespace in the + # corresponding dictionary file. + # + # ==== Examples + # + # [].to_sentence # => "" + # ['one'].to_sentence # => "one" + # ['one', 'two'].to_sentence # => "one and two" + # ['one', 'two', 'three'].to_sentence # => "one, two, and three" + # + # ['one', 'two'].to_sentence(passing: 'invalid option') + # # => ArgumentError: Unknown key: :passing. Valid keys are: :words_connector, :two_words_connector, :last_word_connector, :locale + # + # ['one', 'two'].to_sentence(two_words_connector: '-') + # # => "one-two" + # + # ['one', 'two', 'three'].to_sentence(words_connector: ' or ', last_word_connector: ' or at least ') + # # => "one or two or at least three" + # + # Using :locale option: + # + # # Given this locale dictionary: + # # + # # es: + # # support: + # # array: + # # words_connector: " o " + # # two_words_connector: " y " + # # last_word_connector: " o al menos " + # + # ['uno', 'dos'].to_sentence(locale: :es) + # # => "uno y dos" + # + # ['uno', 'dos', 'tres'].to_sentence(locale: :es) + # # => "uno o dos o al menos tres" + def to_sentence(options = {}) + options.assert_valid_keys(:words_connector, :two_words_connector, :last_word_connector, :locale) + + default_connectors = { + words_connector: ", ", + two_words_connector: " and ", + last_word_connector: ", and " + } + if defined?(I18n) + i18n_connectors = I18n.translate(:'support.array', locale: options[:locale], default: {}) + default_connectors.merge!(i18n_connectors) + end + options = default_connectors.merge!(options) + + case length + when 0 + "" + when 1 + "#{self[0]}" + when 2 + "#{self[0]}#{options[:two_words_connector]}#{self[1]}" + else + "#{self[0...-1].join(options[:words_connector])}#{options[:last_word_connector]}#{self[-1]}" + end + end + + # Extends Array#to_s to convert a collection of elements into a + # comma separated id list if :db argument is given as the format. + # + # Blog.all.to_formatted_s(:db) # => "1,2,3" + # Blog.none.to_formatted_s(:db) # => "null" + # [1,2].to_formatted_s # => "[1, 2]" + def to_formatted_s(format = :default) + case format + when :db + if empty? + "null" + else + collect(&:id).join(",") + end + else + to_default_s + end + end + alias_method :to_default_s, :to_s + alias_method :to_s, :to_formatted_s + + # Returns a string that represents the array in XML by invoking +to_xml+ + # on each element. Active Record collections delegate their representation + # in XML to this method. + # + # All elements are expected to respond to +to_xml+, if any of them does + # not then an exception is raised. + # + # The root node reflects the class name of the first element in plural + # if all elements belong to the same type and that's not Hash: + # + # customer.projects.to_xml + # + # + # + # + # 20000.0 + # 1567 + # 2008-04-09 + # ... + # + # + # 57230.0 + # 1567 + # 2008-04-15 + # ... + # + # + # + # Otherwise the root element is "objects": + # + # [{ foo: 1, bar: 2}, { baz: 3}].to_xml + # + # + # + # + # 2 + # 1 + # + # + # 3 + # + # + # + # If the collection is empty the root element is "nil-classes" by default: + # + # [].to_xml + # + # + # + # + # To ensure a meaningful root element use the :root option: + # + # customer_with_no_projects.projects.to_xml(root: 'projects') + # + # + # + # + # By default name of the node for the children of root is root.singularize. + # You can change it with the :children option. + # + # The +options+ hash is passed downwards: + # + # Message.all.to_xml(skip_types: true) + # + # + # + # + # 2008-03-07T09:58:18+01:00 + # 1 + # 1 + # 2008-03-07T09:58:18+01:00 + # 1 + # + # + # + def to_xml(options = {}) + require "active_support/builder" unless defined?(Builder) + + options = options.dup + options[:indent] ||= 2 + options[:builder] ||= Builder::XmlMarkup.new(indent: options[:indent]) + options[:root] ||= \ + if first.class != Hash && all? { |e| e.is_a?(first.class) } + underscored = ActiveSupport::Inflector.underscore(first.class.name) + ActiveSupport::Inflector.pluralize(underscored).tr("/", "_") + else + "objects" + end + + builder = options[:builder] + builder.instruct! unless options.delete(:skip_instruct) + + root = ActiveSupport::XmlMini.rename_key(options[:root].to_s, options) + children = options.delete(:children) || root.singularize + attributes = options[:skip_types] ? {} : { type: "array" } + + if empty? + builder.tag!(root, attributes) + else + builder.tag!(root, attributes) do + each { |value| ActiveSupport::XmlMini.to_tag(children, value, options) } + yield builder if block_given? + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/array/extract_options.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/array/extract_options.rb new file mode 100644 index 0000000000..8c7cb2e780 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/array/extract_options.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +class Hash + # By default, only instances of Hash itself are extractable. + # Subclasses of Hash may implement this method and return + # true to declare themselves as extractable. If a Hash + # is extractable, Array#extract_options! pops it from + # the Array when it is the last element of the Array. + def extractable_options? + instance_of?(Hash) + end +end + +class Array + # Extracts options from a set of arguments. Removes and returns the last + # element in the array if it's a hash, otherwise returns a blank hash. + # + # def options(*args) + # args.extract_options! + # end + # + # options(1, 2) # => {} + # options(1, 2, a: :b) # => {:a=>:b} + def extract_options! + if last.is_a?(Hash) && last.extractable_options? + pop + else + {} + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/array/grouping.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/array/grouping.rb new file mode 100644 index 0000000000..67e760bc4b --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/array/grouping.rb @@ -0,0 +1,109 @@ +# frozen_string_literal: true + +class Array + # Splits or iterates over the array in groups of size +number+, + # padding any remaining slots with +fill_with+ unless it is +false+. + # + # %w(1 2 3 4 5 6 7 8 9 10).in_groups_of(3) {|group| p group} + # ["1", "2", "3"] + # ["4", "5", "6"] + # ["7", "8", "9"] + # ["10", nil, nil] + # + # %w(1 2 3 4 5).in_groups_of(2, ' ') {|group| p group} + # ["1", "2"] + # ["3", "4"] + # ["5", " "] + # + # %w(1 2 3 4 5).in_groups_of(2, false) {|group| p group} + # ["1", "2"] + # ["3", "4"] + # ["5"] + def in_groups_of(number, fill_with = nil) + if number.to_i <= 0 + raise ArgumentError, + "Group size must be a positive integer, was #{number.inspect}" + end + + if fill_with == false + collection = self + else + # size % number gives how many extra we have; + # subtracting from number gives how many to add; + # modulo number ensures we don't add group of just fill. + padding = (number - size % number) % number + collection = dup.concat(Array.new(padding, fill_with)) + end + + if block_given? + collection.each_slice(number) { |slice| yield(slice) } + else + collection.each_slice(number).to_a + end + end + + # Splits or iterates over the array in +number+ of groups, padding any + # remaining slots with +fill_with+ unless it is +false+. + # + # %w(1 2 3 4 5 6 7 8 9 10).in_groups(3) {|group| p group} + # ["1", "2", "3", "4"] + # ["5", "6", "7", nil] + # ["8", "9", "10", nil] + # + # %w(1 2 3 4 5 6 7 8 9 10).in_groups(3, ' ') {|group| p group} + # ["1", "2", "3", "4"] + # ["5", "6", "7", " "] + # ["8", "9", "10", " "] + # + # %w(1 2 3 4 5 6 7).in_groups(3, false) {|group| p group} + # ["1", "2", "3"] + # ["4", "5"] + # ["6", "7"] + def in_groups(number, fill_with = nil) + # size.div number gives minor group size; + # size % number gives how many objects need extra accommodation; + # each group hold either division or division + 1 items. + division = size.div number + modulo = size % number + + # create a new array avoiding dup + groups = [] + start = 0 + + number.times do |index| + length = division + (modulo > 0 && modulo > index ? 1 : 0) + groups << last_group = slice(start, length) + last_group << fill_with if fill_with != false && + modulo > 0 && length == division + start += length + end + + if block_given? + groups.each { |g| yield(g) } + else + groups + end + end + + # Divides the array into one or more subarrays based on a delimiting +value+ + # or the result of an optional block. + # + # [1, 2, 3, 4, 5].split(3) # => [[1, 2], [4, 5]] + # (1..10).to_a.split { |i| i % 3 == 0 } # => [[1, 2], [4, 5], [7, 8], [10]] + def split(value = nil) + arr = dup + result = [] + if block_given? + while (idx = arr.index { |i| yield i }) + result << arr.shift(idx) + arr.shift + end + else + while (idx = arr.index(value)) + result << arr.shift(idx) + arr.shift + end + end + result << arr + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/array/inquiry.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/array/inquiry.rb new file mode 100644 index 0000000000..92c61bf201 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/array/inquiry.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +require "active_support/array_inquirer" + +class Array + # Wraps the array in an +ArrayInquirer+ object, which gives a friendlier way + # to check its string-like contents. + # + # pets = [:cat, :dog].inquiry + # + # pets.cat? # => true + # pets.ferret? # => false + # + # pets.any?(:cat, :ferret) # => true + # pets.any?(:ferret, :alligator) # => false + def inquiry + ActiveSupport::ArrayInquirer.new(self) + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/array/prepend_and_append.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/array/prepend_and_append.rb new file mode 100644 index 0000000000..661971d7cd --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/array/prepend_and_append.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class Array + # The human way of thinking about adding stuff to the end of a list is with append. + alias_method :append, :push unless [].respond_to?(:append) + + # The human way of thinking about adding stuff to the beginning of a list is with prepend. + alias_method :prepend, :unshift unless [].respond_to?(:prepend) +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/array/wrap.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/array/wrap.rb new file mode 100644 index 0000000000..d62f97edbf --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/array/wrap.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +class Array + # Wraps its argument in an array unless it is already an array (or array-like). + # + # Specifically: + # + # * If the argument is +nil+ an empty array is returned. + # * Otherwise, if the argument responds to +to_ary+ it is invoked, and its result returned. + # * Otherwise, returns an array with the argument as its single element. + # + # Array.wrap(nil) # => [] + # Array.wrap([1, 2, 3]) # => [1, 2, 3] + # Array.wrap(0) # => [0] + # + # This method is similar in purpose to Kernel#Array, but there are some differences: + # + # * If the argument responds to +to_ary+ the method is invoked. Kernel#Array + # moves on to try +to_a+ if the returned value is +nil+, but Array.wrap returns + # an array with the argument as its single element right away. + # * If the returned value from +to_ary+ is neither +nil+ nor an +Array+ object, Kernel#Array + # raises an exception, while Array.wrap does not, it just returns the value. + # * It does not call +to_a+ on the argument, if the argument does not respond to +to_ary+ + # it returns an array with the argument as its single element. + # + # The last point is easily explained with some enumerables: + # + # Array(foo: :bar) # => [[:foo, :bar]] + # Array.wrap(foo: :bar) # => [{:foo=>:bar}] + # + # There's also a related idiom that uses the splat operator: + # + # [*object] + # + # which returns [] for +nil+, but calls to Array(object) otherwise. + # + # The differences with Kernel#Array explained above + # apply to the rest of objects. + def self.wrap(object) + if object.nil? + [] + elsif object.respond_to?(:to_ary) + object.to_ary || [object] + else + [object] + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/benchmark.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/benchmark.rb new file mode 100644 index 0000000000..641b58c8b8 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/benchmark.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +require "benchmark" + +class << Benchmark + # Benchmark realtime in milliseconds. + # + # Benchmark.realtime { User.all } + # # => 8.0e-05 + # + # Benchmark.ms { User.all } + # # => 0.074 + def ms + 1000 * realtime { yield } + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/big_decimal.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/big_decimal.rb new file mode 100644 index 0000000000..9e6a9d6331 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/big_decimal.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +require "active_support/core_ext/big_decimal/conversions" diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/big_decimal/conversions.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/big_decimal/conversions.rb new file mode 100644 index 0000000000..52bd229416 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/big_decimal/conversions.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +require "bigdecimal" +require "bigdecimal/util" + +module ActiveSupport + module BigDecimalWithDefaultFormat #:nodoc: + def to_s(format = "F") + super(format) + end + end +end + +BigDecimal.prepend(ActiveSupport::BigDecimalWithDefaultFormat) diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/class.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/class.rb new file mode 100644 index 0000000000..1c110fd07b --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/class.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +require "active_support/core_ext/class/attribute" +require "active_support/core_ext/class/subclasses" diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/class/attribute.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/class/attribute.rb new file mode 100644 index 0000000000..7928efb871 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/class/attribute.rb @@ -0,0 +1,146 @@ +# frozen_string_literal: true + +require "active_support/core_ext/kernel/singleton_class" +require "active_support/core_ext/module/redefine_method" +require "active_support/core_ext/array/extract_options" + +class Class + # Declare a class-level attribute whose value is inheritable by subclasses. + # Subclasses can change their own value and it will not impact parent class. + # + # ==== Options + # + # * :instance_reader - Sets the instance reader method (defaults to true). + # * :instance_writer - Sets the instance writer method (defaults to true). + # * :instance_accessor - Sets both instance methods (defaults to true). + # * :instance_predicate - Sets a predicate method (defaults to true). + # * :default - Sets a default value for the attribute (defaults to nil). + # + # ==== Examples + # + # class Base + # class_attribute :setting + # end + # + # class Subclass < Base + # end + # + # Base.setting = true + # Subclass.setting # => true + # Subclass.setting = false + # Subclass.setting # => false + # Base.setting # => true + # + # In the above case as long as Subclass does not assign a value to setting + # by performing Subclass.setting = _something_, Subclass.setting + # would read value assigned to parent class. Once Subclass assigns a value then + # the value assigned by Subclass would be returned. + # + # This matches normal Ruby method inheritance: think of writing an attribute + # on a subclass as overriding the reader method. However, you need to be aware + # when using +class_attribute+ with mutable structures as +Array+ or +Hash+. + # In such cases, you don't want to do changes in place. Instead use setters: + # + # Base.setting = [] + # Base.setting # => [] + # Subclass.setting # => [] + # + # # Appending in child changes both parent and child because it is the same object: + # Subclass.setting << :foo + # Base.setting # => [:foo] + # Subclass.setting # => [:foo] + # + # # Use setters to not propagate changes: + # Base.setting = [] + # Subclass.setting += [:foo] + # Base.setting # => [] + # Subclass.setting # => [:foo] + # + # For convenience, an instance predicate method is defined as well. + # To skip it, pass instance_predicate: false. + # + # Subclass.setting? # => false + # + # Instances may overwrite the class value in the same way: + # + # Base.setting = true + # object = Base.new + # object.setting # => true + # object.setting = false + # object.setting # => false + # Base.setting # => true + # + # To opt out of the instance reader method, pass instance_reader: false. + # + # object.setting # => NoMethodError + # object.setting? # => NoMethodError + # + # To opt out of the instance writer method, pass instance_writer: false. + # + # object.setting = false # => NoMethodError + # + # To opt out of both instance methods, pass instance_accessor: false. + # + # To set a default value for the attribute, pass default:, like so: + # + # class_attribute :settings, default: {} + def class_attribute(*attrs) + options = attrs.extract_options! + instance_reader = options.fetch(:instance_accessor, true) && options.fetch(:instance_reader, true) + instance_writer = options.fetch(:instance_accessor, true) && options.fetch(:instance_writer, true) + instance_predicate = options.fetch(:instance_predicate, true) + default_value = options.fetch(:default, nil) + + attrs.each do |name| + singleton_class.silence_redefinition_of_method(name) + define_singleton_method(name) { nil } + + singleton_class.silence_redefinition_of_method("#{name}?") + define_singleton_method("#{name}?") { !!public_send(name) } if instance_predicate + + ivar = "@#{name}" + + singleton_class.silence_redefinition_of_method("#{name}=") + define_singleton_method("#{name}=") do |val| + singleton_class.class_eval do + redefine_method(name) { val } + end + + if singleton_class? + class_eval do + redefine_method(name) do + if instance_variable_defined? ivar + instance_variable_get ivar + else + singleton_class.send name + end + end + end + end + val + end + + if instance_reader + redefine_method(name) do + if instance_variable_defined?(ivar) + instance_variable_get ivar + else + self.class.public_send name + end + end + + redefine_method("#{name}?") { !!public_send(name) } if instance_predicate + end + + if instance_writer + redefine_method("#{name}=") do |val| + instance_variable_set ivar, val + end + end + + unless default_value.nil? + self.send("#{name}=", default_value) + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/class/attribute_accessors.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/class/attribute_accessors.rb new file mode 100644 index 0000000000..a77354e153 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/class/attribute_accessors.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +# cattr_* became mattr_* aliases in 7dfbd91b0780fbd6a1dd9bfbc176e10894871d2d, +# but we keep this around for libraries that directly require it knowing they +# want cattr_*. No need to deprecate. +require "active_support/core_ext/module/attribute_accessors" diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/class/subclasses.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/class/subclasses.rb new file mode 100644 index 0000000000..75e65337b7 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/class/subclasses.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +class Class + begin + # Test if this Ruby supports each_object against singleton_class + ObjectSpace.each_object(Numeric.singleton_class) {} + + # Returns an array with all classes that are < than its receiver. + # + # class C; end + # C.descendants # => [] + # + # class B < C; end + # C.descendants # => [B] + # + # class A < B; end + # C.descendants # => [B, A] + # + # class D < C; end + # C.descendants # => [B, A, D] + def descendants + descendants = [] + ObjectSpace.each_object(singleton_class) do |k| + next if k.singleton_class? + descendants.unshift k unless k == self + end + descendants + end + rescue StandardError # JRuby 9.0.4.0 and earlier + def descendants + descendants = [] + ObjectSpace.each_object(Class) do |k| + descendants.unshift k if k < self + end + descendants.uniq! + descendants + end + end + + # Returns an array with the direct children of +self+. + # + # class Foo; end + # class Bar < Foo; end + # class Baz < Bar; end + # + # Foo.subclasses # => [Bar] + def subclasses + subclasses, chain = [], descendants + chain.each do |k| + subclasses << k unless chain.any? { |c| c > k } + end + subclasses + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date.rb new file mode 100644 index 0000000000..cce73f2db2 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +require "active_support/core_ext/date/acts_like" +require "active_support/core_ext/date/blank" +require "active_support/core_ext/date/calculations" +require "active_support/core_ext/date/conversions" +require "active_support/core_ext/date/zones" diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date/acts_like.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date/acts_like.rb new file mode 100644 index 0000000000..c8077f3774 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date/acts_like.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +require "active_support/core_ext/object/acts_like" + +class Date + # Duck-types as a Date-like class. See Object#acts_like?. + def acts_like_date? + true + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date/blank.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date/blank.rb new file mode 100644 index 0000000000..e6271c79b3 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date/blank.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +require "date" + +class Date #:nodoc: + # No Date is blank: + # + # Date.today.blank? # => false + # + # @return [false] + def blank? + false + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date/calculations.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date/calculations.rb new file mode 100644 index 0000000000..1cd7acb05d --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date/calculations.rb @@ -0,0 +1,145 @@ +# frozen_string_literal: true + +require "date" +require "active_support/duration" +require "active_support/core_ext/object/acts_like" +require "active_support/core_ext/date/zones" +require "active_support/core_ext/time/zones" +require "active_support/core_ext/date_and_time/calculations" + +class Date + include DateAndTime::Calculations + + class << self + attr_accessor :beginning_of_week_default + + # Returns the week start (e.g. :monday) for the current request, if this has been set (via Date.beginning_of_week=). + # If Date.beginning_of_week has not been set for the current request, returns the week start specified in config.beginning_of_week. + # If no config.beginning_of_week was specified, returns :monday. + def beginning_of_week + Thread.current[:beginning_of_week] || beginning_of_week_default || :monday + end + + # Sets Date.beginning_of_week to a week start (e.g. :monday) for current request/thread. + # + # This method accepts any of the following day symbols: + # :monday, :tuesday, :wednesday, :thursday, :friday, :saturday, :sunday + def beginning_of_week=(week_start) + Thread.current[:beginning_of_week] = find_beginning_of_week!(week_start) + end + + # Returns week start day symbol (e.g. :monday), or raises an +ArgumentError+ for invalid day symbol. + def find_beginning_of_week!(week_start) + raise ArgumentError, "Invalid beginning of week: #{week_start}" unless ::Date::DAYS_INTO_WEEK.key?(week_start) + week_start + end + + # Returns a new Date representing the date 1 day ago (i.e. yesterday's date). + def yesterday + ::Date.current.yesterday + end + + # Returns a new Date representing the date 1 day after today (i.e. tomorrow's date). + def tomorrow + ::Date.current.tomorrow + end + + # Returns Time.zone.today when Time.zone or config.time_zone are set, otherwise just returns Date.today. + def current + ::Time.zone ? ::Time.zone.today : ::Date.today + end + end + + # Converts Date to a Time (or DateTime if necessary) with the time portion set to the beginning of the day (0:00) + # and then subtracts the specified number of seconds. + def ago(seconds) + in_time_zone.since(-seconds) + end + + # Converts Date to a Time (or DateTime if necessary) with the time portion set to the beginning of the day (0:00) + # and then adds the specified number of seconds + def since(seconds) + in_time_zone.since(seconds) + end + alias :in :since + + # Converts Date to a Time (or DateTime if necessary) with the time portion set to the beginning of the day (0:00) + def beginning_of_day + in_time_zone + end + alias :midnight :beginning_of_day + alias :at_midnight :beginning_of_day + alias :at_beginning_of_day :beginning_of_day + + # Converts Date to a Time (or DateTime if necessary) with the time portion set to the middle of the day (12:00) + def middle_of_day + in_time_zone.middle_of_day + end + alias :midday :middle_of_day + alias :noon :middle_of_day + alias :at_midday :middle_of_day + alias :at_noon :middle_of_day + alias :at_middle_of_day :middle_of_day + + # Converts Date to a Time (or DateTime if necessary) with the time portion set to the end of the day (23:59:59) + def end_of_day + in_time_zone.end_of_day + end + alias :at_end_of_day :end_of_day + + def plus_with_duration(other) #:nodoc: + if ActiveSupport::Duration === other + other.since(self) + else + plus_without_duration(other) + end + end + alias_method :plus_without_duration, :+ + alias_method :+, :plus_with_duration + + def minus_with_duration(other) #:nodoc: + if ActiveSupport::Duration === other + plus_with_duration(-other) + else + minus_without_duration(other) + end + end + alias_method :minus_without_duration, :- + alias_method :-, :minus_with_duration + + # Provides precise Date calculations for years, months, and days. The +options+ parameter takes a hash with + # any of these keys: :years, :months, :weeks, :days. + def advance(options) + options = options.dup + d = self + d = d >> options.delete(:years) * 12 if options[:years] + d = d >> options.delete(:months) if options[:months] + d = d + options.delete(:weeks) * 7 if options[:weeks] + d = d + options.delete(:days) if options[:days] + d + end + + # Returns a new Date where one or more of the elements have been changed according to the +options+ parameter. + # The +options+ parameter is a hash with a combination of these keys: :year, :month, :day. + # + # Date.new(2007, 5, 12).change(day: 1) # => Date.new(2007, 5, 1) + # Date.new(2007, 5, 12).change(year: 2005, month: 1) # => Date.new(2005, 1, 12) + def change(options) + ::Date.new( + options.fetch(:year, year), + options.fetch(:month, month), + options.fetch(:day, day) + ) + end + + # Allow Date to be compared with Time by converting to DateTime and relying on the <=> from there. + def compare_with_coercion(other) + if other.is_a?(Time) + to_datetime <=> other + else + compare_without_coercion(other) + end + end + alias_method :compare_without_coercion, :<=> + alias_method :<=>, :compare_with_coercion +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date/conversions.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date/conversions.rb new file mode 100644 index 0000000000..870119dc7f --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date/conversions.rb @@ -0,0 +1,96 @@ +# frozen_string_literal: true + +require "date" +require "active_support/inflector/methods" +require "active_support/core_ext/date/zones" +require "active_support/core_ext/module/redefine_method" + +class Date + DATE_FORMATS = { + short: "%d %b", + long: "%B %d, %Y", + db: "%Y-%m-%d", + number: "%Y%m%d", + long_ordinal: lambda { |date| + day_format = ActiveSupport::Inflector.ordinalize(date.day) + date.strftime("%B #{day_format}, %Y") # => "April 25th, 2007" + }, + rfc822: "%d %b %Y", + iso8601: lambda { |date| date.iso8601 } + } + + # Convert to a formatted string. See DATE_FORMATS for predefined formats. + # + # This method is aliased to to_s. + # + # date = Date.new(2007, 11, 10) # => Sat, 10 Nov 2007 + # + # date.to_formatted_s(:db) # => "2007-11-10" + # date.to_s(:db) # => "2007-11-10" + # + # date.to_formatted_s(:short) # => "10 Nov" + # date.to_formatted_s(:number) # => "20071110" + # date.to_formatted_s(:long) # => "November 10, 2007" + # date.to_formatted_s(:long_ordinal) # => "November 10th, 2007" + # date.to_formatted_s(:rfc822) # => "10 Nov 2007" + # date.to_formatted_s(:iso8601) # => "2007-11-10" + # + # == Adding your own date formats to to_formatted_s + # You can add your own formats to the Date::DATE_FORMATS hash. + # Use the format name as the hash key and either a strftime string + # or Proc instance that takes a date argument as the value. + # + # # config/initializers/date_formats.rb + # Date::DATE_FORMATS[:month_and_year] = '%B %Y' + # Date::DATE_FORMATS[:short_ordinal] = ->(date) { date.strftime("%B #{date.day.ordinalize}") } + def to_formatted_s(format = :default) + if formatter = DATE_FORMATS[format] + if formatter.respond_to?(:call) + formatter.call(self).to_s + else + strftime(formatter) + end + else + to_default_s + end + end + alias_method :to_default_s, :to_s + alias_method :to_s, :to_formatted_s + + # Overrides the default inspect method with a human readable one, e.g., "Mon, 21 Feb 2005" + def readable_inspect + strftime("%a, %d %b %Y") + end + alias_method :default_inspect, :inspect + alias_method :inspect, :readable_inspect + + silence_redefinition_of_method :to_time + + # Converts a Date instance to a Time, where the time is set to the beginning of the day. + # The timezone can be either :local or :utc (default :local). + # + # date = Date.new(2007, 11, 10) # => Sat, 10 Nov 2007 + # + # date.to_time # => 2007-11-10 00:00:00 0800 + # date.to_time(:local) # => 2007-11-10 00:00:00 0800 + # + # date.to_time(:utc) # => 2007-11-10 00:00:00 UTC + # + # NOTE: The :local timezone is Ruby's *process* timezone, i.e. ENV['TZ']. + # If the *application's* timezone is needed, then use +in_time_zone+ instead. + def to_time(form = :local) + raise ArgumentError, "Expected :local or :utc, got #{form.inspect}." unless [:local, :utc].include?(form) + ::Time.send(form, year, month, day) + end + + silence_redefinition_of_method :xmlschema + + # Returns a string which represents the time in used time zone as DateTime + # defined by XML Schema: + # + # date = Date.new(2015, 05, 23) # => Sat, 23 May 2015 + # date.xmlschema # => "2015-05-23T00:00:00+04:00" + def xmlschema + in_time_zone.xmlschema + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date/zones.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date/zones.rb new file mode 100644 index 0000000000..2dcf97cff8 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date/zones.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +require "date" +require "active_support/core_ext/date_and_time/zones" + +class Date + include DateAndTime::Zones +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_and_time/calculations.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_and_time/calculations.rb new file mode 100644 index 0000000000..f6cb1a384c --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_and_time/calculations.rb @@ -0,0 +1,374 @@ +# frozen_string_literal: true + +require "active_support/core_ext/object/try" + +module DateAndTime + module Calculations + DAYS_INTO_WEEK = { + monday: 0, + tuesday: 1, + wednesday: 2, + thursday: 3, + friday: 4, + saturday: 5, + sunday: 6 + } + WEEKEND_DAYS = [ 6, 0 ] + + # Returns a new date/time representing yesterday. + def yesterday + advance(days: -1) + end + + # Returns a new date/time the specified number of days ago. + def prev_day(days = 1) + advance(days: -days) + end + + # Returns a new date/time representing tomorrow. + def tomorrow + advance(days: 1) + end + + # Returns a new date/time the specified number of days in the future. + def next_day(days = 1) + advance(days: days) + end + + # Returns true if the date/time is today. + def today? + to_date == ::Date.current + end + + # Returns true if the date/time is in the past. + def past? + self < self.class.current + end + + # Returns true if the date/time is in the future. + def future? + self > self.class.current + end + + # Returns true if the date/time falls on a Saturday or Sunday. + def on_weekend? + WEEKEND_DAYS.include?(wday) + end + + # Returns true if the date/time does not fall on a Saturday or Sunday. + def on_weekday? + !WEEKEND_DAYS.include?(wday) + end + + # Returns a new date/time the specified number of days ago. + def days_ago(days) + advance(days: -days) + end + + # Returns a new date/time the specified number of days in the future. + def days_since(days) + advance(days: days) + end + + # Returns a new date/time the specified number of weeks ago. + def weeks_ago(weeks) + advance(weeks: -weeks) + end + + # Returns a new date/time the specified number of weeks in the future. + def weeks_since(weeks) + advance(weeks: weeks) + end + + # Returns a new date/time the specified number of months ago. + def months_ago(months) + advance(months: -months) + end + + # Returns a new date/time the specified number of months in the future. + def months_since(months) + advance(months: months) + end + + # Returns a new date/time the specified number of years ago. + def years_ago(years) + advance(years: -years) + end + + # Returns a new date/time the specified number of years in the future. + def years_since(years) + advance(years: years) + end + + # Returns a new date/time at the start of the month. + # + # today = Date.today # => Thu, 18 Jun 2015 + # today.beginning_of_month # => Mon, 01 Jun 2015 + # + # +DateTime+ objects will have a time set to 0:00. + # + # now = DateTime.current # => Thu, 18 Jun 2015 15:23:13 +0000 + # now.beginning_of_month # => Mon, 01 Jun 2015 00:00:00 +0000 + def beginning_of_month + first_hour(change(day: 1)) + end + alias :at_beginning_of_month :beginning_of_month + + # Returns a new date/time at the start of the quarter. + # + # today = Date.today # => Fri, 10 Jul 2015 + # today.beginning_of_quarter # => Wed, 01 Jul 2015 + # + # +DateTime+ objects will have a time set to 0:00. + # + # now = DateTime.current # => Fri, 10 Jul 2015 18:41:29 +0000 + # now.beginning_of_quarter # => Wed, 01 Jul 2015 00:00:00 +0000 + def beginning_of_quarter + first_quarter_month = [10, 7, 4, 1].detect { |m| m <= month } + beginning_of_month.change(month: first_quarter_month) + end + alias :at_beginning_of_quarter :beginning_of_quarter + + # Returns a new date/time at the end of the quarter. + # + # today = Date.today # => Fri, 10 Jul 2015 + # today.end_of_quarter # => Wed, 30 Sep 2015 + # + # +DateTime+ objects will have a time set to 23:59:59. + # + # now = DateTime.current # => Fri, 10 Jul 2015 18:41:29 +0000 + # now.end_of_quarter # => Wed, 30 Sep 2015 23:59:59 +0000 + def end_of_quarter + last_quarter_month = [3, 6, 9, 12].detect { |m| m >= month } + beginning_of_month.change(month: last_quarter_month).end_of_month + end + alias :at_end_of_quarter :end_of_quarter + + # Returns a new date/time at the beginning of the year. + # + # today = Date.today # => Fri, 10 Jul 2015 + # today.beginning_of_year # => Thu, 01 Jan 2015 + # + # +DateTime+ objects will have a time set to 0:00. + # + # now = DateTime.current # => Fri, 10 Jul 2015 18:41:29 +0000 + # now.beginning_of_year # => Thu, 01 Jan 2015 00:00:00 +0000 + def beginning_of_year + change(month: 1).beginning_of_month + end + alias :at_beginning_of_year :beginning_of_year + + # Returns a new date/time representing the given day in the next week. + # + # today = Date.today # => Thu, 07 May 2015 + # today.next_week # => Mon, 11 May 2015 + # + # The +given_day_in_next_week+ defaults to the beginning of the week + # which is determined by +Date.beginning_of_week+ or +config.beginning_of_week+ + # when set. + # + # today = Date.today # => Thu, 07 May 2015 + # today.next_week(:friday) # => Fri, 15 May 2015 + # + # +DateTime+ objects have their time set to 0:00 unless +same_time+ is true. + # + # now = DateTime.current # => Thu, 07 May 2015 13:31:16 +0000 + # now.next_week # => Mon, 11 May 2015 00:00:00 +0000 + def next_week(given_day_in_next_week = Date.beginning_of_week, same_time: false) + result = first_hour(weeks_since(1).beginning_of_week.days_since(days_span(given_day_in_next_week))) + same_time ? copy_time_to(result) : result + end + + # Returns a new date/time representing the next weekday. + def next_weekday + if next_day.on_weekend? + next_week(:monday, same_time: true) + else + next_day + end + end + + # Returns a new date/time the specified number of months in the future. + def next_month(months = 1) + advance(months: months) + end + + # Short-hand for months_since(3) + def next_quarter + months_since(3) + end + + # Returns a new date/time the specified number of years in the future. + def next_year(years = 1) + advance(years: years) + end + + # Returns a new date/time representing the given day in the previous week. + # Week is assumed to start on +start_day+, default is + # +Date.beginning_of_week+ or +config.beginning_of_week+ when set. + # DateTime objects have their time set to 0:00 unless +same_time+ is true. + def prev_week(start_day = Date.beginning_of_week, same_time: false) + result = first_hour(weeks_ago(1).beginning_of_week.days_since(days_span(start_day))) + same_time ? copy_time_to(result) : result + end + alias_method :last_week, :prev_week + + # Returns a new date/time representing the previous weekday. + def prev_weekday + if prev_day.on_weekend? + copy_time_to(beginning_of_week(:friday)) + else + prev_day + end + end + alias_method :last_weekday, :prev_weekday + + # Returns a new date/time the specified number of months ago. + def prev_month(months = 1) + advance(months: -months) + end + + # Short-hand for months_ago(1). + def last_month + months_ago(1) + end + + # Short-hand for months_ago(3). + def prev_quarter + months_ago(3) + end + alias_method :last_quarter, :prev_quarter + + # Returns a new date/time the specified number of years ago. + def prev_year(years = 1) + advance(years: -years) + end + + # Short-hand for years_ago(1). + def last_year + years_ago(1) + end + + # Returns the number of days to the start of the week on the given day. + # Week is assumed to start on +start_day+, default is + # +Date.beginning_of_week+ or +config.beginning_of_week+ when set. + def days_to_week_start(start_day = Date.beginning_of_week) + start_day_number = DAYS_INTO_WEEK[start_day] + current_day_number = wday != 0 ? wday - 1 : 6 + (current_day_number - start_day_number) % 7 + end + + # Returns a new date/time representing the start of this week on the given day. + # Week is assumed to start on +start_day+, default is + # +Date.beginning_of_week+ or +config.beginning_of_week+ when set. + # +DateTime+ objects have their time set to 0:00. + def beginning_of_week(start_day = Date.beginning_of_week) + result = days_ago(days_to_week_start(start_day)) + acts_like?(:time) ? result.midnight : result + end + alias :at_beginning_of_week :beginning_of_week + + # Returns Monday of this week assuming that week starts on Monday. + # +DateTime+ objects have their time set to 0:00. + def monday + beginning_of_week(:monday) + end + + # Returns a new date/time representing the end of this week on the given day. + # Week is assumed to start on +start_day+, default is + # +Date.beginning_of_week+ or +config.beginning_of_week+ when set. + # DateTime objects have their time set to 23:59:59. + def end_of_week(start_day = Date.beginning_of_week) + last_hour(days_since(6 - days_to_week_start(start_day))) + end + alias :at_end_of_week :end_of_week + + # Returns Sunday of this week assuming that week starts on Monday. + # +DateTime+ objects have their time set to 23:59:59. + def sunday + end_of_week(:monday) + end + + # Returns a new date/time representing the end of the month. + # DateTime objects will have a time set to 23:59:59. + def end_of_month + last_day = ::Time.days_in_month(month, year) + last_hour(days_since(last_day - day)) + end + alias :at_end_of_month :end_of_month + + # Returns a new date/time representing the end of the year. + # DateTime objects will have a time set to 23:59:59. + def end_of_year + change(month: 12).end_of_month + end + alias :at_end_of_year :end_of_year + + # Returns a Range representing the whole day of the current date/time. + def all_day + beginning_of_day..end_of_day + end + + # Returns a Range representing the whole week of the current date/time. + # Week starts on start_day, default is Date.beginning_of_week or config.beginning_of_week when set. + def all_week(start_day = Date.beginning_of_week) + beginning_of_week(start_day)..end_of_week(start_day) + end + + # Returns a Range representing the whole month of the current date/time. + def all_month + beginning_of_month..end_of_month + end + + # Returns a Range representing the whole quarter of the current date/time. + def all_quarter + beginning_of_quarter..end_of_quarter + end + + # Returns a Range representing the whole year of the current date/time. + def all_year + beginning_of_year..end_of_year + end + + # Returns a new date/time representing the next occurrence of the specified day of week. + # + # today = Date.today # => Thu, 14 Dec 2017 + # today.next_occurring(:monday) # => Mon, 18 Dec 2017 + # today.next_occurring(:thursday) # => Thu, 21 Dec 2017 + def next_occurring(day_of_week) + current_day_number = wday != 0 ? wday - 1 : 6 + from_now = DAYS_INTO_WEEK.fetch(day_of_week) - current_day_number + from_now += 7 unless from_now > 0 + advance(days: from_now) + end + + # Returns a new date/time representing the previous occurrence of the specified day of week. + # + # today = Date.today # => Thu, 14 Dec 2017 + # today.prev_occurring(:monday) # => Mon, 11 Dec 2017 + # today.prev_occurring(:thursday) # => Thu, 07 Dec 2017 + def prev_occurring(day_of_week) + current_day_number = wday != 0 ? wday - 1 : 6 + ago = current_day_number - DAYS_INTO_WEEK.fetch(day_of_week) + ago += 7 unless ago > 0 + advance(days: -ago) + end + + private + def first_hour(date_or_time) + date_or_time.acts_like?(:time) ? date_or_time.beginning_of_day : date_or_time + end + + def last_hour(date_or_time) + date_or_time.acts_like?(:time) ? date_or_time.end_of_day : date_or_time + end + + def days_span(day) + (DAYS_INTO_WEEK[day] - DAYS_INTO_WEEK[Date.beginning_of_week]) % 7 + end + + def copy_time_to(other) + other.change(hour: hour, min: min, sec: sec, nsec: try(:nsec)) + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_and_time/compatibility.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_and_time/compatibility.rb new file mode 100644 index 0000000000..d33c36ef73 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_and_time/compatibility.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +require "active_support/core_ext/module/attribute_accessors" + +module DateAndTime + module Compatibility + # If true, +to_time+ preserves the timezone offset of receiver. + # + # NOTE: With Ruby 2.4+ the default for +to_time+ changed from + # converting to the local system time, to preserving the offset + # of the receiver. For backwards compatibility we're overriding + # this behavior, but new apps will have an initializer that sets + # this to true, because the new behavior is preferred. + mattr_accessor :preserve_timezone, instance_writer: false, default: false + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_and_time/zones.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_and_time/zones.rb new file mode 100644 index 0000000000..894fd9b76d --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_and_time/zones.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: true + +module DateAndTime + module Zones + # Returns the simultaneous time in Time.zone if a zone is given or + # if Time.zone_default is set. Otherwise, it returns the current time. + # + # Time.zone = 'Hawaii' # => 'Hawaii' + # Time.utc(2000).in_time_zone # => Fri, 31 Dec 1999 14:00:00 HST -10:00 + # Date.new(2000).in_time_zone # => Sat, 01 Jan 2000 00:00:00 HST -10:00 + # + # This method is similar to Time#localtime, except that it uses Time.zone as the local zone + # instead of the operating system's time zone. + # + # You can also pass in a TimeZone instance or string that identifies a TimeZone as an argument, + # and the conversion will be based on that zone instead of Time.zone. + # + # Time.utc(2000).in_time_zone('Alaska') # => Fri, 31 Dec 1999 15:00:00 AKST -09:00 + # Date.new(2000).in_time_zone('Alaska') # => Sat, 01 Jan 2000 00:00:00 AKST -09:00 + def in_time_zone(zone = ::Time.zone) + time_zone = ::Time.find_zone! zone + time = acts_like?(:time) ? self : nil + + if time_zone + time_with_zone(time, time_zone) + else + time || to_time + end + end + + private + + def time_with_zone(time, zone) + if time + ActiveSupport::TimeWithZone.new(time.utc? ? time : time.getutc, zone) + else + ActiveSupport::TimeWithZone.new(nil, zone, to_time(:utc)) + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_time.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_time.rb new file mode 100644 index 0000000000..790dbeec1b --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_time.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +require "active_support/core_ext/date_time/acts_like" +require "active_support/core_ext/date_time/blank" +require "active_support/core_ext/date_time/calculations" +require "active_support/core_ext/date_time/compatibility" +require "active_support/core_ext/date_time/conversions" diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_time/acts_like.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_time/acts_like.rb new file mode 100644 index 0000000000..5dccdfe219 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_time/acts_like.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +require "date" +require "active_support/core_ext/object/acts_like" + +class DateTime + # Duck-types as a Date-like class. See Object#acts_like?. + def acts_like_date? + true + end + + # Duck-types as a Time-like class. See Object#acts_like?. + def acts_like_time? + true + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_time/blank.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_time/blank.rb new file mode 100644 index 0000000000..a52c8bc150 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_time/blank.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +require "date" + +class DateTime #:nodoc: + # No DateTime is ever blank: + # + # DateTime.now.blank? # => false + # + # @return [false] + def blank? + false + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_time/calculations.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_time/calculations.rb new file mode 100644 index 0000000000..e61b23f842 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_time/calculations.rb @@ -0,0 +1,211 @@ +# frozen_string_literal: true + +require "date" + +class DateTime + class << self + # Returns Time.zone.now.to_datetime when Time.zone or + # config.time_zone are set, otherwise returns + # Time.now.to_datetime. + def current + ::Time.zone ? ::Time.zone.now.to_datetime : ::Time.now.to_datetime + end + end + + # Returns the number of seconds since 00:00:00. + # + # DateTime.new(2012, 8, 29, 0, 0, 0).seconds_since_midnight # => 0 + # DateTime.new(2012, 8, 29, 12, 34, 56).seconds_since_midnight # => 45296 + # DateTime.new(2012, 8, 29, 23, 59, 59).seconds_since_midnight # => 86399 + def seconds_since_midnight + sec + (min * 60) + (hour * 3600) + end + + # Returns the number of seconds until 23:59:59. + # + # DateTime.new(2012, 8, 29, 0, 0, 0).seconds_until_end_of_day # => 86399 + # DateTime.new(2012, 8, 29, 12, 34, 56).seconds_until_end_of_day # => 41103 + # DateTime.new(2012, 8, 29, 23, 59, 59).seconds_until_end_of_day # => 0 + def seconds_until_end_of_day + end_of_day.to_i - to_i + end + + # Returns the fraction of a second as a +Rational+ + # + # DateTime.new(2012, 8, 29, 0, 0, 0.5).subsec # => (1/2) + def subsec + sec_fraction + end + + # Returns a new DateTime where one or more of the elements have been changed + # according to the +options+ parameter. The time options (:hour, + # :min, :sec) reset cascadingly, so if only the hour is + # passed, then minute and sec is set to 0. If the hour and minute is passed, + # then sec is set to 0. The +options+ parameter takes a hash with any of these + # keys: :year, :month, :day, :hour, + # :min, :sec, :offset, :start. + # + # DateTime.new(2012, 8, 29, 22, 35, 0).change(day: 1) # => DateTime.new(2012, 8, 1, 22, 35, 0) + # DateTime.new(2012, 8, 29, 22, 35, 0).change(year: 1981, day: 1) # => DateTime.new(1981, 8, 1, 22, 35, 0) + # DateTime.new(2012, 8, 29, 22, 35, 0).change(year: 1981, hour: 0) # => DateTime.new(1981, 8, 29, 0, 0, 0) + def change(options) + if new_nsec = options[:nsec] + raise ArgumentError, "Can't change both :nsec and :usec at the same time: #{options.inspect}" if options[:usec] + new_fraction = Rational(new_nsec, 1000000000) + else + new_usec = options.fetch(:usec, (options[:hour] || options[:min] || options[:sec]) ? 0 : Rational(nsec, 1000)) + new_fraction = Rational(new_usec, 1000000) + end + + raise ArgumentError, "argument out of range" if new_fraction >= 1 + + ::DateTime.civil( + options.fetch(:year, year), + options.fetch(:month, month), + options.fetch(:day, day), + options.fetch(:hour, hour), + options.fetch(:min, options[:hour] ? 0 : min), + options.fetch(:sec, (options[:hour] || options[:min]) ? 0 : sec) + new_fraction, + options.fetch(:offset, offset), + options.fetch(:start, start) + ) + end + + # Uses Date to provide precise Time calculations for years, months, and days. + # The +options+ parameter takes a hash with any of these keys: :years, + # :months, :weeks, :days, :hours, + # :minutes, :seconds. + def advance(options) + unless options[:weeks].nil? + options[:weeks], partial_weeks = options[:weeks].divmod(1) + options[:days] = options.fetch(:days, 0) + 7 * partial_weeks + end + + unless options[:days].nil? + options[:days], partial_days = options[:days].divmod(1) + options[:hours] = options.fetch(:hours, 0) + 24 * partial_days + end + + d = to_date.advance(options) + datetime_advanced_by_date = change(year: d.year, month: d.month, day: d.day) + seconds_to_advance = \ + options.fetch(:seconds, 0) + + options.fetch(:minutes, 0) * 60 + + options.fetch(:hours, 0) * 3600 + + if seconds_to_advance.zero? + datetime_advanced_by_date + else + datetime_advanced_by_date.since(seconds_to_advance) + end + end + + # Returns a new DateTime representing the time a number of seconds ago. + # Do not use this method in combination with x.months, use months_ago instead! + def ago(seconds) + since(-seconds) + end + + # Returns a new DateTime representing the time a number of seconds since the + # instance time. Do not use this method in combination with x.months, use + # months_since instead! + def since(seconds) + self + Rational(seconds.round, 86400) + end + alias :in :since + + # Returns a new DateTime representing the start of the day (0:00). + def beginning_of_day + change(hour: 0) + end + alias :midnight :beginning_of_day + alias :at_midnight :beginning_of_day + alias :at_beginning_of_day :beginning_of_day + + # Returns a new DateTime representing the middle of the day (12:00) + def middle_of_day + change(hour: 12) + end + alias :midday :middle_of_day + alias :noon :middle_of_day + alias :at_midday :middle_of_day + alias :at_noon :middle_of_day + alias :at_middle_of_day :middle_of_day + + # Returns a new DateTime representing the end of the day (23:59:59). + def end_of_day + change(hour: 23, min: 59, sec: 59, usec: Rational(999999999, 1000)) + end + alias :at_end_of_day :end_of_day + + # Returns a new DateTime representing the start of the hour (hh:00:00). + def beginning_of_hour + change(min: 0) + end + alias :at_beginning_of_hour :beginning_of_hour + + # Returns a new DateTime representing the end of the hour (hh:59:59). + def end_of_hour + change(min: 59, sec: 59, usec: Rational(999999999, 1000)) + end + alias :at_end_of_hour :end_of_hour + + # Returns a new DateTime representing the start of the minute (hh:mm:00). + def beginning_of_minute + change(sec: 0) + end + alias :at_beginning_of_minute :beginning_of_minute + + # Returns a new DateTime representing the end of the minute (hh:mm:59). + def end_of_minute + change(sec: 59, usec: Rational(999999999, 1000)) + end + alias :at_end_of_minute :end_of_minute + + # Returns a Time instance of the simultaneous time in the system timezone. + def localtime(utc_offset = nil) + utc = new_offset(0) + + Time.utc( + utc.year, utc.month, utc.day, + utc.hour, utc.min, utc.sec + utc.sec_fraction + ).getlocal(utc_offset) + end + alias_method :getlocal, :localtime + + # Returns a Time instance of the simultaneous time in the UTC timezone. + # + # DateTime.civil(2005, 2, 21, 10, 11, 12, Rational(-6, 24)) # => Mon, 21 Feb 2005 10:11:12 -0600 + # DateTime.civil(2005, 2, 21, 10, 11, 12, Rational(-6, 24)).utc # => Mon, 21 Feb 2005 16:11:12 UTC + def utc + utc = new_offset(0) + + Time.utc( + utc.year, utc.month, utc.day, + utc.hour, utc.min, utc.sec + utc.sec_fraction + ) + end + alias_method :getgm, :utc + alias_method :getutc, :utc + alias_method :gmtime, :utc + + # Returns +true+ if offset == 0. + def utc? + offset == 0 + end + + # Returns the offset value in seconds. + def utc_offset + (offset * 86400).to_i + end + + # Layers additional behavior on DateTime#<=> so that Time and + # ActiveSupport::TimeWithZone instances can be compared with a DateTime. + def <=>(other) + if other.respond_to? :to_datetime + super other.to_datetime rescue nil + else + super + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_time/compatibility.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_time/compatibility.rb new file mode 100644 index 0000000000..7600a067cc --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_time/compatibility.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require "active_support/core_ext/date_and_time/compatibility" +require "active_support/core_ext/module/redefine_method" + +class DateTime + include DateAndTime::Compatibility + + silence_redefinition_of_method :to_time + + # Either return an instance of +Time+ with the same UTC offset + # as +self+ or an instance of +Time+ representing the same time + # in the local system timezone depending on the setting of + # on the setting of +ActiveSupport.to_time_preserves_timezone+. + def to_time + preserve_timezone ? getlocal(utc_offset) : getlocal + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_time/conversions.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_time/conversions.rb new file mode 100644 index 0000000000..29725c89f7 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/date_time/conversions.rb @@ -0,0 +1,107 @@ +# frozen_string_literal: true + +require "date" +require "active_support/inflector/methods" +require "active_support/core_ext/time/conversions" +require "active_support/core_ext/date_time/calculations" +require "active_support/values/time_zone" + +class DateTime + # Convert to a formatted string. See Time::DATE_FORMATS for predefined formats. + # + # This method is aliased to to_s. + # + # === Examples + # datetime = DateTime.civil(2007, 12, 4, 0, 0, 0, 0) # => Tue, 04 Dec 2007 00:00:00 +0000 + # + # datetime.to_formatted_s(:db) # => "2007-12-04 00:00:00" + # datetime.to_s(:db) # => "2007-12-04 00:00:00" + # datetime.to_s(:number) # => "20071204000000" + # datetime.to_formatted_s(:short) # => "04 Dec 00:00" + # datetime.to_formatted_s(:long) # => "December 04, 2007 00:00" + # datetime.to_formatted_s(:long_ordinal) # => "December 4th, 2007 00:00" + # datetime.to_formatted_s(:rfc822) # => "Tue, 04 Dec 2007 00:00:00 +0000" + # datetime.to_formatted_s(:iso8601) # => "2007-12-04T00:00:00+00:00" + # + # == Adding your own datetime formats to to_formatted_s + # DateTime formats are shared with Time. You can add your own to the + # Time::DATE_FORMATS hash. Use the format name as the hash key and + # either a strftime string or Proc instance that takes a time or + # datetime argument as the value. + # + # # config/initializers/time_formats.rb + # Time::DATE_FORMATS[:month_and_year] = '%B %Y' + # Time::DATE_FORMATS[:short_ordinal] = lambda { |time| time.strftime("%B #{time.day.ordinalize}") } + def to_formatted_s(format = :default) + if formatter = ::Time::DATE_FORMATS[format] + formatter.respond_to?(:call) ? formatter.call(self).to_s : strftime(formatter) + else + to_default_s + end + end + alias_method :to_default_s, :to_s if instance_methods(false).include?(:to_s) + alias_method :to_s, :to_formatted_s + + # Returns a formatted string of the offset from UTC, or an alternative + # string if the time zone is already UTC. + # + # datetime = DateTime.civil(2000, 1, 1, 0, 0, 0, Rational(-6, 24)) + # datetime.formatted_offset # => "-06:00" + # datetime.formatted_offset(false) # => "-0600" + def formatted_offset(colon = true, alternate_utc_string = nil) + utc? && alternate_utc_string || ActiveSupport::TimeZone.seconds_to_utc_offset(utc_offset, colon) + end + + # Overrides the default inspect method with a human readable one, e.g., "Mon, 21 Feb 2005 14:30:00 +0000". + def readable_inspect + to_s(:rfc822) + end + alias_method :default_inspect, :inspect + alias_method :inspect, :readable_inspect + + # Returns DateTime with local offset for given year if format is local else + # offset is zero. + # + # DateTime.civil_from_format :local, 2012 + # # => Sun, 01 Jan 2012 00:00:00 +0300 + # DateTime.civil_from_format :local, 2012, 12, 17 + # # => Mon, 17 Dec 2012 00:00:00 +0000 + def self.civil_from_format(utc_or_local, year, month = 1, day = 1, hour = 0, min = 0, sec = 0) + if utc_or_local.to_sym == :local + offset = ::Time.local(year, month, day).utc_offset.to_r / 86400 + else + offset = 0 + end + civil(year, month, day, hour, min, sec, offset) + end + + # Converts +self+ to a floating-point number of seconds, including fractional microseconds, since the Unix epoch. + def to_f + seconds_since_unix_epoch.to_f + sec_fraction + end + + # Converts +self+ to an integer number of seconds since the Unix epoch. + def to_i + seconds_since_unix_epoch.to_i + end + + # Returns the fraction of a second as microseconds + def usec + (sec_fraction * 1_000_000).to_i + end + + # Returns the fraction of a second as nanoseconds + def nsec + (sec_fraction * 1_000_000_000).to_i + end + + private + + def offset_in_seconds + (offset * 86400).to_i + end + + def seconds_since_unix_epoch + (jd - 2440588) * 86400 - offset_in_seconds + seconds_since_midnight + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/digest/uuid.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/digest/uuid.rb new file mode 100644 index 0000000000..6e949a2d72 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/digest/uuid.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +require "securerandom" + +module Digest + module UUID + DNS_NAMESPACE = "k\xA7\xB8\x10\x9D\xAD\x11\xD1\x80\xB4\x00\xC0O\xD40\xC8" #:nodoc: + URL_NAMESPACE = "k\xA7\xB8\x11\x9D\xAD\x11\xD1\x80\xB4\x00\xC0O\xD40\xC8" #:nodoc: + OID_NAMESPACE = "k\xA7\xB8\x12\x9D\xAD\x11\xD1\x80\xB4\x00\xC0O\xD40\xC8" #:nodoc: + X500_NAMESPACE = "k\xA7\xB8\x14\x9D\xAD\x11\xD1\x80\xB4\x00\xC0O\xD40\xC8" #:nodoc: + + # Generates a v5 non-random UUID (Universally Unique IDentifier). + # + # Using Digest::MD5 generates version 3 UUIDs; Digest::SHA1 generates version 5 UUIDs. + # uuid_from_hash always generates the same UUID for a given name and namespace combination. + # + # See RFC 4122 for details of UUID at: https://www.ietf.org/rfc/rfc4122.txt + def self.uuid_from_hash(hash_class, uuid_namespace, name) + if hash_class == Digest::MD5 + version = 3 + elsif hash_class == Digest::SHA1 + version = 5 + else + raise ArgumentError, "Expected Digest::SHA1 or Digest::MD5, got #{hash_class.name}." + end + + hash = hash_class.new + hash.update(uuid_namespace) + hash.update(name) + + ary = hash.digest.unpack("NnnnnN") + ary[2] = (ary[2] & 0x0FFF) | (version << 12) + ary[3] = (ary[3] & 0x3FFF) | 0x8000 + + "%08x-%04x-%04x-%04x-%04x%08x" % ary + end + + # Convenience method for uuid_from_hash using Digest::MD5. + def self.uuid_v3(uuid_namespace, name) + uuid_from_hash(Digest::MD5, uuid_namespace, name) + end + + # Convenience method for uuid_from_hash using Digest::SHA1. + def self.uuid_v5(uuid_namespace, name) + uuid_from_hash(Digest::SHA1, uuid_namespace, name) + end + + # Convenience method for SecureRandom.uuid. + def self.uuid_v4 + SecureRandom.uuid + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/enumerable.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/enumerable.rb new file mode 100644 index 0000000000..cea6f98cfa --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/enumerable.rb @@ -0,0 +1,164 @@ +# frozen_string_literal: true + +module Enumerable + # Enumerable#sum was added in Ruby 2.4, but it only works with Numeric elements + # when we omit an identity. + # + # We tried shimming it to attempt the fast native method, rescue TypeError, + # and fall back to the compatible implementation, but that's much slower than + # just calling the compat method in the first place. + if Enumerable.instance_methods(false).include?(:sum) && !((?a..?b).sum rescue false) + # :stopdoc: + + # We can't use Refinements here because Refinements with Module which will be prepended + # doesn't work well https://bugs.ruby-lang.org/issues/13446 + alias :_original_sum_with_required_identity :sum + private :_original_sum_with_required_identity + + # :startdoc: + + # Calculates a sum from the elements. + # + # payments.sum { |p| p.price * p.tax_rate } + # payments.sum(&:price) + # + # The latter is a shortcut for: + # + # payments.inject(0) { |sum, p| sum + p.price } + # + # It can also calculate the sum without the use of a block. + # + # [5, 15, 10].sum # => 30 + # ['foo', 'bar'].sum # => "foobar" + # [[1, 2], [3, 1, 5]].sum # => [1, 2, 3, 1, 5] + # + # The default sum of an empty list is zero. You can override this default: + # + # [].sum(Payment.new(0)) { |i| i.amount } # => Payment.new(0) + def sum(identity = nil, &block) + if identity + _original_sum_with_required_identity(identity, &block) + elsif block_given? + map(&block).sum(identity) + else + inject(:+) || 0 + end + end + else + def sum(identity = nil, &block) + if block_given? + map(&block).sum(identity) + else + sum = identity ? inject(identity, :+) : inject(:+) + sum || identity || 0 + end + end + end + + # Convert an enumerable to a hash. + # + # people.index_by(&:login) + # # => { "nextangle" => , "chade-" => , ...} + # people.index_by { |person| "#{person.first_name} #{person.last_name}" } + # # => { "Chade- Fowlersburg-e" => , "David Heinemeier Hansson" => , ...} + def index_by + if block_given? + result = {} + each { |elem| result[yield(elem)] = elem } + result + else + to_enum(:index_by) { size if respond_to?(:size) } + end + end + + # Returns +true+ if the enumerable has more than 1 element. Functionally + # equivalent to enum.to_a.size > 1. Can be called with a block too, + # much like any?, so people.many? { |p| p.age > 26 } returns +true+ + # if more than one person is over 26. + def many? + cnt = 0 + if block_given? + any? do |element| + cnt += 1 if yield element + cnt > 1 + end + else + any? { (cnt += 1) > 1 } + end + end + + # The negative of the Enumerable#include?. Returns +true+ if the + # collection does not include the object. + def exclude?(object) + !include?(object) + end + + # Returns a copy of the enumerable without the specified elements. + # + # ["David", "Rafael", "Aaron", "Todd"].without "Aaron", "Todd" + # # => ["David", "Rafael"] + # + # {foo: 1, bar: 2, baz: 3}.without :bar + # # => {foo: 1, baz: 3} + def without(*elements) + reject { |element| elements.include?(element) } + end + + # Convert an enumerable to an array based on the given key. + # + # [{ name: "David" }, { name: "Rafael" }, { name: "Aaron" }].pluck(:name) + # # => ["David", "Rafael", "Aaron"] + # + # [{ id: 1, name: "David" }, { id: 2, name: "Rafael" }].pluck(:id, :name) + # # => [[1, "David"], [2, "Rafael"]] + def pluck(*keys) + if keys.many? + map { |element| keys.map { |key| element[key] } } + else + map { |element| element[keys.first] } + end + end +end + +class Range #:nodoc: + # Optimize range sum to use arithmetic progression if a block is not given and + # we have a range of numeric values. + def sum(identity = nil) + if block_given? || !(first.is_a?(Integer) && last.is_a?(Integer)) + super + else + actual_last = exclude_end? ? (last - 1) : last + if actual_last >= first + sum = identity || 0 + sum + (actual_last - first + 1) * (actual_last + first) / 2 + else + identity || 0 + end + end + end +end + +# Array#sum was added in Ruby 2.4 but it only works with Numeric elements. +# +# We tried shimming it to attempt the fast native method, rescue TypeError, +# and fall back to the compatible implementation, but that's much slower than +# just calling the compat method in the first place. +if Array.instance_methods(false).include?(:sum) && !(%w[a].sum rescue false) + # Using Refinements here in order not to expose our internal method + using Module.new { + refine Array do + alias :orig_sum :sum + end + } + + class Array + def sum(init = nil, &block) #:nodoc: + if init.is_a?(Numeric) || first.is_a?(Numeric) + init ||= 0 + orig_sum(init, &block) + else + super + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/file.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/file.rb new file mode 100644 index 0000000000..64553bfa4e --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/file.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +require "active_support/core_ext/file/atomic" diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash.rb new file mode 100644 index 0000000000..e19aeaa983 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require "active_support/core_ext/hash/compact" +require "active_support/core_ext/hash/conversions" +require "active_support/core_ext/hash/deep_merge" +require "active_support/core_ext/hash/except" +require "active_support/core_ext/hash/indifferent_access" +require "active_support/core_ext/hash/keys" +require "active_support/core_ext/hash/reverse_merge" +require "active_support/core_ext/hash/slice" +require "active_support/core_ext/hash/transform_values" diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/compact.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/compact.rb new file mode 100644 index 0000000000..d6364dd9f3 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/compact.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +class Hash + unless Hash.instance_methods(false).include?(:compact) + # Returns a hash with non +nil+ values. + # + # hash = { a: true, b: false, c: nil } + # hash.compact # => { a: true, b: false } + # hash # => { a: true, b: false, c: nil } + # { c: nil }.compact # => {} + # { c: true }.compact # => { c: true } + def compact + select { |_, value| !value.nil? } + end + end + + unless Hash.instance_methods(false).include?(:compact!) + # Replaces current hash with non +nil+ values. + # Returns +nil+ if no changes were made, otherwise returns the hash. + # + # hash = { a: true, b: false, c: nil } + # hash.compact! # => { a: true, b: false } + # hash # => { a: true, b: false } + # { c: true }.compact! # => nil + def compact! + reject! { |_, value| value.nil? } + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/conversions.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/conversions.rb new file mode 100644 index 0000000000..5b48254646 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/conversions.rb @@ -0,0 +1,263 @@ +# frozen_string_literal: true + +require "active_support/xml_mini" +require "active_support/time" +require "active_support/core_ext/object/blank" +require "active_support/core_ext/object/to_param" +require "active_support/core_ext/object/to_query" +require "active_support/core_ext/array/wrap" +require "active_support/core_ext/hash/reverse_merge" +require "active_support/core_ext/string/inflections" + +class Hash + # Returns a string containing an XML representation of its receiver: + # + # { foo: 1, bar: 2 }.to_xml + # # => + # # + # # + # # 1 + # # 2 + # # + # + # To do so, the method loops over the pairs and builds nodes that depend on + # the _values_. Given a pair +key+, +value+: + # + # * If +value+ is a hash there's a recursive call with +key+ as :root. + # + # * If +value+ is an array there's a recursive call with +key+ as :root, + # and +key+ singularized as :children. + # + # * If +value+ is a callable object it must expect one or two arguments. Depending + # on the arity, the callable is invoked with the +options+ hash as first argument + # with +key+ as :root, and +key+ singularized as second argument. The + # callable can add nodes by using options[:builder]. + # + # {foo: lambda { |options, key| options[:builder].b(key) }}.to_xml + # # => "foo" + # + # * If +value+ responds to +to_xml+ the method is invoked with +key+ as :root. + # + # class Foo + # def to_xml(options) + # options[:builder].bar 'fooing!' + # end + # end + # + # { foo: Foo.new }.to_xml(skip_instruct: true) + # # => + # # + # # fooing! + # # + # + # * Otherwise, a node with +key+ as tag is created with a string representation of + # +value+ as text node. If +value+ is +nil+ an attribute "nil" set to "true" is added. + # Unless the option :skip_types exists and is true, an attribute "type" is + # added as well according to the following mapping: + # + # XML_TYPE_NAMES = { + # "Symbol" => "symbol", + # "Integer" => "integer", + # "BigDecimal" => "decimal", + # "Float" => "float", + # "TrueClass" => "boolean", + # "FalseClass" => "boolean", + # "Date" => "date", + # "DateTime" => "dateTime", + # "Time" => "dateTime" + # } + # + # By default the root node is "hash", but that's configurable via the :root option. + # + # The default XML builder is a fresh instance of Builder::XmlMarkup. You can + # configure your own builder with the :builder option. The method also accepts + # options like :dasherize and friends, they are forwarded to the builder. + def to_xml(options = {}) + require "active_support/builder" unless defined?(Builder) + + options = options.dup + options[:indent] ||= 2 + options[:root] ||= "hash" + options[:builder] ||= Builder::XmlMarkup.new(indent: options[:indent]) + + builder = options[:builder] + builder.instruct! unless options.delete(:skip_instruct) + + root = ActiveSupport::XmlMini.rename_key(options[:root].to_s, options) + + builder.tag!(root) do + each { |key, value| ActiveSupport::XmlMini.to_tag(key, value, options) } + yield builder if block_given? + end + end + + class << self + # Returns a Hash containing a collection of pairs when the key is the node name and the value is + # its content + # + # xml = <<-XML + # + # + # 1 + # 2 + # + # XML + # + # hash = Hash.from_xml(xml) + # # => {"hash"=>{"foo"=>1, "bar"=>2}} + # + # +DisallowedType+ is raised if the XML contains attributes with type="yaml" or + # type="symbol". Use Hash.from_trusted_xml to + # parse this XML. + # + # Custom +disallowed_types+ can also be passed in the form of an + # array. + # + # xml = <<-XML + # + # + # 1 + # "David" + # + # XML + # + # hash = Hash.from_xml(xml, ['integer']) + # # => ActiveSupport::XMLConverter::DisallowedType: Disallowed type attribute: "integer" + # + # Note that passing custom disallowed types will override the default types, + # which are Symbol and YAML. + def from_xml(xml, disallowed_types = nil) + ActiveSupport::XMLConverter.new(xml, disallowed_types).to_h + end + + # Builds a Hash from XML just like Hash.from_xml, but also allows Symbol and YAML. + def from_trusted_xml(xml) + from_xml xml, [] + end + end +end + +module ActiveSupport + class XMLConverter # :nodoc: + # Raised if the XML contains attributes with type="yaml" or + # type="symbol". Read Hash#from_xml for more details. + class DisallowedType < StandardError + def initialize(type) + super "Disallowed type attribute: #{type.inspect}" + end + end + + DISALLOWED_TYPES = %w(symbol yaml) + + def initialize(xml, disallowed_types = nil) + @xml = normalize_keys(XmlMini.parse(xml)) + @disallowed_types = disallowed_types || DISALLOWED_TYPES + end + + def to_h + deep_to_h(@xml) + end + + private + def normalize_keys(params) + case params + when Hash + Hash[params.map { |k, v| [k.to_s.tr("-", "_"), normalize_keys(v)] } ] + when Array + params.map { |v| normalize_keys(v) } + else + params + end + end + + def deep_to_h(value) + case value + when Hash + process_hash(value) + when Array + process_array(value) + when String + value + else + raise "can't typecast #{value.class.name} - #{value.inspect}" + end + end + + def process_hash(value) + if value.include?("type") && !value["type"].is_a?(Hash) && @disallowed_types.include?(value["type"]) + raise DisallowedType, value["type"] + end + + if become_array?(value) + _, entries = Array.wrap(value.detect { |k, v| not v.is_a?(String) }) + if entries.nil? || value["__content__"].try(:empty?) + [] + else + case entries + when Array + entries.collect { |v| deep_to_h(v) } + when Hash + [deep_to_h(entries)] + else + raise "can't typecast #{entries.inspect}" + end + end + elsif become_content?(value) + process_content(value) + + elsif become_empty_string?(value) + "" + elsif become_hash?(value) + xml_value = Hash[value.map { |k, v| [k, deep_to_h(v)] }] + + # Turn { files: { file: # } } into { files: # } so it is compatible with + # how multipart uploaded files from HTML appear + xml_value["file"].is_a?(StringIO) ? xml_value["file"] : xml_value + end + end + + def become_content?(value) + value["type"] == "file" || (value["__content__"] && (value.keys.size == 1 || value["__content__"].present?)) + end + + def become_array?(value) + value["type"] == "array" + end + + def become_empty_string?(value) + # { "string" => true } + # No tests fail when the second term is removed. + value["type"] == "string" && value["nil"] != "true" + end + + def become_hash?(value) + !nothing?(value) && !garbage?(value) + end + + def nothing?(value) + # blank or nil parsed values are represented by nil + value.blank? || value["nil"] == "true" + end + + def garbage?(value) + # If the type is the only element which makes it then + # this still makes the value nil, except if type is + # an XML node(where type['value'] is a Hash) + value["type"] && !value["type"].is_a?(::Hash) && value.size == 1 + end + + def process_content(value) + content = value["__content__"] + if parser = ActiveSupport::XmlMini::PARSING[value["type"]] + parser.arity == 1 ? parser.call(content) : parser.call(content, value) + else + content + end + end + + def process_array(value) + value.map! { |i| deep_to_h(i) } + value.length > 1 ? value : value.first + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/except.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/except.rb new file mode 100644 index 0000000000..6258610c98 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/except.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class Hash + # Returns a hash that includes everything except given keys. + # hash = { a: true, b: false, c: nil } + # hash.except(:c) # => { a: true, b: false } + # hash.except(:a, :b) # => { c: nil } + # hash # => { a: true, b: false, c: nil } + # + # This is useful for limiting a set of parameters to everything but a few known toggles: + # @person.update(params[:person].except(:admin)) + def except(*keys) + dup.except!(*keys) + end + + # Removes the given keys from hash and returns it. + # hash = { a: true, b: false, c: nil } + # hash.except!(:c) # => { a: true, b: false } + # hash # => { a: true, b: false } + def except!(*keys) + keys.each { |key| delete(key) } + self + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/indifferent_access.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/indifferent_access.rb new file mode 100644 index 0000000000..a38f33f128 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/indifferent_access.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +require "active_support/hash_with_indifferent_access" + +class Hash + # Returns an ActiveSupport::HashWithIndifferentAccess out of its receiver: + # + # { a: 1 }.with_indifferent_access['a'] # => 1 + def with_indifferent_access + ActiveSupport::HashWithIndifferentAccess.new(self) + end + + # Called when object is nested under an object that receives + # #with_indifferent_access. This method will be called on the current object + # by the enclosing object and is aliased to #with_indifferent_access by + # default. Subclasses of Hash may overwrite this method to return +self+ if + # converting to an ActiveSupport::HashWithIndifferentAccess would not be + # desirable. + # + # b = { b: 1 } + # { a: b }.with_indifferent_access['a'] # calls b.nested_under_indifferent_access + # # => {"b"=>1} + alias nested_under_indifferent_access with_indifferent_access +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/keys.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/keys.rb new file mode 100644 index 0000000000..bdf196ec3d --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/keys.rb @@ -0,0 +1,172 @@ +# frozen_string_literal: true + +class Hash + # Returns a new hash with all keys converted using the +block+ operation. + # + # hash = { name: 'Rob', age: '28' } + # + # hash.transform_keys { |key| key.to_s.upcase } # => {"NAME"=>"Rob", "AGE"=>"28"} + # + # If you do not provide a +block+, it will return an Enumerator + # for chaining with other methods: + # + # hash.transform_keys.with_index { |k, i| [k, i].join } # => {"name0"=>"Rob", "age1"=>"28"} + def transform_keys + return enum_for(:transform_keys) { size } unless block_given? + result = {} + each_key do |key| + result[yield(key)] = self[key] + end + result + end unless method_defined? :transform_keys + + # Destructively converts all keys using the +block+ operations. + # Same as +transform_keys+ but modifies +self+. + def transform_keys! + return enum_for(:transform_keys!) { size } unless block_given? + keys.each do |key| + self[yield(key)] = delete(key) + end + self + end unless method_defined? :transform_keys! + + # Returns a new hash with all keys converted to strings. + # + # hash = { name: 'Rob', age: '28' } + # + # hash.stringify_keys + # # => {"name"=>"Rob", "age"=>"28"} + def stringify_keys + transform_keys(&:to_s) + end + + # Destructively converts all keys to strings. Same as + # +stringify_keys+, but modifies +self+. + def stringify_keys! + transform_keys!(&:to_s) + end + + # Returns a new hash with all keys converted to symbols, as long as + # they respond to +to_sym+. + # + # hash = { 'name' => 'Rob', 'age' => '28' } + # + # hash.symbolize_keys + # # => {:name=>"Rob", :age=>"28"} + def symbolize_keys + transform_keys { |key| key.to_sym rescue key } + end + alias_method :to_options, :symbolize_keys + + # Destructively converts all keys to symbols, as long as they respond + # to +to_sym+. Same as +symbolize_keys+, but modifies +self+. + def symbolize_keys! + transform_keys! { |key| key.to_sym rescue key } + end + alias_method :to_options!, :symbolize_keys! + + # Validates all keys in a hash match *valid_keys, raising + # +ArgumentError+ on a mismatch. + # + # Note that keys are treated differently than HashWithIndifferentAccess, + # meaning that string and symbol keys will not match. + # + # { name: 'Rob', years: '28' }.assert_valid_keys(:name, :age) # => raises "ArgumentError: Unknown key: :years. Valid keys are: :name, :age" + # { name: 'Rob', age: '28' }.assert_valid_keys('name', 'age') # => raises "ArgumentError: Unknown key: :name. Valid keys are: 'name', 'age'" + # { name: 'Rob', age: '28' }.assert_valid_keys(:name, :age) # => passes, raises nothing + def assert_valid_keys(*valid_keys) + valid_keys.flatten! + each_key do |k| + unless valid_keys.include?(k) + raise ArgumentError.new("Unknown key: #{k.inspect}. Valid keys are: #{valid_keys.map(&:inspect).join(', ')}") + end + end + end + + # Returns a new hash with all keys converted by the block operation. + # This includes the keys from the root hash and from all + # nested hashes and arrays. + # + # hash = { person: { name: 'Rob', age: '28' } } + # + # hash.deep_transform_keys{ |key| key.to_s.upcase } + # # => {"PERSON"=>{"NAME"=>"Rob", "AGE"=>"28"}} + def deep_transform_keys(&block) + _deep_transform_keys_in_object(self, &block) + end + + # Destructively converts all keys by using the block operation. + # This includes the keys from the root hash and from all + # nested hashes and arrays. + def deep_transform_keys!(&block) + _deep_transform_keys_in_object!(self, &block) + end + + # Returns a new hash with all keys converted to strings. + # This includes the keys from the root hash and from all + # nested hashes and arrays. + # + # hash = { person: { name: 'Rob', age: '28' } } + # + # hash.deep_stringify_keys + # # => {"person"=>{"name"=>"Rob", "age"=>"28"}} + def deep_stringify_keys + deep_transform_keys(&:to_s) + end + + # Destructively converts all keys to strings. + # This includes the keys from the root hash and from all + # nested hashes and arrays. + def deep_stringify_keys! + deep_transform_keys!(&:to_s) + end + + # Returns a new hash with all keys converted to symbols, as long as + # they respond to +to_sym+. This includes the keys from the root hash + # and from all nested hashes and arrays. + # + # hash = { 'person' => { 'name' => 'Rob', 'age' => '28' } } + # + # hash.deep_symbolize_keys + # # => {:person=>{:name=>"Rob", :age=>"28"}} + def deep_symbolize_keys + deep_transform_keys { |key| key.to_sym rescue key } + end + + # Destructively converts all keys to symbols, as long as they respond + # to +to_sym+. This includes the keys from the root hash and from all + # nested hashes and arrays. + def deep_symbolize_keys! + deep_transform_keys! { |key| key.to_sym rescue key } + end + + private + # support methods for deep transforming nested hashes and arrays + def _deep_transform_keys_in_object(object, &block) + case object + when Hash + object.each_with_object({}) do |(key, value), result| + result[yield(key)] = _deep_transform_keys_in_object(value, &block) + end + when Array + object.map { |e| _deep_transform_keys_in_object(e, &block) } + else + object + end + end + + def _deep_transform_keys_in_object!(object, &block) + case object + when Hash + object.keys.each do |key| + value = object.delete(key) + object[yield(key)] = _deep_transform_keys_in_object!(value, &block) + end + object + when Array + object.map! { |e| _deep_transform_keys_in_object!(e, &block) } + else + object + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/reverse_merge.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/reverse_merge.rb new file mode 100644 index 0000000000..ef8d592829 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/reverse_merge.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class Hash + # Merges the caller into +other_hash+. For example, + # + # options = options.reverse_merge(size: 25, velocity: 10) + # + # is equivalent to + # + # options = { size: 25, velocity: 10 }.merge(options) + # + # This is particularly useful for initializing an options hash + # with default values. + def reverse_merge(other_hash) + other_hash.merge(self) + end + alias_method :with_defaults, :reverse_merge + + # Destructive +reverse_merge+. + def reverse_merge!(other_hash) + replace(reverse_merge(other_hash)) + end + alias_method :reverse_update, :reverse_merge! + alias_method :with_defaults!, :reverse_merge! +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/slice.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/slice.rb new file mode 100644 index 0000000000..2bd0a56ea4 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/slice.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +class Hash + # Slices a hash to include only the given keys. Returns a hash containing + # the given keys. + # + # { a: 1, b: 2, c: 3, d: 4 }.slice(:a, :b) + # # => {:a=>1, :b=>2} + # + # This is useful for limiting an options hash to valid keys before + # passing to a method: + # + # def search(criteria = {}) + # criteria.assert_valid_keys(:mass, :velocity, :time) + # end + # + # search(options.slice(:mass, :velocity, :time)) + # + # If you have an array of keys you want to limit to, you should splat them: + # + # valid_keys = [:mass, :velocity, :time] + # search(options.slice(*valid_keys)) + def slice(*keys) + keys.each_with_object(Hash.new) { |k, hash| hash[k] = self[k] if has_key?(k) } + end unless method_defined?(:slice) + + # Replaces the hash with only the given keys. + # Returns a hash containing the removed key/value pairs. + # + # { a: 1, b: 2, c: 3, d: 4 }.slice!(:a, :b) + # # => {:c=>3, :d=>4} + def slice!(*keys) + omit = slice(*self.keys - keys) + hash = slice(*keys) + hash.default = default + hash.default_proc = default_proc if default_proc + replace(hash) + omit + end + + # Removes and returns the key/value pairs matching the given keys. + # + # { a: 1, b: 2, c: 3, d: 4 }.extract!(:a, :b) # => {:a=>1, :b=>2} + # { a: 1, b: 2 }.extract!(:a, :x) # => {:a=>1} + def extract!(*keys) + keys.each_with_object(self.class.new) { |key, result| result[key] = delete(key) if has_key?(key) } + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/transform_values.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/transform_values.rb new file mode 100644 index 0000000000..4b19c9fc1f --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/transform_values.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +class Hash + # Returns a new hash with the results of running +block+ once for every value. + # The keys are unchanged. + # + # { a: 1, b: 2, c: 3 }.transform_values { |x| x * 2 } # => { a: 2, b: 4, c: 6 } + # + # If you do not provide a +block+, it will return an Enumerator + # for chaining with other methods: + # + # { a: 1, b: 2 }.transform_values.with_index { |v, i| [v, i].join.to_i } # => { a: 10, b: 21 } + def transform_values + return enum_for(:transform_values) { size } unless block_given? + return {} if empty? + result = self.class.new + each do |key, value| + result[key] = yield(value) + end + result + end unless method_defined? :transform_values + + # Destructively converts all values using the +block+ operations. + # Same as +transform_values+ but modifies +self+. + def transform_values! + return enum_for(:transform_values!) { size } unless block_given? + each do |key, value| + self[key] = yield(value) + end + end unless method_defined? :transform_values! + # TODO: Remove this file when supporting only Ruby 2.4+. +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/integer.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/integer.rb new file mode 100644 index 0000000000..d22701306a --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/integer.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +require "active_support/core_ext/integer/multiple" +require "active_support/core_ext/integer/inflections" +require "active_support/core_ext/integer/time" diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/integer/inflections.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/integer/inflections.rb new file mode 100644 index 0000000000..aef3266f28 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/integer/inflections.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require "active_support/inflector" + +class Integer + # Ordinalize turns a number into an ordinal string used to denote the + # position in an ordered sequence such as 1st, 2nd, 3rd, 4th. + # + # 1.ordinalize # => "1st" + # 2.ordinalize # => "2nd" + # 1002.ordinalize # => "1002nd" + # 1003.ordinalize # => "1003rd" + # -11.ordinalize # => "-11th" + # -1001.ordinalize # => "-1001st" + def ordinalize + ActiveSupport::Inflector.ordinalize(self) + end + + # Ordinal returns the suffix used to denote the position + # in an ordered sequence such as 1st, 2nd, 3rd, 4th. + # + # 1.ordinal # => "st" + # 2.ordinal # => "nd" + # 1002.ordinal # => "nd" + # 1003.ordinal # => "rd" + # -11.ordinal # => "th" + # -1001.ordinal # => "st" + def ordinal + ActiveSupport::Inflector.ordinal(self) + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/integer/multiple.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/integer/multiple.rb new file mode 100644 index 0000000000..e7606662d3 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/integer/multiple.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +class Integer + # Check whether the integer is evenly divisible by the argument. + # + # 0.multiple_of?(0) # => true + # 6.multiple_of?(5) # => false + # 10.multiple_of?(2) # => true + def multiple_of?(number) + number != 0 ? self % number == 0 : zero? + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/integer/time.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/integer/time.rb new file mode 100644 index 0000000000..5efb89cf9f --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/integer/time.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +require "active_support/duration" +require "active_support/core_ext/numeric/time" + +class Integer + # Returns a Duration instance matching the number of months provided. + # + # 2.months # => 2 months + def months + ActiveSupport::Duration.months(self) + end + alias :month :months + + # Returns a Duration instance matching the number of years provided. + # + # 2.years # => 2 years + def years + ActiveSupport::Duration.years(self) + end + alias :year :years +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/kernel.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/kernel.rb new file mode 100644 index 0000000000..0f4356fbdd --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/kernel.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +require "active_support/core_ext/kernel/agnostics" +require "active_support/core_ext/kernel/concern" +require "active_support/core_ext/kernel/reporting" +require "active_support/core_ext/kernel/singleton_class" diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/kernel/agnostics.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/kernel/agnostics.rb new file mode 100644 index 0000000000..403b5f31f0 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/kernel/agnostics.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class Object + # Makes backticks behave (somewhat more) similarly on all platforms. + # On win32 `nonexistent_command` raises Errno::ENOENT; on Unix, the + # spawned shell prints a message to stderr and sets $?. We emulate + # Unix on the former but not the latter. + def `(command) #:nodoc: + super + rescue Errno::ENOENT => e + STDERR.puts "#$0: #{e}" + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/kernel/concern.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/kernel/concern.rb new file mode 100644 index 0000000000..0b2baed780 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/kernel/concern.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +require "active_support/core_ext/module/concerning" + +module Kernel + module_function + + # A shortcut to define a toplevel concern, not within a module. + # + # See Module::Concerning for more. + def concern(topic, &module_definition) + Object.concern topic, &module_definition + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/kernel/reporting.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/kernel/reporting.rb new file mode 100644 index 0000000000..9155bd6c10 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/kernel/reporting.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +module Kernel + module_function + + # Sets $VERBOSE to +nil+ for the duration of the block and back to its original + # value afterwards. + # + # silence_warnings do + # value = noisy_call # no warning voiced + # end + # + # noisy_call # warning voiced + def silence_warnings + with_warnings(nil) { yield } + end + + # Sets $VERBOSE to +true+ for the duration of the block and back to its + # original value afterwards. + def enable_warnings + with_warnings(true) { yield } + end + + # Sets $VERBOSE for the duration of the block and back to its original + # value afterwards. + def with_warnings(flag) + old_verbose, $VERBOSE = $VERBOSE, flag + yield + ensure + $VERBOSE = old_verbose + end + + # Blocks and ignores any exception passed as argument if raised within the block. + # + # suppress(ZeroDivisionError) do + # 1/0 + # puts 'This code is NOT reached' + # end + # + # puts 'This code gets executed and nothing related to ZeroDivisionError was seen' + def suppress(*exception_classes) + yield + rescue *exception_classes + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/kernel/singleton_class.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/kernel/singleton_class.rb new file mode 100644 index 0000000000..6715eba80a --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/kernel/singleton_class.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +module Kernel + # class_eval on an object acts like singleton_class.class_eval. + def class_eval(*args, &block) + singleton_class.class_eval(*args, &block) + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/load_error.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/load_error.rb new file mode 100644 index 0000000000..750f858fcc --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/load_error.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class LoadError + # Returns true if the given path name (except perhaps for the ".rb" + # extension) is the missing file which caused the exception to be raised. + def is_missing?(location) + location.sub(/\.rb$/, "".freeze) == path.sub(/\.rb$/, "".freeze) + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/marshal.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/marshal.rb new file mode 100644 index 0000000000..0c72cd7b47 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/marshal.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module ActiveSupport + module MarshalWithAutoloading # :nodoc: + def load(source, proc = nil) + super(source, proc) + rescue ArgumentError, NameError => exc + if exc.message.match(%r|undefined class/module (.+?)(?:::)?\z|) + # try loading the class/module + loaded = $1.constantize + + raise unless $1 == loaded.name + + # if it is an IO we need to go back to read the object + source.rewind if source.respond_to?(:rewind) + retry + else + raise exc + end + end + end +end + +Marshal.singleton_class.prepend(ActiveSupport::MarshalWithAutoloading) diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module.rb new file mode 100644 index 0000000000..d91e3fba6a --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +require "active_support/core_ext/module/aliasing" +require "active_support/core_ext/module/introspection" +require "active_support/core_ext/module/anonymous" +require "active_support/core_ext/module/reachable" +require "active_support/core_ext/module/attribute_accessors" +require "active_support/core_ext/module/attribute_accessors_per_thread" +require "active_support/core_ext/module/attr_internal" +require "active_support/core_ext/module/concerning" +require "active_support/core_ext/module/delegation" +require "active_support/core_ext/module/deprecation" +require "active_support/core_ext/module/redefine_method" +require "active_support/core_ext/module/remove_method" diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/aliasing.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/aliasing.rb new file mode 100644 index 0000000000..6f64d11627 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/aliasing.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +class Module + # Allows you to make aliases for attributes, which includes + # getter, setter, and a predicate. + # + # class Content < ActiveRecord::Base + # # has a title attribute + # end + # + # class Email < Content + # alias_attribute :subject, :title + # end + # + # e = Email.find(1) + # e.title # => "Superstars" + # e.subject # => "Superstars" + # e.subject? # => true + # e.subject = "Megastars" + # e.title # => "Megastars" + def alias_attribute(new_name, old_name) + # The following reader methods use an explicit `self` receiver in order to + # support aliases that start with an uppercase letter. Otherwise, they would + # be resolved as constants instead. + module_eval <<-STR, __FILE__, __LINE__ + 1 + def #{new_name}; self.#{old_name}; end # def subject; self.title; end + def #{new_name}?; self.#{old_name}?; end # def subject?; self.title?; end + def #{new_name}=(v); self.#{old_name} = v; end # def subject=(v); self.title = v; end + STR + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/anonymous.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/anonymous.rb new file mode 100644 index 0000000000..d1c86b8722 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/anonymous.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +class Module + # A module may or may not have a name. + # + # module M; end + # M.name # => "M" + # + # m = Module.new + # m.name # => nil + # + # +anonymous?+ method returns true if module does not have a name, false otherwise: + # + # Module.new.anonymous? # => true + # + # module M; end + # M.anonymous? # => false + # + # A module gets a name when it is first assigned to a constant. Either + # via the +module+ or +class+ keyword or by an explicit assignment: + # + # m = Module.new # creates an anonymous module + # m.anonymous? # => true + # M = m # m gets a name here as a side-effect + # m.name # => "M" + # m.anonymous? # => false + def anonymous? + name.nil? + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/attr_internal.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/attr_internal.rb new file mode 100644 index 0000000000..7801f6d181 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/attr_internal.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +class Module + # Declares an attribute reader backed by an internally-named instance variable. + def attr_internal_reader(*attrs) + attrs.each { |attr_name| attr_internal_define(attr_name, :reader) } + end + + # Declares an attribute writer backed by an internally-named instance variable. + def attr_internal_writer(*attrs) + attrs.each { |attr_name| attr_internal_define(attr_name, :writer) } + end + + # Declares an attribute reader and writer backed by an internally-named instance + # variable. + def attr_internal_accessor(*attrs) + attr_internal_reader(*attrs) + attr_internal_writer(*attrs) + end + alias_method :attr_internal, :attr_internal_accessor + + class << self; attr_accessor :attr_internal_naming_format end + self.attr_internal_naming_format = "@_%s" + + private + def attr_internal_ivar_name(attr) + Module.attr_internal_naming_format % attr + end + + def attr_internal_define(attr_name, type) + internal_name = attr_internal_ivar_name(attr_name).sub(/\A@/, "") + # use native attr_* methods as they are faster on some Ruby implementations + send("attr_#{type}", internal_name) + attr_name, internal_name = "#{attr_name}=", "#{internal_name}=" if type == :writer + alias_method attr_name, internal_name + remove_method internal_name + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/attribute_accessors.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/attribute_accessors.rb new file mode 100644 index 0000000000..580baffa2b --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/attribute_accessors.rb @@ -0,0 +1,215 @@ +# frozen_string_literal: true + +require "active_support/core_ext/array/extract_options" +require "active_support/core_ext/regexp" + +# Extends the module object with class/module and instance accessors for +# class/module attributes, just like the native attr* accessors for instance +# attributes. +class Module + # Defines a class attribute and creates a class and instance reader methods. + # The underlying class variable is set to +nil+, if it is not previously + # defined. All class and instance methods created will be public, even if + # this method is called with a private or protected access modifier. + # + # module HairColors + # mattr_reader :hair_colors + # end + # + # HairColors.hair_colors # => nil + # HairColors.class_variable_set("@@hair_colors", [:brown, :black]) + # HairColors.hair_colors # => [:brown, :black] + # + # The attribute name must be a valid method name in Ruby. + # + # module Foo + # mattr_reader :"1_Badname" + # end + # # => NameError: invalid attribute name: 1_Badname + # + # If you want to opt out the creation on the instance reader method, pass + # instance_reader: false or instance_accessor: false. + # + # module HairColors + # mattr_reader :hair_colors, instance_reader: false + # end + # + # class Person + # include HairColors + # end + # + # Person.new.hair_colors # => NoMethodError + # + # You can set a default value for the attribute. + # + # module HairColors + # mattr_reader :hair_colors, default: [:brown, :black, :blonde, :red] + # end + # + # class Person + # include HairColors + # end + # + # Person.new.hair_colors # => [:brown, :black, :blonde, :red] + def mattr_reader(*syms, instance_reader: true, instance_accessor: true, default: nil) + syms.each do |sym| + raise NameError.new("invalid attribute name: #{sym}") unless /\A[_A-Za-z]\w*\z/.match?(sym) + class_eval(<<-EOS, __FILE__, __LINE__ + 1) + @@#{sym} = nil unless defined? @@#{sym} + + def self.#{sym} + @@#{sym} + end + EOS + + if instance_reader && instance_accessor + class_eval(<<-EOS, __FILE__, __LINE__ + 1) + def #{sym} + @@#{sym} + end + EOS + end + + sym_default_value = (block_given? && default.nil?) ? yield : default + class_variable_set("@@#{sym}", sym_default_value) unless sym_default_value.nil? + end + end + alias :cattr_reader :mattr_reader + + # Defines a class attribute and creates a class and instance writer methods to + # allow assignment to the attribute. All class and instance methods created + # will be public, even if this method is called with a private or protected + # access modifier. + # + # module HairColors + # mattr_writer :hair_colors + # end + # + # class Person + # include HairColors + # end + # + # HairColors.hair_colors = [:brown, :black] + # Person.class_variable_get("@@hair_colors") # => [:brown, :black] + # Person.new.hair_colors = [:blonde, :red] + # HairColors.class_variable_get("@@hair_colors") # => [:blonde, :red] + # + # If you want to opt out the instance writer method, pass + # instance_writer: false or instance_accessor: false. + # + # module HairColors + # mattr_writer :hair_colors, instance_writer: false + # end + # + # class Person + # include HairColors + # end + # + # Person.new.hair_colors = [:blonde, :red] # => NoMethodError + # + # You can set a default value for the attribute. + # + # module HairColors + # mattr_writer :hair_colors, default: [:brown, :black, :blonde, :red] + # end + # + # class Person + # include HairColors + # end + # + # Person.class_variable_get("@@hair_colors") # => [:brown, :black, :blonde, :red] + def mattr_writer(*syms, instance_writer: true, instance_accessor: true, default: nil) + syms.each do |sym| + raise NameError.new("invalid attribute name: #{sym}") unless /\A[_A-Za-z]\w*\z/.match?(sym) + class_eval(<<-EOS, __FILE__, __LINE__ + 1) + @@#{sym} = nil unless defined? @@#{sym} + + def self.#{sym}=(obj) + @@#{sym} = obj + end + EOS + + if instance_writer && instance_accessor + class_eval(<<-EOS, __FILE__, __LINE__ + 1) + def #{sym}=(obj) + @@#{sym} = obj + end + EOS + end + + sym_default_value = (block_given? && default.nil?) ? yield : default + send("#{sym}=", sym_default_value) unless sym_default_value.nil? + end + end + alias :cattr_writer :mattr_writer + + # Defines both class and instance accessors for class attributes. + # All class and instance methods created will be public, even if + # this method is called with a private or protected access modifier. + # + # module HairColors + # mattr_accessor :hair_colors + # end + # + # class Person + # include HairColors + # end + # + # HairColors.hair_colors = [:brown, :black, :blonde, :red] + # HairColors.hair_colors # => [:brown, :black, :blonde, :red] + # Person.new.hair_colors # => [:brown, :black, :blonde, :red] + # + # If a subclass changes the value then that would also change the value for + # parent class. Similarly if parent class changes the value then that would + # change the value of subclasses too. + # + # class Male < Person + # end + # + # Male.new.hair_colors << :blue + # Person.new.hair_colors # => [:brown, :black, :blonde, :red, :blue] + # + # To opt out of the instance writer method, pass instance_writer: false. + # To opt out of the instance reader method, pass instance_reader: false. + # + # module HairColors + # mattr_accessor :hair_colors, instance_writer: false, instance_reader: false + # end + # + # class Person + # include HairColors + # end + # + # Person.new.hair_colors = [:brown] # => NoMethodError + # Person.new.hair_colors # => NoMethodError + # + # Or pass instance_accessor: false, to opt out both instance methods. + # + # module HairColors + # mattr_accessor :hair_colors, instance_accessor: false + # end + # + # class Person + # include HairColors + # end + # + # Person.new.hair_colors = [:brown] # => NoMethodError + # Person.new.hair_colors # => NoMethodError + # + # You can set a default value for the attribute. + # + # module HairColors + # mattr_accessor :hair_colors, default: [:brown, :black, :blonde, :red] + # end + # + # class Person + # include HairColors + # end + # + # Person.class_variable_get("@@hair_colors") # => [:brown, :black, :blonde, :red] + def mattr_accessor(*syms, instance_reader: true, instance_writer: true, instance_accessor: true, default: nil, &blk) + mattr_reader(*syms, instance_reader: instance_reader, instance_accessor: instance_accessor, default: default, &blk) + mattr_writer(*syms, instance_writer: instance_writer, instance_accessor: instance_accessor, default: default) + end + alias :cattr_accessor :mattr_accessor +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb new file mode 100644 index 0000000000..4b9b6ea9bd --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb @@ -0,0 +1,150 @@ +# frozen_string_literal: true + +require "active_support/core_ext/array/extract_options" +require "active_support/core_ext/regexp" + +# Extends the module object with class/module and instance accessors for +# class/module attributes, just like the native attr* accessors for instance +# attributes, but does so on a per-thread basis. +# +# So the values are scoped within the Thread.current space under the class name +# of the module. +class Module + # Defines a per-thread class attribute and creates class and instance reader methods. + # The underlying per-thread class variable is set to +nil+, if it is not previously defined. + # + # module Current + # thread_mattr_reader :user + # end + # + # Current.user # => nil + # Thread.current[:attr_Current_user] = "DHH" + # Current.user # => "DHH" + # + # The attribute name must be a valid method name in Ruby. + # + # module Foo + # thread_mattr_reader :"1_Badname" + # end + # # => NameError: invalid attribute name: 1_Badname + # + # If you want to opt out of the creation of the instance reader method, pass + # instance_reader: false or instance_accessor: false. + # + # class Current + # thread_mattr_reader :user, instance_reader: false + # end + # + # Current.new.user # => NoMethodError + def thread_mattr_reader(*syms) # :nodoc: + options = syms.extract_options! + + syms.each do |sym| + raise NameError.new("invalid attribute name: #{sym}") unless /^[_A-Za-z]\w*$/.match?(sym) + + # The following generated method concatenates `name` because we want it + # to work with inheritance via polymorphism. + class_eval(<<-EOS, __FILE__, __LINE__ + 1) + def self.#{sym} + Thread.current["attr_" + name + "_#{sym}"] + end + EOS + + unless options[:instance_reader] == false || options[:instance_accessor] == false + class_eval(<<-EOS, __FILE__, __LINE__ + 1) + def #{sym} + self.class.#{sym} + end + EOS + end + end + end + alias :thread_cattr_reader :thread_mattr_reader + + # Defines a per-thread class attribute and creates a class and instance writer methods to + # allow assignment to the attribute. + # + # module Current + # thread_mattr_writer :user + # end + # + # Current.user = "DHH" + # Thread.current[:attr_Current_user] # => "DHH" + # + # If you want to opt out of the creation of the instance writer method, pass + # instance_writer: false or instance_accessor: false. + # + # class Current + # thread_mattr_writer :user, instance_writer: false + # end + # + # Current.new.user = "DHH" # => NoMethodError + def thread_mattr_writer(*syms) # :nodoc: + options = syms.extract_options! + syms.each do |sym| + raise NameError.new("invalid attribute name: #{sym}") unless /^[_A-Za-z]\w*$/.match?(sym) + + # The following generated method concatenates `name` because we want it + # to work with inheritance via polymorphism. + class_eval(<<-EOS, __FILE__, __LINE__ + 1) + def self.#{sym}=(obj) + Thread.current["attr_" + name + "_#{sym}"] = obj + end + EOS + + unless options[:instance_writer] == false || options[:instance_accessor] == false + class_eval(<<-EOS, __FILE__, __LINE__ + 1) + def #{sym}=(obj) + self.class.#{sym} = obj + end + EOS + end + end + end + alias :thread_cattr_writer :thread_mattr_writer + + # Defines both class and instance accessors for class attributes. + # + # class Account + # thread_mattr_accessor :user + # end + # + # Account.user = "DHH" + # Account.user # => "DHH" + # Account.new.user # => "DHH" + # + # If a subclass changes the value, the parent class' value is not changed. + # Similarly, if the parent class changes the value, the value of subclasses + # is not changed. + # + # class Customer < Account + # end + # + # Customer.user = "Rafael" + # Customer.user # => "Rafael" + # Account.user # => "DHH" + # + # To opt out of the instance writer method, pass instance_writer: false. + # To opt out of the instance reader method, pass instance_reader: false. + # + # class Current + # thread_mattr_accessor :user, instance_writer: false, instance_reader: false + # end + # + # Current.new.user = "DHH" # => NoMethodError + # Current.new.user # => NoMethodError + # + # Or pass instance_accessor: false, to opt out both instance methods. + # + # class Current + # mattr_accessor :user, instance_accessor: false + # end + # + # Current.new.user = "DHH" # => NoMethodError + # Current.new.user # => NoMethodError + def thread_mattr_accessor(*syms) + thread_mattr_reader(*syms) + thread_mattr_writer(*syms) + end + alias :thread_cattr_accessor :thread_mattr_accessor +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/concerning.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/concerning.rb new file mode 100644 index 0000000000..7bbbf321ab --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/concerning.rb @@ -0,0 +1,134 @@ +# frozen_string_literal: true + +require "active_support/concern" + +class Module + # = Bite-sized separation of concerns + # + # We often find ourselves with a medium-sized chunk of behavior that we'd + # like to extract, but only mix in to a single class. + # + # Extracting a plain old Ruby object to encapsulate it and collaborate or + # delegate to the original object is often a good choice, but when there's + # no additional state to encapsulate or we're making DSL-style declarations + # about the parent class, introducing new collaborators can obfuscate rather + # than simplify. + # + # The typical route is to just dump everything in a monolithic class, perhaps + # with a comment, as a least-bad alternative. Using modules in separate files + # means tedious sifting to get a big-picture view. + # + # = Dissatisfying ways to separate small concerns + # + # == Using comments: + # + # class Todo < ApplicationRecord + # # Other todo implementation + # # ... + # + # ## Event tracking + # has_many :events + # + # before_create :track_creation + # + # private + # def track_creation + # # ... + # end + # end + # + # == With an inline module: + # + # Noisy syntax. + # + # class Todo < ApplicationRecord + # # Other todo implementation + # # ... + # + # module EventTracking + # extend ActiveSupport::Concern + # + # included do + # has_many :events + # before_create :track_creation + # end + # + # private + # def track_creation + # # ... + # end + # end + # include EventTracking + # end + # + # == Mix-in noise exiled to its own file: + # + # Once our chunk of behavior starts pushing the scroll-to-understand-it + # boundary, we give in and move it to a separate file. At this size, the + # increased overhead can be a reasonable tradeoff even if it reduces our + # at-a-glance perception of how things work. + # + # class Todo < ApplicationRecord + # # Other todo implementation + # # ... + # + # include TodoEventTracking + # end + # + # = Introducing Module#concerning + # + # By quieting the mix-in noise, we arrive at a natural, low-ceremony way to + # separate bite-sized concerns. + # + # class Todo < ApplicationRecord + # # Other todo implementation + # # ... + # + # concerning :EventTracking do + # included do + # has_many :events + # before_create :track_creation + # end + # + # private + # def track_creation + # # ... + # end + # end + # end + # + # Todo.ancestors + # # => [Todo, Todo::EventTracking, ApplicationRecord, Object] + # + # This small step has some wonderful ripple effects. We can + # * grok the behavior of our class in one glance, + # * clean up monolithic junk-drawer classes by separating their concerns, and + # * stop leaning on protected/private for crude "this is internal stuff" modularity. + module Concerning + # Define a new concern and mix it in. + def concerning(topic, &block) + include concern(topic, &block) + end + + # A low-cruft shortcut to define a concern. + # + # concern :EventTracking do + # ... + # end + # + # is equivalent to + # + # module EventTracking + # extend ActiveSupport::Concern + # + # ... + # end + def concern(topic, &module_definition) + const_set topic, Module.new { + extend ::ActiveSupport::Concern + module_eval(&module_definition) + } + end + end + include Concerning +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/delegation.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/delegation.rb new file mode 100644 index 0000000000..4310df3024 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/delegation.rb @@ -0,0 +1,287 @@ +# frozen_string_literal: true + +require "set" +require "active_support/core_ext/regexp" + +class Module + # Error generated by +delegate+ when a method is called on +nil+ and +allow_nil+ + # option is not used. + class DelegationError < NoMethodError; end + + RUBY_RESERVED_KEYWORDS = %w(alias and BEGIN begin break case class def defined? do + else elsif END end ensure false for if in module next nil not or redo rescue retry + return self super then true undef unless until when while yield) + DELEGATION_RESERVED_KEYWORDS = %w(_ arg args block) + DELEGATION_RESERVED_METHOD_NAMES = Set.new( + RUBY_RESERVED_KEYWORDS + DELEGATION_RESERVED_KEYWORDS + ).freeze + + # Provides a +delegate+ class method to easily expose contained objects' + # public methods as your own. + # + # ==== Options + # * :to - Specifies the target object + # * :prefix - Prefixes the new method with the target name or a custom prefix + # * :allow_nil - if set to true, prevents a +Module::DelegationError+ + # from being raised + # + # The macro receives one or more method names (specified as symbols or + # strings) and the name of the target object via the :to option + # (also a symbol or string). + # + # Delegation is particularly useful with Active Record associations: + # + # class Greeter < ActiveRecord::Base + # def hello + # 'hello' + # end + # + # def goodbye + # 'goodbye' + # end + # end + # + # class Foo < ActiveRecord::Base + # belongs_to :greeter + # delegate :hello, to: :greeter + # end + # + # Foo.new.hello # => "hello" + # Foo.new.goodbye # => NoMethodError: undefined method `goodbye' for # + # + # Multiple delegates to the same target are allowed: + # + # class Foo < ActiveRecord::Base + # belongs_to :greeter + # delegate :hello, :goodbye, to: :greeter + # end + # + # Foo.new.goodbye # => "goodbye" + # + # Methods can be delegated to instance variables, class variables, or constants + # by providing them as a symbols: + # + # class Foo + # CONSTANT_ARRAY = [0,1,2,3] + # @@class_array = [4,5,6,7] + # + # def initialize + # @instance_array = [8,9,10,11] + # end + # delegate :sum, to: :CONSTANT_ARRAY + # delegate :min, to: :@@class_array + # delegate :max, to: :@instance_array + # end + # + # Foo.new.sum # => 6 + # Foo.new.min # => 4 + # Foo.new.max # => 11 + # + # It's also possible to delegate a method to the class by using +:class+: + # + # class Foo + # def self.hello + # "world" + # end + # + # delegate :hello, to: :class + # end + # + # Foo.new.hello # => "world" + # + # Delegates can optionally be prefixed using the :prefix option. If the value + # is true, the delegate methods are prefixed with the name of the object being + # delegated to. + # + # Person = Struct.new(:name, :address) + # + # class Invoice < Struct.new(:client) + # delegate :name, :address, to: :client, prefix: true + # end + # + # john_doe = Person.new('John Doe', 'Vimmersvej 13') + # invoice = Invoice.new(john_doe) + # invoice.client_name # => "John Doe" + # invoice.client_address # => "Vimmersvej 13" + # + # It is also possible to supply a custom prefix. + # + # class Invoice < Struct.new(:client) + # delegate :name, :address, to: :client, prefix: :customer + # end + # + # invoice = Invoice.new(john_doe) + # invoice.customer_name # => 'John Doe' + # invoice.customer_address # => 'Vimmersvej 13' + # + # If the target is +nil+ and does not respond to the delegated method a + # +Module::DelegationError+ is raised. If you wish to instead return +nil+, + # use the :allow_nil option. + # + # class User < ActiveRecord::Base + # has_one :profile + # delegate :age, to: :profile + # end + # + # User.new.age + # # => Module::DelegationError: User#age delegated to profile.age, but profile is nil + # + # But if not having a profile yet is fine and should not be an error + # condition: + # + # class User < ActiveRecord::Base + # has_one :profile + # delegate :age, to: :profile, allow_nil: true + # end + # + # User.new.age # nil + # + # Note that if the target is not +nil+ then the call is attempted regardless of the + # :allow_nil option, and thus an exception is still raised if said object + # does not respond to the method: + # + # class Foo + # def initialize(bar) + # @bar = bar + # end + # + # delegate :name, to: :@bar, allow_nil: true + # end + # + # Foo.new("Bar").name # raises NoMethodError: undefined method `name' + # + # The target method must be public, otherwise it will raise +NoMethodError+. + def delegate(*methods, to: nil, prefix: nil, allow_nil: nil) + unless to + raise ArgumentError, "Delegation needs a target. Supply an options hash with a :to key as the last argument (e.g. delegate :hello, to: :greeter)." + end + + if prefix == true && /^[^a-z_]/.match?(to) + raise ArgumentError, "Can only automatically set the delegation prefix when delegating to a method." + end + + method_prefix = \ + if prefix + "#{prefix == true ? to : prefix}_" + else + "" + end + + location = caller_locations(1, 1).first + file, line = location.path, location.lineno + + to = to.to_s + to = "self.#{to}" if DELEGATION_RESERVED_METHOD_NAMES.include?(to) + + methods.map do |method| + # Attribute writer methods only accept one argument. Makes sure []= + # methods still accept two arguments. + definition = /[^\]]=$/.match?(method) ? "arg" : "*args, &block" + + # The following generated method calls the target exactly once, storing + # the returned value in a dummy variable. + # + # Reason is twofold: On one hand doing less calls is in general better. + # On the other hand it could be that the target has side-effects, + # whereas conceptually, from the user point of view, the delegator should + # be doing one call. + if allow_nil + method_def = [ + "def #{method_prefix}#{method}(#{definition})", + "_ = #{to}", + "if !_.nil? || nil.respond_to?(:#{method})", + " _.#{method}(#{definition})", + "end", + "end" + ].join ";" + else + exception = %(raise DelegationError, "#{self}##{method_prefix}#{method} delegated to #{to}.#{method}, but #{to} is nil: \#{self.inspect}") + + method_def = [ + "def #{method_prefix}#{method}(#{definition})", + " _ = #{to}", + " _.#{method}(#{definition})", + "rescue NoMethodError => e", + " if _.nil? && e.name == :#{method}", + " #{exception}", + " else", + " raise", + " end", + "end" + ].join ";" + end + + module_eval(method_def, file, line) + end + end + + # When building decorators, a common pattern may emerge: + # + # class Partition + # def initialize(event) + # @event = event + # end + # + # def person + # @event.detail.person || @event.creator + # end + # + # private + # def respond_to_missing?(name, include_private = false) + # @event.respond_to?(name, include_private) + # end + # + # def method_missing(method, *args, &block) + # @event.send(method, *args, &block) + # end + # end + # + # With Module#delegate_missing_to, the above is condensed to: + # + # class Partition + # delegate_missing_to :@event + # + # def initialize(event) + # @event = event + # end + # + # def person + # @event.detail.person || @event.creator + # end + # end + # + # The target can be anything callable within the object, e.g. instance + # variables, methods, constants, etc. + # + # The delegated method must be public on the target, otherwise it will + # raise +NoMethodError+. + def delegate_missing_to(target) + target = target.to_s + target = "self.#{target}" if DELEGATION_RESERVED_METHOD_NAMES.include?(target) + + module_eval <<-RUBY, __FILE__, __LINE__ + 1 + def respond_to_missing?(name, include_private = false) + # It may look like an oversight, but we deliberately do not pass + # +include_private+, because they do not get delegated. + + #{target}.respond_to?(name) || super + end + + def method_missing(method, *args, &block) + if #{target}.respond_to?(method) + #{target}.public_send(method, *args, &block) + else + begin + super + rescue NoMethodError + if #{target}.nil? + raise DelegationError, "\#{method} delegated to #{target}, but #{target} is nil" + else + raise + end + end + end + end + RUBY + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/deprecation.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/deprecation.rb new file mode 100644 index 0000000000..71c42eb357 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/deprecation.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class Module + # deprecate :foo + # deprecate bar: 'message' + # deprecate :foo, :bar, baz: 'warning!', qux: 'gone!' + # + # You can also use custom deprecator instance: + # + # deprecate :foo, deprecator: MyLib::Deprecator.new + # deprecate :foo, bar: "warning!", deprecator: MyLib::Deprecator.new + # + # \Custom deprecators must respond to deprecation_warning(deprecated_method_name, message, caller_backtrace) + # method where you can implement your custom warning behavior. + # + # class MyLib::Deprecator + # def deprecation_warning(deprecated_method_name, message, caller_backtrace = nil) + # message = "#{deprecated_method_name} is deprecated and will be removed from MyLibrary | #{message}" + # Kernel.warn message + # end + # end + def deprecate(*method_names) + ActiveSupport::Deprecation.deprecate_methods(self, *method_names) + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/introspection.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/introspection.rb new file mode 100644 index 0000000000..c5bb598bd1 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/introspection.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true + +require "active_support/inflector" + +class Module + # Returns the name of the module containing this one. + # + # M::N.parent_name # => "M" + def parent_name + if defined?(@parent_name) + @parent_name + else + parent_name = name =~ /::[^:]+\Z/ ? $`.freeze : nil + @parent_name = parent_name unless frozen? + parent_name + end + end + + # Returns the module which contains this one according to its name. + # + # module M + # module N + # end + # end + # X = M::N + # + # M::N.parent # => M + # X.parent # => M + # + # The parent of top-level and anonymous modules is Object. + # + # M.parent # => Object + # Module.new.parent # => Object + def parent + parent_name ? ActiveSupport::Inflector.constantize(parent_name) : Object + end + + # Returns all the parents of this module according to its name, ordered from + # nested outwards. The receiver is not contained within the result. + # + # module M + # module N + # end + # end + # X = M::N + # + # M.parents # => [Object] + # M::N.parents # => [M, Object] + # X.parents # => [M, Object] + def parents + parents = [] + if parent_name + parts = parent_name.split("::") + until parts.empty? + parents << ActiveSupport::Inflector.constantize(parts * "::") + parts.pop + end + end + parents << Object unless parents.include? Object + parents + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/reachable.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/reachable.rb new file mode 100644 index 0000000000..e9cbda5245 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/reachable.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require "active_support/core_ext/module/anonymous" +require "active_support/core_ext/string/inflections" + +class Module + def reachable? #:nodoc: + !anonymous? && name.safe_constantize.equal?(self) + end + deprecate :reachable? +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/redefine_method.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/redefine_method.rb new file mode 100644 index 0000000000..a0a6622ca4 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/redefine_method.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +class Module + if RUBY_VERSION >= "2.3" + # Marks the named method as intended to be redefined, if it exists. + # Suppresses the Ruby method redefinition warning. Prefer + # #redefine_method where possible. + def silence_redefinition_of_method(method) + if method_defined?(method) || private_method_defined?(method) + # This suppresses the "method redefined" warning; the self-alias + # looks odd, but means we don't need to generate a unique name + alias_method method, method + end + end + else + def silence_redefinition_of_method(method) + if method_defined?(method) || private_method_defined?(method) + alias_method :__rails_redefine, method + remove_method :__rails_redefine + end + end + end + + # Replaces the existing method definition, if there is one, with the passed + # block as its body. + def redefine_method(method, &block) + visibility = method_visibility(method) + silence_redefinition_of_method(method) + define_method(method, &block) + send(visibility, method) + end + + # Replaces the existing singleton method definition, if there is one, with + # the passed block as its body. + def redefine_singleton_method(method, &block) + singleton_class.redefine_method(method, &block) + end + + def method_visibility(method) # :nodoc: + case + when private_method_defined?(method) + :private + when protected_method_defined?(method) + :protected + else + :public + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/remove_method.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/remove_method.rb new file mode 100644 index 0000000000..97eb5f9eca --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/module/remove_method.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +require "active_support/core_ext/module/redefine_method" + +class Module + # Removes the named method, if it exists. + def remove_possible_method(method) + if method_defined?(method) || private_method_defined?(method) + undef_method(method) + end + end + + # Removes the named singleton method, if it exists. + def remove_possible_singleton_method(method) + singleton_class.remove_possible_method(method) + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/name_error.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/name_error.rb new file mode 100644 index 0000000000..6d37cd9dfd --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/name_error.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +class NameError + # Extract the name of the missing constant from the exception message. + # + # begin + # HelloWorld + # rescue NameError => e + # e.missing_name + # end + # # => "HelloWorld" + def missing_name + # Since ruby v2.3.0 `did_you_mean` gem is loaded by default. + # It extends NameError#message with spell corrections which are SLOW. + # We should use original_message message instead. + message = respond_to?(:original_message) ? original_message : self.message + + if /undefined local variable or method/ !~ message + $1 if /((::)?([A-Z]\w*)(::[A-Z]\w*)*)$/ =~ message + end + end + + # Was this exception raised because the given name was missing? + # + # begin + # HelloWorld + # rescue NameError => e + # e.missing_name?("HelloWorld") + # end + # # => true + def missing_name?(name) + if name.is_a? Symbol + self.name == name + else + missing_name == name.to_s + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/numeric.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/numeric.rb new file mode 100644 index 0000000000..0b04e359f9 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/numeric.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +require "active_support/core_ext/numeric/bytes" +require "active_support/core_ext/numeric/time" +require "active_support/core_ext/numeric/inquiry" +require "active_support/core_ext/numeric/conversions" diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/numeric/bytes.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/numeric/bytes.rb new file mode 100644 index 0000000000..b002eba406 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/numeric/bytes.rb @@ -0,0 +1,66 @@ +# frozen_string_literal: true + +class Numeric + KILOBYTE = 1024 + MEGABYTE = KILOBYTE * 1024 + GIGABYTE = MEGABYTE * 1024 + TERABYTE = GIGABYTE * 1024 + PETABYTE = TERABYTE * 1024 + EXABYTE = PETABYTE * 1024 + + # Enables the use of byte calculations and declarations, like 45.bytes + 2.6.megabytes + # + # 2.bytes # => 2 + def bytes + self + end + alias :byte :bytes + + # Returns the number of bytes equivalent to the kilobytes provided. + # + # 2.kilobytes # => 2048 + def kilobytes + self * KILOBYTE + end + alias :kilobyte :kilobytes + + # Returns the number of bytes equivalent to the megabytes provided. + # + # 2.megabytes # => 2_097_152 + def megabytes + self * MEGABYTE + end + alias :megabyte :megabytes + + # Returns the number of bytes equivalent to the gigabytes provided. + # + # 2.gigabytes # => 2_147_483_648 + def gigabytes + self * GIGABYTE + end + alias :gigabyte :gigabytes + + # Returns the number of bytes equivalent to the terabytes provided. + # + # 2.terabytes # => 2_199_023_255_552 + def terabytes + self * TERABYTE + end + alias :terabyte :terabytes + + # Returns the number of bytes equivalent to the petabytes provided. + # + # 2.petabytes # => 2_251_799_813_685_248 + def petabytes + self * PETABYTE + end + alias :petabyte :petabytes + + # Returns the number of bytes equivalent to the exabytes provided. + # + # 2.exabytes # => 2_305_843_009_213_693_952 + def exabytes + self * EXABYTE + end + alias :exabyte :exabytes +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/numeric/conversions.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/numeric/conversions.rb new file mode 100644 index 0000000000..f6c2713986 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/numeric/conversions.rb @@ -0,0 +1,140 @@ +# frozen_string_literal: true + +require "active_support/core_ext/big_decimal/conversions" +require "active_support/number_helper" +require "active_support/core_ext/module/deprecation" + +module ActiveSupport::NumericWithFormat + # Provides options for converting numbers into formatted strings. + # Options are provided for phone numbers, currency, percentage, + # precision, positional notation, file size and pretty printing. + # + # ==== Options + # + # For details on which formats use which options, see ActiveSupport::NumberHelper + # + # ==== Examples + # + # Phone Numbers: + # 5551234.to_s(:phone) # => "555-1234" + # 1235551234.to_s(:phone) # => "123-555-1234" + # 1235551234.to_s(:phone, area_code: true) # => "(123) 555-1234" + # 1235551234.to_s(:phone, delimiter: ' ') # => "123 555 1234" + # 1235551234.to_s(:phone, area_code: true, extension: 555) # => "(123) 555-1234 x 555" + # 1235551234.to_s(:phone, country_code: 1) # => "+1-123-555-1234" + # 1235551234.to_s(:phone, country_code: 1, extension: 1343, delimiter: '.') + # # => "+1.123.555.1234 x 1343" + # + # Currency: + # 1234567890.50.to_s(:currency) # => "$1,234,567,890.50" + # 1234567890.506.to_s(:currency) # => "$1,234,567,890.51" + # 1234567890.506.to_s(:currency, precision: 3) # => "$1,234,567,890.506" + # 1234567890.506.to_s(:currency, locale: :fr) # => "1 234 567 890,51 €" + # -1234567890.50.to_s(:currency, negative_format: '(%u%n)') + # # => "($1,234,567,890.50)" + # 1234567890.50.to_s(:currency, unit: '£', separator: ',', delimiter: '') + # # => "£1234567890,50" + # 1234567890.50.to_s(:currency, unit: '£', separator: ',', delimiter: '', format: '%n %u') + # # => "1234567890,50 £" + # + # Percentage: + # 100.to_s(:percentage) # => "100.000%" + # 100.to_s(:percentage, precision: 0) # => "100%" + # 1000.to_s(:percentage, delimiter: '.', separator: ',') # => "1.000,000%" + # 302.24398923423.to_s(:percentage, precision: 5) # => "302.24399%" + # 1000.to_s(:percentage, locale: :fr) # => "1 000,000%" + # 100.to_s(:percentage, format: '%n %') # => "100.000 %" + # + # Delimited: + # 12345678.to_s(:delimited) # => "12,345,678" + # 12345678.05.to_s(:delimited) # => "12,345,678.05" + # 12345678.to_s(:delimited, delimiter: '.') # => "12.345.678" + # 12345678.to_s(:delimited, delimiter: ',') # => "12,345,678" + # 12345678.05.to_s(:delimited, separator: ' ') # => "12,345,678 05" + # 12345678.05.to_s(:delimited, locale: :fr) # => "12 345 678,05" + # 98765432.98.to_s(:delimited, delimiter: ' ', separator: ',') + # # => "98 765 432,98" + # + # Rounded: + # 111.2345.to_s(:rounded) # => "111.235" + # 111.2345.to_s(:rounded, precision: 2) # => "111.23" + # 13.to_s(:rounded, precision: 5) # => "13.00000" + # 389.32314.to_s(:rounded, precision: 0) # => "389" + # 111.2345.to_s(:rounded, significant: true) # => "111" + # 111.2345.to_s(:rounded, precision: 1, significant: true) # => "100" + # 13.to_s(:rounded, precision: 5, significant: true) # => "13.000" + # 111.234.to_s(:rounded, locale: :fr) # => "111,234" + # 13.to_s(:rounded, precision: 5, significant: true, strip_insignificant_zeros: true) + # # => "13" + # 389.32314.to_s(:rounded, precision: 4, significant: true) # => "389.3" + # 1111.2345.to_s(:rounded, precision: 2, separator: ',', delimiter: '.') + # # => "1.111,23" + # + # Human-friendly size in Bytes: + # 123.to_s(:human_size) # => "123 Bytes" + # 1234.to_s(:human_size) # => "1.21 KB" + # 12345.to_s(:human_size) # => "12.1 KB" + # 1234567.to_s(:human_size) # => "1.18 MB" + # 1234567890.to_s(:human_size) # => "1.15 GB" + # 1234567890123.to_s(:human_size) # => "1.12 TB" + # 1234567890123456.to_s(:human_size) # => "1.1 PB" + # 1234567890123456789.to_s(:human_size) # => "1.07 EB" + # 1234567.to_s(:human_size, precision: 2) # => "1.2 MB" + # 483989.to_s(:human_size, precision: 2) # => "470 KB" + # 1234567.to_s(:human_size, precision: 2, separator: ',') # => "1,2 MB" + # 1234567890123.to_s(:human_size, precision: 5) # => "1.1228 TB" + # 524288000.to_s(:human_size, precision: 5) # => "500 MB" + # + # Human-friendly format: + # 123.to_s(:human) # => "123" + # 1234.to_s(:human) # => "1.23 Thousand" + # 12345.to_s(:human) # => "12.3 Thousand" + # 1234567.to_s(:human) # => "1.23 Million" + # 1234567890.to_s(:human) # => "1.23 Billion" + # 1234567890123.to_s(:human) # => "1.23 Trillion" + # 1234567890123456.to_s(:human) # => "1.23 Quadrillion" + # 1234567890123456789.to_s(:human) # => "1230 Quadrillion" + # 489939.to_s(:human, precision: 2) # => "490 Thousand" + # 489939.to_s(:human, precision: 4) # => "489.9 Thousand" + # 1234567.to_s(:human, precision: 4, + # significant: false) # => "1.2346 Million" + # 1234567.to_s(:human, precision: 1, + # separator: ',', + # significant: false) # => "1,2 Million" + def to_s(format = nil, options = nil) + case format + when nil + super() + when Integer, String + super(format) + when :phone + ActiveSupport::NumberHelper.number_to_phone(self, options || {}) + when :currency + ActiveSupport::NumberHelper.number_to_currency(self, options || {}) + when :percentage + ActiveSupport::NumberHelper.number_to_percentage(self, options || {}) + when :delimited + ActiveSupport::NumberHelper.number_to_delimited(self, options || {}) + when :rounded + ActiveSupport::NumberHelper.number_to_rounded(self, options || {}) + when :human + ActiveSupport::NumberHelper.number_to_human(self, options || {}) + when :human_size + ActiveSupport::NumberHelper.number_to_human_size(self, options || {}) + when Symbol + super() + else + super(format) + end + end +end + +# Ruby 2.4+ unifies Fixnum & Bignum into Integer. +if 0.class == Integer + Integer.prepend ActiveSupport::NumericWithFormat +else + Fixnum.prepend ActiveSupport::NumericWithFormat + Bignum.prepend ActiveSupport::NumericWithFormat +end +Float.prepend ActiveSupport::NumericWithFormat +BigDecimal.prepend ActiveSupport::NumericWithFormat diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/numeric/inquiry.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/numeric/inquiry.rb new file mode 100644 index 0000000000..15334c91f1 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/numeric/inquiry.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +unless 1.respond_to?(:positive?) # TODO: Remove this file when we drop support to ruby < 2.3 + class Numeric + # Returns true if the number is positive. + # + # 1.positive? # => true + # 0.positive? # => false + # -1.positive? # => false + def positive? + self > 0 + end + + # Returns true if the number is negative. + # + # -1.negative? # => true + # 0.negative? # => false + # 1.negative? # => false + def negative? + self < 0 + end + end + + class Complex + undef :positive? + undef :negative? + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/numeric/time.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/numeric/time.rb new file mode 100644 index 0000000000..bc4627f7a2 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/numeric/time.rb @@ -0,0 +1,66 @@ +# frozen_string_literal: true + +require "active_support/duration" +require "active_support/core_ext/time/calculations" +require "active_support/core_ext/time/acts_like" +require "active_support/core_ext/date/calculations" +require "active_support/core_ext/date/acts_like" + +class Numeric + # Returns a Duration instance matching the number of seconds provided. + # + # 2.seconds # => 2 seconds + def seconds + ActiveSupport::Duration.seconds(self) + end + alias :second :seconds + + # Returns a Duration instance matching the number of minutes provided. + # + # 2.minutes # => 2 minutes + def minutes + ActiveSupport::Duration.minutes(self) + end + alias :minute :minutes + + # Returns a Duration instance matching the number of hours provided. + # + # 2.hours # => 2 hours + def hours + ActiveSupport::Duration.hours(self) + end + alias :hour :hours + + # Returns a Duration instance matching the number of days provided. + # + # 2.days # => 2 days + def days + ActiveSupport::Duration.days(self) + end + alias :day :days + + # Returns a Duration instance matching the number of weeks provided. + # + # 2.weeks # => 2 weeks + def weeks + ActiveSupport::Duration.weeks(self) + end + alias :week :weeks + + # Returns a Duration instance matching the number of fortnights provided. + # + # 2.fortnights # => 4 weeks + def fortnights + ActiveSupport::Duration.weeks(self * 2) + end + alias :fortnight :fortnights + + # Returns the number of milliseconds equivalent to the seconds provided. + # Used with the standard time durations. + # + # 2.in_milliseconds # => 2000 + # 1.hour.in_milliseconds # => 3600000 + def in_milliseconds + self * 1000 + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object.rb new file mode 100644 index 0000000000..efd34cc692 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +require "active_support/core_ext/object/acts_like" +require "active_support/core_ext/object/blank" +require "active_support/core_ext/object/duplicable" +require "active_support/core_ext/object/deep_dup" +require "active_support/core_ext/object/try" +require "active_support/core_ext/object/inclusion" + +require "active_support/core_ext/object/conversions" +require "active_support/core_ext/object/instance_variables" + +require "active_support/core_ext/object/json" +require "active_support/core_ext/object/to_param" +require "active_support/core_ext/object/to_query" +require "active_support/core_ext/object/with_options" diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/acts_like.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/acts_like.rb new file mode 100644 index 0000000000..403ee20e39 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/acts_like.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class Object + # A duck-type assistant method. For example, Active Support extends Date + # to define an acts_like_date? method, and extends Time to define + # acts_like_time?. As a result, we can do x.acts_like?(:time) and + # x.acts_like?(:date) to do duck-type-safe comparisons, since classes that + # we want to act like Time simply need to define an acts_like_time? method. + def acts_like?(duck) + case duck + when :time + respond_to? :acts_like_time? + when :date + respond_to? :acts_like_date? + when :string + respond_to? :acts_like_string? + else + respond_to? :"acts_like_#{duck}?" + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/conversions.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/conversions.rb new file mode 100644 index 0000000000..624fb8d77c --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/conversions.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +require "active_support/core_ext/object/to_param" +require "active_support/core_ext/object/to_query" +require "active_support/core_ext/array/conversions" +require "active_support/core_ext/hash/conversions" diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/deep_dup.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/deep_dup.rb new file mode 100644 index 0000000000..c66c5eb2d9 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/deep_dup.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +require "active_support/core_ext/object/duplicable" + +class Object + # Returns a deep copy of object if it's duplicable. If it's + # not duplicable, returns +self+. + # + # object = Object.new + # dup = object.deep_dup + # dup.instance_variable_set(:@a, 1) + # + # object.instance_variable_defined?(:@a) # => false + # dup.instance_variable_defined?(:@a) # => true + def deep_dup + duplicable? ? dup : self + end +end + +class Array + # Returns a deep copy of array. + # + # array = [1, [2, 3]] + # dup = array.deep_dup + # dup[1][2] = 4 + # + # array[1][2] # => nil + # dup[1][2] # => 4 + def deep_dup + map(&:deep_dup) + end +end + +class Hash + # Returns a deep copy of hash. + # + # hash = { a: { b: 'b' } } + # dup = hash.deep_dup + # dup[:a][:c] = 'c' + # + # hash[:a][:c] # => nil + # dup[:a][:c] # => "c" + def deep_dup + hash = dup + each_pair do |key, value| + if key.frozen? && ::String === key + hash[key] = value.deep_dup + else + hash.delete(key) + hash[key.deep_dup] = value.deep_dup + end + end + hash + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/duplicable.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/duplicable.rb new file mode 100644 index 0000000000..9bb99087bc --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/duplicable.rb @@ -0,0 +1,156 @@ +# frozen_string_literal: true + +#-- +# Most objects are cloneable, but not all. For example you can't dup methods: +# +# method(:puts).dup # => TypeError: allocator undefined for Method +# +# Classes may signal their instances are not duplicable removing +dup+/+clone+ +# or raising exceptions from them. So, to dup an arbitrary object you normally +# use an optimistic approach and are ready to catch an exception, say: +# +# arbitrary_object.dup rescue object +# +# Rails dups objects in a few critical spots where they are not that arbitrary. +# That rescue is very expensive (like 40 times slower than a predicate), and it +# is often triggered. +# +# That's why we hardcode the following cases and check duplicable? instead of +# using that rescue idiom. +#++ +class Object + # Can you safely dup this object? + # + # False for method objects; + # true otherwise. + def duplicable? + true + end +end + +class NilClass + begin + nil.dup + rescue TypeError + + # +nil+ is not duplicable: + # + # nil.duplicable? # => false + # nil.dup # => TypeError: can't dup NilClass + def duplicable? + false + end + end +end + +class FalseClass + begin + false.dup + rescue TypeError + + # +false+ is not duplicable: + # + # false.duplicable? # => false + # false.dup # => TypeError: can't dup FalseClass + def duplicable? + false + end + end +end + +class TrueClass + begin + true.dup + rescue TypeError + + # +true+ is not duplicable: + # + # true.duplicable? # => false + # true.dup # => TypeError: can't dup TrueClass + def duplicable? + false + end + end +end + +class Symbol + begin + :symbol.dup # Ruby 2.4.x. + "symbol_from_string".to_sym.dup # Some symbols can't `dup` in Ruby 2.4.0. + rescue TypeError + + # Symbols are not duplicable: + # + # :my_symbol.duplicable? # => false + # :my_symbol.dup # => TypeError: can't dup Symbol + def duplicable? + false + end + end +end + +class Numeric + begin + 1.dup + rescue TypeError + + # Numbers are not duplicable: + # + # 3.duplicable? # => false + # 3.dup # => TypeError: can't dup Integer + def duplicable? + false + end + end +end + +require "bigdecimal" +class BigDecimal + # BigDecimals are duplicable: + # + # BigDecimal("1.2").duplicable? # => true + # BigDecimal("1.2").dup # => # + def duplicable? + true + end +end + +class Method + # Methods are not duplicable: + # + # method(:puts).duplicable? # => false + # method(:puts).dup # => TypeError: allocator undefined for Method + def duplicable? + false + end +end + +class Complex + begin + Complex(1).dup + rescue TypeError + + # Complexes are not duplicable: + # + # Complex(1).duplicable? # => false + # Complex(1).dup # => TypeError: can't copy Complex + def duplicable? + false + end + end +end + +class Rational + begin + Rational(1).dup + rescue TypeError + + # Rationals are not duplicable: + # + # Rational(1).duplicable? # => false + # Rational(1).dup # => TypeError: can't copy Rational + def duplicable? + false + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/inclusion.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/inclusion.rb new file mode 100644 index 0000000000..6064e92f20 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/inclusion.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +class Object + # Returns true if this object is included in the argument. Argument must be + # any object which responds to +#include?+. Usage: + # + # characters = ["Konata", "Kagami", "Tsukasa"] + # "Konata".in?(characters) # => true + # + # This will throw an +ArgumentError+ if the argument doesn't respond + # to +#include?+. + def in?(another_object) + another_object.include?(self) + rescue NoMethodError + raise ArgumentError.new("The parameter passed to #in? must respond to #include?") + end + + # Returns the receiver if it's included in the argument otherwise returns +nil+. + # Argument must be any object which responds to +#include?+. Usage: + # + # params[:bucket_type].presence_in %w( project calendar ) + # + # This will throw an +ArgumentError+ if the argument doesn't respond to +#include?+. + # + # @return [Object] + def presence_in(another_object) + in?(another_object) ? self : nil + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/instance_variables.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/instance_variables.rb new file mode 100644 index 0000000000..12fdf840b5 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/instance_variables.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +class Object + # Returns a hash with string keys that maps instance variable names without "@" to their + # corresponding values. + # + # class C + # def initialize(x, y) + # @x, @y = x, y + # end + # end + # + # C.new(0, 1).instance_values # => {"x" => 0, "y" => 1} + def instance_values + Hash[instance_variables.map { |name| [name[1..-1], instance_variable_get(name)] }] + end + + # Returns an array of instance variable names as strings including "@". + # + # class C + # def initialize(x, y) + # @x, @y = x, y + # end + # end + # + # C.new(0, 1).instance_variable_names # => ["@y", "@x"] + def instance_variable_names + instance_variables.map(&:to_s) + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/json.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/json.rb new file mode 100644 index 0000000000..f7c623fe13 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/json.rb @@ -0,0 +1,227 @@ +# frozen_string_literal: true + +# Hack to load json gem first so we can overwrite its to_json. +require "json" +require "bigdecimal" +require "uri/generic" +require "pathname" +require "active_support/core_ext/big_decimal/conversions" # for #to_s +require "active_support/core_ext/hash/except" +require "active_support/core_ext/hash/slice" +require "active_support/core_ext/object/instance_variables" +require "time" +require "active_support/core_ext/time/conversions" +require "active_support/core_ext/date_time/conversions" +require "active_support/core_ext/date/conversions" + +# The JSON gem adds a few modules to Ruby core classes containing :to_json definition, overwriting +# their default behavior. That said, we need to define the basic to_json method in all of them, +# otherwise they will always use to_json gem implementation, which is backwards incompatible in +# several cases (for instance, the JSON implementation for Hash does not work) with inheritance +# and consequently classes as ActiveSupport::OrderedHash cannot be serialized to json. +# +# On the other hand, we should avoid conflict with ::JSON.{generate,dump}(obj). Unfortunately, the +# JSON gem's encoder relies on its own to_json implementation to encode objects. Since it always +# passes a ::JSON::State object as the only argument to to_json, we can detect that and forward the +# calls to the original to_json method. +# +# It should be noted that when using ::JSON.{generate,dump} directly, ActiveSupport's encoder is +# bypassed completely. This means that as_json won't be invoked and the JSON gem will simply +# ignore any options it does not natively understand. This also means that ::JSON.{generate,dump} +# should give exactly the same results with or without active support. + +module ActiveSupport + module ToJsonWithActiveSupportEncoder # :nodoc: + def to_json(options = nil) + if options.is_a?(::JSON::State) + # Called from JSON.{generate,dump}, forward it to JSON gem's to_json + super(options) + else + # to_json is being invoked directly, use ActiveSupport's encoder + ActiveSupport::JSON.encode(self, options) + end + end + end +end + +[Object, Array, FalseClass, Float, Hash, Integer, NilClass, String, TrueClass, Enumerable].reverse_each do |klass| + klass.prepend(ActiveSupport::ToJsonWithActiveSupportEncoder) +end + +class Object + def as_json(options = nil) #:nodoc: + if respond_to?(:to_hash) + to_hash.as_json(options) + else + instance_values.as_json(options) + end + end +end + +class Struct #:nodoc: + def as_json(options = nil) + Hash[members.zip(values)].as_json(options) + end +end + +class TrueClass + def as_json(options = nil) #:nodoc: + self + end +end + +class FalseClass + def as_json(options = nil) #:nodoc: + self + end +end + +class NilClass + def as_json(options = nil) #:nodoc: + self + end +end + +class String + def as_json(options = nil) #:nodoc: + self + end +end + +class Symbol + def as_json(options = nil) #:nodoc: + to_s + end +end + +class Numeric + def as_json(options = nil) #:nodoc: + self + end +end + +class Float + # Encoding Infinity or NaN to JSON should return "null". The default returns + # "Infinity" or "NaN" which are not valid JSON. + def as_json(options = nil) #:nodoc: + finite? ? self : nil + end +end + +class BigDecimal + # A BigDecimal would be naturally represented as a JSON number. Most libraries, + # however, parse non-integer JSON numbers directly as floats. Clients using + # those libraries would get in general a wrong number and no way to recover + # other than manually inspecting the string with the JSON code itself. + # + # That's why a JSON string is returned. The JSON literal is not numeric, but + # if the other end knows by contract that the data is supposed to be a + # BigDecimal, it still has the chance to post-process the string and get the + # real value. + def as_json(options = nil) #:nodoc: + finite? ? to_s : nil + end +end + +class Regexp + def as_json(options = nil) #:nodoc: + to_s + end +end + +module Enumerable + def as_json(options = nil) #:nodoc: + to_a.as_json(options) + end +end + +class IO + def as_json(options = nil) #:nodoc: + to_s + end +end + +class Range + def as_json(options = nil) #:nodoc: + to_s + end +end + +class Array + def as_json(options = nil) #:nodoc: + map { |v| options ? v.as_json(options.dup) : v.as_json } + end +end + +class Hash + def as_json(options = nil) #:nodoc: + # create a subset of the hash by applying :only or :except + subset = if options + if attrs = options[:only] + slice(*Array(attrs)) + elsif attrs = options[:except] + except(*Array(attrs)) + else + self + end + else + self + end + + Hash[subset.map { |k, v| [k.to_s, options ? v.as_json(options.dup) : v.as_json] }] + end +end + +class Time + def as_json(options = nil) #:nodoc: + if ActiveSupport::JSON::Encoding.use_standard_json_time_format + xmlschema(ActiveSupport::JSON::Encoding.time_precision) + else + %(#{strftime("%Y/%m/%d %H:%M:%S")} #{formatted_offset(false)}) + end + end +end + +class Date + def as_json(options = nil) #:nodoc: + if ActiveSupport::JSON::Encoding.use_standard_json_time_format + strftime("%Y-%m-%d") + else + strftime("%Y/%m/%d") + end + end +end + +class DateTime + def as_json(options = nil) #:nodoc: + if ActiveSupport::JSON::Encoding.use_standard_json_time_format + xmlschema(ActiveSupport::JSON::Encoding.time_precision) + else + strftime("%Y/%m/%d %H:%M:%S %z") + end + end +end + +class URI::Generic #:nodoc: + def as_json(options = nil) + to_s + end +end + +class Pathname #:nodoc: + def as_json(options = nil) + to_s + end +end + +class Process::Status #:nodoc: + def as_json(options = nil) + { exitstatus: exitstatus, pid: pid } + end +end + +class Exception + def as_json(options = nil) + to_s + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/to_param.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/to_param.rb new file mode 100644 index 0000000000..6d2bdd70f3 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/to_param.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +require "active_support/core_ext/object/to_query" diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/to_query.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/to_query.rb new file mode 100644 index 0000000000..bac6ff9c97 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/to_query.rb @@ -0,0 +1,89 @@ +# frozen_string_literal: true + +require "cgi" + +class Object + # Alias of to_s. + def to_param + to_s + end + + # Converts an object into a string suitable for use as a URL query string, + # using the given key as the param name. + def to_query(key) + "#{CGI.escape(key.to_param)}=#{CGI.escape(to_param.to_s)}" + end +end + +class NilClass + # Returns +self+. + def to_param + self + end +end + +class TrueClass + # Returns +self+. + def to_param + self + end +end + +class FalseClass + # Returns +self+. + def to_param + self + end +end + +class Array + # Calls to_param on all its elements and joins the result with + # slashes. This is used by url_for in Action Pack. + def to_param + collect(&:to_param).join "/" + end + + # Converts an array into a string suitable for use as a URL query string, + # using the given +key+ as the param name. + # + # ['Rails', 'coding'].to_query('hobbies') # => "hobbies%5B%5D=Rails&hobbies%5B%5D=coding" + def to_query(key) + prefix = "#{key}[]" + + if empty? + nil.to_query(prefix) + else + collect { |value| value.to_query(prefix) }.join "&" + end + end +end + +class Hash + # Returns a string representation of the receiver suitable for use as a URL + # query string: + # + # {name: 'David', nationality: 'Danish'}.to_query + # # => "name=David&nationality=Danish" + # + # An optional namespace can be passed to enclose key names: + # + # {name: 'David', nationality: 'Danish'}.to_query('user') + # # => "user%5Bname%5D=David&user%5Bnationality%5D=Danish" + # + # The string pairs "key=value" that conform the query string + # are sorted lexicographically in ascending order. + # + # This method is also aliased as +to_param+. + def to_query(namespace = nil) + query = collect do |key, value| + unless (value.is_a?(Hash) || value.is_a?(Array)) && value.empty? + value.to_query(namespace ? "#{namespace}[#{key}]" : key) + end + end.compact + + query.sort! unless namespace.to_s.include?("[]") + query.join("&") + end + + alias_method :to_param, :to_query +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/try.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/try.rb new file mode 100644 index 0000000000..c874691629 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/try.rb @@ -0,0 +1,148 @@ +# frozen_string_literal: true + +require "delegate" + +module ActiveSupport + module Tryable #:nodoc: + def try(*a, &b) + try!(*a, &b) if a.empty? || respond_to?(a.first) + end + + def try!(*a, &b) + if a.empty? && block_given? + if b.arity == 0 + instance_eval(&b) + else + yield self + end + else + public_send(*a, &b) + end + end + end +end + +class Object + include ActiveSupport::Tryable + + ## + # :method: try + # + # :call-seq: + # try(*a, &b) + # + # Invokes the public method whose name goes as first argument just like + # +public_send+ does, except that if the receiver does not respond to it the + # call returns +nil+ rather than raising an exception. + # + # This method is defined to be able to write + # + # @person.try(:name) + # + # instead of + # + # @person.name if @person + # + # +try+ calls can be chained: + # + # @person.try(:spouse).try(:name) + # + # instead of + # + # @person.spouse.name if @person && @person.spouse + # + # +try+ will also return +nil+ if the receiver does not respond to the method: + # + # @person.try(:non_existing_method) # => nil + # + # instead of + # + # @person.non_existing_method if @person.respond_to?(:non_existing_method) # => nil + # + # +try+ returns +nil+ when called on +nil+ regardless of whether it responds + # to the method: + # + # nil.try(:to_i) # => nil, rather than 0 + # + # Arguments and blocks are forwarded to the method if invoked: + # + # @posts.try(:each_slice, 2) do |a, b| + # ... + # end + # + # The number of arguments in the signature must match. If the object responds + # to the method the call is attempted and +ArgumentError+ is still raised + # in case of argument mismatch. + # + # If +try+ is called without arguments it yields the receiver to a given + # block unless it is +nil+: + # + # @person.try do |p| + # ... + # end + # + # You can also call try with a block without accepting an argument, and the block + # will be instance_eval'ed instead: + # + # @person.try { upcase.truncate(50) } + # + # Please also note that +try+ is defined on +Object+. Therefore, it won't work + # with instances of classes that do not have +Object+ among their ancestors, + # like direct subclasses of +BasicObject+. + + ## + # :method: try! + # + # :call-seq: + # try!(*a, &b) + # + # Same as #try, but raises a +NoMethodError+ exception if the receiver is + # not +nil+ and does not implement the tried method. + # + # "a".try!(:upcase) # => "A" + # nil.try!(:upcase) # => nil + # 123.try!(:upcase) # => NoMethodError: undefined method `upcase' for 123:Integer +end + +class Delegator + include ActiveSupport::Tryable + + ## + # :method: try + # + # :call-seq: + # try(a*, &b) + # + # See Object#try + + ## + # :method: try! + # + # :call-seq: + # try!(a*, &b) + # + # See Object#try! +end + +class NilClass + # Calling +try+ on +nil+ always returns +nil+. + # It becomes especially helpful when navigating through associations that may return +nil+. + # + # nil.try(:name) # => nil + # + # Without +try+ + # @person && @person.children.any? && @person.children.first.name + # + # With +try+ + # @person.try(:children).try(:first).try(:name) + def try(*args) + nil + end + + # Calling +try!+ on +nil+ always returns +nil+. + # + # nil.try!(:name) # => nil + def try!(*args) + nil + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/with_options.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/with_options.rb new file mode 100644 index 0000000000..2838fd76be --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/with_options.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true + +require "active_support/option_merger" + +class Object + # An elegant way to factor duplication out of options passed to a series of + # method calls. Each method called in the block, with the block variable as + # the receiver, will have its options merged with the default +options+ hash + # provided. Each method called on the block variable must take an options + # hash as its final argument. + # + # Without with_options, this code contains duplication: + # + # class Account < ActiveRecord::Base + # has_many :customers, dependent: :destroy + # has_many :products, dependent: :destroy + # has_many :invoices, dependent: :destroy + # has_many :expenses, dependent: :destroy + # end + # + # Using with_options, we can remove the duplication: + # + # class Account < ActiveRecord::Base + # with_options dependent: :destroy do |assoc| + # assoc.has_many :customers + # assoc.has_many :products + # assoc.has_many :invoices + # assoc.has_many :expenses + # end + # end + # + # It can also be used with an explicit receiver: + # + # I18n.with_options locale: user.locale, scope: 'newsletter' do |i18n| + # subject i18n.t :subject + # body i18n.t :body, user_name: user.name + # end + # + # When you don't pass an explicit receiver, it executes the whole block + # in merging options context: + # + # class Account < ActiveRecord::Base + # with_options dependent: :destroy do + # has_many :customers + # has_many :products + # has_many :invoices + # has_many :expenses + # end + # end + # + # with_options can also be nested since the call is forwarded to its receiver. + # + # NOTE: Each nesting level will merge inherited defaults in addition to their own. + # + # class Post < ActiveRecord::Base + # with_options if: :persisted?, length: { minimum: 50 } do + # validates :content, if: -> { content.present? } + # end + # end + # + # The code is equivalent to: + # + # validates :content, length: { minimum: 50 }, if: -> { content.present? } + # + # Hence the inherited default for +if+ key is ignored. + # + # NOTE: You cannot call class methods implicitly inside of with_options. + # You can access these methods using the class name instead: + # + # class Phone < ActiveRecord::Base + # enum phone_number_type: [home: 0, office: 1, mobile: 2] + # + # with_options presence: true do + # validates :phone_number_type, inclusion: { in: Phone.phone_number_types.keys } + # end + # end + # + def with_options(options, &block) + option_merger = ActiveSupport::OptionMerger.new(self, options) + block.arity.zero? ? option_merger.instance_eval(&block) : block.call(option_merger) + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/range.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/range.rb new file mode 100644 index 0000000000..4074e91d17 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/range.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +require "active_support/core_ext/range/conversions" +require "active_support/core_ext/range/include_range" +require "active_support/core_ext/range/include_time_with_zone" +require "active_support/core_ext/range/overlaps" +require "active_support/core_ext/range/each" diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/range/conversions.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/range/conversions.rb new file mode 100644 index 0000000000..8832fbcb3c --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/range/conversions.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +module ActiveSupport::RangeWithFormat + RANGE_FORMATS = { + db: -> (start, stop) do + case start + when String then "BETWEEN '#{start}' AND '#{stop}'" + else + "BETWEEN '#{start.to_s(:db)}' AND '#{stop.to_s(:db)}'" + end + end + } + + # Convert range to a formatted string. See RANGE_FORMATS for predefined formats. + # + # range = (1..100) # => 1..100 + # + # range.to_s # => "1..100" + # range.to_s(:db) # => "BETWEEN '1' AND '100'" + # + # == Adding your own range formats to to_s + # You can add your own formats to the Range::RANGE_FORMATS hash. + # Use the format name as the hash key and a Proc instance. + # + # # config/initializers/range_formats.rb + # Range::RANGE_FORMATS[:short] = ->(start, stop) { "Between #{start.to_s(:db)} and #{stop.to_s(:db)}" } + def to_s(format = :default) + if formatter = RANGE_FORMATS[format] + formatter.call(first, last) + else + super() + end + end + + alias_method :to_default_s, :to_s + alias_method :to_formatted_s, :to_s +end + +Range.prepend(ActiveSupport::RangeWithFormat) diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/range/each.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/range/each.rb new file mode 100644 index 0000000000..2f22cd0e92 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/range/each.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +require "active_support/time_with_zone" + +module ActiveSupport + module EachTimeWithZone #:nodoc: + def each(&block) + ensure_iteration_allowed + super + end + + def step(n = 1, &block) + ensure_iteration_allowed + super + end + + private + + def ensure_iteration_allowed + raise TypeError, "can't iterate from #{first.class}" if first.is_a?(TimeWithZone) + end + end +end + +Range.prepend(ActiveSupport::EachTimeWithZone) diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/range/include_range.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/range/include_range.rb new file mode 100644 index 0000000000..7ba1011921 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/range/include_range.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module ActiveSupport + module IncludeWithRange #:nodoc: + # Extends the default Range#include? to support range comparisons. + # (1..5).include?(1..5) # => true + # (1..5).include?(2..3) # => true + # (1..5).include?(2..6) # => false + # + # The native Range#include? behavior is untouched. + # ('a'..'f').include?('c') # => true + # (5..9).include?(11) # => false + def include?(value) + if value.is_a?(::Range) + # 1...10 includes 1..9 but it does not include 1..10. + operator = exclude_end? && !value.exclude_end? ? :< : :<= + super(value.first) && value.last.send(operator, last) + else + super + end + end + end +end + +Range.prepend(ActiveSupport::IncludeWithRange) diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/range/include_time_with_zone.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/range/include_time_with_zone.rb new file mode 100644 index 0000000000..5f80acf68e --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/range/include_time_with_zone.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require "active_support/time_with_zone" + +module ActiveSupport + module IncludeTimeWithZone #:nodoc: + # Extends the default Range#include? to support ActiveSupport::TimeWithZone. + # + # (1.hour.ago..1.hour.from_now).include?(Time.current) # => true + # + def include?(value) + if first.is_a?(TimeWithZone) + cover?(value) + elsif last.is_a?(TimeWithZone) + cover?(value) + else + super + end + end + end +end + +Range.prepend(ActiveSupport::IncludeTimeWithZone) diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/range/overlaps.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/range/overlaps.rb new file mode 100644 index 0000000000..f753607f8b --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/range/overlaps.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +class Range + # Compare two ranges and see if they overlap each other + # (1..5).overlaps?(4..6) # => true + # (1..5).overlaps?(7..9) # => false + def overlaps?(other) + cover?(other.first) || other.cover?(first) + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/securerandom.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/securerandom.rb new file mode 100644 index 0000000000..b4a491f5fd --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/securerandom.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +require "securerandom" + +module SecureRandom + BASE58_ALPHABET = ("0".."9").to_a + ("A".."Z").to_a + ("a".."z").to_a - ["0", "O", "I", "l"] + # SecureRandom.base58 generates a random base58 string. + # + # The argument _n_ specifies the length, of the random string to be generated. + # + # If _n_ is not specified or is +nil+, 16 is assumed. It may be larger in the future. + # + # The result may contain alphanumeric characters except 0, O, I and l + # + # p SecureRandom.base58 # => "4kUgL2pdQMSCQtjE" + # p SecureRandom.base58(24) # => "77TMHrHJFvFDwodq8w7Ev2m7" + # + def self.base58(n = 16) + SecureRandom.random_bytes(n).unpack("C*").map do |byte| + idx = byte % 64 + idx = SecureRandom.random_number(58) if idx >= 58 + BASE58_ALPHABET[idx] + end.join + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string.rb new file mode 100644 index 0000000000..757d15c51a --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require "active_support/core_ext/string/conversions" +require "active_support/core_ext/string/filters" +require "active_support/core_ext/string/multibyte" +require "active_support/core_ext/string/starts_ends_with" +require "active_support/core_ext/string/inflections" +require "active_support/core_ext/string/access" +require "active_support/core_ext/string/behavior" +require "active_support/core_ext/string/output_safety" +require "active_support/core_ext/string/exclude" +require "active_support/core_ext/string/strip" +require "active_support/core_ext/string/inquiry" +require "active_support/core_ext/string/indent" +require "active_support/core_ext/string/zones" diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/access.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/access.rb new file mode 100644 index 0000000000..58591bbaaf --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/access.rb @@ -0,0 +1,106 @@ +# frozen_string_literal: true + +class String + # If you pass a single integer, returns a substring of one character at that + # position. The first character of the string is at position 0, the next at + # position 1, and so on. If a range is supplied, a substring containing + # characters at offsets given by the range is returned. In both cases, if an + # offset is negative, it is counted from the end of the string. Returns +nil+ + # if the initial offset falls outside the string. Returns an empty string if + # the beginning of the range is greater than the end of the string. + # + # str = "hello" + # str.at(0) # => "h" + # str.at(1..3) # => "ell" + # str.at(-2) # => "l" + # str.at(-2..-1) # => "lo" + # str.at(5) # => nil + # str.at(5..-1) # => "" + # + # If a Regexp is given, the matching portion of the string is returned. + # If a String is given, that given string is returned if it occurs in + # the string. In both cases, +nil+ is returned if there is no match. + # + # str = "hello" + # str.at(/lo/) # => "lo" + # str.at(/ol/) # => nil + # str.at("lo") # => "lo" + # str.at("ol") # => nil + def at(position) + self[position] + end + + # Returns a substring from the given position to the end of the string. + # If the position is negative, it is counted from the end of the string. + # + # str = "hello" + # str.from(0) # => "hello" + # str.from(3) # => "lo" + # str.from(-2) # => "lo" + # + # You can mix it with +to+ method and do fun things like: + # + # str = "hello" + # str.from(0).to(-1) # => "hello" + # str.from(1).to(-2) # => "ell" + def from(position) + self[position..-1] + end + + # Returns a substring from the beginning of the string to the given position. + # If the position is negative, it is counted from the end of the string. + # + # str = "hello" + # str.to(0) # => "h" + # str.to(3) # => "hell" + # str.to(-2) # => "hell" + # + # You can mix it with +from+ method and do fun things like: + # + # str = "hello" + # str.from(0).to(-1) # => "hello" + # str.from(1).to(-2) # => "ell" + def to(position) + self[0..position] + end + + # Returns the first character. If a limit is supplied, returns a substring + # from the beginning of the string until it reaches the limit value. If the + # given limit is greater than or equal to the string length, returns a copy of self. + # + # str = "hello" + # str.first # => "h" + # str.first(1) # => "h" + # str.first(2) # => "he" + # str.first(0) # => "" + # str.first(6) # => "hello" + def first(limit = 1) + if limit == 0 + "" + elsif limit >= size + dup + else + to(limit - 1) + end + end + + # Returns the last character of the string. If a limit is supplied, returns a substring + # from the end of the string until it reaches the limit value (counting backwards). If + # the given limit is greater than or equal to the string length, returns a copy of self. + # + # str = "hello" + # str.last # => "o" + # str.last(1) # => "o" + # str.last(2) # => "lo" + # str.last(0) # => "" + # str.last(6) # => "hello" + def last(limit = 1) + if limit == 0 + "" + elsif limit >= size + dup + else + from(-limit) + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/behavior.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/behavior.rb new file mode 100644 index 0000000000..35a5aa7840 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/behavior.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +class String + # Enables more predictable duck-typing on String-like classes. See Object#acts_like?. + def acts_like_string? + true + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/conversions.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/conversions.rb new file mode 100644 index 0000000000..29a88b07ad --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/conversions.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +require "date" +require "active_support/core_ext/time/calculations" + +class String + # Converts a string to a Time value. + # The +form+ can be either :utc or :local (default :local). + # + # The time is parsed using Time.parse method. + # If +form+ is :local, then the time is in the system timezone. + # If the date part is missing then the current date is used and if + # the time part is missing then it is assumed to be 00:00:00. + # + # "13-12-2012".to_time # => 2012-12-13 00:00:00 +0100 + # "06:12".to_time # => 2012-12-13 06:12:00 +0100 + # "2012-12-13 06:12".to_time # => 2012-12-13 06:12:00 +0100 + # "2012-12-13T06:12".to_time # => 2012-12-13 06:12:00 +0100 + # "2012-12-13T06:12".to_time(:utc) # => 2012-12-13 06:12:00 UTC + # "12/13/2012".to_time # => ArgumentError: argument out of range + def to_time(form = :local) + parts = Date._parse(self, false) + used_keys = %i(year mon mday hour min sec sec_fraction offset) + return if (parts.keys & used_keys).empty? + + now = Time.now + time = Time.new( + parts.fetch(:year, now.year), + parts.fetch(:mon, now.month), + parts.fetch(:mday, now.day), + parts.fetch(:hour, 0), + parts.fetch(:min, 0), + parts.fetch(:sec, 0) + parts.fetch(:sec_fraction, 0), + parts.fetch(:offset, form == :utc ? 0 : nil) + ) + + form == :utc ? time.utc : time.to_time + end + + # Converts a string to a Date value. + # + # "1-1-2012".to_date # => Sun, 01 Jan 2012 + # "01/01/2012".to_date # => Sun, 01 Jan 2012 + # "2012-12-13".to_date # => Thu, 13 Dec 2012 + # "12/13/2012".to_date # => ArgumentError: invalid date + def to_date + ::Date.parse(self, false) unless blank? + end + + # Converts a string to a DateTime value. + # + # "1-1-2012".to_datetime # => Sun, 01 Jan 2012 00:00:00 +0000 + # "01/01/2012 23:59:59".to_datetime # => Sun, 01 Jan 2012 23:59:59 +0000 + # "2012-12-13 12:50".to_datetime # => Thu, 13 Dec 2012 12:50:00 +0000 + # "12/13/2012".to_datetime # => ArgumentError: invalid date + def to_datetime + ::DateTime.parse(self, false) unless blank? + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/exclude.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/exclude.rb new file mode 100644 index 0000000000..8e462689f1 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/exclude.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class String + # The inverse of String#include?. Returns true if the string + # does not include the other string. + # + # "hello".exclude? "lo" # => false + # "hello".exclude? "ol" # => true + # "hello".exclude? ?h # => false + def exclude?(string) + !include?(string) + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/filters.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/filters.rb new file mode 100644 index 0000000000..66e721eea3 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/filters.rb @@ -0,0 +1,104 @@ +# frozen_string_literal: true + +class String + # Returns the string, first removing all whitespace on both ends of + # the string, and then changing remaining consecutive whitespace + # groups into one space each. + # + # Note that it handles both ASCII and Unicode whitespace. + # + # %{ Multi-line + # string }.squish # => "Multi-line string" + # " foo bar \n \t boo".squish # => "foo bar boo" + def squish + dup.squish! + end + + # Performs a destructive squish. See String#squish. + # str = " foo bar \n \t boo" + # str.squish! # => "foo bar boo" + # str # => "foo bar boo" + def squish! + gsub!(/[[:space:]]+/, " ") + strip! + self + end + + # Returns a new string with all occurrences of the patterns removed. + # str = "foo bar test" + # str.remove(" test") # => "foo bar" + # str.remove(" test", /bar/) # => "foo " + # str # => "foo bar test" + def remove(*patterns) + dup.remove!(*patterns) + end + + # Alters the string by removing all occurrences of the patterns. + # str = "foo bar test" + # str.remove!(" test", /bar/) # => "foo " + # str # => "foo " + def remove!(*patterns) + patterns.each do |pattern| + gsub! pattern, "" + end + + self + end + + # Truncates a given +text+ after a given length if +text+ is longer than length: + # + # 'Once upon a time in a world far far away'.truncate(27) + # # => "Once upon a time in a wo..." + # + # Pass a string or regexp :separator to truncate +text+ at a natural break: + # + # 'Once upon a time in a world far far away'.truncate(27, separator: ' ') + # # => "Once upon a time in a..." + # + # 'Once upon a time in a world far far away'.truncate(27, separator: /\s/) + # # => "Once upon a time in a..." + # + # The last characters will be replaced with the :omission string (defaults to "...") + # for a total length not exceeding length: + # + # 'And they found that many people were sleeping better.'.truncate(25, omission: '... (continued)') + # # => "And they f... (continued)" + def truncate(truncate_at, options = {}) + return dup unless length > truncate_at + + omission = options[:omission] || "..." + length_with_room_for_omission = truncate_at - omission.length + stop = \ + if options[:separator] + rindex(options[:separator], length_with_room_for_omission) || length_with_room_for_omission + else + length_with_room_for_omission + end + + "#{self[0, stop]}#{omission}" + end + + # Truncates a given +text+ after a given number of words (words_count): + # + # 'Once upon a time in a world far far away'.truncate_words(4) + # # => "Once upon a time..." + # + # Pass a string or regexp :separator to specify a different separator of words: + # + # 'Once
upon
a
time
in
a
world'.truncate_words(5, separator: '
') + # # => "Once
upon
a
time
in..." + # + # The last characters will be replaced with the :omission string (defaults to "..."): + # + # 'And they found that many people were sleeping better.'.truncate_words(5, omission: '... (continued)') + # # => "And they found that many... (continued)" + def truncate_words(words_count, options = {}) + sep = options[:separator] || /\s+/ + sep = Regexp.escape(sep.to_s) unless Regexp === sep + if self =~ /\A((?>.+?#{sep}){#{words_count - 1}}.+?)#{sep}.*/m + $1 + (options[:omission] || "...") + else + dup + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/indent.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/indent.rb new file mode 100644 index 0000000000..af9d181487 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/indent.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +class String + # Same as +indent+, except it indents the receiver in-place. + # + # Returns the indented string, or +nil+ if there was nothing to indent. + def indent!(amount, indent_string = nil, indent_empty_lines = false) + indent_string = indent_string || self[/^[ \t]/] || " " + re = indent_empty_lines ? /^/ : /^(?!$)/ + gsub!(re, indent_string * amount) + end + + # Indents the lines in the receiver: + # + # < + # def some_method + # some_code + # end + # + # The second argument, +indent_string+, specifies which indent string to + # use. The default is +nil+, which tells the method to make a guess by + # peeking at the first indented line, and fallback to a space if there is + # none. + # + # " foo".indent(2) # => " foo" + # "foo\n\t\tbar".indent(2) # => "\t\tfoo\n\t\t\t\tbar" + # "foo".indent(2, "\t") # => "\t\tfoo" + # + # While +indent_string+ is typically one space or tab, it may be any string. + # + # The third argument, +indent_empty_lines+, is a flag that says whether + # empty lines should be indented. Default is false. + # + # "foo\n\nbar".indent(2) # => " foo\n\n bar" + # "foo\n\nbar".indent(2, nil, true) # => " foo\n \n bar" + # + def indent(amount, indent_string = nil, indent_empty_lines = false) + dup.tap { |_| _.indent!(amount, indent_string, indent_empty_lines) } + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/inflections.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/inflections.rb new file mode 100644 index 0000000000..8af301734a --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/inflections.rb @@ -0,0 +1,254 @@ +# frozen_string_literal: true + +require "active_support/inflector/methods" +require "active_support/inflector/transliterate" + +# String inflections define new methods on the String class to transform names for different purposes. +# For instance, you can figure out the name of a table from the name of a class. +# +# 'ScaleScore'.tableize # => "scale_scores" +# +class String + # Returns the plural form of the word in the string. + # + # If the optional parameter +count+ is specified, + # the singular form will be returned if count == 1. + # For any other value of +count+ the plural will be returned. + # + # If the optional parameter +locale+ is specified, + # the word will be pluralized as a word of that language. + # By default, this parameter is set to :en. + # You must define your own inflection rules for languages other than English. + # + # 'post'.pluralize # => "posts" + # 'octopus'.pluralize # => "octopi" + # 'sheep'.pluralize # => "sheep" + # 'words'.pluralize # => "words" + # 'the blue mailman'.pluralize # => "the blue mailmen" + # 'CamelOctopus'.pluralize # => "CamelOctopi" + # 'apple'.pluralize(1) # => "apple" + # 'apple'.pluralize(2) # => "apples" + # 'ley'.pluralize(:es) # => "leyes" + # 'ley'.pluralize(1, :es) # => "ley" + def pluralize(count = nil, locale = :en) + locale = count if count.is_a?(Symbol) + if count == 1 + dup + else + ActiveSupport::Inflector.pluralize(self, locale) + end + end + + # The reverse of +pluralize+, returns the singular form of a word in a string. + # + # If the optional parameter +locale+ is specified, + # the word will be singularized as a word of that language. + # By default, this parameter is set to :en. + # You must define your own inflection rules for languages other than English. + # + # 'posts'.singularize # => "post" + # 'octopi'.singularize # => "octopus" + # 'sheep'.singularize # => "sheep" + # 'word'.singularize # => "word" + # 'the blue mailmen'.singularize # => "the blue mailman" + # 'CamelOctopi'.singularize # => "CamelOctopus" + # 'leyes'.singularize(:es) # => "ley" + def singularize(locale = :en) + ActiveSupport::Inflector.singularize(self, locale) + end + + # +constantize+ tries to find a declared constant with the name specified + # in the string. It raises a NameError when the name is not in CamelCase + # or is not initialized. See ActiveSupport::Inflector.constantize + # + # 'Module'.constantize # => Module + # 'Class'.constantize # => Class + # 'blargle'.constantize # => NameError: wrong constant name blargle + def constantize + ActiveSupport::Inflector.constantize(self) + end + + # +safe_constantize+ tries to find a declared constant with the name specified + # in the string. It returns +nil+ when the name is not in CamelCase + # or is not initialized. See ActiveSupport::Inflector.safe_constantize + # + # 'Module'.safe_constantize # => Module + # 'Class'.safe_constantize # => Class + # 'blargle'.safe_constantize # => nil + def safe_constantize + ActiveSupport::Inflector.safe_constantize(self) + end + + # By default, +camelize+ converts strings to UpperCamelCase. If the argument to camelize + # is set to :lower then camelize produces lowerCamelCase. + # + # +camelize+ will also convert '/' to '::' which is useful for converting paths to namespaces. + # + # 'active_record'.camelize # => "ActiveRecord" + # 'active_record'.camelize(:lower) # => "activeRecord" + # 'active_record/errors'.camelize # => "ActiveRecord::Errors" + # 'active_record/errors'.camelize(:lower) # => "activeRecord::Errors" + def camelize(first_letter = :upper) + case first_letter + when :upper + ActiveSupport::Inflector.camelize(self, true) + when :lower + ActiveSupport::Inflector.camelize(self, false) + else + raise ArgumentError, "Invalid option, use either :upper or :lower." + end + end + alias_method :camelcase, :camelize + + # Capitalizes all the words and replaces some characters in the string to create + # a nicer looking title. +titleize+ is meant for creating pretty output. It is not + # used in the Rails internals. + # + # The trailing '_id','Id'.. can be kept and capitalized by setting the + # optional parameter +keep_id_suffix+ to true. + # By default, this parameter is false. + # + # +titleize+ is also aliased as +titlecase+. + # + # 'man from the boondocks'.titleize # => "Man From The Boondocks" + # 'x-men: the last stand'.titleize # => "X Men: The Last Stand" + # 'string_ending_with_id'.titleize(keep_id_suffix: true) # => "String Ending With Id" + def titleize(keep_id_suffix: false) + ActiveSupport::Inflector.titleize(self, keep_id_suffix: keep_id_suffix) + end + alias_method :titlecase, :titleize + + # The reverse of +camelize+. Makes an underscored, lowercase form from the expression in the string. + # + # +underscore+ will also change '::' to '/' to convert namespaces to paths. + # + # 'ActiveModel'.underscore # => "active_model" + # 'ActiveModel::Errors'.underscore # => "active_model/errors" + def underscore + ActiveSupport::Inflector.underscore(self) + end + + # Replaces underscores with dashes in the string. + # + # 'puni_puni'.dasherize # => "puni-puni" + def dasherize + ActiveSupport::Inflector.dasherize(self) + end + + # Removes the module part from the constant expression in the string. + # + # 'ActiveSupport::Inflector::Inflections'.demodulize # => "Inflections" + # 'Inflections'.demodulize # => "Inflections" + # '::Inflections'.demodulize # => "Inflections" + # ''.demodulize # => '' + # + # See also +deconstantize+. + def demodulize + ActiveSupport::Inflector.demodulize(self) + end + + # Removes the rightmost segment from the constant expression in the string. + # + # 'Net::HTTP'.deconstantize # => "Net" + # '::Net::HTTP'.deconstantize # => "::Net" + # 'String'.deconstantize # => "" + # '::String'.deconstantize # => "" + # ''.deconstantize # => "" + # + # See also +demodulize+. + def deconstantize + ActiveSupport::Inflector.deconstantize(self) + end + + # Replaces special characters in a string so that it may be used as part of a 'pretty' URL. + # + # class Person + # def to_param + # "#{id}-#{name.parameterize}" + # end + # end + # + # @person = Person.find(1) + # # => # + # + # <%= link_to(@person.name, person_path) %> + # # => Donald E. Knuth + # + # To preserve the case of the characters in a string, use the +preserve_case+ argument. + # + # class Person + # def to_param + # "#{id}-#{name.parameterize(preserve_case: true)}" + # end + # end + # + # @person = Person.find(1) + # # => # + # + # <%= link_to(@person.name, person_path) %> + # # => Donald E. Knuth + def parameterize(separator: "-", preserve_case: false) + ActiveSupport::Inflector.parameterize(self, separator: separator, preserve_case: preserve_case) + end + + # Creates the name of a table like Rails does for models to table names. This method + # uses the +pluralize+ method on the last word in the string. + # + # 'RawScaledScorer'.tableize # => "raw_scaled_scorers" + # 'ham_and_egg'.tableize # => "ham_and_eggs" + # 'fancyCategory'.tableize # => "fancy_categories" + def tableize + ActiveSupport::Inflector.tableize(self) + end + + # Creates a class name from a plural table name like Rails does for table names to models. + # Note that this returns a string and not a class. (To convert to an actual class + # follow +classify+ with +constantize+.) + # + # 'ham_and_eggs'.classify # => "HamAndEgg" + # 'posts'.classify # => "Post" + def classify + ActiveSupport::Inflector.classify(self) + end + + # Capitalizes the first word, turns underscores into spaces, and (by default)strips a + # trailing '_id' if present. + # Like +titleize+, this is meant for creating pretty output. + # + # The capitalization of the first word can be turned off by setting the + # optional parameter +capitalize+ to false. + # By default, this parameter is true. + # + # The trailing '_id' can be kept and capitalized by setting the + # optional parameter +keep_id_suffix+ to true. + # By default, this parameter is false. + # + # 'employee_salary'.humanize # => "Employee salary" + # 'author_id'.humanize # => "Author" + # 'author_id'.humanize(capitalize: false) # => "author" + # '_id'.humanize # => "Id" + # 'author_id'.humanize(keep_id_suffix: true) # => "Author Id" + def humanize(capitalize: true, keep_id_suffix: false) + ActiveSupport::Inflector.humanize(self, capitalize: capitalize, keep_id_suffix: keep_id_suffix) + end + + # Converts just the first character to uppercase. + # + # 'what a Lovely Day'.upcase_first # => "What a Lovely Day" + # 'w'.upcase_first # => "W" + # ''.upcase_first # => "" + def upcase_first + ActiveSupport::Inflector.upcase_first(self) + end + + # Creates a foreign key name from a class name. + # +separate_class_name_and_id_with_underscore+ sets whether + # the method should put '_' between the name and 'id'. + # + # 'Message'.foreign_key # => "message_id" + # 'Message'.foreign_key(false) # => "messageid" + # 'Admin::Post'.foreign_key # => "post_id" + def foreign_key(separate_class_name_and_id_with_underscore = true) + ActiveSupport::Inflector.foreign_key(self, separate_class_name_and_id_with_underscore) + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/inquiry.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/inquiry.rb new file mode 100644 index 0000000000..a796d5fb4f --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/inquiry.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require "active_support/string_inquirer" + +class String + # Wraps the current string in the ActiveSupport::StringInquirer class, + # which gives you a prettier way to test for equality. + # + # env = 'production'.inquiry + # env.production? # => true + # env.development? # => false + def inquiry + ActiveSupport::StringInquirer.new(self) + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/multibyte.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/multibyte.rb new file mode 100644 index 0000000000..07c0d16398 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/multibyte.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +require "active_support/multibyte" + +class String + # == Multibyte proxy + # + # +mb_chars+ is a multibyte safe proxy for string methods. + # + # It creates and returns an instance of the ActiveSupport::Multibyte::Chars class which + # encapsulates the original string. A Unicode safe version of all the String methods are defined on this proxy + # class. If the proxy class doesn't respond to a certain method, it's forwarded to the encapsulated string. + # + # >> "lj".upcase + # => "lj" + # >> "lj".mb_chars.upcase.to_s + # => "LJ" + # + # NOTE: An above example is useful for pre Ruby 2.4. Ruby 2.4 supports Unicode case mappings. + # + # == Method chaining + # + # All the methods on the Chars proxy which normally return a string will return a Chars object. This allows + # method chaining on the result of any of these methods. + # + # name.mb_chars.reverse.length # => 12 + # + # == Interoperability and configuration + # + # The Chars object tries to be as interchangeable with String objects as possible: sorting and comparing between + # String and Char work like expected. The bang! methods change the internal string representation in the Chars + # object. Interoperability problems can be resolved easily with a +to_s+ call. + # + # For more information about the methods defined on the Chars proxy see ActiveSupport::Multibyte::Chars. For + # information about how to change the default Multibyte behavior see ActiveSupport::Multibyte. + def mb_chars + ActiveSupport::Multibyte.proxy_class.new(self) + end + + # Returns +true+ if string has utf_8 encoding. + # + # utf_8_str = "some string".encode "UTF-8" + # iso_str = "some string".encode "ISO-8859-1" + # + # utf_8_str.is_utf8? # => true + # iso_str.is_utf8? # => false + def is_utf8? + case encoding + when Encoding::UTF_8 + valid_encoding? + when Encoding::ASCII_8BIT, Encoding::US_ASCII + dup.force_encoding(Encoding::UTF_8).valid_encoding? + else + false + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/output_safety.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/output_safety.rb new file mode 100644 index 0000000000..f3bdc2977e --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/output_safety.rb @@ -0,0 +1,258 @@ +# frozen_string_literal: true + +require "erb" +require "active_support/core_ext/kernel/singleton_class" +require "active_support/core_ext/module/redefine_method" +require "active_support/multibyte/unicode" + +class ERB + module Util + HTML_ESCAPE = { "&" => "&", ">" => ">", "<" => "<", '"' => """, "'" => "'" } + JSON_ESCAPE = { "&" => '\u0026', ">" => '\u003e', "<" => '\u003c', "\u2028" => '\u2028', "\u2029" => '\u2029' } + HTML_ESCAPE_ONCE_REGEXP = /["><']|&(?!([a-zA-Z]+|(#\d+)|(#[xX][\dA-Fa-f]+));)/ + JSON_ESCAPE_REGEXP = /[\u2028\u2029&><]/u + + # A utility method for escaping HTML tag characters. + # This method is also aliased as h. + # + # puts html_escape('is a > 0 & a < 10?') + # # => is a > 0 & a < 10? + def html_escape(s) + unwrapped_html_escape(s).html_safe + end + + silence_redefinition_of_method :h + alias h html_escape + + module_function :h + + singleton_class.silence_redefinition_of_method :html_escape + module_function :html_escape + + # HTML escapes strings but doesn't wrap them with an ActiveSupport::SafeBuffer. + # This method is not for public consumption! Seriously! + def unwrapped_html_escape(s) # :nodoc: + s = s.to_s + if s.html_safe? + s + else + CGI.escapeHTML(ActiveSupport::Multibyte::Unicode.tidy_bytes(s)) + end + end + module_function :unwrapped_html_escape + + # A utility method for escaping HTML without affecting existing escaped entities. + # + # html_escape_once('1 < 2 & 3') + # # => "1 < 2 & 3" + # + # html_escape_once('<< Accept & Checkout') + # # => "<< Accept & Checkout" + def html_escape_once(s) + result = ActiveSupport::Multibyte::Unicode.tidy_bytes(s.to_s).gsub(HTML_ESCAPE_ONCE_REGEXP, HTML_ESCAPE) + s.html_safe? ? result.html_safe : result + end + + module_function :html_escape_once + + # A utility method for escaping HTML entities in JSON strings. Specifically, the + # &, > and < characters are replaced with their equivalent unicode escaped form - + # \u0026, \u003e, and \u003c. The Unicode sequences \u2028 and \u2029 are also + # escaped as they are treated as newline characters in some JavaScript engines. + # These sequences have identical meaning as the original characters inside the + # context of a JSON string, so assuming the input is a valid and well-formed + # JSON value, the output will have equivalent meaning when parsed: + # + # json = JSON.generate({ name: ""}) + # # => "{\"name\":\"\"}" + # + # json_escape(json) + # # => "{\"name\":\"\\u003C/script\\u003E\\u003Cscript\\u003Ealert('PWNED!!!')\\u003C/script\\u003E\"}" + # + # JSON.parse(json) == JSON.parse(json_escape(json)) + # # => true + # + # The intended use case for this method is to escape JSON strings before including + # them inside a script tag to avoid XSS vulnerability: + # + # + # + # It is necessary to +raw+ the result of +json_escape+, so that quotation marks + # don't get converted to " entities. +json_escape+ doesn't + # automatically flag the result as HTML safe, since the raw value is unsafe to + # use inside HTML attributes. + # + # If your JSON is being used downstream for insertion into the DOM, be aware of + # whether or not it is being inserted via +html()+. Most jQuery plugins do this. + # If that is the case, be sure to +html_escape+ or +sanitize+ any user-generated + # content returned by your JSON. + # + # If you need to output JSON elsewhere in your HTML, you can just do something + # like this, as any unsafe characters (including quotation marks) will be + # automatically escaped for you: + # + #
...
+ # + # WARNING: this helper only works with valid JSON. Using this on non-JSON values + # will open up serious XSS vulnerabilities. For example, if you replace the + # +current_user.to_json+ in the example above with user input instead, the browser + # will happily eval() that string as JavaScript. + # + # The escaping performed in this method is identical to those performed in the + # Active Support JSON encoder when +ActiveSupport.escape_html_entities_in_json+ is + # set to true. Because this transformation is idempotent, this helper can be + # applied even if +ActiveSupport.escape_html_entities_in_json+ is already true. + # + # Therefore, when you are unsure if +ActiveSupport.escape_html_entities_in_json+ + # is enabled, or if you are unsure where your JSON string originated from, it + # is recommended that you always apply this helper (other libraries, such as the + # JSON gem, do not provide this kind of protection by default; also some gems + # might override +to_json+ to bypass Active Support's encoder). + def json_escape(s) + result = s.to_s.gsub(JSON_ESCAPE_REGEXP, JSON_ESCAPE) + s.html_safe? ? result.html_safe : result + end + + module_function :json_escape + end +end + +class Object + def html_safe? + false + end +end + +class Numeric + def html_safe? + true + end +end + +module ActiveSupport #:nodoc: + class SafeBuffer < String + UNSAFE_STRING_METHODS = %w( + capitalize chomp chop delete downcase gsub lstrip next reverse rstrip + slice squeeze strip sub succ swapcase tr tr_s upcase + ) + + alias_method :original_concat, :concat + private :original_concat + + # Raised when ActiveSupport::SafeBuffer#safe_concat is called on unsafe buffers. + class SafeConcatError < StandardError + def initialize + super "Could not concatenate to the buffer because it is not html safe." + end + end + + def [](*args) + if args.size < 2 + super + elsif html_safe? + new_safe_buffer = super + + if new_safe_buffer + new_safe_buffer.instance_variable_set :@html_safe, true + end + + new_safe_buffer + else + to_str[*args] + end + end + + def safe_concat(value) + raise SafeConcatError unless html_safe? + original_concat(value) + end + + def initialize(str = "") + @html_safe = true + super + end + + def initialize_copy(other) + super + @html_safe = other.html_safe? + end + + def clone_empty + self[0, 0] + end + + def concat(value) + super(html_escape_interpolated_argument(value)) + end + alias << concat + + def prepend(value) + super(html_escape_interpolated_argument(value)) + end + + def +(other) + dup.concat(other) + end + + def %(args) + case args + when Hash + escaped_args = Hash[args.map { |k, arg| [k, html_escape_interpolated_argument(arg)] }] + else + escaped_args = Array(args).map { |arg| html_escape_interpolated_argument(arg) } + end + + self.class.new(super(escaped_args)) + end + + def html_safe? + defined?(@html_safe) && @html_safe + end + + def to_s + self + end + + def to_param + to_str + end + + def encode_with(coder) + coder.represent_object nil, to_str + end + + UNSAFE_STRING_METHODS.each do |unsafe_method| + if unsafe_method.respond_to?(unsafe_method) + class_eval <<-EOT, __FILE__, __LINE__ + 1 + def #{unsafe_method}(*args, &block) # def capitalize(*args, &block) + to_str.#{unsafe_method}(*args, &block) # to_str.capitalize(*args, &block) + end # end + + def #{unsafe_method}!(*args) # def capitalize!(*args) + @html_safe = false # @html_safe = false + super # super + end # end + EOT + end + end + + private + + def html_escape_interpolated_argument(arg) + (!html_safe? || arg.html_safe?) ? arg : CGI.escapeHTML(arg.to_s) + end + end +end + +class String + # Marks a string as trusted safe. It will be inserted into HTML with no + # additional escaping performed. It is your responsibility to ensure that the + # string contains no malicious content. This method is equivalent to the + # +raw+ helper in views. It is recommended that you use +sanitize+ instead of + # this method. It should never be called on user input. + def html_safe + ActiveSupport::SafeBuffer.new(self) + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/starts_ends_with.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/starts_ends_with.rb new file mode 100644 index 0000000000..919eb7a573 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/starts_ends_with.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +class String + alias_method :starts_with?, :start_with? + alias_method :ends_with?, :end_with? +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/strip.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/strip.rb new file mode 100644 index 0000000000..cc26274e4a --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/strip.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class String + # Strips indentation in heredocs. + # + # For example in + # + # if options[:usage] + # puts <<-USAGE.strip_heredoc + # This command does such and such. + # + # Supported options are: + # -h This message + # ... + # USAGE + # end + # + # the user would see the usage message aligned against the left margin. + # + # Technically, it looks for the least indented non-empty line + # in the whole string, and removes that amount of leading whitespace. + def strip_heredoc + gsub(/^#{scan(/^[ \t]*(?=\S)/).min}/, "".freeze) + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/zones.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/zones.rb new file mode 100644 index 0000000000..55dc231464 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/string/zones.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +require "active_support/core_ext/string/conversions" +require "active_support/core_ext/time/zones" + +class String + # Converts String to a TimeWithZone in the current zone if Time.zone or Time.zone_default + # is set, otherwise converts String to a Time via String#to_time + def in_time_zone(zone = ::Time.zone) + if zone + ::Time.find_zone!(zone).parse(self) + else + to_time + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/time.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/time.rb new file mode 100644 index 0000000000..c809def05f --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/time.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +require "active_support/core_ext/time/acts_like" +require "active_support/core_ext/time/calculations" +require "active_support/core_ext/time/compatibility" +require "active_support/core_ext/time/conversions" +require "active_support/core_ext/time/zones" diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/time/acts_like.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/time/acts_like.rb new file mode 100644 index 0000000000..8572b49639 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/time/acts_like.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +require "active_support/core_ext/object/acts_like" + +class Time + # Duck-types as a Time-like class. See Object#acts_like?. + def acts_like_time? + true + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/time/calculations.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/time/calculations.rb new file mode 100644 index 0000000000..120768dec5 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/time/calculations.rb @@ -0,0 +1,315 @@ +# frozen_string_literal: true + +require "active_support/duration" +require "active_support/core_ext/time/conversions" +require "active_support/time_with_zone" +require "active_support/core_ext/time/zones" +require "active_support/core_ext/date_and_time/calculations" +require "active_support/core_ext/date/calculations" + +class Time + include DateAndTime::Calculations + + COMMON_YEAR_DAYS_IN_MONTH = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] + + class << self + # Overriding case equality method so that it returns true for ActiveSupport::TimeWithZone instances + def ===(other) + super || (self == Time && other.is_a?(ActiveSupport::TimeWithZone)) + end + + # Returns the number of days in the given month. + # If no year is specified, it will use the current year. + def days_in_month(month, year = current.year) + if month == 2 && ::Date.gregorian_leap?(year) + 29 + else + COMMON_YEAR_DAYS_IN_MONTH[month] + end + end + + # Returns the number of days in the given year. + # If no year is specified, it will use the current year. + def days_in_year(year = current.year) + days_in_month(2, year) + 337 + end + + # Returns Time.zone.now when Time.zone or config.time_zone are set, otherwise just returns Time.now. + def current + ::Time.zone ? ::Time.zone.now : ::Time.now + end + + # Layers additional behavior on Time.at so that ActiveSupport::TimeWithZone and DateTime + # instances can be used when called with a single argument + def at_with_coercion(*args) + return at_without_coercion(*args) if args.size != 1 + + # Time.at can be called with a time or numerical value + time_or_number = args.first + + if time_or_number.is_a?(ActiveSupport::TimeWithZone) || time_or_number.is_a?(DateTime) + at_without_coercion(time_or_number.to_f).getlocal + else + at_without_coercion(time_or_number) + end + end + alias_method :at_without_coercion, :at + alias_method :at, :at_with_coercion + + # Creates a +Time+ instance from an RFC 3339 string. + # + # Time.rfc3339('1999-12-31T14:00:00-10:00') # => 2000-01-01 00:00:00 -1000 + # + # If the time or offset components are missing then an +ArgumentError+ will be raised. + # + # Time.rfc3339('1999-12-31') # => ArgumentError: invalid date + def rfc3339(str) + parts = Date._rfc3339(str) + + raise ArgumentError, "invalid date" if parts.empty? + + Time.new( + parts.fetch(:year), + parts.fetch(:mon), + parts.fetch(:mday), + parts.fetch(:hour), + parts.fetch(:min), + parts.fetch(:sec) + parts.fetch(:sec_fraction, 0), + parts.fetch(:offset) + ) + end + end + + # Returns the number of seconds since 00:00:00. + # + # Time.new(2012, 8, 29, 0, 0, 0).seconds_since_midnight # => 0.0 + # Time.new(2012, 8, 29, 12, 34, 56).seconds_since_midnight # => 45296.0 + # Time.new(2012, 8, 29, 23, 59, 59).seconds_since_midnight # => 86399.0 + def seconds_since_midnight + to_i - change(hour: 0).to_i + (usec / 1.0e+6) + end + + # Returns the number of seconds until 23:59:59. + # + # Time.new(2012, 8, 29, 0, 0, 0).seconds_until_end_of_day # => 86399 + # Time.new(2012, 8, 29, 12, 34, 56).seconds_until_end_of_day # => 41103 + # Time.new(2012, 8, 29, 23, 59, 59).seconds_until_end_of_day # => 0 + def seconds_until_end_of_day + end_of_day.to_i - to_i + end + + # Returns the fraction of a second as a +Rational+ + # + # Time.new(2012, 8, 29, 0, 0, 0.5).sec_fraction # => (1/2) + def sec_fraction + subsec + end + + # Returns a new Time where one or more of the elements have been changed according + # to the +options+ parameter. The time options (:hour, :min, + # :sec, :usec, :nsec) reset cascadingly, so if only + # the hour is passed, then minute, sec, usec and nsec is set to 0. If the hour + # and minute is passed, then sec, usec and nsec is set to 0. The +options+ parameter + # takes a hash with any of these keys: :year, :month, :day, + # :hour, :min, :sec, :usec, :nsec, + # :offset. Pass either :usec or :nsec, not both. + # + # Time.new(2012, 8, 29, 22, 35, 0).change(day: 1) # => Time.new(2012, 8, 1, 22, 35, 0) + # Time.new(2012, 8, 29, 22, 35, 0).change(year: 1981, day: 1) # => Time.new(1981, 8, 1, 22, 35, 0) + # Time.new(2012, 8, 29, 22, 35, 0).change(year: 1981, hour: 0) # => Time.new(1981, 8, 29, 0, 0, 0) + def change(options) + new_year = options.fetch(:year, year) + new_month = options.fetch(:month, month) + new_day = options.fetch(:day, day) + new_hour = options.fetch(:hour, hour) + new_min = options.fetch(:min, options[:hour] ? 0 : min) + new_sec = options.fetch(:sec, (options[:hour] || options[:min]) ? 0 : sec) + new_offset = options.fetch(:offset, nil) + + if new_nsec = options[:nsec] + raise ArgumentError, "Can't change both :nsec and :usec at the same time: #{options.inspect}" if options[:usec] + new_usec = Rational(new_nsec, 1000) + else + new_usec = options.fetch(:usec, (options[:hour] || options[:min] || options[:sec]) ? 0 : Rational(nsec, 1000)) + end + + raise ArgumentError, "argument out of range" if new_usec >= 1000000 + + new_sec += Rational(new_usec, 1000000) + + if new_offset + ::Time.new(new_year, new_month, new_day, new_hour, new_min, new_sec, new_offset) + elsif utc? + ::Time.utc(new_year, new_month, new_day, new_hour, new_min, new_sec) + elsif zone + ::Time.local(new_year, new_month, new_day, new_hour, new_min, new_sec) + else + ::Time.new(new_year, new_month, new_day, new_hour, new_min, new_sec, utc_offset) + end + end + + # Uses Date to provide precise Time calculations for years, months, and days + # according to the proleptic Gregorian calendar. The +options+ parameter + # takes a hash with any of these keys: :years, :months, + # :weeks, :days, :hours, :minutes, + # :seconds. + # + # Time.new(2015, 8, 1, 14, 35, 0).advance(seconds: 1) # => 2015-08-01 14:35:01 -0700 + # Time.new(2015, 8, 1, 14, 35, 0).advance(minutes: 1) # => 2015-08-01 14:36:00 -0700 + # Time.new(2015, 8, 1, 14, 35, 0).advance(hours: 1) # => 2015-08-01 15:35:00 -0700 + # Time.new(2015, 8, 1, 14, 35, 0).advance(days: 1) # => 2015-08-02 14:35:00 -0700 + # Time.new(2015, 8, 1, 14, 35, 0).advance(weeks: 1) # => 2015-08-08 14:35:00 -0700 + def advance(options) + unless options[:weeks].nil? + options[:weeks], partial_weeks = options[:weeks].divmod(1) + options[:days] = options.fetch(:days, 0) + 7 * partial_weeks + end + + unless options[:days].nil? + options[:days], partial_days = options[:days].divmod(1) + options[:hours] = options.fetch(:hours, 0) + 24 * partial_days + end + + d = to_date.advance(options) + d = d.gregorian if d.julian? + time_advanced_by_date = change(year: d.year, month: d.month, day: d.day) + seconds_to_advance = \ + options.fetch(:seconds, 0) + + options.fetch(:minutes, 0) * 60 + + options.fetch(:hours, 0) * 3600 + + if seconds_to_advance.zero? + time_advanced_by_date + else + time_advanced_by_date.since(seconds_to_advance) + end + end + + # Returns a new Time representing the time a number of seconds ago, this is basically a wrapper around the Numeric extension + def ago(seconds) + since(-seconds) + end + + # Returns a new Time representing the time a number of seconds since the instance time + def since(seconds) + self + seconds + rescue + to_datetime.since(seconds) + end + alias :in :since + + # Returns a new Time representing the start of the day (0:00) + def beginning_of_day + change(hour: 0) + end + alias :midnight :beginning_of_day + alias :at_midnight :beginning_of_day + alias :at_beginning_of_day :beginning_of_day + + # Returns a new Time representing the middle of the day (12:00) + def middle_of_day + change(hour: 12) + end + alias :midday :middle_of_day + alias :noon :middle_of_day + alias :at_midday :middle_of_day + alias :at_noon :middle_of_day + alias :at_middle_of_day :middle_of_day + + # Returns a new Time representing the end of the day, 23:59:59.999999 + def end_of_day + change( + hour: 23, + min: 59, + sec: 59, + usec: Rational(999999999, 1000) + ) + end + alias :at_end_of_day :end_of_day + + # Returns a new Time representing the start of the hour (x:00) + def beginning_of_hour + change(min: 0) + end + alias :at_beginning_of_hour :beginning_of_hour + + # Returns a new Time representing the end of the hour, x:59:59.999999 + def end_of_hour + change( + min: 59, + sec: 59, + usec: Rational(999999999, 1000) + ) + end + alias :at_end_of_hour :end_of_hour + + # Returns a new Time representing the start of the minute (x:xx:00) + def beginning_of_minute + change(sec: 0) + end + alias :at_beginning_of_minute :beginning_of_minute + + # Returns a new Time representing the end of the minute, x:xx:59.999999 + def end_of_minute + change( + sec: 59, + usec: Rational(999999999, 1000) + ) + end + alias :at_end_of_minute :end_of_minute + + def plus_with_duration(other) #:nodoc: + if ActiveSupport::Duration === other + other.since(self) + else + plus_without_duration(other) + end + end + alias_method :plus_without_duration, :+ + alias_method :+, :plus_with_duration + + def minus_with_duration(other) #:nodoc: + if ActiveSupport::Duration === other + other.until(self) + else + minus_without_duration(other) + end + end + alias_method :minus_without_duration, :- + alias_method :-, :minus_with_duration + + # Time#- can also be used to determine the number of seconds between two Time instances. + # We're layering on additional behavior so that ActiveSupport::TimeWithZone instances + # are coerced into values that Time#- will recognize + def minus_with_coercion(other) + other = other.comparable_time if other.respond_to?(:comparable_time) + other.is_a?(DateTime) ? to_f - other.to_f : minus_without_coercion(other) + end + alias_method :minus_without_coercion, :- + alias_method :-, :minus_with_coercion + + # Layers additional behavior on Time#<=> so that DateTime and ActiveSupport::TimeWithZone instances + # can be chronologically compared with a Time + def compare_with_coercion(other) + # we're avoiding Time#to_datetime and Time#to_time because they're expensive + if other.class == Time + compare_without_coercion(other) + elsif other.is_a?(Time) + compare_without_coercion(other.to_time) + else + to_datetime <=> other + end + end + alias_method :compare_without_coercion, :<=> + alias_method :<=>, :compare_with_coercion + + # Layers additional behavior on Time#eql? so that ActiveSupport::TimeWithZone instances + # can be eql? to an equivalent Time + def eql_with_coercion(other) + # if other is an ActiveSupport::TimeWithZone, coerce a Time instance from it so we can do eql? comparison + other = other.comparable_time if other.respond_to?(:comparable_time) + eql_without_coercion(other) + end + alias_method :eql_without_coercion, :eql? + alias_method :eql?, :eql_with_coercion +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/time/compatibility.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/time/compatibility.rb new file mode 100644 index 0000000000..495e4f307b --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/time/compatibility.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +require "active_support/core_ext/date_and_time/compatibility" +require "active_support/core_ext/module/redefine_method" + +class Time + include DateAndTime::Compatibility + + silence_redefinition_of_method :to_time + + # Either return +self+ or the time in the local system timezone depending + # on the setting of +ActiveSupport.to_time_preserves_timezone+. + def to_time + preserve_timezone ? self : getlocal + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/time/conversions.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/time/conversions.rb new file mode 100644 index 0000000000..345cb2832c --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/time/conversions.rb @@ -0,0 +1,72 @@ +# frozen_string_literal: true + +require "active_support/inflector/methods" +require "active_support/values/time_zone" + +class Time + DATE_FORMATS = { + db: "%Y-%m-%d %H:%M:%S", + number: "%Y%m%d%H%M%S", + nsec: "%Y%m%d%H%M%S%9N", + usec: "%Y%m%d%H%M%S%6N", + time: "%H:%M", + short: "%d %b %H:%M", + long: "%B %d, %Y %H:%M", + long_ordinal: lambda { |time| + day_format = ActiveSupport::Inflector.ordinalize(time.day) + time.strftime("%B #{day_format}, %Y %H:%M") + }, + rfc822: lambda { |time| + offset_format = time.formatted_offset(false) + time.strftime("%a, %d %b %Y %H:%M:%S #{offset_format}") + }, + iso8601: lambda { |time| time.iso8601 } + } + + # Converts to a formatted string. See DATE_FORMATS for built-in formats. + # + # This method is aliased to to_s. + # + # time = Time.now # => 2007-01-18 06:10:17 -06:00 + # + # time.to_formatted_s(:time) # => "06:10" + # time.to_s(:time) # => "06:10" + # + # time.to_formatted_s(:db) # => "2007-01-18 06:10:17" + # time.to_formatted_s(:number) # => "20070118061017" + # time.to_formatted_s(:short) # => "18 Jan 06:10" + # time.to_formatted_s(:long) # => "January 18, 2007 06:10" + # time.to_formatted_s(:long_ordinal) # => "January 18th, 2007 06:10" + # time.to_formatted_s(:rfc822) # => "Thu, 18 Jan 2007 06:10:17 -0600" + # time.to_formatted_s(:iso8601) # => "2007-01-18T06:10:17-06:00" + # + # == Adding your own time formats to +to_formatted_s+ + # You can add your own formats to the Time::DATE_FORMATS hash. + # Use the format name as the hash key and either a strftime string + # or Proc instance that takes a time argument as the value. + # + # # config/initializers/time_formats.rb + # Time::DATE_FORMATS[:month_and_year] = '%B %Y' + # Time::DATE_FORMATS[:short_ordinal] = ->(time) { time.strftime("%B #{time.day.ordinalize}") } + def to_formatted_s(format = :default) + if formatter = DATE_FORMATS[format] + formatter.respond_to?(:call) ? formatter.call(self).to_s : strftime(formatter) + else + to_default_s + end + end + alias_method :to_default_s, :to_s + alias_method :to_s, :to_formatted_s + + # Returns a formatted string of the offset from UTC, or an alternative + # string if the time zone is already UTC. + # + # Time.local(2000).formatted_offset # => "-06:00" + # Time.local(2000).formatted_offset(false) # => "-0600" + def formatted_offset(colon = true, alternate_utc_string = nil) + utc? && alternate_utc_string || ActiveSupport::TimeZone.seconds_to_utc_offset(utc_offset, colon) + end + + # Aliased to +xmlschema+ for compatibility with +DateTime+ + alias_method :rfc3339, :xmlschema +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/time/zones.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/time/zones.rb new file mode 100644 index 0000000000..a5588fd488 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/time/zones.rb @@ -0,0 +1,113 @@ +# frozen_string_literal: true + +require "active_support/time_with_zone" +require "active_support/core_ext/time/acts_like" +require "active_support/core_ext/date_and_time/zones" + +class Time + include DateAndTime::Zones + class << self + attr_accessor :zone_default + + # Returns the TimeZone for the current request, if this has been set (via Time.zone=). + # If Time.zone has not been set for the current request, returns the TimeZone specified in config.time_zone. + def zone + Thread.current[:time_zone] || zone_default + end + + # Sets Time.zone to a TimeZone object for the current request/thread. + # + # This method accepts any of the following: + # + # * A Rails TimeZone object. + # * An identifier for a Rails TimeZone object (e.g., "Eastern Time (US & Canada)", -5.hours). + # * A TZInfo::Timezone object. + # * An identifier for a TZInfo::Timezone object (e.g., "America/New_York"). + # + # Here's an example of how you might set Time.zone on a per request basis and reset it when the request is done. + # current_user.time_zone just needs to return a string identifying the user's preferred time zone: + # + # class ApplicationController < ActionController::Base + # around_action :set_time_zone + # + # def set_time_zone + # if logged_in? + # Time.use_zone(current_user.time_zone) { yield } + # else + # yield + # end + # end + # end + def zone=(time_zone) + Thread.current[:time_zone] = find_zone!(time_zone) + end + + # Allows override of Time.zone locally inside supplied block; + # resets Time.zone to existing value when done. + # + # class ApplicationController < ActionController::Base + # around_action :set_time_zone + # + # private + # + # def set_time_zone + # Time.use_zone(current_user.timezone) { yield } + # end + # end + # + # NOTE: This won't affect any ActiveSupport::TimeWithZone + # objects that have already been created, e.g. any model timestamp + # attributes that have been read before the block will remain in + # the application's default timezone. + def use_zone(time_zone) + new_zone = find_zone!(time_zone) + begin + old_zone, ::Time.zone = ::Time.zone, new_zone + yield + ensure + ::Time.zone = old_zone + end + end + + # Returns a TimeZone instance matching the time zone provided. + # Accepts the time zone in any format supported by Time.zone=. + # Raises an +ArgumentError+ for invalid time zones. + # + # Time.find_zone! "America/New_York" # => # + # Time.find_zone! "EST" # => # + # Time.find_zone! -5.hours # => # + # Time.find_zone! nil # => nil + # Time.find_zone! false # => false + # Time.find_zone! "NOT-A-TIMEZONE" # => ArgumentError: Invalid Timezone: NOT-A-TIMEZONE + def find_zone!(time_zone) + if !time_zone || time_zone.is_a?(ActiveSupport::TimeZone) + time_zone + else + # Look up the timezone based on the identifier (unless we've been + # passed a TZInfo::Timezone) + unless time_zone.respond_to?(:period_for_local) + time_zone = ActiveSupport::TimeZone[time_zone] || TZInfo::Timezone.get(time_zone) + end + + # Return if a TimeZone instance, or wrap in a TimeZone instance if a TZInfo::Timezone + if time_zone.is_a?(ActiveSupport::TimeZone) + time_zone + else + ActiveSupport::TimeZone.create(time_zone.name, nil, time_zone) + end + end + rescue TZInfo::InvalidTimezoneIdentifier + raise ArgumentError, "Invalid Timezone: #{time_zone}" + end + + # Returns a TimeZone instance matching the time zone provided. + # Accepts the time zone in any format supported by Time.zone=. + # Returns +nil+ for invalid time zones. + # + # Time.find_zone "America/New_York" # => # + # Time.find_zone "NOT-A-TIMEZONE" # => nil + def find_zone(time_zone) + find_zone!(time_zone) rescue nil + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/uri.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/uri.rb new file mode 100644 index 0000000000..78a381cdc8 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/uri.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +require "uri" +if RUBY_VERSION < "2.6.0" + require "active_support/core_ext/module/redefine_method" + URI::Parser.class_eval do + silence_redefinition_of_method :unescape + def unescape(str, escaped = /%[a-fA-F\d]{2}/) + # TODO: Are we actually sure that ASCII == UTF-8? + # YK: My initial experiments say yes, but let's be sure please + enc = str.encoding + enc = Encoding::UTF_8 if enc == Encoding::US_ASCII + str.gsub(escaped) { |match| [match[1, 2].hex].pack("C") }.force_encoding(enc) + end + end +end + +module URI + class << self + def parser + @parser ||= URI::Parser.new + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/deprecation.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/deprecation.rb new file mode 100644 index 0000000000..a1ad2ca465 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/deprecation.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +require "singleton" + +module ActiveSupport + # \Deprecation specifies the API used by Rails to deprecate methods, instance + # variables, objects and constants. + class Deprecation + # active_support.rb sets an autoload for ActiveSupport::Deprecation. + # + # If these requires were at the top of the file the constant would not be + # defined by the time their files were loaded. Since some of them reopen + # ActiveSupport::Deprecation its autoload would be triggered, resulting in + # a circular require warning for active_support/deprecation.rb. + # + # So, we define the constant first, and load dependencies later. + require "active_support/deprecation/instance_delegator" + require "active_support/deprecation/behaviors" + require "active_support/deprecation/reporting" + require "active_support/deprecation/constant_accessor" + require "active_support/deprecation/method_wrappers" + require "active_support/deprecation/proxy_wrappers" + require "active_support/core_ext/module/deprecation" + + include Singleton + include InstanceDelegator + include Behavior + include Reporting + include MethodWrapper + + # The version number in which the deprecated behavior will be removed, by default. + attr_accessor :deprecation_horizon + + # It accepts two parameters on initialization. The first is a version of library + # and the second is a library name. + # + # ActiveSupport::Deprecation.new('2.0', 'MyLibrary') + def initialize(deprecation_horizon = "6.0", gem_name = "Rails") + self.gem_name = gem_name + self.deprecation_horizon = deprecation_horizon + # By default, warnings are not silenced and debugging is off. + self.silenced = false + self.debug = false + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/deprecation/behaviors.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/deprecation/behaviors.rb new file mode 100644 index 0000000000..3abd25aa85 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/deprecation/behaviors.rb @@ -0,0 +1,109 @@ +# frozen_string_literal: true + +require "active_support/notifications" + +module ActiveSupport + # Raised when ActiveSupport::Deprecation::Behavior#behavior is set with :raise. + # You would set :raise, as a behavior to raise errors and proactively report exceptions from deprecations. + class DeprecationException < StandardError + end + + class Deprecation + # Default warning behaviors per Rails.env. + DEFAULT_BEHAVIORS = { + raise: ->(message, callstack, deprecation_horizon, gem_name) { + e = DeprecationException.new(message) + e.set_backtrace(callstack.map(&:to_s)) + raise e + }, + + stderr: ->(message, callstack, deprecation_horizon, gem_name) { + $stderr.puts(message) + $stderr.puts callstack.join("\n ") if debug + }, + + log: ->(message, callstack, deprecation_horizon, gem_name) { + logger = + if defined?(Rails.logger) && Rails.logger + Rails.logger + else + require "active_support/logger" + ActiveSupport::Logger.new($stderr) + end + logger.warn message + logger.debug callstack.join("\n ") if debug + }, + + notify: ->(message, callstack, deprecation_horizon, gem_name) { + notification_name = "deprecation.#{gem_name.underscore.tr('/', '_')}" + ActiveSupport::Notifications.instrument(notification_name, + message: message, + callstack: callstack, + gem_name: gem_name, + deprecation_horizon: deprecation_horizon) + }, + + silence: ->(message, callstack, deprecation_horizon, gem_name) {}, + } + + # Behavior module allows to determine how to display deprecation messages. + # You can create a custom behavior or set any from the +DEFAULT_BEHAVIORS+ + # constant. Available behaviors are: + # + # [+raise+] Raise ActiveSupport::DeprecationException. + # [+stderr+] Log all deprecation warnings to +$stderr+. + # [+log+] Log all deprecation warnings to +Rails.logger+. + # [+notify+] Use +ActiveSupport::Notifications+ to notify +deprecation.rails+. + # [+silence+] Do nothing. + # + # Setting behaviors only affects deprecations that happen after boot time. + # For more information you can read the documentation of the +behavior=+ method. + module Behavior + # Whether to print a backtrace along with the warning. + attr_accessor :debug + + # Returns the current behavior or if one isn't set, defaults to +:stderr+. + def behavior + @behavior ||= [DEFAULT_BEHAVIORS[:stderr]] + end + + # Sets the behavior to the specified value. Can be a single value, array, + # or an object that responds to +call+. + # + # Available behaviors: + # + # [+raise+] Raise ActiveSupport::DeprecationException. + # [+stderr+] Log all deprecation warnings to +$stderr+. + # [+log+] Log all deprecation warnings to +Rails.logger+. + # [+notify+] Use +ActiveSupport::Notifications+ to notify +deprecation.rails+. + # [+silence+] Do nothing. + # + # Setting behaviors only affects deprecations that happen after boot time. + # Deprecation warnings raised by gems are not affected by this setting + # because they happen before Rails boots up. + # + # ActiveSupport::Deprecation.behavior = :stderr + # ActiveSupport::Deprecation.behavior = [:stderr, :log] + # ActiveSupport::Deprecation.behavior = MyCustomHandler + # ActiveSupport::Deprecation.behavior = ->(message, callstack, deprecation_horizon, gem_name) { + # # custom stuff + # } + def behavior=(behavior) + @behavior = Array(behavior).map { |b| DEFAULT_BEHAVIORS[b] || arity_coerce(b) } + end + + private + def arity_coerce(behavior) + unless behavior.respond_to?(:call) + raise ArgumentError, "#{behavior.inspect} is not a valid deprecation behavior." + end + + if behavior.arity == 4 || behavior.arity == -1 + behavior + else + -> message, callstack, _, _ { behavior.call(message, callstack) } + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/deprecation/constant_accessor.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/deprecation/constant_accessor.rb new file mode 100644 index 0000000000..1ed0015812 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/deprecation/constant_accessor.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +module ActiveSupport + class Deprecation + # DeprecatedConstantAccessor transforms a constant into a deprecated one by + # hooking +const_missing+. + # + # It takes the names of an old (deprecated) constant and of a new constant + # (both in string form) and optionally a deprecator. The deprecator defaults + # to +ActiveSupport::Deprecator+ if none is specified. + # + # The deprecated constant now returns the same object as the new one rather + # than a proxy object, so it can be used transparently in +rescue+ blocks + # etc. + # + # PLANETS = %w(mercury venus earth mars jupiter saturn uranus neptune pluto) + # + # # (In a later update, the original implementation of `PLANETS` has been removed.) + # + # PLANETS_POST_2006 = %w(mercury venus earth mars jupiter saturn uranus neptune) + # include ActiveSupport::Deprecation::DeprecatedConstantAccessor + # deprecate_constant 'PLANETS', 'PLANETS_POST_2006' + # + # PLANETS.map { |planet| planet.capitalize } + # # => DEPRECATION WARNING: PLANETS is deprecated! Use PLANETS_POST_2006 instead. + # (Backtrace information…) + # ["Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"] + module DeprecatedConstantAccessor + def self.included(base) + require "active_support/inflector/methods" + + extension = Module.new do + def const_missing(missing_const_name) + if class_variable_defined?(:@@_deprecated_constants) + if (replacement = class_variable_get(:@@_deprecated_constants)[missing_const_name.to_s]) + replacement[:deprecator].warn(replacement[:message] || "#{name}::#{missing_const_name} is deprecated! Use #{replacement[:new]} instead.", caller_locations) + return ActiveSupport::Inflector.constantize(replacement[:new].to_s) + end + end + super + end + + def deprecate_constant(const_name, new_constant, message: nil, deprecator: ActiveSupport::Deprecation.instance) + class_variable_set(:@@_deprecated_constants, {}) unless class_variable_defined?(:@@_deprecated_constants) + class_variable_get(:@@_deprecated_constants)[const_name.to_s] = { new: new_constant, message: message, deprecator: deprecator } + end + end + base.singleton_class.prepend extension + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/deprecation/instance_delegator.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/deprecation/instance_delegator.rb new file mode 100644 index 0000000000..8beda373a2 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/deprecation/instance_delegator.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +require "active_support/core_ext/kernel/singleton_class" +require "active_support/core_ext/module/delegation" + +module ActiveSupport + class Deprecation + module InstanceDelegator # :nodoc: + def self.included(base) + base.extend(ClassMethods) + base.singleton_class.prepend(OverrideDelegators) + base.public_class_method :new + end + + module ClassMethods # :nodoc: + def include(included_module) + included_module.instance_methods.each { |m| method_added(m) } + super + end + + def method_added(method_name) + singleton_class.delegate(method_name, to: :instance) + end + end + + module OverrideDelegators # :nodoc: + def warn(message = nil, callstack = nil) + callstack ||= caller_locations(2) + super + end + + def deprecation_warning(deprecated_method_name, message = nil, caller_backtrace = nil) + caller_backtrace ||= caller_locations(2) + super + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/deprecation/method_wrappers.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/deprecation/method_wrappers.rb new file mode 100644 index 0000000000..5be893d281 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/deprecation/method_wrappers.rb @@ -0,0 +1,77 @@ +# frozen_string_literal: true + +require "active_support/core_ext/module/aliasing" +require "active_support/core_ext/array/extract_options" + +module ActiveSupport + class Deprecation + module MethodWrapper + # Declare that a method has been deprecated. + # + # class Fred + # def aaa; end + # def bbb; end + # def ccc; end + # def ddd; end + # def eee; end + # end + # + # Using the default deprecator: + # ActiveSupport::Deprecation.deprecate_methods(Fred, :aaa, bbb: :zzz, ccc: 'use Bar#ccc instead') + # # => Fred + # + # Fred.new.aaa + # # DEPRECATION WARNING: aaa is deprecated and will be removed from Rails 5.1. (called from irb_binding at (irb):10) + # # => nil + # + # Fred.new.bbb + # # DEPRECATION WARNING: bbb is deprecated and will be removed from Rails 5.1 (use zzz instead). (called from irb_binding at (irb):11) + # # => nil + # + # Fred.new.ccc + # # DEPRECATION WARNING: ccc is deprecated and will be removed from Rails 5.1 (use Bar#ccc instead). (called from irb_binding at (irb):12) + # # => nil + # + # Passing in a custom deprecator: + # custom_deprecator = ActiveSupport::Deprecation.new('next-release', 'MyGem') + # ActiveSupport::Deprecation.deprecate_methods(Fred, ddd: :zzz, deprecator: custom_deprecator) + # # => [:ddd] + # + # Fred.new.ddd + # DEPRECATION WARNING: ddd is deprecated and will be removed from MyGem next-release (use zzz instead). (called from irb_binding at (irb):15) + # # => nil + # + # Using a custom deprecator directly: + # custom_deprecator = ActiveSupport::Deprecation.new('next-release', 'MyGem') + # custom_deprecator.deprecate_methods(Fred, eee: :zzz) + # # => [:eee] + # + # Fred.new.eee + # DEPRECATION WARNING: eee is deprecated and will be removed from MyGem next-release (use zzz instead). (called from irb_binding at (irb):18) + # # => nil + def deprecate_methods(target_module, *method_names) + options = method_names.extract_options! + deprecator = options.delete(:deprecator) || self + method_names += options.keys + + mod = Module.new do + method_names.each do |method_name| + define_method(method_name) do |*args, &block| + deprecator.deprecation_warning(method_name, options[method_name]) + super(*args, &block) + end + + case + when target_module.protected_method_defined?(method_name) + protected method_name + when target_module.private_method_defined?(method_name) + private method_name + end + end + end + + target_module.prepend(mod) + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/deprecation/proxy_wrappers.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/deprecation/proxy_wrappers.rb new file mode 100644 index 0000000000..896c0d2d8e --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/deprecation/proxy_wrappers.rb @@ -0,0 +1,154 @@ +# frozen_string_literal: true + +require "active_support/core_ext/regexp" + +module ActiveSupport + class Deprecation + class DeprecationProxy #:nodoc: + def self.new(*args, &block) + object = args.first + + return object unless object + super + end + + instance_methods.each { |m| undef_method m unless /^__|^object_id$/.match?(m) } + + # Don't give a deprecation warning on inspect since test/unit and error + # logs rely on it for diagnostics. + def inspect + target.inspect + end + + private + def method_missing(called, *args, &block) + warn caller_locations, called, args + target.__send__(called, *args, &block) + end + end + + # DeprecatedObjectProxy transforms an object into a deprecated one. It + # takes an object, a deprecation message and optionally a deprecator. The + # deprecator defaults to +ActiveSupport::Deprecator+ if none is specified. + # + # deprecated_object = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(Object.new, "This object is now deprecated") + # # => # + # + # deprecated_object.to_s + # DEPRECATION WARNING: This object is now deprecated. + # (Backtrace) + # # => "#" + class DeprecatedObjectProxy < DeprecationProxy + def initialize(object, message, deprecator = ActiveSupport::Deprecation.instance) + @object = object + @message = message + @deprecator = deprecator + end + + private + def target + @object + end + + def warn(callstack, called, args) + @deprecator.warn(@message, callstack) + end + end + + # DeprecatedInstanceVariableProxy transforms an instance variable into a + # deprecated one. It takes an instance of a class, a method on that class + # and an instance variable. It optionally takes a deprecator as the last + # argument. The deprecator defaults to +ActiveSupport::Deprecator+ if none + # is specified. + # + # class Example + # def initialize + # @request = ActiveSupport::Deprecation::DeprecatedInstanceVariableProxy.new(self, :request, :@request) + # @_request = :special_request + # end + # + # def request + # @_request + # end + # + # def old_request + # @request + # end + # end + # + # example = Example.new + # # => # + # + # example.old_request.to_s + # # => DEPRECATION WARNING: @request is deprecated! Call request.to_s instead of + # @request.to_s + # (Backtrace information…) + # "special_request" + # + # example.request.to_s + # # => "special_request" + class DeprecatedInstanceVariableProxy < DeprecationProxy + def initialize(instance, method, var = "@#{method}", deprecator = ActiveSupport::Deprecation.instance) + @instance = instance + @method = method + @var = var + @deprecator = deprecator + end + + private + def target + @instance.__send__(@method) + end + + def warn(callstack, called, args) + @deprecator.warn("#{@var} is deprecated! Call #{@method}.#{called} instead of #{@var}.#{called}. Args: #{args.inspect}", callstack) + end + end + + # DeprecatedConstantProxy transforms a constant into a deprecated one. It + # takes the names of an old (deprecated) constant and of a new constant + # (both in string form) and optionally a deprecator. The deprecator defaults + # to +ActiveSupport::Deprecator+ if none is specified. The deprecated constant + # now returns the value of the new one. + # + # PLANETS = %w(mercury venus earth mars jupiter saturn uranus neptune pluto) + # + # # (In a later update, the original implementation of `PLANETS` has been removed.) + # + # PLANETS_POST_2006 = %w(mercury venus earth mars jupiter saturn uranus neptune) + # PLANETS = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('PLANETS', 'PLANETS_POST_2006') + # + # PLANETS.map { |planet| planet.capitalize } + # # => DEPRECATION WARNING: PLANETS is deprecated! Use PLANETS_POST_2006 instead. + # (Backtrace information…) + # ["Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"] + class DeprecatedConstantProxy < DeprecationProxy + def initialize(old_const, new_const, deprecator = ActiveSupport::Deprecation.instance, message: "#{old_const} is deprecated! Use #{new_const} instead.") + require "active_support/inflector/methods" + + @old_const = old_const + @new_const = new_const + @deprecator = deprecator + @message = message + end + + # Returns the class of the new constant. + # + # PLANETS_POST_2006 = %w(mercury venus earth mars jupiter saturn uranus neptune) + # PLANETS = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('PLANETS', 'PLANETS_POST_2006') + # PLANETS.class # => Array + def class + target.class + end + + private + def target + ActiveSupport::Inflector.constantize(@new_const.to_s) + end + + def warn(callstack, called, args) + @deprecator.warn(@message, callstack) + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/deprecation/reporting.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/deprecation/reporting.rb new file mode 100644 index 0000000000..7075b5b869 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/deprecation/reporting.rb @@ -0,0 +1,114 @@ +# frozen_string_literal: true + +require "rbconfig" + +module ActiveSupport + class Deprecation + module Reporting + # Whether to print a message (silent mode) + attr_accessor :silenced + # Name of gem where method is deprecated + attr_accessor :gem_name + + # Outputs a deprecation warning to the output configured by + # ActiveSupport::Deprecation.behavior. + # + # ActiveSupport::Deprecation.warn('something broke!') + # # => "DEPRECATION WARNING: something broke! (called from your_code.rb:1)" + def warn(message = nil, callstack = nil) + return if silenced + + callstack ||= caller_locations(2) + deprecation_message(callstack, message).tap do |m| + behavior.each { |b| b.call(m, callstack, deprecation_horizon, gem_name) } + end + end + + # Silence deprecation warnings within the block. + # + # ActiveSupport::Deprecation.warn('something broke!') + # # => "DEPRECATION WARNING: something broke! (called from your_code.rb:1)" + # + # ActiveSupport::Deprecation.silence do + # ActiveSupport::Deprecation.warn('something broke!') + # end + # # => nil + def silence + old_silenced, @silenced = @silenced, true + yield + ensure + @silenced = old_silenced + end + + def deprecation_warning(deprecated_method_name, message = nil, caller_backtrace = nil) + caller_backtrace ||= caller_locations(2) + deprecated_method_warning(deprecated_method_name, message).tap do |msg| + warn(msg, caller_backtrace) + end + end + + private + # Outputs a deprecation warning message + # + # deprecated_method_warning(:method_name) + # # => "method_name is deprecated and will be removed from Rails #{deprecation_horizon}" + # deprecated_method_warning(:method_name, :another_method) + # # => "method_name is deprecated and will be removed from Rails #{deprecation_horizon} (use another_method instead)" + # deprecated_method_warning(:method_name, "Optional message") + # # => "method_name is deprecated and will be removed from Rails #{deprecation_horizon} (Optional message)" + def deprecated_method_warning(method_name, message = nil) + warning = "#{method_name} is deprecated and will be removed from #{gem_name} #{deprecation_horizon}" + case message + when Symbol then "#{warning} (use #{message} instead)" + when String then "#{warning} (#{message})" + else warning + end + end + + def deprecation_message(callstack, message = nil) + message ||= "You are using deprecated behavior which will be removed from the next major or minor release." + "DEPRECATION WARNING: #{message} #{deprecation_caller_message(callstack)}" + end + + def deprecation_caller_message(callstack) + file, line, method = extract_callstack(callstack) + if file + if line && method + "(called from #{method} at #{file}:#{line})" + else + "(called from #{file}:#{line})" + end + end + end + + def extract_callstack(callstack) + return _extract_callstack(callstack) if callstack.first.is_a? String + + offending_line = callstack.find { |frame| + frame.absolute_path && !ignored_callstack(frame.absolute_path) + } || callstack.first + + [offending_line.path, offending_line.lineno, offending_line.label] + end + + def _extract_callstack(callstack) + warn "Please pass `caller_locations` to the deprecation API" if $VERBOSE + offending_line = callstack.find { |line| !ignored_callstack(line) } || callstack.first + + if offending_line + if md = offending_line.match(/^(.+?):(\d+)(?::in `(.*?)')?/) + md.captures + else + offending_line + end + end + end + + RAILS_GEM_ROOT = File.expand_path("../../../..", __dir__) + "/" + + def ignored_callstack(path) + path.start_with?(RAILS_GEM_ROOT) || path.start_with?(RbConfig::CONFIG["rubylibdir"]) + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/duration.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/duration.rb new file mode 100644 index 0000000000..88897f811e --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/duration.rb @@ -0,0 +1,432 @@ +# frozen_string_literal: true + +require "active_support/core_ext/array/conversions" +require "active_support/core_ext/module/delegation" +require "active_support/core_ext/object/acts_like" +require "active_support/core_ext/string/filters" +require "active_support/deprecation" + +module ActiveSupport + # Provides accurate date and time measurements using Date#advance and + # Time#advance, respectively. It mainly supports the methods on Numeric. + # + # 1.month.ago # equivalent to Time.now.advance(months: -1) + class Duration + class Scalar < Numeric #:nodoc: + attr_reader :value + delegate :to_i, :to_f, :to_s, to: :value + + def initialize(value) + @value = value + end + + def coerce(other) + [Scalar.new(other), self] + end + + def -@ + Scalar.new(-value) + end + + def <=>(other) + if Scalar === other || Duration === other + value <=> other.value + elsif Numeric === other + value <=> other + else + nil + end + end + + def +(other) + if Duration === other + seconds = value + other.parts[:seconds] + new_parts = other.parts.merge(seconds: seconds) + new_value = value + other.value + + Duration.new(new_value, new_parts) + else + calculate(:+, other) + end + end + + def -(other) + if Duration === other + seconds = value - other.parts[:seconds] + new_parts = other.parts.map { |part, other_value| [part, -other_value] }.to_h + new_parts = new_parts.merge(seconds: seconds) + new_value = value - other.value + + Duration.new(new_value, new_parts) + else + calculate(:-, other) + end + end + + def *(other) + if Duration === other + new_parts = other.parts.map { |part, other_value| [part, value * other_value] }.to_h + new_value = value * other.value + + Duration.new(new_value, new_parts) + else + calculate(:*, other) + end + end + + def /(other) + if Duration === other + value / other.value + else + calculate(:/, other) + end + end + + def %(other) + if Duration === other + Duration.build(value % other.value) + else + calculate(:%, other) + end + end + + private + def calculate(op, other) + if Scalar === other + Scalar.new(value.public_send(op, other.value)) + elsif Numeric === other + Scalar.new(value.public_send(op, other)) + else + raise_type_error(other) + end + end + + def raise_type_error(other) + raise TypeError, "no implicit conversion of #{other.class} into #{self.class}" + end + end + + SECONDS_PER_MINUTE = 60 + SECONDS_PER_HOUR = 3600 + SECONDS_PER_DAY = 86400 + SECONDS_PER_WEEK = 604800 + SECONDS_PER_MONTH = 2629746 # 1/12 of a gregorian year + SECONDS_PER_YEAR = 31556952 # length of a gregorian year (365.2425 days) + + PARTS_IN_SECONDS = { + seconds: 1, + minutes: SECONDS_PER_MINUTE, + hours: SECONDS_PER_HOUR, + days: SECONDS_PER_DAY, + weeks: SECONDS_PER_WEEK, + months: SECONDS_PER_MONTH, + years: SECONDS_PER_YEAR + }.freeze + + PARTS = [:years, :months, :weeks, :days, :hours, :minutes, :seconds].freeze + + attr_accessor :value, :parts + + autoload :ISO8601Parser, "active_support/duration/iso8601_parser" + autoload :ISO8601Serializer, "active_support/duration/iso8601_serializer" + + class << self + # Creates a new Duration from string formatted according to ISO 8601 Duration. + # + # See {ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601#Durations] for more information. + # This method allows negative parts to be present in pattern. + # If invalid string is provided, it will raise +ActiveSupport::Duration::ISO8601Parser::ParsingError+. + def parse(iso8601duration) + parts = ISO8601Parser.new(iso8601duration).parse! + new(calculate_total_seconds(parts), parts) + end + + def ===(other) #:nodoc: + other.is_a?(Duration) + rescue ::NoMethodError + false + end + + def seconds(value) #:nodoc: + new(value, [[:seconds, value]]) + end + + def minutes(value) #:nodoc: + new(value * SECONDS_PER_MINUTE, [[:minutes, value]]) + end + + def hours(value) #:nodoc: + new(value * SECONDS_PER_HOUR, [[:hours, value]]) + end + + def days(value) #:nodoc: + new(value * SECONDS_PER_DAY, [[:days, value]]) + end + + def weeks(value) #:nodoc: + new(value * SECONDS_PER_WEEK, [[:weeks, value]]) + end + + def months(value) #:nodoc: + new(value * SECONDS_PER_MONTH, [[:months, value]]) + end + + def years(value) #:nodoc: + new(value * SECONDS_PER_YEAR, [[:years, value]]) + end + + # Creates a new Duration from a seconds value that is converted + # to the individual parts: + # + # ActiveSupport::Duration.build(31556952).parts # => {:years=>1} + # ActiveSupport::Duration.build(2716146).parts # => {:months=>1, :days=>1} + # + def build(value) + parts = {} + remainder = value.to_f + + PARTS.each do |part| + unless part == :seconds + part_in_seconds = PARTS_IN_SECONDS[part] + parts[part] = remainder.div(part_in_seconds) + remainder = (remainder % part_in_seconds).round(9) + end + end + + parts[:seconds] = remainder + + new(value, parts) + end + + private + + def calculate_total_seconds(parts) + parts.inject(0) do |total, (part, value)| + total + value * PARTS_IN_SECONDS[part] + end + end + end + + def initialize(value, parts) #:nodoc: + @value, @parts = value, parts.to_h + @parts.default = 0 + @parts.reject! { |k, v| v.zero? } + end + + def coerce(other) #:nodoc: + if Scalar === other + [other, self] + else + [Scalar.new(other), self] + end + end + + # Compares one Duration with another or a Numeric to this Duration. + # Numeric values are treated as seconds. + def <=>(other) + if Duration === other + value <=> other.value + elsif Numeric === other + value <=> other + end + end + + # Adds another Duration or a Numeric to this Duration. Numeric values + # are treated as seconds. + def +(other) + if Duration === other + parts = @parts.dup + other.parts.each do |(key, value)| + parts[key] += value + end + Duration.new(value + other.value, parts) + else + seconds = @parts[:seconds] + other + Duration.new(value + other, @parts.merge(seconds: seconds)) + end + end + + # Subtracts another Duration or a Numeric from this Duration. Numeric + # values are treated as seconds. + def -(other) + self + (-other) + end + + # Multiplies this Duration by a Numeric and returns a new Duration. + def *(other) + if Scalar === other || Duration === other + Duration.new(value * other.value, parts.map { |type, number| [type, number * other.value] }) + elsif Numeric === other + Duration.new(value * other, parts.map { |type, number| [type, number * other] }) + else + raise_type_error(other) + end + end + + # Divides this Duration by a Numeric and returns a new Duration. + def /(other) + if Scalar === other + Duration.new(value / other.value, parts.map { |type, number| [type, number / other.value] }) + elsif Duration === other + value / other.value + elsif Numeric === other + Duration.new(value / other, parts.map { |type, number| [type, number / other] }) + else + raise_type_error(other) + end + end + + # Returns the modulo of this Duration by another Duration or Numeric. + # Numeric values are treated as seconds. + def %(other) + if Duration === other || Scalar === other + Duration.build(value % other.value) + elsif Numeric === other + Duration.build(value % other) + else + raise_type_error(other) + end + end + + def -@ #:nodoc: + Duration.new(-value, parts.map { |type, number| [type, -number] }) + end + + def is_a?(klass) #:nodoc: + Duration == klass || value.is_a?(klass) + end + alias :kind_of? :is_a? + + def instance_of?(klass) # :nodoc: + Duration == klass || value.instance_of?(klass) + end + + # Returns +true+ if +other+ is also a Duration instance with the + # same +value+, or if other == value. + def ==(other) + if Duration === other + other.value == value + else + other == value + end + end + + # Returns the amount of seconds a duration covers as a string. + # For more information check to_i method. + # + # 1.day.to_s # => "86400" + def to_s + @value.to_s + end + + # Returns the number of seconds that this Duration represents. + # + # 1.minute.to_i # => 60 + # 1.hour.to_i # => 3600 + # 1.day.to_i # => 86400 + # + # Note that this conversion makes some assumptions about the + # duration of some periods, e.g. months are always 1/12 of year + # and years are 365.2425 days: + # + # # equivalent to (1.year / 12).to_i + # 1.month.to_i # => 2629746 + # + # # equivalent to 365.2425.days.to_i + # 1.year.to_i # => 31556952 + # + # In such cases, Ruby's core + # Date[http://ruby-doc.org/stdlib/libdoc/date/rdoc/Date.html] and + # Time[http://ruby-doc.org/stdlib/libdoc/time/rdoc/Time.html] should be used for precision + # date and time arithmetic. + def to_i + @value.to_i + end + + # Returns +true+ if +other+ is also a Duration instance, which has the + # same parts as this one. + def eql?(other) + Duration === other && other.value.eql?(value) + end + + def hash + @value.hash + end + + # Calculates a new Time or Date that is as far in the future + # as this Duration represents. + def since(time = ::Time.current) + sum(1, time) + end + alias :from_now :since + alias :after :since + + # Calculates a new Time or Date that is as far in the past + # as this Duration represents. + def ago(time = ::Time.current) + sum(-1, time) + end + alias :until :ago + alias :before :ago + + def inspect #:nodoc: + return "0 seconds" if parts.empty? + + parts. + reduce(::Hash.new(0)) { |h, (l, r)| h[l] += r; h }. + sort_by { |unit, _ | PARTS.index(unit) }. + map { |unit, val| "#{val} #{val == 1 ? unit.to_s.chop : unit.to_s}" }. + to_sentence(locale: ::I18n.default_locale) + end + + def as_json(options = nil) #:nodoc: + to_i + end + + def init_with(coder) #:nodoc: + initialize(coder["value"], coder["parts"]) + end + + def encode_with(coder) #:nodoc: + coder.map = { "value" => @value, "parts" => @parts } + end + + # Build ISO 8601 Duration string for this duration. + # The +precision+ parameter can be used to limit seconds' precision of duration. + def iso8601(precision: nil) + ISO8601Serializer.new(self, precision: precision).serialize + end + + private + + def sum(sign, time = ::Time.current) + parts.inject(time) do |t, (type, number)| + if t.acts_like?(:time) || t.acts_like?(:date) + if type == :seconds + t.since(sign * number) + elsif type == :minutes + t.since(sign * number * 60) + elsif type == :hours + t.since(sign * number * 3600) + else + t.advance(type => sign * number) + end + else + raise ::ArgumentError, "expected a time or date, got #{time.inspect}" + end + end + end + + def respond_to_missing?(method, _) + value.respond_to?(method) + end + + def method_missing(method, *args, &block) + value.public_send(method, *args, &block) + end + + def raise_type_error(other) + raise TypeError, "no implicit conversion of #{other.class} into #{self.class}" + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/i18n.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/i18n.rb new file mode 100644 index 0000000000..d60b3eff30 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/i18n.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require "active_support/core_ext/hash/deep_merge" +require "active_support/core_ext/hash/except" +require "active_support/core_ext/hash/slice" +begin + require "i18n" +rescue LoadError => e + $stderr.puts "The i18n gem is not available. Please add it to your Gemfile and run bundle install" + raise e +end +require "active_support/lazy_load_hooks" + +ActiveSupport.run_load_hooks(:i18n) +I18n.load_path << File.expand_path("locale/en.yml", __dir__) diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/inflections.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/inflections.rb new file mode 100644 index 0000000000..baf1cb3038 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/inflections.rb @@ -0,0 +1,72 @@ +# frozen_string_literal: true + +require "active_support/inflector/inflections" + +#-- +# Defines the standard inflection rules. These are the starting point for +# new projects and are not considered complete. The current set of inflection +# rules is frozen. This means, we do not change them to become more complete. +# This is a safety measure to keep existing applications from breaking. +#++ +module ActiveSupport + Inflector.inflections(:en) do |inflect| + inflect.plural(/$/, "s") + inflect.plural(/s$/i, "s") + inflect.plural(/^(ax|test)is$/i, '\1es') + inflect.plural(/(octop|vir)us$/i, '\1i') + inflect.plural(/(octop|vir)i$/i, '\1i') + inflect.plural(/(alias|status)$/i, '\1es') + inflect.plural(/(bu)s$/i, '\1ses') + inflect.plural(/(buffal|tomat)o$/i, '\1oes') + inflect.plural(/([ti])um$/i, '\1a') + inflect.plural(/([ti])a$/i, '\1a') + inflect.plural(/sis$/i, "ses") + inflect.plural(/(?:([^f])fe|([lr])f)$/i, '\1\2ves') + inflect.plural(/(hive)$/i, '\1s') + inflect.plural(/([^aeiouy]|qu)y$/i, '\1ies') + inflect.plural(/(x|ch|ss|sh)$/i, '\1es') + inflect.plural(/(matr|vert|ind)(?:ix|ex)$/i, '\1ices') + inflect.plural(/^(m|l)ouse$/i, '\1ice') + inflect.plural(/^(m|l)ice$/i, '\1ice') + inflect.plural(/^(ox)$/i, '\1en') + inflect.plural(/^(oxen)$/i, '\1') + inflect.plural(/(quiz)$/i, '\1zes') + + inflect.singular(/s$/i, "") + inflect.singular(/(ss)$/i, '\1') + inflect.singular(/(n)ews$/i, '\1ews') + inflect.singular(/([ti])a$/i, '\1um') + inflect.singular(/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)$/i, '\1sis') + inflect.singular(/(^analy)(sis|ses)$/i, '\1sis') + inflect.singular(/([^f])ves$/i, '\1fe') + inflect.singular(/(hive)s$/i, '\1') + inflect.singular(/(tive)s$/i, '\1') + inflect.singular(/([lr])ves$/i, '\1f') + inflect.singular(/([^aeiouy]|qu)ies$/i, '\1y') + inflect.singular(/(s)eries$/i, '\1eries') + inflect.singular(/(m)ovies$/i, '\1ovie') + inflect.singular(/(x|ch|ss|sh)es$/i, '\1') + inflect.singular(/^(m|l)ice$/i, '\1ouse') + inflect.singular(/(bus)(es)?$/i, '\1') + inflect.singular(/(o)es$/i, '\1') + inflect.singular(/(shoe)s$/i, '\1') + inflect.singular(/(cris|test)(is|es)$/i, '\1is') + inflect.singular(/^(a)x[ie]s$/i, '\1xis') + inflect.singular(/(octop|vir)(us|i)$/i, '\1us') + inflect.singular(/(alias|status)(es)?$/i, '\1') + inflect.singular(/^(ox)en/i, '\1') + inflect.singular(/(vert|ind)ices$/i, '\1ex') + inflect.singular(/(matr)ices$/i, '\1ix') + inflect.singular(/(quiz)zes$/i, '\1') + inflect.singular(/(database)s$/i, '\1') + + inflect.irregular("person", "people") + inflect.irregular("man", "men") + inflect.irregular("child", "children") + inflect.irregular("sex", "sexes") + inflect.irregular("move", "moves") + inflect.irregular("zombie", "zombies") + + inflect.uncountable(%w(equipment information rice money species series fish sheep jeans police)) + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/inflector/inflections.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/inflector/inflections.rb new file mode 100644 index 0000000000..7e5dff1d6d --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/inflector/inflections.rb @@ -0,0 +1,260 @@ +# frozen_string_literal: true + +require "concurrent/map" +require "active_support/core_ext/array/prepend_and_append" +require "active_support/core_ext/regexp" +require "active_support/i18n" +require "active_support/deprecation" + +module ActiveSupport + module Inflector + extend self + + # A singleton instance of this class is yielded by Inflector.inflections, + # which can then be used to specify additional inflection rules. If passed + # an optional locale, rules for other languages can be specified. The + # default locale is :en. Only rules for English are provided. + # + # ActiveSupport::Inflector.inflections(:en) do |inflect| + # inflect.plural /^(ox)$/i, '\1\2en' + # inflect.singular /^(ox)en/i, '\1' + # + # inflect.irregular 'octopus', 'octopi' + # + # inflect.uncountable 'equipment' + # end + # + # New rules are added at the top. So in the example above, the irregular + # rule for octopus will now be the first of the pluralization and + # singularization rules that is runs. This guarantees that your rules run + # before any of the rules that may already have been loaded. + class Inflections + @__instance__ = Concurrent::Map.new + + class Uncountables < Array + def initialize + @regex_array = [] + super + end + + def delete(entry) + super entry + @regex_array.delete(to_regex(entry)) + end + + def <<(*word) + add(word) + end + + def add(words) + words = words.flatten.map(&:downcase) + concat(words) + @regex_array += words.map { |word| to_regex(word) } + self + end + + def uncountable?(str) + @regex_array.any? { |regex| regex.match? str } + end + + private + def to_regex(string) + /\b#{::Regexp.escape(string)}\Z/i + end + end + + def self.instance(locale = :en) + @__instance__[locale] ||= new + end + + attr_reader :plurals, :singulars, :uncountables, :humans, :acronyms, :acronym_regex + deprecate :acronym_regex + + attr_reader :acronyms_camelize_regex, :acronyms_underscore_regex # :nodoc: + + def initialize + @plurals, @singulars, @uncountables, @humans, @acronyms = [], [], Uncountables.new, [], {} + define_acronym_regex_patterns + end + + # Private, for the test suite. + def initialize_dup(orig) # :nodoc: + %w(plurals singulars uncountables humans acronyms).each do |scope| + instance_variable_set("@#{scope}", orig.send(scope).dup) + end + define_acronym_regex_patterns + end + + # Specifies a new acronym. An acronym must be specified as it will appear + # in a camelized string. An underscore string that contains the acronym + # will retain the acronym when passed to +camelize+, +humanize+, or + # +titleize+. A camelized string that contains the acronym will maintain + # the acronym when titleized or humanized, and will convert the acronym + # into a non-delimited single lowercase word when passed to +underscore+. + # + # acronym 'HTML' + # titleize 'html' # => 'HTML' + # camelize 'html' # => 'HTML' + # underscore 'MyHTML' # => 'my_html' + # + # The acronym, however, must occur as a delimited unit and not be part of + # another word for conversions to recognize it: + # + # acronym 'HTTP' + # camelize 'my_http_delimited' # => 'MyHTTPDelimited' + # camelize 'https' # => 'Https', not 'HTTPs' + # underscore 'HTTPS' # => 'http_s', not 'https' + # + # acronym 'HTTPS' + # camelize 'https' # => 'HTTPS' + # underscore 'HTTPS' # => 'https' + # + # Note: Acronyms that are passed to +pluralize+ will no longer be + # recognized, since the acronym will not occur as a delimited unit in the + # pluralized result. To work around this, you must specify the pluralized + # form as an acronym as well: + # + # acronym 'API' + # camelize(pluralize('api')) # => 'Apis' + # + # acronym 'APIs' + # camelize(pluralize('api')) # => 'APIs' + # + # +acronym+ may be used to specify any word that contains an acronym or + # otherwise needs to maintain a non-standard capitalization. The only + # restriction is that the word must begin with a capital letter. + # + # acronym 'RESTful' + # underscore 'RESTful' # => 'restful' + # underscore 'RESTfulController' # => 'restful_controller' + # titleize 'RESTfulController' # => 'RESTful Controller' + # camelize 'restful' # => 'RESTful' + # camelize 'restful_controller' # => 'RESTfulController' + # + # acronym 'McDonald' + # underscore 'McDonald' # => 'mcdonald' + # camelize 'mcdonald' # => 'McDonald' + def acronym(word) + @acronyms[word.downcase] = word + define_acronym_regex_patterns + end + + # Specifies a new pluralization rule and its replacement. The rule can + # either be a string or a regular expression. The replacement should + # always be a string that may include references to the matched data from + # the rule. + def plural(rule, replacement) + @uncountables.delete(rule) if rule.is_a?(String) + @uncountables.delete(replacement) + @plurals.prepend([rule, replacement]) + end + + # Specifies a new singularization rule and its replacement. The rule can + # either be a string or a regular expression. The replacement should + # always be a string that may include references to the matched data from + # the rule. + def singular(rule, replacement) + @uncountables.delete(rule) if rule.is_a?(String) + @uncountables.delete(replacement) + @singulars.prepend([rule, replacement]) + end + + # Specifies a new irregular that applies to both pluralization and + # singularization at the same time. This can only be used for strings, not + # regular expressions. You simply pass the irregular in singular and + # plural form. + # + # irregular 'octopus', 'octopi' + # irregular 'person', 'people' + def irregular(singular, plural) + @uncountables.delete(singular) + @uncountables.delete(plural) + + s0 = singular[0] + srest = singular[1..-1] + + p0 = plural[0] + prest = plural[1..-1] + + if s0.upcase == p0.upcase + plural(/(#{s0})#{srest}$/i, '\1' + prest) + plural(/(#{p0})#{prest}$/i, '\1' + prest) + + singular(/(#{s0})#{srest}$/i, '\1' + srest) + singular(/(#{p0})#{prest}$/i, '\1' + srest) + else + plural(/#{s0.upcase}(?i)#{srest}$/, p0.upcase + prest) + plural(/#{s0.downcase}(?i)#{srest}$/, p0.downcase + prest) + plural(/#{p0.upcase}(?i)#{prest}$/, p0.upcase + prest) + plural(/#{p0.downcase}(?i)#{prest}$/, p0.downcase + prest) + + singular(/#{s0.upcase}(?i)#{srest}$/, s0.upcase + srest) + singular(/#{s0.downcase}(?i)#{srest}$/, s0.downcase + srest) + singular(/#{p0.upcase}(?i)#{prest}$/, s0.upcase + srest) + singular(/#{p0.downcase}(?i)#{prest}$/, s0.downcase + srest) + end + end + + # Specifies words that are uncountable and should not be inflected. + # + # uncountable 'money' + # uncountable 'money', 'information' + # uncountable %w( money information rice ) + def uncountable(*words) + @uncountables.add(words) + end + + # Specifies a humanized form of a string by a regular expression rule or + # by a string mapping. When using a regular expression based replacement, + # the normal humanize formatting is called after the replacement. When a + # string is used, the human form should be specified as desired (example: + # 'The name', not 'the_name'). + # + # human /_cnt$/i, '\1_count' + # human 'legacy_col_person_name', 'Name' + def human(rule, replacement) + @humans.prepend([rule, replacement]) + end + + # Clears the loaded inflections within a given scope (default is + # :all). Give the scope as a symbol of the inflection type, the + # options are: :plurals, :singulars, :uncountables, + # :humans. + # + # clear :all + # clear :plurals + def clear(scope = :all) + case scope + when :all + @plurals, @singulars, @uncountables, @humans = [], [], Uncountables.new, [] + else + instance_variable_set "@#{scope}", [] + end + end + + private + + def define_acronym_regex_patterns + @acronym_regex = @acronyms.empty? ? /(?=a)b/ : /#{@acronyms.values.join("|")}/ + @acronyms_camelize_regex = /^(?:#{@acronym_regex}(?=\b|[A-Z_])|\w)/ + @acronyms_underscore_regex = /(?:(?<=([A-Za-z\d]))|\b)(#{@acronym_regex})(?=\b|[^a-z])/ + end + end + + # Yields a singleton instance of Inflector::Inflections so you can specify + # additional inflector rules. If passed an optional locale, rules for other + # languages can be specified. If not specified, defaults to :en. + # Only rules for English are provided. + # + # ActiveSupport::Inflector.inflections(:en) do |inflect| + # inflect.uncountable 'rails' + # end + def inflections(locale = :en) + if block_given? + yield Inflections.instance(locale) + else + Inflections.instance(locale) + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/inflector/methods.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/inflector/methods.rb new file mode 100644 index 0000000000..7e782e2a93 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/inflector/methods.rb @@ -0,0 +1,408 @@ +# frozen_string_literal: true + +require "active_support/inflections" +require "active_support/core_ext/regexp" + +module ActiveSupport + # The Inflector transforms words from singular to plural, class names to table + # names, modularized class names to ones without, and class names to foreign + # keys. The default inflections for pluralization, singularization, and + # uncountable words are kept in inflections.rb. + # + # The Rails core team has stated patches for the inflections library will not + # be accepted in order to avoid breaking legacy applications which may be + # relying on errant inflections. If you discover an incorrect inflection and + # require it for your application or wish to define rules for languages other + # than English, please correct or add them yourself (explained below). + module Inflector + extend self + + # Returns the plural form of the word in the string. + # + # If passed an optional +locale+ parameter, the word will be + # pluralized using rules defined for that language. By default, + # this parameter is set to :en. + # + # pluralize('post') # => "posts" + # pluralize('octopus') # => "octopi" + # pluralize('sheep') # => "sheep" + # pluralize('words') # => "words" + # pluralize('CamelOctopus') # => "CamelOctopi" + # pluralize('ley', :es) # => "leyes" + def pluralize(word, locale = :en) + apply_inflections(word, inflections(locale).plurals, locale) + end + + # The reverse of #pluralize, returns the singular form of a word in a + # string. + # + # If passed an optional +locale+ parameter, the word will be + # singularized using rules defined for that language. By default, + # this parameter is set to :en. + # + # singularize('posts') # => "post" + # singularize('octopi') # => "octopus" + # singularize('sheep') # => "sheep" + # singularize('word') # => "word" + # singularize('CamelOctopi') # => "CamelOctopus" + # singularize('leyes', :es) # => "ley" + def singularize(word, locale = :en) + apply_inflections(word, inflections(locale).singulars, locale) + end + + # Converts strings to UpperCamelCase. + # If the +uppercase_first_letter+ parameter is set to false, then produces + # lowerCamelCase. + # + # Also converts '/' to '::' which is useful for converting + # paths to namespaces. + # + # camelize('active_model') # => "ActiveModel" + # camelize('active_model', false) # => "activeModel" + # camelize('active_model/errors') # => "ActiveModel::Errors" + # camelize('active_model/errors', false) # => "activeModel::Errors" + # + # As a rule of thumb you can think of +camelize+ as the inverse of + # #underscore, though there are cases where that does not hold: + # + # camelize(underscore('SSLError')) # => "SslError" + def camelize(term, uppercase_first_letter = true) + string = term.to_s + if uppercase_first_letter + string = string.sub(/^[a-z\d]*/) { |match| inflections.acronyms[match] || match.capitalize } + else + string = string.sub(inflections.acronyms_camelize_regex) { |match| match.downcase } + end + string.gsub!(/(?:_|(\/))([a-z\d]*)/i) { "#{$1}#{inflections.acronyms[$2] || $2.capitalize}" } + string.gsub!("/".freeze, "::".freeze) + string + end + + # Makes an underscored, lowercase form from the expression in the string. + # + # Changes '::' to '/' to convert namespaces to paths. + # + # underscore('ActiveModel') # => "active_model" + # underscore('ActiveModel::Errors') # => "active_model/errors" + # + # As a rule of thumb you can think of +underscore+ as the inverse of + # #camelize, though there are cases where that does not hold: + # + # camelize(underscore('SSLError')) # => "SslError" + def underscore(camel_cased_word) + return camel_cased_word unless /[A-Z-]|::/.match?(camel_cased_word) + word = camel_cased_word.to_s.gsub("::".freeze, "/".freeze) + word.gsub!(inflections.acronyms_underscore_regex) { "#{$1 && '_'.freeze }#{$2.downcase}" } + word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2'.freeze) + word.gsub!(/([a-z\d])([A-Z])/, '\1_\2'.freeze) + word.tr!("-".freeze, "_".freeze) + word.downcase! + word + end + + # Tweaks an attribute name for display to end users. + # + # Specifically, performs these transformations: + # + # * Applies human inflection rules to the argument. + # * Deletes leading underscores, if any. + # * Removes a "_id" suffix if present. + # * Replaces underscores with spaces, if any. + # * Downcases all words except acronyms. + # * Capitalizes the first word. + # The capitalization of the first word can be turned off by setting the + # +:capitalize+ option to false (default is true). + # + # The trailing '_id' can be kept and capitalized by setting the + # optional parameter +keep_id_suffix+ to true (default is false). + # + # humanize('employee_salary') # => "Employee salary" + # humanize('author_id') # => "Author" + # humanize('author_id', capitalize: false) # => "author" + # humanize('_id') # => "Id" + # humanize('author_id', keep_id_suffix: true) # => "Author Id" + # + # If "SSL" was defined to be an acronym: + # + # humanize('ssl_error') # => "SSL error" + # + def humanize(lower_case_and_underscored_word, capitalize: true, keep_id_suffix: false) + result = lower_case_and_underscored_word.to_s.dup + + inflections.humans.each { |(rule, replacement)| break if result.sub!(rule, replacement) } + + result.sub!(/\A_+/, "".freeze) + unless keep_id_suffix + result.sub!(/_id\z/, "".freeze) + end + result.tr!("_".freeze, " ".freeze) + + result.gsub!(/([a-z\d]*)/i) do |match| + "#{inflections.acronyms[match.downcase] || match.downcase}" + end + + if capitalize + result.sub!(/\A\w/) { |match| match.upcase } + end + + result + end + + # Converts just the first character to uppercase. + # + # upcase_first('what a Lovely Day') # => "What a Lovely Day" + # upcase_first('w') # => "W" + # upcase_first('') # => "" + def upcase_first(string) + string.length > 0 ? string[0].upcase.concat(string[1..-1]) : "" + end + + # Capitalizes all the words and replaces some characters in the string to + # create a nicer looking title. +titleize+ is meant for creating pretty + # output. It is not used in the Rails internals. + # + # The trailing '_id','Id'.. can be kept and capitalized by setting the + # optional parameter +keep_id_suffix+ to true. + # By default, this parameter is false. + # + # +titleize+ is also aliased as +titlecase+. + # + # titleize('man from the boondocks') # => "Man From The Boondocks" + # titleize('x-men: the last stand') # => "X Men: The Last Stand" + # titleize('TheManWithoutAPast') # => "The Man Without A Past" + # titleize('raiders_of_the_lost_ark') # => "Raiders Of The Lost Ark" + # titleize('string_ending_with_id', keep_id_suffix: true) # => "String Ending With Id" + def titleize(word, keep_id_suffix: false) + humanize(underscore(word), keep_id_suffix: keep_id_suffix).gsub(/\b(? "raw_scaled_scorers" + # tableize('ham_and_egg') # => "ham_and_eggs" + # tableize('fancyCategory') # => "fancy_categories" + def tableize(class_name) + pluralize(underscore(class_name)) + end + + # Creates a class name from a plural table name like Rails does for table + # names to models. Note that this returns a string and not a Class (To + # convert to an actual class follow +classify+ with #constantize). + # + # classify('ham_and_eggs') # => "HamAndEgg" + # classify('posts') # => "Post" + # + # Singular names are not handled correctly: + # + # classify('calculus') # => "Calculus" + def classify(table_name) + # strip out any leading schema name + camelize(singularize(table_name.to_s.sub(/.*\./, "".freeze))) + end + + # Replaces underscores with dashes in the string. + # + # dasherize('puni_puni') # => "puni-puni" + def dasherize(underscored_word) + underscored_word.tr("_".freeze, "-".freeze) + end + + # Removes the module part from the expression in the string. + # + # demodulize('ActiveSupport::Inflector::Inflections') # => "Inflections" + # demodulize('Inflections') # => "Inflections" + # demodulize('::Inflections') # => "Inflections" + # demodulize('') # => "" + # + # See also #deconstantize. + def demodulize(path) + path = path.to_s + if i = path.rindex("::") + path[(i + 2)..-1] + else + path + end + end + + # Removes the rightmost segment from the constant expression in the string. + # + # deconstantize('Net::HTTP') # => "Net" + # deconstantize('::Net::HTTP') # => "::Net" + # deconstantize('String') # => "" + # deconstantize('::String') # => "" + # deconstantize('') # => "" + # + # See also #demodulize. + def deconstantize(path) + path.to_s[0, path.rindex("::") || 0] # implementation based on the one in facets' Module#spacename + end + + # Creates a foreign key name from a class name. + # +separate_class_name_and_id_with_underscore+ sets whether + # the method should put '_' between the name and 'id'. + # + # foreign_key('Message') # => "message_id" + # foreign_key('Message', false) # => "messageid" + # foreign_key('Admin::Post') # => "post_id" + def foreign_key(class_name, separate_class_name_and_id_with_underscore = true) + underscore(demodulize(class_name)) + (separate_class_name_and_id_with_underscore ? "_id" : "id") + end + + # Tries to find a constant with the name specified in the argument string. + # + # constantize('Module') # => Module + # constantize('Foo::Bar') # => Foo::Bar + # + # The name is assumed to be the one of a top-level constant, no matter + # whether it starts with "::" or not. No lexical context is taken into + # account: + # + # C = 'outside' + # module M + # C = 'inside' + # C # => 'inside' + # constantize('C') # => 'outside', same as ::C + # end + # + # NameError is raised when the name is not in CamelCase or the constant is + # unknown. + def constantize(camel_cased_word) + names = camel_cased_word.split("::".freeze) + + # Trigger a built-in NameError exception including the ill-formed constant in the message. + Object.const_get(camel_cased_word) if names.empty? + + # Remove the first blank element in case of '::ClassName' notation. + names.shift if names.size > 1 && names.first.empty? + + names.inject(Object) do |constant, name| + if constant == Object + constant.const_get(name) + else + candidate = constant.const_get(name) + next candidate if constant.const_defined?(name, false) + next candidate unless Object.const_defined?(name) + + # Go down the ancestors to check if it is owned directly. The check + # stops when we reach Object or the end of ancestors tree. + constant = constant.ancestors.inject(constant) do |const, ancestor| + break const if ancestor == Object + break ancestor if ancestor.const_defined?(name, false) + const + end + + # owner is in Object, so raise + constant.const_get(name, false) + end + end + end + + # Tries to find a constant with the name specified in the argument string. + # + # safe_constantize('Module') # => Module + # safe_constantize('Foo::Bar') # => Foo::Bar + # + # The name is assumed to be the one of a top-level constant, no matter + # whether it starts with "::" or not. No lexical context is taken into + # account: + # + # C = 'outside' + # module M + # C = 'inside' + # C # => 'inside' + # safe_constantize('C') # => 'outside', same as ::C + # end + # + # +nil+ is returned when the name is not in CamelCase or the constant (or + # part of it) is unknown. + # + # safe_constantize('blargle') # => nil + # safe_constantize('UnknownModule') # => nil + # safe_constantize('UnknownModule::Foo::Bar') # => nil + def safe_constantize(camel_cased_word) + constantize(camel_cased_word) + rescue NameError => e + raise if e.name && !(camel_cased_word.to_s.split("::").include?(e.name.to_s) || + e.name.to_s == camel_cased_word.to_s) + rescue ArgumentError => e + raise unless /not missing constant #{const_regexp(camel_cased_word)}!$/.match?(e.message) + end + + # Returns the suffix that should be added to a number to denote the position + # in an ordered sequence such as 1st, 2nd, 3rd, 4th. + # + # ordinal(1) # => "st" + # ordinal(2) # => "nd" + # ordinal(1002) # => "nd" + # ordinal(1003) # => "rd" + # ordinal(-11) # => "th" + # ordinal(-1021) # => "st" + def ordinal(number) + abs_number = number.to_i.abs + + if (11..13).include?(abs_number % 100) + "th" + else + case abs_number % 10 + when 1; "st" + when 2; "nd" + when 3; "rd" + else "th" + end + end + end + + # Turns a number into an ordinal string used to denote the position in an + # ordered sequence such as 1st, 2nd, 3rd, 4th. + # + # ordinalize(1) # => "1st" + # ordinalize(2) # => "2nd" + # ordinalize(1002) # => "1002nd" + # ordinalize(1003) # => "1003rd" + # ordinalize(-11) # => "-11th" + # ordinalize(-1021) # => "-1021st" + def ordinalize(number) + "#{number}#{ordinal(number)}" + end + + private + + # Mounts a regular expression, returned as a string to ease interpolation, + # that will match part by part the given constant. + # + # const_regexp("Foo::Bar::Baz") # => "Foo(::Bar(::Baz)?)?" + # const_regexp("::") # => "::" + def const_regexp(camel_cased_word) + parts = camel_cased_word.split("::".freeze) + + return Regexp.escape(camel_cased_word) if parts.blank? + + last = parts.pop + + parts.reverse.inject(last) do |acc, part| + part.empty? ? acc : "#{part}(::#{acc})?" + end + end + + # Applies inflection rules for +singularize+ and +pluralize+. + # + # If passed an optional +locale+ parameter, the uncountables will be + # found for that locale. + # + # apply_inflections('post', inflections.plurals, :en) # => "posts" + # apply_inflections('posts', inflections.singulars, :en) # => "post" + def apply_inflections(word, rules, locale = :en) + result = word.to_s.dup + + if word.empty? || inflections(locale).uncountables.uncountable?(result) + result + else + rules.each { |(rule, replacement)| break if result.sub!(rule, replacement) } + result + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/inflector/transliterate.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/inflector/transliterate.rb new file mode 100644 index 0000000000..6f2ca4999c --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/inflector/transliterate.rb @@ -0,0 +1,118 @@ +# frozen_string_literal: true + +require "active_support/core_ext/string/multibyte" +require "active_support/i18n" + +module ActiveSupport + module Inflector + # Replaces non-ASCII characters with an ASCII approximation, or if none + # exists, a replacement character which defaults to "?". + # + # transliterate('Ærøskøbing') + # # => "AEroskobing" + # + # Default approximations are provided for Western/Latin characters, + # e.g, "ø", "ñ", "é", "ß", etc. + # + # This method is I18n aware, so you can set up custom approximations for a + # locale. This can be useful, for example, to transliterate German's "ü" + # and "ö" to "ue" and "oe", or to add support for transliterating Russian + # to ASCII. + # + # In order to make your custom transliterations available, you must set + # them as the i18n.transliterate.rule i18n key: + # + # # Store the transliterations in locales/de.yml + # i18n: + # transliterate: + # rule: + # ü: "ue" + # ö: "oe" + # + # # Or set them using Ruby + # I18n.backend.store_translations(:de, i18n: { + # transliterate: { + # rule: { + # 'ü' => 'ue', + # 'ö' => 'oe' + # } + # } + # }) + # + # The value for i18n.transliterate.rule can be a simple Hash that + # maps characters to ASCII approximations as shown above, or, for more + # complex requirements, a Proc: + # + # I18n.backend.store_translations(:de, i18n: { + # transliterate: { + # rule: ->(string) { MyTransliterator.transliterate(string) } + # } + # }) + # + # Now you can have different transliterations for each locale: + # + # I18n.locale = :en + # transliterate('Jürgen') + # # => "Jurgen" + # + # I18n.locale = :de + # transliterate('Jürgen') + # # => "Juergen" + def transliterate(string, replacement = "?".freeze) + raise ArgumentError, "Can only transliterate strings. Received #{string.class.name}" unless string.is_a?(String) + + I18n.transliterate( + ActiveSupport::Multibyte::Unicode.normalize( + ActiveSupport::Multibyte::Unicode.tidy_bytes(string), :c), + replacement: replacement) + end + + # Replaces special characters in a string so that it may be used as part of + # a 'pretty' URL. + # + # parameterize("Donald E. Knuth") # => "donald-e-knuth" + # parameterize("^très|Jolie-- ") # => "tres-jolie" + # + # To use a custom separator, override the +separator+ argument. + # + # parameterize("Donald E. Knuth", separator: '_') # => "donald_e_knuth" + # parameterize("^très|Jolie__ ", separator: '_') # => "tres_jolie" + # + # To preserve the case of the characters in a string, use the +preserve_case+ argument. + # + # parameterize("Donald E. Knuth", preserve_case: true) # => "Donald-E-Knuth" + # parameterize("^très|Jolie-- ", preserve_case: true) # => "tres-Jolie" + # + # It preserves dashes and underscores unless they are used as separators: + # + # parameterize("^très|Jolie__ ") # => "tres-jolie__" + # parameterize("^très|Jolie-- ", separator: "_") # => "tres_jolie--" + # parameterize("^très_Jolie-- ", separator: ".") # => "tres_jolie--" + # + def parameterize(string, separator: "-", preserve_case: false) + # Replace accented chars with their ASCII equivalents. + parameterized_string = transliterate(string) + + # Turn unwanted chars into the separator. + parameterized_string.gsub!(/[^a-z0-9\-_]+/i, separator) + + unless separator.nil? || separator.empty? + if separator == "-".freeze + re_duplicate_separator = /-{2,}/ + re_leading_trailing_separator = /^-|-$/i + else + re_sep = Regexp.escape(separator) + re_duplicate_separator = /#{re_sep}{2,}/ + re_leading_trailing_separator = /^#{re_sep}|#{re_sep}$/i + end + # No more than one of the separator in a row. + parameterized_string.gsub!(re_duplicate_separator, separator) + # Remove leading/trailing separator. + parameterized_string.gsub!(re_leading_trailing_separator, "".freeze) + end + + parameterized_string.downcase! unless preserve_case + parameterized_string + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb new file mode 100644 index 0000000000..dc8080c469 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb @@ -0,0 +1,78 @@ +# frozen_string_literal: true + +module ActiveSupport + # lazy_load_hooks allows Rails to lazily load a lot of components and thus + # making the app boot faster. Because of this feature now there is no need to + # require ActiveRecord::Base at boot time purely to apply + # configuration. Instead a hook is registered that applies configuration once + # ActiveRecord::Base is loaded. Here ActiveRecord::Base is + # used as example but this feature can be applied elsewhere too. + # + # Here is an example where +on_load+ method is called to register a hook. + # + # initializer 'active_record.initialize_timezone' do + # ActiveSupport.on_load(:active_record) do + # self.time_zone_aware_attributes = true + # self.default_timezone = :utc + # end + # end + # + # When the entirety of +ActiveRecord::Base+ has been + # evaluated then +run_load_hooks+ is invoked. The very last line of + # +ActiveRecord::Base+ is: + # + # ActiveSupport.run_load_hooks(:active_record, ActiveRecord::Base) + module LazyLoadHooks + def self.extended(base) # :nodoc: + base.class_eval do + @load_hooks = Hash.new { |h, k| h[k] = [] } + @loaded = Hash.new { |h, k| h[k] = [] } + @run_once = Hash.new { |h, k| h[k] = [] } + end + end + + # Declares a block that will be executed when a Rails component is fully + # loaded. + # + # Options: + # + # * :yield - Yields the object that run_load_hooks to +block+. + # * :run_once - Given +block+ will run only once. + def on_load(name, options = {}, &block) + @loaded[name].each do |base| + execute_hook(name, base, options, block) + end + + @load_hooks[name] << [block, options] + end + + def run_load_hooks(name, base = Object) + @loaded[name] << base + @load_hooks[name].each do |hook, options| + execute_hook(name, base, options, hook) + end + end + + private + + def with_execution_control(name, block, once) + unless @run_once[name].include?(block) + @run_once[name] << block if once + + yield + end + end + + def execute_hook(name, base, options, block) + with_execution_control(name, block, options[:run_once]) do + if options[:yield] + block.call(base) + else + base.instance_eval(&block) + end + end + end + end + + extend LazyLoadHooks +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/multibyte.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/multibyte.rb new file mode 100644 index 0000000000..3fe3a05e93 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/multibyte.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module ActiveSupport #:nodoc: + module Multibyte + autoload :Chars, "active_support/multibyte/chars" + autoload :Unicode, "active_support/multibyte/unicode" + + # The proxy class returned when calling mb_chars. You can use this accessor + # to configure your own proxy class so you can support other encodings. See + # the ActiveSupport::Multibyte::Chars implementation for an example how to + # do this. + # + # ActiveSupport::Multibyte.proxy_class = CharsForUTF32 + def self.proxy_class=(klass) + @proxy_class = klass + end + + # Returns the current proxy class. + def self.proxy_class + @proxy_class ||= ActiveSupport::Multibyte::Chars + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/notifications.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/notifications.rb new file mode 100644 index 0000000000..6207de8094 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/notifications.rb @@ -0,0 +1,216 @@ +# frozen_string_literal: true + +require "active_support/notifications/instrumenter" +require "active_support/notifications/fanout" +require "active_support/per_thread_registry" + +module ActiveSupport + # = Notifications + # + # ActiveSupport::Notifications provides an instrumentation API for + # Ruby. + # + # == Instrumenters + # + # To instrument an event you just need to do: + # + # ActiveSupport::Notifications.instrument('render', extra: :information) do + # render plain: 'Foo' + # end + # + # That first executes the block and then notifies all subscribers once done. + # + # In the example above +render+ is the name of the event, and the rest is called + # the _payload_. The payload is a mechanism that allows instrumenters to pass + # extra information to subscribers. Payloads consist of a hash whose contents + # are arbitrary and generally depend on the event. + # + # == Subscribers + # + # You can consume those events and the information they provide by registering + # a subscriber. + # + # ActiveSupport::Notifications.subscribe('render') do |name, start, finish, id, payload| + # name # => String, name of the event (such as 'render' from above) + # start # => Time, when the instrumented block started execution + # finish # => Time, when the instrumented block ended execution + # id # => String, unique ID for this notification + # payload # => Hash, the payload + # end + # + # For instance, let's store all "render" events in an array: + # + # events = [] + # + # ActiveSupport::Notifications.subscribe('render') do |*args| + # events << ActiveSupport::Notifications::Event.new(*args) + # end + # + # That code returns right away, you are just subscribing to "render" events. + # The block is saved and will be called whenever someone instruments "render": + # + # ActiveSupport::Notifications.instrument('render', extra: :information) do + # render plain: 'Foo' + # end + # + # event = events.first + # event.name # => "render" + # event.duration # => 10 (in milliseconds) + # event.payload # => { extra: :information } + # + # The block in the subscribe call gets the name of the event, start + # timestamp, end timestamp, a string with a unique identifier for that event + # (something like "535801666f04d0298cd6"), and a hash with the payload, in + # that order. + # + # If an exception happens during that particular instrumentation the payload will + # have a key :exception with an array of two elements as value: a string with + # the name of the exception class, and the exception message. + # The :exception_object key of the payload will have the exception + # itself as the value. + # + # As the previous example depicts, the class ActiveSupport::Notifications::Event + # is able to take the arguments as they come and provide an object-oriented + # interface to that data. + # + # It is also possible to pass an object which responds to call method + # as the second parameter to the subscribe method instead of a block: + # + # module ActionController + # class PageRequest + # def call(name, started, finished, unique_id, payload) + # Rails.logger.debug ['notification:', name, started, finished, unique_id, payload].join(' ') + # end + # end + # end + # + # ActiveSupport::Notifications.subscribe('process_action.action_controller', ActionController::PageRequest.new) + # + # resulting in the following output within the logs including a hash with the payload: + # + # notification: process_action.action_controller 2012-04-13 01:08:35 +0300 2012-04-13 01:08:35 +0300 af358ed7fab884532ec7 { + # controller: "Devise::SessionsController", + # action: "new", + # params: {"action"=>"new", "controller"=>"devise/sessions"}, + # format: :html, + # method: "GET", + # path: "/login/sign_in", + # status: 200, + # view_runtime: 279.3080806732178, + # db_runtime: 40.053 + # } + # + # You can also subscribe to all events whose name matches a certain regexp: + # + # ActiveSupport::Notifications.subscribe(/render/) do |*args| + # ... + # end + # + # and even pass no argument to subscribe, in which case you are subscribing + # to all events. + # + # == Temporary Subscriptions + # + # Sometimes you do not want to subscribe to an event for the entire life of + # the application. There are two ways to unsubscribe. + # + # WARNING: The instrumentation framework is designed for long-running subscribers, + # use this feature sparingly because it wipes some internal caches and that has + # a negative impact on performance. + # + # === Subscribe While a Block Runs + # + # You can subscribe to some event temporarily while some block runs. For + # example, in + # + # callback = lambda {|*args| ... } + # ActiveSupport::Notifications.subscribed(callback, "sql.active_record") do + # ... + # end + # + # the callback will be called for all "sql.active_record" events instrumented + # during the execution of the block. The callback is unsubscribed automatically + # after that. + # + # === Manual Unsubscription + # + # The +subscribe+ method returns a subscriber object: + # + # subscriber = ActiveSupport::Notifications.subscribe("render") do |*args| + # ... + # end + # + # To prevent that block from being called anymore, just unsubscribe passing + # that reference: + # + # ActiveSupport::Notifications.unsubscribe(subscriber) + # + # You can also unsubscribe by passing the name of the subscriber object. Note + # that this will unsubscribe all subscriptions with the given name: + # + # ActiveSupport::Notifications.unsubscribe("render") + # + # == Default Queue + # + # Notifications ships with a queue implementation that consumes and publishes events + # to all log subscribers. You can use any queue implementation you want. + # + module Notifications + class << self + attr_accessor :notifier + + def publish(name, *args) + notifier.publish(name, *args) + end + + def instrument(name, payload = {}) + if notifier.listening?(name) + instrumenter.instrument(name, payload) { yield payload if block_given? } + else + yield payload if block_given? + end + end + + def subscribe(*args, &block) + notifier.subscribe(*args, &block) + end + + def subscribed(callback, *args, &block) + subscriber = subscribe(*args, &callback) + yield + ensure + unsubscribe(subscriber) + end + + def unsubscribe(subscriber_or_name) + notifier.unsubscribe(subscriber_or_name) + end + + def instrumenter + InstrumentationRegistry.instance.instrumenter_for(notifier) + end + end + + # This class is a registry which holds all of the +Instrumenter+ objects + # in a particular thread local. To access the +Instrumenter+ object for a + # particular +notifier+, you can call the following method: + # + # InstrumentationRegistry.instrumenter_for(notifier) + # + # The instrumenters for multiple notifiers are held in a single instance of + # this class. + class InstrumentationRegistry # :nodoc: + extend ActiveSupport::PerThreadRegistry + + def initialize + @registry = {} + end + + def instrumenter_for(notifier) + @registry[notifier] ||= Instrumenter.new(notifier) + end + end + + self.notifier = Fanout.new + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/notifications/fanout.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/notifications/fanout.rb new file mode 100644 index 0000000000..25aab175b4 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/notifications/fanout.rb @@ -0,0 +1,159 @@ +# frozen_string_literal: true + +require "mutex_m" +require "concurrent/map" + +module ActiveSupport + module Notifications + # This is a default queue implementation that ships with Notifications. + # It just pushes events to all registered log subscribers. + # + # This class is thread safe. All methods are reentrant. + class Fanout + include Mutex_m + + def initialize + @subscribers = [] + @listeners_for = Concurrent::Map.new + super + end + + def subscribe(pattern = nil, block = Proc.new) + subscriber = Subscribers.new pattern, block + synchronize do + @subscribers << subscriber + @listeners_for.clear + end + subscriber + end + + def unsubscribe(subscriber_or_name) + synchronize do + case subscriber_or_name + when String + @subscribers.reject! { |s| s.matches?(subscriber_or_name) } + else + @subscribers.delete(subscriber_or_name) + end + + @listeners_for.clear + end + end + + def start(name, id, payload) + listeners_for(name).each { |s| s.start(name, id, payload) } + end + + def finish(name, id, payload, listeners = listeners_for(name)) + listeners.each { |s| s.finish(name, id, payload) } + end + + def publish(name, *args) + listeners_for(name).each { |s| s.publish(name, *args) } + end + + def listeners_for(name) + # this is correctly done double-checked locking (Concurrent::Map's lookups have volatile semantics) + @listeners_for[name] || synchronize do + # use synchronisation when accessing @subscribers + @listeners_for[name] ||= @subscribers.select { |s| s.subscribed_to?(name) } + end + end + + def listening?(name) + listeners_for(name).any? + end + + # This is a sync queue, so there is no waiting. + def wait + end + + module Subscribers # :nodoc: + def self.new(pattern, listener) + if listener.respond_to?(:start) && listener.respond_to?(:finish) + subscriber = Evented.new pattern, listener + else + subscriber = Timed.new pattern, listener + end + + unless pattern + AllMessages.new(subscriber) + else + subscriber + end + end + + class Evented #:nodoc: + def initialize(pattern, delegate) + @pattern = pattern + @delegate = delegate + @can_publish = delegate.respond_to?(:publish) + end + + def publish(name, *args) + if @can_publish + @delegate.publish name, *args + end + end + + def start(name, id, payload) + @delegate.start name, id, payload + end + + def finish(name, id, payload) + @delegate.finish name, id, payload + end + + def subscribed_to?(name) + @pattern === name + end + + def matches?(name) + @pattern && @pattern === name + end + end + + class Timed < Evented # :nodoc: + def publish(name, *args) + @delegate.call name, *args + end + + def start(name, id, payload) + timestack = Thread.current[:_timestack] ||= [] + timestack.push Time.now + end + + def finish(name, id, payload) + timestack = Thread.current[:_timestack] + started = timestack.pop + @delegate.call(name, started, Time.now, id, payload) + end + end + + class AllMessages # :nodoc: + def initialize(delegate) + @delegate = delegate + end + + def start(name, id, payload) + @delegate.start name, id, payload + end + + def finish(name, id, payload) + @delegate.finish name, id, payload + end + + def publish(name, *args) + @delegate.publish name, *args + end + + def subscribed_to?(name) + true + end + + alias :matches? :=== + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/notifications/instrumenter.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/notifications/instrumenter.rb new file mode 100644 index 0000000000..e99f5ee688 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/notifications/instrumenter.rb @@ -0,0 +1,93 @@ +# frozen_string_literal: true + +require "securerandom" + +module ActiveSupport + module Notifications + # Instrumenters are stored in a thread local. + class Instrumenter + attr_reader :id + + def initialize(notifier) + @id = unique_id + @notifier = notifier + end + + # Instrument the given block by measuring the time taken to execute it + # and publish it. Notice that events get sent even if an error occurs + # in the passed-in block. + def instrument(name, payload = {}) + # some of the listeners might have state + listeners_state = start name, payload + begin + yield payload + rescue Exception => e + payload[:exception] = [e.class.name, e.message] + payload[:exception_object] = e + raise e + ensure + finish_with_state listeners_state, name, payload + end + end + + # Send a start notification with +name+ and +payload+. + def start(name, payload) + @notifier.start name, @id, payload + end + + # Send a finish notification with +name+ and +payload+. + def finish(name, payload) + @notifier.finish name, @id, payload + end + + def finish_with_state(listeners_state, name, payload) + @notifier.finish name, @id, payload, listeners_state + end + + private + + def unique_id + SecureRandom.hex(10) + end + end + + class Event + attr_reader :name, :time, :transaction_id, :payload, :children + attr_accessor :end + + def initialize(name, start, ending, transaction_id, payload) + @name = name + @payload = payload.dup + @time = start + @transaction_id = transaction_id + @end = ending + @children = [] + @duration = nil + end + + # Returns the difference in milliseconds between when the execution of the + # event started and when it ended. + # + # ActiveSupport::Notifications.subscribe('wait') do |*args| + # @event = ActiveSupport::Notifications::Event.new(*args) + # end + # + # ActiveSupport::Notifications.instrument('wait') do + # sleep 1 + # end + # + # @event.duration # => 1000.138 + def duration + @duration ||= 1000.0 * (self.end - time) + end + + def <<(event) + @children << event + end + + def parent_of?(event) + @children.include? event + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/per_thread_registry.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/per_thread_registry.rb new file mode 100644 index 0000000000..eb92fb4371 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/per_thread_registry.rb @@ -0,0 +1,60 @@ +# frozen_string_literal: true + +require "active_support/core_ext/module/delegation" + +module ActiveSupport + # NOTE: This approach has been deprecated for end-user code in favor of {thread_mattr_accessor}[rdoc-ref:Module#thread_mattr_accessor] and friends. + # Please use that approach instead. + # + # This module is used to encapsulate access to thread local variables. + # + # Instead of polluting the thread locals namespace: + # + # Thread.current[:connection_handler] + # + # you define a class that extends this module: + # + # module ActiveRecord + # class RuntimeRegistry + # extend ActiveSupport::PerThreadRegistry + # + # attr_accessor :connection_handler + # end + # end + # + # and invoke the declared instance accessors as class methods. So + # + # ActiveRecord::RuntimeRegistry.connection_handler = connection_handler + # + # sets a connection handler local to the current thread, and + # + # ActiveRecord::RuntimeRegistry.connection_handler + # + # returns a connection handler local to the current thread. + # + # This feature is accomplished by instantiating the class and storing the + # instance as a thread local keyed by the class name. In the example above + # a key "ActiveRecord::RuntimeRegistry" is stored in Thread.current. + # The class methods proxy to said thread local instance. + # + # If the class has an initializer, it must accept no arguments. + module PerThreadRegistry + def self.extended(object) + object.instance_variable_set "@per_thread_registry_key", object.name.freeze + end + + def instance + Thread.current[@per_thread_registry_key] ||= new + end + + private + def method_missing(name, *args, &block) + # Caches the method definition as a singleton method of the receiver. + # + # By letting #delegate handle it, we avoid an enclosure that'll capture args. + singleton_class.delegate name, to: :instance + + send(name, *args, &block) + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/time.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/time.rb new file mode 100644 index 0000000000..51854675bf --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/time.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module ActiveSupport + autoload :Duration, "active_support/duration" + autoload :TimeWithZone, "active_support/time_with_zone" + autoload :TimeZone, "active_support/values/time_zone" +end + +require "date" +require "time" + +require "active_support/core_ext/time" +require "active_support/core_ext/date" +require "active_support/core_ext/date_time" + +require "active_support/core_ext/integer/time" +require "active_support/core_ext/numeric/time" + +require "active_support/core_ext/string/conversions" +require "active_support/core_ext/string/zones" diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/time_with_zone.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/time_with_zone.rb new file mode 100644 index 0000000000..20650ce714 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/time_with_zone.rb @@ -0,0 +1,551 @@ +# frozen_string_literal: true + +require "active_support/duration" +require "active_support/values/time_zone" +require "active_support/core_ext/object/acts_like" +require "active_support/core_ext/date_and_time/compatibility" + +module ActiveSupport + # A Time-like class that can represent a time in any time zone. Necessary + # because standard Ruby Time instances are limited to UTC and the + # system's ENV['TZ'] zone. + # + # You shouldn't ever need to create a TimeWithZone instance directly via +new+. + # Instead use methods +local+, +parse+, +at+ and +now+ on TimeZone instances, + # and +in_time_zone+ on Time and DateTime instances. + # + # Time.zone = 'Eastern Time (US & Canada)' # => 'Eastern Time (US & Canada)' + # Time.zone.local(2007, 2, 10, 15, 30, 45) # => Sat, 10 Feb 2007 15:30:45 EST -05:00 + # Time.zone.parse('2007-02-10 15:30:45') # => Sat, 10 Feb 2007 15:30:45 EST -05:00 + # Time.zone.at(1171139445) # => Sat, 10 Feb 2007 15:30:45 EST -05:00 + # Time.zone.now # => Sun, 18 May 2008 13:07:55 EDT -04:00 + # Time.utc(2007, 2, 10, 20, 30, 45).in_time_zone # => Sat, 10 Feb 2007 15:30:45 EST -05:00 + # + # See Time and TimeZone for further documentation of these methods. + # + # TimeWithZone instances implement the same API as Ruby Time instances, so + # that Time and TimeWithZone instances are interchangeable. + # + # t = Time.zone.now # => Sun, 18 May 2008 13:27:25 EDT -04:00 + # t.hour # => 13 + # t.dst? # => true + # t.utc_offset # => -14400 + # t.zone # => "EDT" + # t.to_s(:rfc822) # => "Sun, 18 May 2008 13:27:25 -0400" + # t + 1.day # => Mon, 19 May 2008 13:27:25 EDT -04:00 + # t.beginning_of_year # => Tue, 01 Jan 2008 00:00:00 EST -05:00 + # t > Time.utc(1999) # => true + # t.is_a?(Time) # => true + # t.is_a?(ActiveSupport::TimeWithZone) # => true + class TimeWithZone + # Report class name as 'Time' to thwart type checking. + def self.name + "Time" + end + + PRECISIONS = Hash.new { |h, n| h[n] = "%FT%T.%#{n}N".freeze } + PRECISIONS[0] = "%FT%T".freeze + + include Comparable, DateAndTime::Compatibility + attr_reader :time_zone + + def initialize(utc_time, time_zone, local_time = nil, period = nil) + @utc = utc_time ? transfer_time_values_to_utc_constructor(utc_time) : nil + @time_zone, @time = time_zone, local_time + @period = @utc ? period : get_period_and_ensure_valid_local_time(period) + end + + # Returns a Time instance that represents the time in +time_zone+. + def time + @time ||= period.to_local(@utc) + end + + # Returns a Time instance of the simultaneous time in the UTC timezone. + def utc + @utc ||= period.to_utc(@time) + end + alias_method :comparable_time, :utc + alias_method :getgm, :utc + alias_method :getutc, :utc + alias_method :gmtime, :utc + + # Returns the underlying TZInfo::TimezonePeriod. + def period + @period ||= time_zone.period_for_utc(@utc) + end + + # Returns the simultaneous time in Time.zone, or the specified zone. + def in_time_zone(new_zone = ::Time.zone) + return self if time_zone == new_zone + utc.in_time_zone(new_zone) + end + + # Returns a Time instance of the simultaneous time in the system timezone. + def localtime(utc_offset = nil) + utc.getlocal(utc_offset) + end + alias_method :getlocal, :localtime + + # Returns true if the current time is within Daylight Savings Time for the + # specified time zone. + # + # Time.zone = 'Eastern Time (US & Canada)' # => 'Eastern Time (US & Canada)' + # Time.zone.parse("2012-5-30").dst? # => true + # Time.zone.parse("2012-11-30").dst? # => false + def dst? + period.dst? + end + alias_method :isdst, :dst? + + # Returns true if the current time zone is set to UTC. + # + # Time.zone = 'UTC' # => 'UTC' + # Time.zone.now.utc? # => true + # Time.zone = 'Eastern Time (US & Canada)' # => 'Eastern Time (US & Canada)' + # Time.zone.now.utc? # => false + def utc? + period.offset.abbreviation == :UTC || period.offset.abbreviation == :UCT + end + alias_method :gmt?, :utc? + + # Returns the offset from current time to UTC time in seconds. + def utc_offset + period.utc_total_offset + end + alias_method :gmt_offset, :utc_offset + alias_method :gmtoff, :utc_offset + + # Returns a formatted string of the offset from UTC, or an alternative + # string if the time zone is already UTC. + # + # Time.zone = 'Eastern Time (US & Canada)' # => "Eastern Time (US & Canada)" + # Time.zone.now.formatted_offset(true) # => "-05:00" + # Time.zone.now.formatted_offset(false) # => "-0500" + # Time.zone = 'UTC' # => "UTC" + # Time.zone.now.formatted_offset(true, "0") # => "0" + def formatted_offset(colon = true, alternate_utc_string = nil) + utc? && alternate_utc_string || TimeZone.seconds_to_utc_offset(utc_offset, colon) + end + + # Returns the time zone abbreviation. + # + # Time.zone = 'Eastern Time (US & Canada)' # => "Eastern Time (US & Canada)" + # Time.zone.now.zone # => "EST" + def zone + period.zone_identifier.to_s + end + + # Returns a string of the object's date, time, zone, and offset from UTC. + # + # Time.zone.now.inspect # => "Thu, 04 Dec 2014 11:00:25 EST -05:00" + def inspect + "#{time.strftime('%a, %d %b %Y %H:%M:%S')} #{zone} #{formatted_offset}" + end + + # Returns a string of the object's date and time in the ISO 8601 standard + # format. + # + # Time.zone.now.xmlschema # => "2014-12-04T11:02:37-05:00" + def xmlschema(fraction_digits = 0) + "#{time.strftime(PRECISIONS[fraction_digits.to_i])}#{formatted_offset(true, 'Z'.freeze)}" + end + alias_method :iso8601, :xmlschema + alias_method :rfc3339, :xmlschema + + # Coerces time to a string for JSON encoding. The default format is ISO 8601. + # You can get %Y/%m/%d %H:%M:%S +offset style by setting + # ActiveSupport::JSON::Encoding.use_standard_json_time_format + # to +false+. + # + # # With ActiveSupport::JSON::Encoding.use_standard_json_time_format = true + # Time.utc(2005,2,1,15,15,10).in_time_zone("Hawaii").to_json + # # => "2005-02-01T05:15:10.000-10:00" + # + # # With ActiveSupport::JSON::Encoding.use_standard_json_time_format = false + # Time.utc(2005,2,1,15,15,10).in_time_zone("Hawaii").to_json + # # => "2005/02/01 05:15:10 -1000" + def as_json(options = nil) + if ActiveSupport::JSON::Encoding.use_standard_json_time_format + xmlschema(ActiveSupport::JSON::Encoding.time_precision) + else + %(#{time.strftime("%Y/%m/%d %H:%M:%S")} #{formatted_offset(false)}) + end + end + + def init_with(coder) #:nodoc: + initialize(coder["utc"], coder["zone"], coder["time"]) + end + + def encode_with(coder) #:nodoc: + coder.tag = "!ruby/object:ActiveSupport::TimeWithZone" + coder.map = { "utc" => utc, "zone" => time_zone, "time" => time } + end + + # Returns a string of the object's date and time in the format used by + # HTTP requests. + # + # Time.zone.now.httpdate # => "Tue, 01 Jan 2013 04:39:43 GMT" + def httpdate + utc.httpdate + end + + # Returns a string of the object's date and time in the RFC 2822 standard + # format. + # + # Time.zone.now.rfc2822 # => "Tue, 01 Jan 2013 04:51:39 +0000" + def rfc2822 + to_s(:rfc822) + end + alias_method :rfc822, :rfc2822 + + # Returns a string of the object's date and time. + # Accepts an optional format: + # * :default - default value, mimics Ruby Time#to_s format. + # * :db - format outputs time in UTC :db time. See Time#to_formatted_s(:db). + # * Any key in Time::DATE_FORMATS can be used. See active_support/core_ext/time/conversions.rb. + def to_s(format = :default) + if format == :db + utc.to_s(format) + elsif formatter = ::Time::DATE_FORMATS[format] + formatter.respond_to?(:call) ? formatter.call(self).to_s : strftime(formatter) + else + "#{time.strftime("%Y-%m-%d %H:%M:%S")} #{formatted_offset(false, 'UTC')}" # mimicking Ruby Time#to_s format + end + end + alias_method :to_formatted_s, :to_s + + # Replaces %Z directive with +zone before passing to Time#strftime, + # so that zone information is correct. + def strftime(format) + format = format.gsub(/((?:\A|[^%])(?:%%)*)%Z/, "\\1#{zone}") + getlocal(utc_offset).strftime(format) + end + + # Use the time in UTC for comparisons. + def <=>(other) + utc <=> other + end + + # Returns true if the current object's time is within the specified + # +min+ and +max+ time. + def between?(min, max) + utc.between?(min, max) + end + + # Returns true if the current object's time is in the past. + def past? + utc.past? + end + + # Returns true if the current object's time falls within + # the current day. + def today? + time.today? + end + + # Returns true if the current object's time is in the future. + def future? + utc.future? + end + + # Returns +true+ if +other+ is equal to current object. + def eql?(other) + other.eql?(utc) + end + + def hash + utc.hash + end + + # Adds an interval of time to the current object's time and returns that + # value as a new TimeWithZone object. + # + # Time.zone = 'Eastern Time (US & Canada)' # => 'Eastern Time (US & Canada)' + # now = Time.zone.now # => Sun, 02 Nov 2014 01:26:28 EDT -04:00 + # now + 1000 # => Sun, 02 Nov 2014 01:43:08 EDT -04:00 + # + # If we're adding a Duration of variable length (i.e., years, months, days), + # move forward from #time, otherwise move forward from #utc, for accuracy + # when moving across DST boundaries. + # + # For instance, a time + 24.hours will advance exactly 24 hours, while a + # time + 1.day will advance 23-25 hours, depending on the day. + # + # now + 24.hours # => Mon, 03 Nov 2014 00:26:28 EST -05:00 + # now + 1.day # => Mon, 03 Nov 2014 01:26:28 EST -05:00 + def +(other) + if duration_of_variable_length?(other) + method_missing(:+, other) + else + result = utc.acts_like?(:date) ? utc.since(other) : utc + other rescue utc.since(other) + result.in_time_zone(time_zone) + end + end + alias_method :since, :+ + alias_method :in, :+ + + # Returns a new TimeWithZone object that represents the difference between + # the current object's time and the +other+ time. + # + # Time.zone = 'Eastern Time (US & Canada)' # => 'Eastern Time (US & Canada)' + # now = Time.zone.now # => Mon, 03 Nov 2014 00:26:28 EST -05:00 + # now - 1000 # => Mon, 03 Nov 2014 00:09:48 EST -05:00 + # + # If subtracting a Duration of variable length (i.e., years, months, days), + # move backward from #time, otherwise move backward from #utc, for accuracy + # when moving across DST boundaries. + # + # For instance, a time - 24.hours will go subtract exactly 24 hours, while a + # time - 1.day will subtract 23-25 hours, depending on the day. + # + # now - 24.hours # => Sun, 02 Nov 2014 01:26:28 EDT -04:00 + # now - 1.day # => Sun, 02 Nov 2014 00:26:28 EDT -04:00 + def -(other) + if other.acts_like?(:time) + to_time - other.to_time + elsif duration_of_variable_length?(other) + method_missing(:-, other) + else + result = utc.acts_like?(:date) ? utc.ago(other) : utc - other rescue utc.ago(other) + result.in_time_zone(time_zone) + end + end + + # Subtracts an interval of time from the current object's time and returns + # the result as a new TimeWithZone object. + # + # Time.zone = 'Eastern Time (US & Canada)' # => 'Eastern Time (US & Canada)' + # now = Time.zone.now # => Mon, 03 Nov 2014 00:26:28 EST -05:00 + # now.ago(1000) # => Mon, 03 Nov 2014 00:09:48 EST -05:00 + # + # If we're subtracting a Duration of variable length (i.e., years, months, + # days), move backward from #time, otherwise move backward from #utc, for + # accuracy when moving across DST boundaries. + # + # For instance, time.ago(24.hours) will move back exactly 24 hours, + # while time.ago(1.day) will move back 23-25 hours, depending on + # the day. + # + # now.ago(24.hours) # => Sun, 02 Nov 2014 01:26:28 EDT -04:00 + # now.ago(1.day) # => Sun, 02 Nov 2014 00:26:28 EDT -04:00 + def ago(other) + since(-other) + end + + # Returns a new +ActiveSupport::TimeWithZone+ where one or more of the elements have + # been changed according to the +options+ parameter. The time options (:hour, + # :min, :sec, :usec, :nsec) reset cascadingly, + # so if only the hour is passed, then minute, sec, usec and nsec is set to 0. If the + # hour and minute is passed, then sec, usec and nsec is set to 0. The +options+ + # parameter takes a hash with any of these keys: :year, :month, + # :day, :hour, :min, :sec, :usec, + # :nsec, :offset, :zone. Pass either :usec + # or :nsec, not both. Similarly, pass either :zone or + # :offset, not both. + # + # t = Time.zone.now # => Fri, 14 Apr 2017 11:45:15 EST -05:00 + # t.change(year: 2020) # => Tue, 14 Apr 2020 11:45:15 EST -05:00 + # t.change(hour: 12) # => Fri, 14 Apr 2017 12:00:00 EST -05:00 + # t.change(min: 30) # => Fri, 14 Apr 2017 11:30:00 EST -05:00 + # t.change(offset: "-10:00") # => Fri, 14 Apr 2017 11:45:15 HST -10:00 + # t.change(zone: "Hawaii") # => Fri, 14 Apr 2017 11:45:15 HST -10:00 + def change(options) + if options[:zone] && options[:offset] + raise ArgumentError, "Can't change both :offset and :zone at the same time: #{options.inspect}" + end + + new_time = time.change(options) + + if options[:zone] + new_zone = ::Time.find_zone(options[:zone]) + elsif options[:offset] + new_zone = ::Time.find_zone(new_time.utc_offset) + end + + new_zone ||= time_zone + periods = new_zone.periods_for_local(new_time) + + self.class.new(nil, new_zone, new_time, periods.include?(period) ? period : nil) + end + + # Uses Date to provide precise Time calculations for years, months, and days + # according to the proleptic Gregorian calendar. The result is returned as a + # new TimeWithZone object. + # + # The +options+ parameter takes a hash with any of these keys: + # :years, :months, :weeks, :days, + # :hours, :minutes, :seconds. + # + # If advancing by a value of variable length (i.e., years, weeks, months, + # days), move forward from #time, otherwise move forward from #utc, for + # accuracy when moving across DST boundaries. + # + # Time.zone = 'Eastern Time (US & Canada)' # => 'Eastern Time (US & Canada)' + # now = Time.zone.now # => Sun, 02 Nov 2014 01:26:28 EDT -04:00 + # now.advance(seconds: 1) # => Sun, 02 Nov 2014 01:26:29 EDT -04:00 + # now.advance(minutes: 1) # => Sun, 02 Nov 2014 01:27:28 EDT -04:00 + # now.advance(hours: 1) # => Sun, 02 Nov 2014 01:26:28 EST -05:00 + # now.advance(days: 1) # => Mon, 03 Nov 2014 01:26:28 EST -05:00 + # now.advance(weeks: 1) # => Sun, 09 Nov 2014 01:26:28 EST -05:00 + # now.advance(months: 1) # => Tue, 02 Dec 2014 01:26:28 EST -05:00 + # now.advance(years: 1) # => Mon, 02 Nov 2015 01:26:28 EST -05:00 + def advance(options) + # If we're advancing a value of variable length (i.e., years, weeks, months, days), advance from #time, + # otherwise advance from #utc, for accuracy when moving across DST boundaries + if options.values_at(:years, :weeks, :months, :days).any? + method_missing(:advance, options) + else + utc.advance(options).in_time_zone(time_zone) + end + end + + %w(year mon month day mday wday yday hour min sec usec nsec to_date).each do |method_name| + class_eval <<-EOV, __FILE__, __LINE__ + 1 + def #{method_name} # def month + time.#{method_name} # time.month + end # end + EOV + end + + # Returns Array of parts of Time in sequence of + # [seconds, minutes, hours, day, month, year, weekday, yearday, dst?, zone]. + # + # now = Time.zone.now # => Tue, 18 Aug 2015 02:29:27 UTC +00:00 + # now.to_a # => [27, 29, 2, 18, 8, 2015, 2, 230, false, "UTC"] + def to_a + [time.sec, time.min, time.hour, time.day, time.mon, time.year, time.wday, time.yday, dst?, zone] + end + + # Returns the object's date and time as a floating point number of seconds + # since the Epoch (January 1, 1970 00:00 UTC). + # + # Time.zone.now.to_f # => 1417709320.285418 + def to_f + utc.to_f + end + + # Returns the object's date and time as an integer number of seconds + # since the Epoch (January 1, 1970 00:00 UTC). + # + # Time.zone.now.to_i # => 1417709320 + def to_i + utc.to_i + end + alias_method :tv_sec, :to_i + + # Returns the object's date and time as a rational number of seconds + # since the Epoch (January 1, 1970 00:00 UTC). + # + # Time.zone.now.to_r # => (708854548642709/500000) + def to_r + utc.to_r + end + + # Returns an instance of DateTime with the timezone's UTC offset + # + # Time.zone.now.to_datetime # => Tue, 18 Aug 2015 02:32:20 +0000 + # Time.current.in_time_zone('Hawaii').to_datetime # => Mon, 17 Aug 2015 16:32:20 -1000 + def to_datetime + @to_datetime ||= utc.to_datetime.new_offset(Rational(utc_offset, 86_400)) + end + + # Returns an instance of +Time+, either with the same UTC offset + # as +self+ or in the local system timezone depending on the setting + # of +ActiveSupport.to_time_preserves_timezone+. + def to_time + if preserve_timezone + @to_time_with_instance_offset ||= getlocal(utc_offset) + else + @to_time_with_system_offset ||= getlocal + end + end + + # So that +self+ acts_like?(:time). + def acts_like_time? + true + end + + # Say we're a Time to thwart type checking. + def is_a?(klass) + klass == ::Time || super + end + alias_method :kind_of?, :is_a? + + # An instance of ActiveSupport::TimeWithZone is never blank + def blank? + false + end + + def freeze + # preload instance variables before freezing + period; utc; time; to_datetime; to_time + super + end + + def marshal_dump + [utc, time_zone.name, time] + end + + def marshal_load(variables) + initialize(variables[0].utc, ::Time.find_zone(variables[1]), variables[2].utc) + end + + # respond_to_missing? is not called in some cases, such as when type conversion is + # performed with Kernel#String + def respond_to?(sym, include_priv = false) + # ensure that we're not going to throw and rescue from NoMethodError in method_missing which is slow + return false if sym.to_sym == :to_str + super + end + + # Ensure proxy class responds to all methods that underlying time instance + # responds to. + def respond_to_missing?(sym, include_priv) + return false if sym.to_sym == :acts_like_date? + time.respond_to?(sym, include_priv) + end + + # Send the missing method to +time+ instance, and wrap result in a new + # TimeWithZone with the existing +time_zone+. + def method_missing(sym, *args, &block) + wrap_with_time_zone time.__send__(sym, *args, &block) + rescue NoMethodError => e + raise e, e.message.sub(time.inspect, inspect), e.backtrace + end + + private + def get_period_and_ensure_valid_local_time(period) + # we don't want a Time.local instance enforcing its own DST rules as well, + # so transfer time values to a utc constructor if necessary + @time = transfer_time_values_to_utc_constructor(@time) unless @time.utc? + begin + period || @time_zone.period_for_local(@time) + rescue ::TZInfo::PeriodNotFound + # time is in the "spring forward" hour gap, so we're moving the time forward one hour and trying again + @time += 1.hour + retry + end + end + + def transfer_time_values_to_utc_constructor(time) + # avoid creating another Time object if possible + return time if time.instance_of?(::Time) && time.utc? + ::Time.utc(time.year, time.month, time.day, time.hour, time.min, time.sec + time.subsec) + end + + def duration_of_variable_length?(obj) + ActiveSupport::Duration === obj && obj.parts.any? { |p| [:years, :months, :weeks, :days].include?(p[0]) } + end + + def wrap_with_time_zone(time) + if time.acts_like?(:time) + periods = time_zone.periods_for_local(time) + self.class.new(nil, time_zone, time, periods.include?(period) ? period : nil) + elsif time.is_a?(Range) + wrap_with_time_zone(time.begin)..wrap_with_time_zone(time.end) + else + time + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/values/time_zone.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/values/time_zone.rb new file mode 100644 index 0000000000..90501bc5f7 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/values/time_zone.rb @@ -0,0 +1,565 @@ +# frozen_string_literal: true + +require "tzinfo" +require "concurrent/map" +require "active_support/core_ext/object/blank" + +module ActiveSupport + # The TimeZone class serves as a wrapper around TZInfo::Timezone instances. + # It allows us to do the following: + # + # * Limit the set of zones provided by TZInfo to a meaningful subset of 134 + # zones. + # * Retrieve and display zones with a friendlier name + # (e.g., "Eastern Time (US & Canada)" instead of "America/New_York"). + # * Lazily load TZInfo::Timezone instances only when they're needed. + # * Create ActiveSupport::TimeWithZone instances via TimeZone's +local+, + # +parse+, +at+ and +now+ methods. + # + # If you set config.time_zone in the Rails Application, you can + # access this TimeZone object via Time.zone: + # + # # application.rb: + # class Application < Rails::Application + # config.time_zone = 'Eastern Time (US & Canada)' + # end + # + # Time.zone # => # + # Time.zone.name # => "Eastern Time (US & Canada)" + # Time.zone.now # => Sun, 18 May 2008 14:30:44 EDT -04:00 + class TimeZone + # Keys are Rails TimeZone names, values are TZInfo identifiers. + MAPPING = { + "International Date Line West" => "Etc/GMT+12", + "Midway Island" => "Pacific/Midway", + "American Samoa" => "Pacific/Pago_Pago", + "Hawaii" => "Pacific/Honolulu", + "Alaska" => "America/Juneau", + "Pacific Time (US & Canada)" => "America/Los_Angeles", + "Tijuana" => "America/Tijuana", + "Mountain Time (US & Canada)" => "America/Denver", + "Arizona" => "America/Phoenix", + "Chihuahua" => "America/Chihuahua", + "Mazatlan" => "America/Mazatlan", + "Central Time (US & Canada)" => "America/Chicago", + "Saskatchewan" => "America/Regina", + "Guadalajara" => "America/Mexico_City", + "Mexico City" => "America/Mexico_City", + "Monterrey" => "America/Monterrey", + "Central America" => "America/Guatemala", + "Eastern Time (US & Canada)" => "America/New_York", + "Indiana (East)" => "America/Indiana/Indianapolis", + "Bogota" => "America/Bogota", + "Lima" => "America/Lima", + "Quito" => "America/Lima", + "Atlantic Time (Canada)" => "America/Halifax", + "Caracas" => "America/Caracas", + "La Paz" => "America/La_Paz", + "Santiago" => "America/Santiago", + "Newfoundland" => "America/St_Johns", + "Brasilia" => "America/Sao_Paulo", + "Buenos Aires" => "America/Argentina/Buenos_Aires", + "Montevideo" => "America/Montevideo", + "Georgetown" => "America/Guyana", + "Puerto Rico" => "America/Puerto_Rico", + "Greenland" => "America/Godthab", + "Mid-Atlantic" => "Atlantic/South_Georgia", + "Azores" => "Atlantic/Azores", + "Cape Verde Is." => "Atlantic/Cape_Verde", + "Dublin" => "Europe/Dublin", + "Edinburgh" => "Europe/London", + "Lisbon" => "Europe/Lisbon", + "London" => "Europe/London", + "Casablanca" => "Africa/Casablanca", + "Monrovia" => "Africa/Monrovia", + "UTC" => "Etc/UTC", + "Belgrade" => "Europe/Belgrade", + "Bratislava" => "Europe/Bratislava", + "Budapest" => "Europe/Budapest", + "Ljubljana" => "Europe/Ljubljana", + "Prague" => "Europe/Prague", + "Sarajevo" => "Europe/Sarajevo", + "Skopje" => "Europe/Skopje", + "Warsaw" => "Europe/Warsaw", + "Zagreb" => "Europe/Zagreb", + "Brussels" => "Europe/Brussels", + "Copenhagen" => "Europe/Copenhagen", + "Madrid" => "Europe/Madrid", + "Paris" => "Europe/Paris", + "Amsterdam" => "Europe/Amsterdam", + "Berlin" => "Europe/Berlin", + "Bern" => "Europe/Zurich", + "Zurich" => "Europe/Zurich", + "Rome" => "Europe/Rome", + "Stockholm" => "Europe/Stockholm", + "Vienna" => "Europe/Vienna", + "West Central Africa" => "Africa/Algiers", + "Bucharest" => "Europe/Bucharest", + "Cairo" => "Africa/Cairo", + "Helsinki" => "Europe/Helsinki", + "Kyiv" => "Europe/Kiev", + "Riga" => "Europe/Riga", + "Sofia" => "Europe/Sofia", + "Tallinn" => "Europe/Tallinn", + "Vilnius" => "Europe/Vilnius", + "Athens" => "Europe/Athens", + "Istanbul" => "Europe/Istanbul", + "Minsk" => "Europe/Minsk", + "Jerusalem" => "Asia/Jerusalem", + "Harare" => "Africa/Harare", + "Pretoria" => "Africa/Johannesburg", + "Kaliningrad" => "Europe/Kaliningrad", + "Moscow" => "Europe/Moscow", + "St. Petersburg" => "Europe/Moscow", + "Volgograd" => "Europe/Volgograd", + "Samara" => "Europe/Samara", + "Kuwait" => "Asia/Kuwait", + "Riyadh" => "Asia/Riyadh", + "Nairobi" => "Africa/Nairobi", + "Baghdad" => "Asia/Baghdad", + "Tehran" => "Asia/Tehran", + "Abu Dhabi" => "Asia/Muscat", + "Muscat" => "Asia/Muscat", + "Baku" => "Asia/Baku", + "Tbilisi" => "Asia/Tbilisi", + "Yerevan" => "Asia/Yerevan", + "Kabul" => "Asia/Kabul", + "Ekaterinburg" => "Asia/Yekaterinburg", + "Islamabad" => "Asia/Karachi", + "Karachi" => "Asia/Karachi", + "Tashkent" => "Asia/Tashkent", + "Chennai" => "Asia/Kolkata", + "Kolkata" => "Asia/Kolkata", + "Mumbai" => "Asia/Kolkata", + "New Delhi" => "Asia/Kolkata", + "Kathmandu" => "Asia/Kathmandu", + "Astana" => "Asia/Dhaka", + "Dhaka" => "Asia/Dhaka", + "Sri Jayawardenepura" => "Asia/Colombo", + "Almaty" => "Asia/Almaty", + "Novosibirsk" => "Asia/Novosibirsk", + "Rangoon" => "Asia/Rangoon", + "Bangkok" => "Asia/Bangkok", + "Hanoi" => "Asia/Bangkok", + "Jakarta" => "Asia/Jakarta", + "Krasnoyarsk" => "Asia/Krasnoyarsk", + "Beijing" => "Asia/Shanghai", + "Chongqing" => "Asia/Chongqing", + "Hong Kong" => "Asia/Hong_Kong", + "Urumqi" => "Asia/Urumqi", + "Kuala Lumpur" => "Asia/Kuala_Lumpur", + "Singapore" => "Asia/Singapore", + "Taipei" => "Asia/Taipei", + "Perth" => "Australia/Perth", + "Irkutsk" => "Asia/Irkutsk", + "Ulaanbaatar" => "Asia/Ulaanbaatar", + "Seoul" => "Asia/Seoul", + "Osaka" => "Asia/Tokyo", + "Sapporo" => "Asia/Tokyo", + "Tokyo" => "Asia/Tokyo", + "Yakutsk" => "Asia/Yakutsk", + "Darwin" => "Australia/Darwin", + "Adelaide" => "Australia/Adelaide", + "Canberra" => "Australia/Melbourne", + "Melbourne" => "Australia/Melbourne", + "Sydney" => "Australia/Sydney", + "Brisbane" => "Australia/Brisbane", + "Hobart" => "Australia/Hobart", + "Vladivostok" => "Asia/Vladivostok", + "Guam" => "Pacific/Guam", + "Port Moresby" => "Pacific/Port_Moresby", + "Magadan" => "Asia/Magadan", + "Srednekolymsk" => "Asia/Srednekolymsk", + "Solomon Is." => "Pacific/Guadalcanal", + "New Caledonia" => "Pacific/Noumea", + "Fiji" => "Pacific/Fiji", + "Kamchatka" => "Asia/Kamchatka", + "Marshall Is." => "Pacific/Majuro", + "Auckland" => "Pacific/Auckland", + "Wellington" => "Pacific/Auckland", + "Nuku'alofa" => "Pacific/Tongatapu", + "Tokelau Is." => "Pacific/Fakaofo", + "Chatham Is." => "Pacific/Chatham", + "Samoa" => "Pacific/Apia" + } + + UTC_OFFSET_WITH_COLON = "%s%02d:%02d" + UTC_OFFSET_WITHOUT_COLON = UTC_OFFSET_WITH_COLON.tr(":", "") + + @lazy_zones_map = Concurrent::Map.new + @country_zones = Concurrent::Map.new + + class << self + # Assumes self represents an offset from UTC in seconds (as returned from + # Time#utc_offset) and turns this into an +HH:MM formatted string. + # + # ActiveSupport::TimeZone.seconds_to_utc_offset(-21_600) # => "-06:00" + def seconds_to_utc_offset(seconds, colon = true) + format = colon ? UTC_OFFSET_WITH_COLON : UTC_OFFSET_WITHOUT_COLON + sign = (seconds < 0 ? "-" : "+") + hours = seconds.abs / 3600 + minutes = (seconds.abs % 3600) / 60 + format % [sign, hours, minutes] + end + + def find_tzinfo(name) + TZInfo::Timezone.new(MAPPING[name] || name) + end + + alias_method :create, :new + + # Returns a TimeZone instance with the given name, or +nil+ if no + # such TimeZone instance exists. (This exists to support the use of + # this class with the +composed_of+ macro.) + def new(name) + self[name] + end + + # Returns an array of all TimeZone objects. There are multiple + # TimeZone objects per time zone, in many cases, to make it easier + # for users to find their own time zone. + def all + @zones ||= zones_map.values.sort + end + + # Locate a specific time zone object. If the argument is a string, it + # is interpreted to mean the name of the timezone to locate. If it is a + # numeric value it is either the hour offset, or the second offset, of the + # timezone to find. (The first one with that offset will be returned.) + # Returns +nil+ if no such time zone is known to the system. + def [](arg) + case arg + when String + begin + @lazy_zones_map[arg] ||= create(arg) + rescue TZInfo::InvalidTimezoneIdentifier + nil + end + when Numeric, ActiveSupport::Duration + arg *= 3600 if arg.abs <= 13 + all.find { |z| z.utc_offset == arg.to_i } + else + raise ArgumentError, "invalid argument to TimeZone[]: #{arg.inspect}" + end + end + + # A convenience method for returning a collection of TimeZone objects + # for time zones in the USA. + def us_zones + country_zones(:us) + end + + # A convenience method for returning a collection of TimeZone objects + # for time zones in the country specified by its ISO 3166-1 Alpha2 code. + def country_zones(country_code) + code = country_code.to_s.upcase + @country_zones[code] ||= load_country_zones(code) + end + + def clear #:nodoc: + @lazy_zones_map = Concurrent::Map.new + @country_zones = Concurrent::Map.new + @zones = nil + @zones_map = nil + end + + private + def load_country_zones(code) + country = TZInfo::Country.get(code) + country.zone_identifiers.map do |tz_id| + if MAPPING.value?(tz_id) + MAPPING.inject([]) do |memo, (key, value)| + memo << self[key] if value == tz_id + memo + end + else + create(tz_id, nil, TZInfo::Timezone.new(tz_id)) + end + end.flatten(1).sort! + end + + def zones_map + @zones_map ||= MAPPING.each_with_object({}) do |(name, _), zones| + timezone = self[name] + zones[name] = timezone if timezone + end + end + end + + include Comparable + attr_reader :name + attr_reader :tzinfo + + # Create a new TimeZone object with the given name and offset. The + # offset is the number of seconds that this time zone is offset from UTC + # (GMT). Seconds were chosen as the offset unit because that is the unit + # that Ruby uses to represent time zone offsets (see Time#utc_offset). + def initialize(name, utc_offset = nil, tzinfo = nil) + @name = name + @utc_offset = utc_offset + @tzinfo = tzinfo || TimeZone.find_tzinfo(name) + end + + # Returns the offset of this time zone from UTC in seconds. + def utc_offset + if @utc_offset + @utc_offset + else + tzinfo.current_period.utc_offset if tzinfo && tzinfo.current_period + end + end + + # Returns a formatted string of the offset from UTC, or an alternative + # string if the time zone is already UTC. + # + # zone = ActiveSupport::TimeZone['Central Time (US & Canada)'] + # zone.formatted_offset # => "-06:00" + # zone.formatted_offset(false) # => "-0600" + def formatted_offset(colon = true, alternate_utc_string = nil) + utc_offset == 0 && alternate_utc_string || self.class.seconds_to_utc_offset(utc_offset, colon) + end + + # Compare this time zone to the parameter. The two are compared first on + # their offsets, and then by name. + def <=>(zone) + return unless zone.respond_to? :utc_offset + result = (utc_offset <=> zone.utc_offset) + result = (name <=> zone.name) if result == 0 + result + end + + # Compare #name and TZInfo identifier to a supplied regexp, returning +true+ + # if a match is found. + def =~(re) + re === name || re === MAPPING[name] + end + + # Returns a textual representation of this time zone. + def to_s + "(GMT#{formatted_offset}) #{name}" + end + + # Method for creating new ActiveSupport::TimeWithZone instance in time zone + # of +self+ from given values. + # + # Time.zone = 'Hawaii' # => "Hawaii" + # Time.zone.local(2007, 2, 1, 15, 30, 45) # => Thu, 01 Feb 2007 15:30:45 HST -10:00 + def local(*args) + time = Time.utc(*args) + ActiveSupport::TimeWithZone.new(nil, self, time) + end + + # Method for creating new ActiveSupport::TimeWithZone instance in time zone + # of +self+ from number of seconds since the Unix epoch. + # + # Time.zone = 'Hawaii' # => "Hawaii" + # Time.utc(2000).to_f # => 946684800.0 + # Time.zone.at(946684800.0) # => Fri, 31 Dec 1999 14:00:00 HST -10:00 + def at(secs) + Time.at(secs).utc.in_time_zone(self) + end + + # Method for creating new ActiveSupport::TimeWithZone instance in time zone + # of +self+ from an ISO 8601 string. + # + # Time.zone = 'Hawaii' # => "Hawaii" + # Time.zone.iso8601('1999-12-31T14:00:00') # => Fri, 31 Dec 1999 14:00:00 HST -10:00 + # + # If the time components are missing then they will be set to zero. + # + # Time.zone = 'Hawaii' # => "Hawaii" + # Time.zone.iso8601('1999-12-31') # => Fri, 31 Dec 1999 00:00:00 HST -10:00 + # + # If the string is invalid then an +ArgumentError+ will be raised unlike +parse+ + # which usually returns +nil+ when given an invalid date string. + def iso8601(str) + parts = Date._iso8601(str) + + raise ArgumentError, "invalid date" if parts.empty? + + time = Time.new( + parts.fetch(:year), + parts.fetch(:mon), + parts.fetch(:mday), + parts.fetch(:hour, 0), + parts.fetch(:min, 0), + parts.fetch(:sec, 0) + parts.fetch(:sec_fraction, 0), + parts.fetch(:offset, 0) + ) + + if parts[:offset] + TimeWithZone.new(time.utc, self) + else + TimeWithZone.new(nil, self, time) + end + end + + # Method for creating new ActiveSupport::TimeWithZone instance in time zone + # of +self+ from parsed string. + # + # Time.zone = 'Hawaii' # => "Hawaii" + # Time.zone.parse('1999-12-31 14:00:00') # => Fri, 31 Dec 1999 14:00:00 HST -10:00 + # + # If upper components are missing from the string, they are supplied from + # TimeZone#now: + # + # Time.zone.now # => Fri, 31 Dec 1999 14:00:00 HST -10:00 + # Time.zone.parse('22:30:00') # => Fri, 31 Dec 1999 22:30:00 HST -10:00 + # + # However, if the date component is not provided, but any other upper + # components are supplied, then the day of the month defaults to 1: + # + # Time.zone.parse('Mar 2000') # => Wed, 01 Mar 2000 00:00:00 HST -10:00 + # + # If the string is invalid then an +ArgumentError+ could be raised. + def parse(str, now = now()) + parts_to_time(Date._parse(str, false), now) + end + + # Method for creating new ActiveSupport::TimeWithZone instance in time zone + # of +self+ from an RFC 3339 string. + # + # Time.zone = 'Hawaii' # => "Hawaii" + # Time.zone.rfc3339('2000-01-01T00:00:00Z') # => Fri, 31 Dec 1999 14:00:00 HST -10:00 + # + # If the time or zone components are missing then an +ArgumentError+ will + # be raised. This is much stricter than either +parse+ or +iso8601+ which + # allow for missing components. + # + # Time.zone = 'Hawaii' # => "Hawaii" + # Time.zone.rfc3339('1999-12-31') # => ArgumentError: invalid date + def rfc3339(str) + parts = Date._rfc3339(str) + + raise ArgumentError, "invalid date" if parts.empty? + + time = Time.new( + parts.fetch(:year), + parts.fetch(:mon), + parts.fetch(:mday), + parts.fetch(:hour), + parts.fetch(:min), + parts.fetch(:sec) + parts.fetch(:sec_fraction, 0), + parts.fetch(:offset) + ) + + TimeWithZone.new(time.utc, self) + end + + # Parses +str+ according to +format+ and returns an ActiveSupport::TimeWithZone. + # + # Assumes that +str+ is a time in the time zone +self+, + # unless +format+ includes an explicit time zone. + # (This is the same behavior as +parse+.) + # In either case, the returned TimeWithZone has the timezone of +self+. + # + # Time.zone = 'Hawaii' # => "Hawaii" + # Time.zone.strptime('1999-12-31 14:00:00', '%Y-%m-%d %H:%M:%S') # => Fri, 31 Dec 1999 14:00:00 HST -10:00 + # + # If upper components are missing from the string, they are supplied from + # TimeZone#now: + # + # Time.zone.now # => Fri, 31 Dec 1999 14:00:00 HST -10:00 + # Time.zone.strptime('22:30:00', '%H:%M:%S') # => Fri, 31 Dec 1999 22:30:00 HST -10:00 + # + # However, if the date component is not provided, but any other upper + # components are supplied, then the day of the month defaults to 1: + # + # Time.zone.strptime('Mar 2000', '%b %Y') # => Wed, 01 Mar 2000 00:00:00 HST -10:00 + def strptime(str, format, now = now()) + parts_to_time(DateTime._strptime(str, format), now) + end + + # Returns an ActiveSupport::TimeWithZone instance representing the current + # time in the time zone represented by +self+. + # + # Time.zone = 'Hawaii' # => "Hawaii" + # Time.zone.now # => Wed, 23 Jan 2008 20:24:27 HST -10:00 + def now + time_now.utc.in_time_zone(self) + end + + # Returns the current date in this time zone. + def today + tzinfo.now.to_date + end + + # Returns the next date in this time zone. + def tomorrow + today + 1 + end + + # Returns the previous date in this time zone. + def yesterday + today - 1 + end + + # Adjust the given time to the simultaneous time in the time zone + # represented by +self+. Returns a Time.utc() instance -- if you want an + # ActiveSupport::TimeWithZone instance, use Time#in_time_zone() instead. + def utc_to_local(time) + tzinfo.utc_to_local(time) + end + + # Adjust the given time to the simultaneous time in UTC. Returns a + # Time.utc() instance. + def local_to_utc(time, dst = true) + tzinfo.local_to_utc(time, dst) + end + + # Available so that TimeZone instances respond like TZInfo::Timezone + # instances. + def period_for_utc(time) + tzinfo.period_for_utc(time) + end + + # Available so that TimeZone instances respond like TZInfo::Timezone + # instances. + def period_for_local(time, dst = true) + tzinfo.period_for_local(time, dst) { |periods| periods.last } + end + + def periods_for_local(time) #:nodoc: + tzinfo.periods_for_local(time) + end + + def init_with(coder) #:nodoc: + initialize(coder["name"]) + end + + def encode_with(coder) #:nodoc: + coder.tag = "!ruby/object:#{self.class}" + coder.map = { "name" => tzinfo.name } + end + + private + def parts_to_time(parts, now) + raise ArgumentError, "invalid date" if parts.nil? + return if parts.empty? + + if parts[:seconds] + time = Time.at(parts[:seconds]) + else + time = Time.new( + parts.fetch(:year, now.year), + parts.fetch(:mon, now.month), + parts.fetch(:mday, parts[:year] || parts[:mon] ? 1 : now.day), + parts.fetch(:hour, 0), + parts.fetch(:min, 0), + parts.fetch(:sec, 0) + parts.fetch(:sec_fraction, 0), + parts.fetch(:offset, 0) + ) + end + + if parts[:offset] || parts[:seconds] + TimeWithZone.new(time.utc, self) + else + TimeWithZone.new(nil, self, time) + end + end + + def time_now + Time.now + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/xml_mini.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/xml_mini.rb new file mode 100644 index 0000000000..337a8f7750 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/xml_mini.rb @@ -0,0 +1,209 @@ +# frozen_string_literal: true + +require "time" +require "base64" +require "bigdecimal" +require "active_support/core_ext/module/delegation" +require "active_support/core_ext/string/inflections" +require "active_support/core_ext/date_time/calculations" + +module ActiveSupport + # = XmlMini + # + # To use the much faster libxml parser: + # gem 'libxml-ruby', '=0.9.7' + # XmlMini.backend = 'LibXML' + module XmlMini + extend self + + # This module decorates files deserialized using Hash.from_xml with + # the original_filename and content_type methods. + module FileLike #:nodoc: + attr_writer :original_filename, :content_type + + def original_filename + @original_filename || "untitled" + end + + def content_type + @content_type || "application/octet-stream" + end + end + + DEFAULT_ENCODINGS = { + "binary" => "base64" + } unless defined?(DEFAULT_ENCODINGS) + + unless defined?(TYPE_NAMES) + TYPE_NAMES = { + "Symbol" => "symbol", + "Integer" => "integer", + "BigDecimal" => "decimal", + "Float" => "float", + "TrueClass" => "boolean", + "FalseClass" => "boolean", + "Date" => "date", + "DateTime" => "dateTime", + "Time" => "dateTime", + "Array" => "array", + "Hash" => "hash" + } + + # No need to map these on Ruby 2.4+ + TYPE_NAMES["Fixnum"] = "integer" unless 0.class == Integer + TYPE_NAMES["Bignum"] = "integer" unless 0.class == Integer + end + + FORMATTING = { + "symbol" => Proc.new { |symbol| symbol.to_s }, + "date" => Proc.new { |date| date.to_s(:db) }, + "dateTime" => Proc.new { |time| time.xmlschema }, + "binary" => Proc.new { |binary| ::Base64.encode64(binary) }, + "yaml" => Proc.new { |yaml| yaml.to_yaml } + } unless defined?(FORMATTING) + + # TODO use regexp instead of Date.parse + unless defined?(PARSING) + PARSING = { + "symbol" => Proc.new { |symbol| symbol.to_s.to_sym }, + "date" => Proc.new { |date| ::Date.parse(date) }, + "datetime" => Proc.new { |time| Time.xmlschema(time).utc rescue ::DateTime.parse(time).utc }, + "integer" => Proc.new { |integer| integer.to_i }, + "float" => Proc.new { |float| float.to_f }, + "decimal" => Proc.new do |number| + if String === number + begin + BigDecimal(number) + rescue ArgumentError + BigDecimal("0") + end + else + BigDecimal(number) + end + end, + "boolean" => Proc.new { |boolean| %w(1 true).include?(boolean.to_s.strip) }, + "string" => Proc.new { |string| string.to_s }, + "yaml" => Proc.new { |yaml| YAML.load(yaml) rescue yaml }, + "base64Binary" => Proc.new { |bin| ::Base64.decode64(bin) }, + "binary" => Proc.new { |bin, entity| _parse_binary(bin, entity) }, + "file" => Proc.new { |file, entity| _parse_file(file, entity) } + } + + PARSING.update( + "double" => PARSING["float"], + "dateTime" => PARSING["datetime"] + ) + end + + attr_accessor :depth + self.depth = 100 + + delegate :parse, to: :backend + + def backend + current_thread_backend || @backend + end + + def backend=(name) + backend = name && cast_backend_name_to_module(name) + self.current_thread_backend = backend if current_thread_backend + @backend = backend + end + + def with_backend(name) + old_backend = current_thread_backend + self.current_thread_backend = name && cast_backend_name_to_module(name) + yield + ensure + self.current_thread_backend = old_backend + end + + def to_tag(key, value, options) + type_name = options.delete(:type) + merged_options = options.merge(root: key, skip_instruct: true) + + if value.is_a?(::Method) || value.is_a?(::Proc) + if value.arity == 1 + value.call(merged_options) + else + value.call(merged_options, key.to_s.singularize) + end + elsif value.respond_to?(:to_xml) + value.to_xml(merged_options) + else + type_name ||= TYPE_NAMES[value.class.name] + type_name ||= value.class.name if value && !value.respond_to?(:to_str) + type_name = type_name.to_s if type_name + type_name = "dateTime" if type_name == "datetime" + + key = rename_key(key.to_s, options) + + attributes = options[:skip_types] || type_name.nil? ? {} : { type: type_name } + attributes[:nil] = true if value.nil? + + encoding = options[:encoding] || DEFAULT_ENCODINGS[type_name] + attributes[:encoding] = encoding if encoding + + formatted_value = FORMATTING[type_name] && !value.nil? ? + FORMATTING[type_name].call(value) : value + + options[:builder].tag!(key, formatted_value, attributes) + end + end + + def rename_key(key, options = {}) + camelize = options[:camelize] + dasherize = !options.has_key?(:dasherize) || options[:dasherize] + if camelize + key = true == camelize ? key.camelize : key.camelize(camelize) + end + key = _dasherize(key) if dasherize + key + end + + private + + def _dasherize(key) + # $2 must be a non-greedy regex for this to work + left, middle, right = /\A(_*)(.*?)(_*)\Z/.match(key.strip)[1, 3] + "#{left}#{middle.tr('_ ', '--')}#{right}" + end + + # TODO: Add support for other encodings + def _parse_binary(bin, entity) + case entity["encoding"] + when "base64" + ::Base64.decode64(bin) + else + bin + end + end + + def _parse_file(file, entity) + f = StringIO.new(::Base64.decode64(file)) + f.extend(FileLike) + f.original_filename = entity["name"] + f.content_type = entity["content_type"] + f + end + + def current_thread_backend + Thread.current[:xml_mini_backend] + end + + def current_thread_backend=(name) + Thread.current[:xml_mini_backend] = name && cast_backend_name_to_module(name) + end + + def cast_backend_name_to_module(name) + if name.is_a?(Module) + name + else + require "active_support/xml_mini/#{name.downcase}" + ActiveSupport.const_get("XmlMini_#{name}") + end + end + end + + XmlMini.backend = "REXML" +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/xml_mini/rexml.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/xml_mini/rexml.rb new file mode 100644 index 0000000000..32458d5b0d --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/xml_mini/rexml.rb @@ -0,0 +1,130 @@ +# frozen_string_literal: true + +require "active_support/core_ext/kernel/reporting" +require "active_support/core_ext/object/blank" +require "stringio" + +module ActiveSupport + module XmlMini_REXML #:nodoc: + extend self + + CONTENT_KEY = "__content__".freeze + + # Parse an XML Document string or IO into a simple hash. + # + # Same as XmlSimple::xml_in but doesn't shoot itself in the foot, + # and uses the defaults from Active Support. + # + # data:: + # XML Document string or IO to parse + def parse(data) + if !data.respond_to?(:read) + data = StringIO.new(data || "") + end + + if data.eof? + {} + else + silence_warnings { require "rexml/document" } unless defined?(REXML::Document) + doc = REXML::Document.new(data) + + if doc.root + merge_element!({}, doc.root, XmlMini.depth) + else + raise REXML::ParseException, + "The document #{doc.to_s.inspect} does not have a valid root" + end + end + end + + private + # Convert an XML element and merge into the hash + # + # hash:: + # Hash to merge the converted element into. + # element:: + # XML element to merge into hash + def merge_element!(hash, element, depth) + raise REXML::ParseException, "The document is too deep" if depth == 0 + merge!(hash, element.name, collapse(element, depth)) + end + + # Actually converts an XML document element into a data structure. + # + # element:: + # The document element to be collapsed. + def collapse(element, depth) + hash = get_attributes(element) + + if element.has_elements? + element.each_element { |child| merge_element!(hash, child, depth - 1) } + merge_texts!(hash, element) unless empty_content?(element) + hash + else + merge_texts!(hash, element) + end + end + + # Merge all the texts of an element into the hash + # + # hash:: + # Hash to add the converted element to. + # element:: + # XML element whose texts are to me merged into the hash + def merge_texts!(hash, element) + unless element.has_text? + hash + else + # must use value to prevent double-escaping + texts = "".dup + element.texts.each { |t| texts << t.value } + merge!(hash, CONTENT_KEY, texts) + end + end + + # Adds a new key/value pair to an existing Hash. If the key to be added + # already exists and the existing value associated with key is not + # an Array, it will be wrapped in an Array. Then the new value is + # appended to that Array. + # + # hash:: + # Hash to add key/value pair to. + # key:: + # Key to be added. + # value:: + # Value to be associated with key. + def merge!(hash, key, value) + if hash.has_key?(key) + if hash[key].instance_of?(Array) + hash[key] << value + else + hash[key] = [hash[key], value] + end + elsif value.instance_of?(Array) + hash[key] = [value] + else + hash[key] = value + end + hash + end + + # Converts the attributes array of an XML element into a hash. + # Returns an empty Hash if node has no attributes. + # + # element:: + # XML element to extract attributes from. + def get_attributes(element) + attributes = {} + element.attributes.each { |n, v| attributes[n] = v } + attributes + end + + # Determines if a document element has text content + # + # element:: + # XML element to be checked. + def empty_content?(element) + element.texts.join.blank? + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n.rb new file mode 100644 index 0000000000..afd61ec424 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n.rb @@ -0,0 +1,372 @@ +# frozen_string_literal: true + +require 'concurrent/map' + +require 'i18n/version' +require 'i18n/exceptions' +require 'i18n/interpolate/ruby' + +module I18n + autoload :Backend, 'i18n/backend' + autoload :Config, 'i18n/config' + autoload :Gettext, 'i18n/gettext' + autoload :Locale, 'i18n/locale' + autoload :Tests, 'i18n/tests' + autoload :Middleware, 'i18n/middleware' + + RESERVED_KEYS = %i[ + cascade + deep_interpolation + default + exception_handler + fallback + fallback_in_progress + format + object + raise + resolve + scope + separator + throw + ].freeze + RESERVED_KEYS_PATTERN = /%\{(#{RESERVED_KEYS.join("|")})\}/ + EMPTY_HASH = {}.freeze + + def self.new_double_nested_cache # :nodoc: + Concurrent::Map.new { |h,k| h[k] = Concurrent::Map.new } + end + + module Base + # Gets I18n configuration object. + def config + Thread.current[:i18n_config] ||= I18n::Config.new + end + + # Sets I18n configuration object. + def config=(value) + Thread.current[:i18n_config] = value + end + + # Write methods which delegates to the configuration object + %w(locale backend default_locale available_locales default_separator + exception_handler load_path enforce_available_locales).each do |method| + module_eval <<-DELEGATORS, __FILE__, __LINE__ + 1 + def #{method} + config.#{method} + end + + def #{method}=(value) + config.#{method} = (value) + end + DELEGATORS + end + + # Tells the backend to reload translations. Used in situations like the + # Rails development environment. Backends can implement whatever strategy + # is useful. + def reload! + config.clear_available_locales_set + config.backend.reload! + end + + # Translates, pluralizes and interpolates a given key using a given locale, + # scope, and default, as well as interpolation values. + # + # *LOOKUP* + # + # Translation data is organized as a nested hash using the upper-level keys + # as namespaces. E.g., ActionView ships with the translation: + # :date => {:formats => {:short => "%b %d"}}. + # + # Translations can be looked up at any level of this hash using the key argument + # and the scope option. E.g., in this example I18n.t :date + # returns the whole translations hash {:formats => {:short => "%b %d"}}. + # + # Key can be either a single key or a dot-separated key (both Strings and Symbols + # work). E.g., the short format can be looked up using both: + # I18n.t 'date.formats.short' + # I18n.t :'date.formats.short' + # + # Scope can be either a single key, a dot-separated key or an array of keys + # or dot-separated keys. Keys and scopes can be combined freely. So these + # examples will all look up the same short date format: + # I18n.t 'date.formats.short' + # I18n.t 'formats.short', :scope => 'date' + # I18n.t 'short', :scope => 'date.formats' + # I18n.t 'short', :scope => %w(date formats) + # + # *INTERPOLATION* + # + # Translations can contain interpolation variables which will be replaced by + # values passed to #translate as part of the options hash, with the keys matching + # the interpolation variable names. + # + # E.g., with a translation :foo => "foo %{bar}" the option + # value for the key +bar+ will be interpolated into the translation: + # I18n.t :foo, :bar => 'baz' # => 'foo baz' + # + # *PLURALIZATION* + # + # Translation data can contain pluralized translations. Pluralized translations + # are arrays of singluar/plural versions of translations like ['Foo', 'Foos']. + # + # Note that I18n::Backend::Simple only supports an algorithm for English + # pluralization rules. Other algorithms can be supported by custom backends. + # + # This returns the singular version of a pluralized translation: + # I18n.t :foo, :count => 1 # => 'Foo' + # + # These both return the plural version of a pluralized translation: + # I18n.t :foo, :count => 0 # => 'Foos' + # I18n.t :foo, :count => 2 # => 'Foos' + # + # The :count option can be used both for pluralization and interpolation. + # E.g., with the translation + # :foo => ['%{count} foo', '%{count} foos'], count will + # be interpolated to the pluralized translation: + # I18n.t :foo, :count => 1 # => '1 foo' + # + # *DEFAULTS* + # + # This returns the translation for :foo or default if no translation was found: + # I18n.t :foo, :default => 'default' + # + # This returns the translation for :foo or the translation for :bar if no + # translation for :foo was found: + # I18n.t :foo, :default => :bar + # + # Returns the translation for :foo or the translation for :bar + # or default if no translations for :foo and :bar were found. + # I18n.t :foo, :default => [:bar, 'default'] + # + # *BULK LOOKUP* + # + # This returns an array with the translations for :foo and :bar. + # I18n.t [:foo, :bar] + # + # Can be used with dot-separated nested keys: + # I18n.t [:'baz.foo', :'baz.bar'] + # + # Which is the same as using a scope option: + # I18n.t [:foo, :bar], :scope => :baz + # + # *LAMBDAS* + # + # Both translations and defaults can be given as Ruby lambdas. Lambdas will be + # called and passed the key and options. + # + # E.g. assuming the key :salutation resolves to: + # lambda { |key, options| options[:gender] == 'm' ? "Mr. #{options[:name]}" : "Mrs. #{options[:name]}" } + # + # Then I18n.t(:salutation, :gender => 'w', :name => 'Smith') will result in "Mrs. Smith". + # + # Note that the string returned by lambda will go through string interpolation too, + # so the following lambda would give the same result: + # lambda { |key, options| options[:gender] == 'm' ? "Mr. %{name}" : "Mrs. %{name}" } + # + # It is recommended to use/implement lambdas in an "idempotent" way. E.g. when + # a cache layer is put in front of I18n.translate it will generate a cache key + # from the argument values passed to #translate. Therefor your lambdas should + # always return the same translations/values per unique combination of argument + # values. + def translate(*args) + options = args.last.is_a?(Hash) ? args.pop.dup : {} + key = args.shift + backend = config.backend + locale = options.delete(:locale) || config.locale + handling = options.delete(:throw) && :throw || options.delete(:raise) && :raise # TODO deprecate :raise + + enforce_available_locales!(locale) + + result = catch(:exception) do + if key.is_a?(Array) + key.map { |k| backend.translate(locale, k, options) } + else + backend.translate(locale, key, options) + end + end + result.is_a?(MissingTranslation) ? handle_exception(handling, result, locale, key, options) : result + end + alias :t :translate + + # Wrapper for translate that adds :raise => true. With + # this option, if no translation is found, it will raise I18n::MissingTranslationData + def translate!(key, options = EMPTY_HASH) + translate(key, options.merge(:raise => true)) + end + alias :t! :translate! + + # Returns true if a translation exists for a given key, otherwise returns false. + def exists?(key, locale = config.locale) + raise I18n::ArgumentError if key.is_a?(String) && key.empty? + config.backend.exists?(locale, key) + end + + # Transliterates UTF-8 characters to ASCII. By default this method will + # transliterate only Latin strings to an ASCII approximation: + # + # I18n.transliterate("Ærøskøbing") + # # => "AEroskobing" + # + # I18n.transliterate("日本語") + # # => "???" + # + # It's also possible to add support for per-locale transliterations. I18n + # expects transliteration rules to be stored at + # i18n.transliterate.rule. + # + # Transliteration rules can either be a Hash or a Proc. Procs must accept a + # single string argument. Hash rules inherit the default transliteration + # rules, while Procs do not. + # + # *Examples* + # + # Setting a Hash in .yml: + # + # i18n: + # transliterate: + # rule: + # ü: "ue" + # ö: "oe" + # + # Setting a Hash using Ruby: + # + # store_translations(:de, :i18n => { + # :transliterate => { + # :rule => { + # "ü" => "ue", + # "ö" => "oe" + # } + # } + # ) + # + # Setting a Proc: + # + # translit = lambda {|string| MyTransliterator.transliterate(string) } + # store_translations(:xx, :i18n => {:transliterate => {:rule => translit}) + # + # Transliterating strings: + # + # I18n.locale = :en + # I18n.transliterate("Jürgen") # => "Jurgen" + # I18n.locale = :de + # I18n.transliterate("Jürgen") # => "Juergen" + # I18n.transliterate("Jürgen", :locale => :en) # => "Jurgen" + # I18n.transliterate("Jürgen", :locale => :de) # => "Juergen" + def transliterate(*args) + options = args.pop.dup if args.last.is_a?(Hash) + key = args.shift + locale = options && options.delete(:locale) || config.locale + handling = options && (options.delete(:throw) && :throw || options.delete(:raise) && :raise) + replacement = options && options.delete(:replacement) + enforce_available_locales!(locale) + config.backend.transliterate(locale, key, replacement) + rescue I18n::ArgumentError => exception + handle_exception(handling, exception, locale, key, options || {}) + end + + # Localizes certain objects, such as dates and numbers to local formatting. + def localize(object, options = nil) + options = options ? options.dup : {} + locale = options.delete(:locale) || config.locale + format = options.delete(:format) || :default + enforce_available_locales!(locale) + config.backend.localize(locale, object, format, options) + end + alias :l :localize + + # Executes block with given I18n.locale set. + def with_locale(tmp_locale = nil) + if tmp_locale + current_locale = self.locale + self.locale = tmp_locale + end + yield + ensure + self.locale = current_locale if tmp_locale + end + + # Merges the given locale, key and scope into a single array of keys. + # Splits keys that contain dots into multiple keys. Makes sure all + # keys are Symbols. + def normalize_keys(locale, key, scope, separator = nil) + separator ||= I18n.default_separator + + keys = [] + keys.concat normalize_key(locale, separator) + keys.concat normalize_key(scope, separator) + keys.concat normalize_key(key, separator) + keys + end + + # Returns true when the passed locale, which can be either a String or a + # Symbol, is in the list of available locales. Returns false otherwise. + def locale_available?(locale) + I18n.config.available_locales_set.include?(locale) + end + + # Raises an InvalidLocale exception when the passed locale is not available. + def enforce_available_locales!(locale) + if config.enforce_available_locales + raise I18n::InvalidLocale.new(locale) if !locale_available?(locale) + end + end + + def available_locales_initialized? + config.available_locales_initialized? + end + + private + + # Any exceptions thrown in translate will be sent to the @@exception_handler + # which can be a Symbol, a Proc or any other Object unless they're forced to + # be raised or thrown (MissingTranslation). + # + # If exception_handler is a Symbol then it will simply be sent to I18n as + # a method call. A Proc will simply be called. In any other case the + # method #call will be called on the exception_handler object. + # + # Examples: + # + # I18n.exception_handler = :custom_exception_handler # this is the default + # I18n.custom_exception_handler(exception, locale, key, options) # will be called like this + # + # I18n.exception_handler = lambda { |*args| ... } # a lambda + # I18n.exception_handler.call(exception, locale, key, options) # will be called like this + # + # I18n.exception_handler = I18nExceptionHandler.new # an object + # I18n.exception_handler.call(exception, locale, key, options) # will be called like this + def handle_exception(handling, exception, locale, key, options) + case handling + when :raise + raise exception.respond_to?(:to_exception) ? exception.to_exception : exception + when :throw + throw :exception, exception + else + case handler = options[:exception_handler] || config.exception_handler + when Symbol + send(handler, exception, locale, key, options) + else + handler.call(exception, locale, key, options) + end + end + end + + @@normalized_key_cache = I18n.new_double_nested_cache + + def normalize_key(key, separator) + @@normalized_key_cache[separator][key] ||= + case key + when Array + key.map { |k| normalize_key(k, separator) }.flatten + else + keys = key.to_s.split(separator) + keys.delete('') + keys.map! { |k| k.to_sym } + keys + end + end + end + + extend Base +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend.rb new file mode 100644 index 0000000000..222271e372 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module I18n + module Backend + autoload :Base, 'i18n/backend/base' + autoload :InterpolationCompiler, 'i18n/backend/interpolation_compiler' + autoload :Cache, 'i18n/backend/cache' + autoload :Cascade, 'i18n/backend/cascade' + autoload :Chain, 'i18n/backend/chain' + autoload :Fallbacks, 'i18n/backend/fallbacks' + autoload :Flatten, 'i18n/backend/flatten' + autoload :Gettext, 'i18n/backend/gettext' + autoload :KeyValue, 'i18n/backend/key_value' + autoload :Memoize, 'i18n/backend/memoize' + autoload :Metadata, 'i18n/backend/metadata' + autoload :Pluralization, 'i18n/backend/pluralization' + autoload :Simple, 'i18n/backend/simple' + autoload :Transliterator, 'i18n/backend/transliterator' + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/base.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/base.rb new file mode 100644 index 0000000000..c6073d69bf --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/base.rb @@ -0,0 +1,258 @@ +# frozen_string_literal: true + +require 'yaml' +require 'i18n/core_ext/hash' +require 'i18n/core_ext/kernel/suppress_warnings' + +module I18n + module Backend + module Base + include I18n::Backend::Transliterator + + # Accepts a list of paths to translation files. Loads translations from + # plain Ruby (*.rb) or YAML files (*.yml). See #load_rb and #load_yml + # for details. + def load_translations(*filenames) + filenames = I18n.load_path if filenames.empty? + filenames.flatten.each { |filename| load_file(filename) } + end + + # This method receives a locale, a data hash and options for storing translations. + # Should be implemented + def store_translations(locale, data, options = EMPTY_HASH) + raise NotImplementedError + end + + def translate(locale, key, options = EMPTY_HASH) + raise I18n::ArgumentError if (key.is_a?(String) || key.is_a?(Symbol)) && key.empty? + raise InvalidLocale.new(locale) unless locale + return nil if key.nil? && !options.key?(:default) + + entry = lookup(locale, key, options[:scope], options) unless key.nil? + + if entry.nil? && options.key?(:default) + entry = default(locale, key, options[:default], options) + else + entry = resolve(locale, key, entry, options) + end + + count = options[:count] + + if entry.nil? && (subtrees? || !count) + if (options.key?(:default) && !options[:default].nil?) || !options.key?(:default) + throw(:exception, I18n::MissingTranslation.new(locale, key, options)) + end + end + + entry = entry.dup if entry.is_a?(String) + entry = pluralize(locale, entry, count) if count + + if entry.nil? && !subtrees? + throw(:exception, I18n::MissingTranslation.new(locale, key, options)) + end + + deep_interpolation = options[:deep_interpolation] + values = options.except(*RESERVED_KEYS) + if values + entry = if deep_interpolation + deep_interpolate(locale, entry, values) + else + interpolate(locale, entry, values) + end + end + entry + end + + def exists?(locale, key) + lookup(locale, key) != nil + end + + # Acts the same as +strftime+, but uses a localized version of the + # format string. Takes a key from the date/time formats translations as + # a format argument (e.g., :short in :'date.formats'). + def localize(locale, object, format = :default, options = EMPTY_HASH) + if object.nil? && options.include?(:default) + return options[:default] + end + raise ArgumentError, "Object must be a Date, DateTime or Time object. #{object.inspect} given." unless object.respond_to?(:strftime) + + if Symbol === format + key = format + type = object.respond_to?(:sec) ? 'time' : 'date' + options = options.merge(:raise => true, :object => object, :locale => locale) + format = I18n.t(:"#{type}.formats.#{key}", options) + end + + format = translate_localization_format(locale, object, format, options) + object.strftime(format) + end + + # Returns an array of locales for which translations are available + # ignoring the reserved translation meta data key :i18n. + def available_locales + raise NotImplementedError + end + + def reload! + end + + protected + + # The method which actually looks up for the translation in the store. + def lookup(locale, key, scope = [], options = EMPTY_HASH) + raise NotImplementedError + end + + def subtrees? + true + end + + # Evaluates defaults. + # If given subject is an Array, it walks the array and returns the + # first translation that can be resolved. Otherwise it tries to resolve + # the translation directly. + def default(locale, object, subject, options = EMPTY_HASH) + options = options.dup.reject { |key, value| key == :default } + case subject + when Array + subject.each do |item| + result = resolve(locale, object, item, options) + return result unless result.nil? + end and nil + else + resolve(locale, object, subject, options) + end + end + + # Resolves a translation. + # If the given subject is a Symbol, it will be translated with the + # given options. If it is a Proc then it will be evaluated. All other + # subjects will be returned directly. + def resolve(locale, object, subject, options = EMPTY_HASH) + return subject if options[:resolve] == false + result = catch(:exception) do + case subject + when Symbol + I18n.translate(subject, options.merge(:locale => locale, :throw => true)) + when Proc + date_or_time = options.delete(:object) || object + resolve(locale, object, subject.call(date_or_time, options)) + else + subject + end + end + result unless result.is_a?(MissingTranslation) + end + + # Picks a translation from a pluralized mnemonic subkey according to English + # pluralization rules : + # - It will pick the :one subkey if count is equal to 1. + # - It will pick the :other subkey otherwise. + # - It will pick the :zero subkey in the special case where count is + # equal to 0 and there is a :zero subkey present. This behaviour is + # not standard with regards to the CLDR pluralization rules. + # Other backends can implement more flexible or complex pluralization rules. + def pluralize(locale, entry, count) + return entry unless entry.is_a?(Hash) && count + + key = pluralization_key(entry, count) + raise InvalidPluralizationData.new(entry, count, key) unless entry.has_key?(key) + entry[key] + end + + # Interpolates values into a given subject. + # + # if the given subject is a string then: + # method interpolates "file %{file} opened by %%{user}", :file => 'test.txt', :user => 'Mr. X' + # # => "file test.txt opened by %{user}" + # + # if the given subject is an array then: + # each element of the array is recursively interpolated (until it finds a string) + # method interpolates ["yes, %{user}", ["maybe no, %{user}, "no, %{user}"]], :user => "bartuz" + # # => "["yes, bartuz",["maybe no, bartuz", "no, bartuz"]]" + def interpolate(locale, subject, values = EMPTY_HASH) + return subject if values.empty? + + case subject + when ::String then I18n.interpolate(subject, values) + when ::Array then subject.map { |element| interpolate(locale, element, values) } + else + subject + end + end + + # Deep interpolation + # + # deep_interpolate { people: { ann: "Ann is %{ann}", john: "John is %{john}" } }, + # ann: 'good', john: 'big' + # #=> { people: { ann: "Ann is good", john: "John is big" } } + def deep_interpolate(locale, data, values = EMPTY_HASH) + return data if values.empty? + + case data + when ::String + I18n.interpolate(data, values) + when ::Hash + data.each_with_object({}) do |(k, v), result| + result[k] = deep_interpolate(locale, v, values) + end + when ::Array + data.map do |v| + deep_interpolate(locale, v, values) + end + else + data + end + end + + # Loads a single translations file by delegating to #load_rb or + # #load_yml depending on the file extension and directly merges the + # data to the existing translations. Raises I18n::UnknownFileType + # for all other file extensions. + def load_file(filename) + type = File.extname(filename).tr('.', '').downcase + raise UnknownFileType.new(type, filename) unless respond_to?(:"load_#{type}", true) + data = send(:"load_#{type}", filename) + unless data.is_a?(Hash) + raise InvalidLocaleData.new(filename, 'expects it to return a hash, but does not') + end + data.each { |locale, d| store_translations(locale, d || {}) } + end + + # Loads a plain Ruby translations file. eval'ing the file must yield + # a Hash containing translation data with locales as toplevel keys. + def load_rb(filename) + eval(IO.read(filename), binding, filename) + end + + # Loads a YAML translations file. The data must have locales as + # toplevel keys. + def load_yml(filename) + begin + YAML.load_file(filename) + rescue TypeError, ScriptError, StandardError => e + raise InvalidLocaleData.new(filename, e.inspect) + end + end + alias_method :load_yaml, :load_yml + + def translate_localization_format(locale, object, format, options) + format.to_s.gsub(/%[aAbBpP]/) do |match| + case match + when '%a' then I18n.t(:"date.abbr_day_names", :locale => locale, :format => format)[object.wday] + when '%A' then I18n.t(:"date.day_names", :locale => locale, :format => format)[object.wday] + when '%b' then I18n.t(:"date.abbr_month_names", :locale => locale, :format => format)[object.mon] + when '%B' then I18n.t(:"date.month_names", :locale => locale, :format => format)[object.mon] + when '%p' then I18n.t(:"time.#{object.hour < 12 ? :am : :pm}", :locale => locale, :format => format).upcase if object.respond_to? :hour + when '%P' then I18n.t(:"time.#{object.hour < 12 ? :am : :pm}", :locale => locale, :format => format).downcase if object.respond_to? :hour + end + end + end + + def pluralization_key(entry, count) + key = :zero if count == 0 && entry.has_key?(:zero) + key ||= count == 1 ? :one : :other + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/cache.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/cache.rb new file mode 100644 index 0000000000..7231c19970 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/cache.rb @@ -0,0 +1,116 @@ +# frozen_string_literal: true + +# This module allows you to easily cache all responses from the backend - thus +# speeding up the I18n aspects of your application quite a bit. +# +# To enable caching you can simply include the Cache module to the Simple +# backend - or whatever other backend you are using: +# +# I18n::Backend::Simple.send(:include, I18n::Backend::Cache) +# +# You will also need to set a cache store implementation that you want to use: +# +# I18n.cache_store = ActiveSupport::Cache.lookup_store(:memory_store) +# +# You can use any cache implementation you want that provides the same API as +# ActiveSupport::Cache (only the methods #fetch and #write are being used). +# +# The cache_key implementation by default assumes you pass values that return +# a valid key from #hash (see +# http://www.ruby-doc.org/core/classes/Object.html#M000337). However, you can +# configure your own digest method via which responds to #hexdigest (see +# http://ruby-doc.org/stdlib/libdoc/digest/rdoc/index.html): +# +# I18n.cache_key_digest = Digest::MD5.new +# +# If you use a lambda as a default value in your translation like this: +# +# I18n.t(:"date.order", :default => lambda {[:month, :day, :year]}) +# +# Then you will always have a cache miss, because each time this method +# is called the lambda will have a different hash value. If you know +# the result of the lambda is a constant as in the example above, then +# to cache this you can make the lambda a constant, like this: +# +# DEFAULT_DATE_ORDER = lambda {[:month, :day, :year]} +# ... +# I18n.t(:"date.order", :default => DEFAULT_DATE_ORDER) +# +# If the lambda may result in different values for each call then consider +# also using the Memoize backend. +# +module I18n + class << self + @@cache_store = nil + @@cache_namespace = nil + @@cache_key_digest = nil + + def cache_store + @@cache_store + end + + def cache_store=(store) + @@cache_store = store + end + + def cache_namespace + @@cache_namespace + end + + def cache_namespace=(namespace) + @@cache_namespace = namespace + end + + def cache_key_digest + @@cache_key_digest + end + + def cache_key_digest=(key_digest) + @@cache_key_digest = key_digest + end + + def perform_caching? + !cache_store.nil? + end + end + + module Backend + # TODO Should the cache be cleared if new translations are stored? + module Cache + def translate(locale, key, options = EMPTY_HASH) + I18n.perform_caching? ? fetch(cache_key(locale, key, options)) { super } : super + end + + protected + + def fetch(cache_key, &block) + result = _fetch(cache_key, &block) + throw(:exception, result) if result.is_a?(MissingTranslation) + result = result.dup if result.frozen? rescue result + result + end + + def _fetch(cache_key, &block) + result = I18n.cache_store.read(cache_key) + return result unless result.nil? + result = catch(:exception, &block) + I18n.cache_store.write(cache_key, result) unless result.is_a?(Proc) + result + end + + def cache_key(locale, key, options) + # This assumes that only simple, native Ruby values are passed to I18n.translate. + "i18n/#{I18n.cache_namespace}/#{locale}/#{digest_item(key)}/#{USE_INSPECT_HASH ? digest_item(options.inspect) : digest_item(options)}" + end + + private + # In Ruby < 1.9 the following is true: { :foo => 1, :bar => 2 }.hash == { :foo => 2, :bar => 1 }.hash + # Therefore we must use the hash of the inspect string instead to avoid cache key colisions. + USE_INSPECT_HASH = RUBY_VERSION <= "1.9" + + def digest_item(key) + I18n.cache_key_digest ? I18n.cache_key_digest.hexdigest(key.to_s) : key.hash + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/cascade.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/cascade.rb new file mode 100644 index 0000000000..782b07b594 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/cascade.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +# The Cascade module adds the ability to do cascading lookups to backends that +# are compatible to the Simple backend. +# +# By cascading lookups we mean that for any key that can not be found the +# Cascade module strips one segment off the scope part of the key and then +# tries to look up the key in that scope. +# +# E.g. when a lookup for the key :"foo.bar.baz" does not yield a result then +# the segment :bar will be stripped off the scope part :"foo.bar" and the new +# scope :foo will be used to look up the key :baz. If that does not succeed +# then the remaining scope segment :foo will be omitted, too, and again the +# key :baz will be looked up (now with no scope). +# +# To enable a cascading lookup one passes the :cascade option: +# +# I18n.t(:'foo.bar.baz', :cascade => true) +# +# This will return the first translation found for :"foo.bar.baz", :"foo.baz" +# or :baz in this order. +# +# The cascading lookup takes precedence over resolving any given defaults. +# I.e. defaults will kick in after the cascading lookups haven't succeeded. +# +# This behavior is useful for libraries like ActiveRecord validations where +# the library wants to give users a bunch of more or less fine-grained options +# of scopes for a particular key. +# +# Thanks to Clemens Kofler for the initial idea and implementation! See +# http://github.com/clemens/i18n-cascading-backend + +module I18n + module Backend + module Cascade + def lookup(locale, key, scope = [], options = EMPTY_HASH) + return super unless cascade = options[:cascade] + + cascade = { :step => 1 } unless cascade.is_a?(Hash) + step = cascade[:step] || 1 + offset = cascade[:offset] || 1 + separator = options[:separator] || I18n.default_separator + skip_root = cascade.has_key?(:skip_root) ? cascade[:skip_root] : true + + scope = I18n.normalize_keys(nil, key, scope, separator) + key = (scope.slice!(-offset, offset) || []).join(separator) + + begin + result = super + return result unless result.nil? + scope = scope.dup + end while (!scope.empty? || !skip_root) && scope.slice!(-step, step) + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/chain.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/chain.rb new file mode 100644 index 0000000000..2bc83cb736 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/chain.rb @@ -0,0 +1,99 @@ +# frozen_string_literal: true + +module I18n + module Backend + # Backend that chains multiple other backends and checks each of them when + # a translation needs to be looked up. This is useful when you want to use + # standard translations with a Simple backend but store custom application + # translations in a database or other backends. + # + # To use the Chain backend instantiate it and set it to the I18n module. + # You can add chained backends through the initializer or backends + # accessor: + # + # # preserves the existing Simple backend set to I18n.backend + # I18n.backend = I18n::Backend::Chain.new(I18n::Backend::ActiveRecord.new, I18n.backend) + # + # The implementation assumes that all backends added to the Chain implement + # a lookup method with the same API as Simple backend does. + class Chain + module Implementation + include Base + + attr_accessor :backends + + def initialize(*backends) + self.backends = backends + end + + def reload! + backends.each { |backend| backend.reload! } + end + + def store_translations(locale, data, options = EMPTY_HASH) + backends.first.store_translations(locale, data, options) + end + + def available_locales + backends.map { |backend| backend.available_locales }.flatten.uniq + end + + def translate(locale, key, default_options = EMPTY_HASH) + namespace = nil + options = default_options.except(:default) + + backends.each do |backend| + catch(:exception) do + options = default_options if backend == backends.last + translation = backend.translate(locale, key, options) + if namespace_lookup?(translation, options) + namespace = _deep_merge(translation, namespace || {}) + elsif !translation.nil? || (options.key?(:default) && options[:default].nil?) + return translation + end + end + end + + return namespace if namespace + throw(:exception, I18n::MissingTranslation.new(locale, key, options)) + end + + def exists?(locale, key) + backends.any? do |backend| + backend.exists?(locale, key) + end + end + + def localize(locale, object, format = :default, options = EMPTY_HASH) + backends.each do |backend| + catch(:exception) do + result = backend.localize(locale, object, format, options) and return result + end + end + throw(:exception, I18n::MissingTranslation.new(locale, format, options)) + end + + protected + def namespace_lookup?(result, options) + result.is_a?(Hash) && !options.has_key?(:count) + end + + private + # This is approximately what gets used in ActiveSupport. + # However since we are not guaranteed to run in an ActiveSupport context + # it is wise to have our own copy. We underscore it + # to not pollute the namespace of the including class. + def _deep_merge(hash, other_hash) + copy = hash.dup + other_hash.each_pair do |k,v| + value_from_other = hash[k] + copy[k] = value_from_other.is_a?(Hash) && v.is_a?(Hash) ? _deep_merge(value_from_other, v) : v + end + copy + end + end + + include Implementation + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/fallbacks.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/fallbacks.rb new file mode 100644 index 0000000000..7355d19299 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/fallbacks.rb @@ -0,0 +1,84 @@ +# frozen_string_literal: true + +# I18n locale fallbacks are useful when you want your application to use +# translations from other locales when translations for the current locale are +# missing. E.g. you might want to use :en translations when translations in +# your applications main locale :de are missing. +# +# To enable locale fallbacks you can simply include the Fallbacks module to +# the Simple backend - or whatever other backend you are using: +# +# I18n::Backend::Simple.include(I18n::Backend::Fallbacks) +module I18n + @@fallbacks = nil + + class << self + # Returns the current fallbacks implementation. Defaults to +I18n::Locale::Fallbacks+. + def fallbacks + @@fallbacks ||= I18n::Locale::Fallbacks.new + end + + # Sets the current fallbacks implementation. Use this to set a different fallbacks implementation. + def fallbacks=(fallbacks) + @@fallbacks = fallbacks + end + end + + module Backend + module Fallbacks + # Overwrites the Base backend translate method so that it will try each + # locale given by I18n.fallbacks for the given locale. E.g. for the + # locale :"de-DE" it might try the locales :"de-DE", :de and :en + # (depends on the fallbacks implementation) until it finds a result with + # the given options. If it does not find any result for any of the + # locales it will then throw MissingTranslation as usual. + # + # The default option takes precedence over fallback locales only when + # it's a Symbol. When the default contains a String, Proc or Hash + # it is evaluated last after all the fallback locales have been tried. + def translate(locale, key, options = EMPTY_HASH) + return super unless options.fetch(:fallback, true) + return super if options[:fallback_in_progress] + default = extract_non_symbol_default!(options) if options[:default] + + fallback_options = options.merge(:fallback_in_progress => true) + I18n.fallbacks[locale].each do |fallback| + begin + catch(:exception) do + result = super(fallback, key, fallback_options) + return result unless result.nil? + end + rescue I18n::InvalidLocale + # we do nothing when the locale is invalid, as this is a fallback anyways. + end + end + + return if options.key?(:default) && options[:default].nil? + + return super(locale, nil, options.merge(:default => default)) if default + throw(:exception, I18n::MissingTranslation.new(locale, key, options)) + end + + def extract_non_symbol_default!(options) + defaults = [options[:default]].flatten + first_non_symbol_default = defaults.detect{|default| !default.is_a?(Symbol)} + if first_non_symbol_default + options[:default] = defaults[0, defaults.index(first_non_symbol_default)] + end + return first_non_symbol_default + end + + def exists?(locale, key) + I18n.fallbacks[locale].each do |fallback| + begin + return true if super(fallback, key) + rescue I18n::InvalidLocale + # we do nothing when the locale is invalid, as this is a fallback anyways. + end + end + + false + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/flatten.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/flatten.rb new file mode 100644 index 0000000000..f2ce3a0d36 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/flatten.rb @@ -0,0 +1,115 @@ +# frozen_string_literal: true + +module I18n + module Backend + # This module contains several helpers to assist flattening translations. + # You may want to flatten translations for: + # + # 1) speed up lookups, as in the Memoize backend; + # 2) In case you want to store translations in a data store, as in ActiveRecord backend; + # + # You can check both backends above for some examples. + # This module also keeps all links in a hash so they can be properly resolved when flattened. + module Flatten + SEPARATOR_ESCAPE_CHAR = "\001" + FLATTEN_SEPARATOR = "." + + # normalize_keys the flatten way. This method is significantly faster + # and creates way less objects than the one at I18n.normalize_keys. + # It also handles escaping the translation keys. + def self.normalize_flat_keys(locale, key, scope, separator) + keys = [scope, key].flatten.compact + separator ||= I18n.default_separator + + if separator != FLATTEN_SEPARATOR + keys.map! do |k| + k.to_s.tr("#{FLATTEN_SEPARATOR}#{separator}", + "#{SEPARATOR_ESCAPE_CHAR}#{FLATTEN_SEPARATOR}") + end + end + + keys.join(".") + end + + # Receives a string and escape the default separator. + def self.escape_default_separator(key) #:nodoc: + key.to_s.tr(FLATTEN_SEPARATOR, SEPARATOR_ESCAPE_CHAR) + end + + # Shortcut to I18n::Backend::Flatten.normalize_flat_keys + # and then resolve_links. + def normalize_flat_keys(locale, key, scope, separator) + key = I18n::Backend::Flatten.normalize_flat_keys(locale, key, scope, separator) + resolve_link(locale, key) + end + + # Store flattened links. + def links + @links ||= I18n.new_double_nested_cache + end + + # Flatten keys for nested Hashes by chaining up keys: + # + # >> { "a" => { "b" => { "c" => "d", "e" => "f" }, "g" => "h" }, "i" => "j"}.wind + # => { "a.b.c" => "d", "a.b.e" => "f", "a.g" => "h", "i" => "j" } + # + def flatten_keys(hash, escape, prev_key=nil, &block) + hash.each_pair do |key, value| + key = escape_default_separator(key) if escape + curr_key = [prev_key, key].compact.join(FLATTEN_SEPARATOR).to_sym + yield curr_key, value + flatten_keys(value, escape, curr_key, &block) if value.is_a?(Hash) + end + end + + # Receives a hash of translations (where the key is a locale and + # the value is another hash) and return a hash with all + # translations flattened. + # + # Nested hashes are included in the flattened hash just if subtree + # is true and Symbols are automatically stored as links. + def flatten_translations(locale, data, escape, subtree) + hash = {} + flatten_keys(data, escape) do |key, value| + if value.is_a?(Hash) + hash[key] = value if subtree + else + store_link(locale, key, value) if value.is_a?(Symbol) + hash[key] = value + end + end + hash + end + + protected + + def store_link(locale, key, link) + links[locale.to_sym][key.to_s] = link.to_s + end + + def resolve_link(locale, key) + key, locale = key.to_s, locale.to_sym + links = self.links[locale] + + if links.key?(key) + links[key] + elsif link = find_link(locale, key) + store_link(locale, key, key.gsub(*link)) + else + key + end + end + + def find_link(locale, key) #:nodoc: + links[locale].each_pair do |from, to| + return [from, to] if key[0, from.length] == from + end && nil + end + + def escape_default_separator(key) #:nodoc: + I18n::Backend::Flatten.escape_default_separator(key) + end + + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/gettext.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/gettext.rb new file mode 100644 index 0000000000..ea2b6a3c9f --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/gettext.rb @@ -0,0 +1,83 @@ +# frozen_string_literal: true + +require 'i18n/gettext' +require 'i18n/gettext/po_parser' + +module I18n + module Backend + # Experimental support for using Gettext po files to store translations. + # + # To use this you can simply include the module to the Simple backend - or + # whatever other backend you are using. + # + # I18n::Backend::Simple.include(I18n::Backend::Gettext) + # + # Now you should be able to include your Gettext translation (*.po) files to + # the +I18n.load_path+ so they're loaded to the backend and you can use them as + # usual: + # + # I18n.load_path += Dir["path/to/locales/*.po"] + # + # Following the Gettext convention this implementation expects that your + # translation files are named by their locales. E.g. the file en.po would + # contain the translations for the English locale. + # + # To translate text you must use one of the translate methods provided by + # I18n::Gettext::Helpers. + # + # include I18n::Gettext::Helpers + # puts _("some string") + # + # Without it strings containing periods (".") will not be translated. + + module Gettext + class PoData < Hash + def set_comment(msgid_or_sym, comment) + # ignore + end + end + + protected + def load_po(filename) + locale = ::File.basename(filename, '.po').to_sym + data = normalize(locale, parse(filename)) + { locale => data } + end + + def parse(filename) + GetText::PoParser.new.parse(::File.read(filename), PoData.new) + end + + def normalize(locale, data) + data.inject({}) do |result, (key, value)| + unless key.nil? || key.empty? + key = key.gsub(I18n::Gettext::CONTEXT_SEPARATOR, '|') + key, value = normalize_pluralization(locale, key, value) if key.index("\000") + + parts = key.split('|').reverse + normalized = parts.inject({}) do |_normalized, part| + { part => _normalized.empty? ? value : _normalized } + end + + result.deep_merge!(normalized) + end + result + end + end + + def normalize_pluralization(locale, key, value) + # FIXME po_parser includes \000 chars that can not be turned into Symbols + key = key.gsub("\000", I18n::Gettext::PLURAL_SEPARATOR).split(I18n::Gettext::PLURAL_SEPARATOR).first + + keys = I18n::Gettext.plural_keys(locale) + values = value.split("\000") + raise "invalid number of plurals: #{values.size}, keys: #{keys.inspect} on #{locale} locale for msgid #{key.inspect} with values #{values.inspect}" if values.size != keys.size + + result = {} + values.each_with_index { |_value, ix| result[keys[ix]] = _value } + [key, result] + end + + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/interpolation_compiler.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/interpolation_compiler.rb new file mode 100644 index 0000000000..8b52e7b3e9 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/interpolation_compiler.rb @@ -0,0 +1,123 @@ +# frozen_string_literal: true + +# The InterpolationCompiler module contains optimizations that can tremendously +# speed up the interpolation process on the Simple backend. +# +# It works by defining a pre-compiled method on stored translation Strings that +# already bring all the knowledge about contained interpolation variables etc. +# so that the actual recurring interpolation will be very fast. +# +# To enable pre-compiled interpolations you can simply include the +# InterpolationCompiler module to the Simple backend: +# +# I18n::Backend::Simple.include(I18n::Backend::InterpolationCompiler) +# +# Note that InterpolationCompiler does not yield meaningful results and consequently +# should not be used with Ruby 1.9 (YARV) but improves performance everywhere else +# (jRuby, Rubinius). +module I18n + module Backend + module InterpolationCompiler + module Compiler + extend self + + TOKENIZER = /(%%\{[^\}]+\}|%\{[^\}]+\})/ + INTERPOLATION_SYNTAX_PATTERN = /(%)?(%\{([^\}]+)\})/ + + def compile_if_an_interpolation(string) + if interpolated_str?(string) + string.instance_eval <<-RUBY_EVAL, __FILE__, __LINE__ + def i18n_interpolate(v = {}) + "#{compiled_interpolation_body(string)}" + end + RUBY_EVAL + end + + string + end + + def interpolated_str?(str) + str.kind_of?(::String) && str =~ INTERPOLATION_SYNTAX_PATTERN + end + + protected + # tokenize("foo %{bar} baz %%{buz}") # => ["foo ", "%{bar}", " baz ", "%%{buz}"] + def tokenize(str) + str.split(TOKENIZER) + end + + def compiled_interpolation_body(str) + tokenize(str).map do |token| + (matchdata = token.match(INTERPOLATION_SYNTAX_PATTERN)) ? handle_interpolation_token(token, matchdata) : escape_plain_str(token) + end.join + end + + def handle_interpolation_token(interpolation, matchdata) + escaped, pattern, key = matchdata.values_at(1, 2, 3) + escaped ? pattern : compile_interpolation_token(key.to_sym) + end + + def compile_interpolation_token(key) + "\#{#{interpolate_or_raise_missing(key)}}" + end + + def interpolate_or_raise_missing(key) + escaped_key = escape_key_sym(key) + RESERVED_KEYS.include?(key) ? reserved_key(escaped_key) : interpolate_key(escaped_key) + end + + def interpolate_key(key) + [direct_key(key), nil_key(key), missing_key(key)].join('||') + end + + def direct_key(key) + "((t = v[#{key}]) && t.respond_to?(:call) ? t.call : t)" + end + + def nil_key(key) + "(v.has_key?(#{key}) && '')" + end + + def missing_key(key) + "I18n.config.missing_interpolation_argument_handler.call(#{key}, v, self)" + end + + def reserved_key(key) + "raise(ReservedInterpolationKey.new(#{key}, self))" + end + + def escape_plain_str(str) + str.gsub(/"|\\|#/) {|x| "\\#{x}"} + end + + def escape_key_sym(key) + # rely on Ruby to do all the hard work :) + key.to_sym.inspect + end + end + + def interpolate(locale, string, values) + if string.respond_to?(:i18n_interpolate) + string.i18n_interpolate(values) + elsif values + super + else + string + end + end + + def store_translations(locale, data, options = EMPTY_HASH) + compile_all_strings_in(data) + super + end + + protected + def compile_all_strings_in(data) + data.each_value do |value| + Compiler.compile_if_an_interpolation(value) + compile_all_strings_in(value) if value.kind_of?(Hash) + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/key_value.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/key_value.rb new file mode 100644 index 0000000000..1d0e0611e7 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/key_value.rb @@ -0,0 +1,180 @@ +# frozen_string_literal: true + +require 'i18n/backend/base' + +module I18n + + begin + require 'oj' + class JSON + class << self + def encode(value) + Oj::Rails.encode(value) + end + def decode(value) + Oj.load(value) + end + end + end + rescue LoadError + require 'active_support/json' + JSON = ActiveSupport::JSON + end + + module Backend + # This is a basic backend for key value stores. It receives on + # initialization the store, which should respond to three methods: + # + # * store#[](key) - Used to get a value + # * store#[]=(key, value) - Used to set a value + # * store#keys - Used to get all keys + # + # Since these stores only supports string, all values are converted + # to JSON before being stored, allowing it to also store booleans, + # hashes and arrays. However, this store does not support Procs. + # + # As the ActiveRecord backend, Symbols are just supported when loading + # translations from the filesystem or through explicit store translations. + # + # Also, avoid calling I18n.available_locales since it's a somehow + # expensive operation in most stores. + # + # == Example + # + # To setup I18n to use TokyoCabinet in memory is quite straightforward: + # + # require 'rufus/tokyo/cabinet' # gem install rufus-tokyo + # I18n.backend = I18n::Backend::KeyValue.new(Rufus::Tokyo::Cabinet.new('*')) + # + # == Performance + # + # You may make this backend even faster by including the Memoize module. + # However, notice that you should properly clear the cache if you change + # values directly in the key-store. + # + # == Subtrees + # + # In most backends, you are allowed to retrieve part of a translation tree: + # + # I18n.backend.store_translations :en, :foo => { :bar => :baz } + # I18n.t "foo" #=> { :bar => :baz } + # + # This backend supports this feature by default, but it slows down the storage + # of new data considerably and makes hard to delete entries. That said, you are + # allowed to disable the storage of subtrees on initialization: + # + # I18n::Backend::KeyValue.new(@store, false) + # + # This is useful if you are using a KeyValue backend chained to a Simple backend. + class KeyValue + module Implementation + attr_accessor :store + + include Base, Flatten + + def initialize(store, subtrees=true) + @store, @subtrees = store, subtrees + end + + def store_translations(locale, data, options = EMPTY_HASH) + escape = options.fetch(:escape, true) + flatten_translations(locale, data, escape, @subtrees).each do |key, value| + key = "#{locale}.#{key}" + + case value + when Hash + if @subtrees && (old_value = @store[key]) + old_value = JSON.decode(old_value) + value = old_value.deep_symbolize_keys.deep_merge!(value) if old_value.is_a?(Hash) + end + when Proc + raise "Key-value stores cannot handle procs" + end + + @store[key] = JSON.encode(value) unless value.is_a?(Symbol) + end + end + + def available_locales + locales = @store.keys.map { |k| k =~ /\./; $` } + locales.uniq! + locales.compact! + locales.map! { |k| k.to_sym } + locales + end + + protected + + def subtrees? + @subtrees + end + + def lookup(locale, key, scope = [], options = EMPTY_HASH) + key = normalize_flat_keys(locale, key, scope, options[:separator]) + value = @store["#{locale}.#{key}"] + value = JSON.decode(value) if value + + if value.is_a?(Hash) + value.deep_symbolize_keys + elsif !value.nil? + value + elsif !@subtrees + SubtreeProxy.new("#{locale}.#{key}", @store) + end + end + + def pluralize(locale, entry, count) + if subtrees? + super + else + return entry unless entry.is_a?(Hash) + key = pluralization_key(entry, count) + entry[key] + end + end + end + + class SubtreeProxy + def initialize(master_key, store) + @master_key = master_key + @store = store + @subtree = nil + end + + def has_key?(key) + @subtree && @subtree.has_key?(key) || self[key] + end + + def [](key) + unless @subtree && value = @subtree[key] + value = @store["#{@master_key}.#{key}"] + if value + value = JSON.decode(value) + (@subtree ||= {})[key] = value + end + end + value + end + + def is_a?(klass) + Hash == klass || super + end + alias :kind_of? :is_a? + + def instance_of?(klass) + Hash == klass || super + end + + def nil? + @subtree.nil? + end + + def inspect + @subtree.inspect + end + end + + include Implementation + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/memoize.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/memoize.rb new file mode 100644 index 0000000000..1aa1feb2f3 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/memoize.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +# Memoize module simply memoizes the values returned by lookup using +# a flat hash and can tremendously speed up the lookup process in a backend. +# +# To enable it you can simply include the Memoize module to your backend: +# +# I18n::Backend::Simple.include(I18n::Backend::Memoize) +# +# Notice that it's the responsibility of the backend to define whenever the +# cache should be cleaned. +module I18n + module Backend + module Memoize + def available_locales + @memoized_locales ||= super + end + + def store_translations(locale, data, options = EMPTY_HASH) + reset_memoizations!(locale) + super + end + + def reload! + reset_memoizations! + super + end + + protected + + def lookup(locale, key, scope = nil, options = EMPTY_HASH) + flat_key = I18n::Backend::Flatten.normalize_flat_keys(locale, + key, scope, options[:separator]).to_sym + flat_hash = memoized_lookup[locale.to_sym] + flat_hash.key?(flat_key) ? flat_hash[flat_key] : (flat_hash[flat_key] = super) + end + + def memoized_lookup + @memoized_lookup ||= I18n.new_double_nested_cache + end + + def reset_memoizations!(locale=nil) + @memoized_locales = nil + (locale ? memoized_lookup[locale.to_sym] : memoized_lookup).clear + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/metadata.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/metadata.rb new file mode 100644 index 0000000000..51ea7a2a88 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/metadata.rb @@ -0,0 +1,71 @@ +# frozen_string_literal: true + +# I18n translation metadata is useful when you want to access information +# about how a translation was looked up, pluralized or interpolated in +# your application. +# +# msg = I18n.t(:message, :default => 'Hi!', :scope => :foo) +# msg.translation_metadata +# # => { :key => :message, :scope => :foo, :default => 'Hi!' } +# +# If a :count option was passed to #translate it will be set to the metadata. +# Likewise, if any interpolation variables were passed they will also be set. +# +# To enable translation metadata you can simply include the Metadata module +# into the Simple backend class - or whatever other backend you are using: +# +# I18n::Backend::Simple.include(I18n::Backend::Metadata) +# +module I18n + module Backend + module Metadata + class << self + def included(base) + Object.class_eval do + def translation_metadata + unless self.frozen? + @translation_metadata ||= {} + else + {} + end + end + + def translation_metadata=(translation_metadata) + @translation_metadata = translation_metadata unless self.frozen? + end + end unless Object.method_defined?(:translation_metadata) + end + end + + def translate(locale, key, options = EMPTY_HASH) + metadata = { + :locale => locale, + :key => key, + :scope => options[:scope], + :default => options[:default], + :separator => options[:separator], + :values => options.reject { |name, _value| RESERVED_KEYS.include?(name) } + } + with_metadata(metadata) { super } + end + + def interpolate(locale, entry, values = EMPTY_HASH) + metadata = entry.translation_metadata.merge(:original => entry) + with_metadata(metadata) { super } + end + + def pluralize(locale, entry, count) + with_metadata(:count => count) { super } + end + + protected + + def with_metadata(metadata, &block) + result = yield + result.translation_metadata = result.translation_metadata.merge(metadata) if result + result + end + + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/pluralization.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/pluralization.rb new file mode 100644 index 0000000000..a0a2f56520 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/pluralization.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +# I18n Pluralization are useful when you want your application to +# customize pluralization rules. +# +# To enable locale specific pluralizations you can simply include the +# Pluralization module to the Simple backend - or whatever other backend you +# are using. +# +# I18n::Backend::Simple.include(I18n::Backend::Pluralization) +# +# You also need to make sure to provide pluralization algorithms to the +# backend, i.e. include them to your I18n.load_path accordingly. +module I18n + module Backend + module Pluralization + # Overwrites the Base backend translate method so that it will check the + # translation meta data space (:i18n) for a locale specific pluralization + # rule and use it to pluralize the given entry. I.e. the library expects + # pluralization rules to be stored at I18n.t(:'i18n.plural.rule') + # + # Pluralization rules are expected to respond to #call(count) and + # return a pluralization key. Valid keys depend on the translation data + # hash (entry) but it is generally recommended to follow CLDR's style, + # i.e., return one of the keys :zero, :one, :few, :many, :other. + # + # The :zero key is always picked directly when count equals 0 AND the + # translation data has the key :zero. This way translators are free to + # either pick a special :zero translation even for languages where the + # pluralizer does not return a :zero key. + def pluralize(locale, entry, count) + return entry unless entry.is_a?(Hash) and count + + pluralizer = pluralizer(locale) + if pluralizer.respond_to?(:call) + key = count == 0 && entry.has_key?(:zero) ? :zero : pluralizer.call(count) + raise InvalidPluralizationData.new(entry, count, key) unless entry.has_key?(key) + entry[key] + else + super + end + end + + protected + + def pluralizers + @pluralizers ||= {} + end + + def pluralizer(locale) + pluralizers[locale] ||= I18n.t(:'i18n.plural.rule', :locale => locale, :resolve => false) + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/simple.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/simple.rb new file mode 100644 index 0000000000..48aeaf48a0 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/simple.rb @@ -0,0 +1,95 @@ +# frozen_string_literal: true + +module I18n + module Backend + # A simple backend that reads translations from YAML files and stores them in + # an in-memory hash. Relies on the Base backend. + # + # The implementation is provided by a Implementation module allowing to easily + # extend Simple backend's behavior by including modules. E.g.: + # + # module I18n::Backend::Pluralization + # def pluralize(*args) + # # extended pluralization logic + # super + # end + # end + # + # I18n::Backend::Simple.include(I18n::Backend::Pluralization) + class Simple + (class << self; self; end).class_eval { public :include } + + module Implementation + include Base + + def initialized? + @initialized ||= false + end + + # Stores translations for the given locale in memory. + # This uses a deep merge for the translations hash, so existing + # translations will be overwritten by new ones only at the deepest + # level of the hash. + def store_translations(locale, data, options = EMPTY_HASH) + if I18n.enforce_available_locales && + I18n.available_locales_initialized? && + !I18n.available_locales.include?(locale.to_sym) && + !I18n.available_locales.include?(locale.to_s) + return data + end + locale = locale.to_sym + translations[locale] ||= {} + data = data.deep_symbolize_keys + translations[locale].deep_merge!(data) + end + + # Get available locales from the translations hash + def available_locales + init_translations unless initialized? + translations.inject([]) do |locales, (locale, data)| + locales << locale unless data.size <= 1 && (data.empty? || data.has_key?(:i18n)) + locales + end + end + + # Clean up translations hash and set initialized to false on reload! + def reload! + @initialized = false + @translations = nil + super + end + + protected + + def init_translations + load_translations + @initialized = true + end + + def translations + @translations ||= {} + end + + # Looks up a translation from the translations hash. Returns nil if + # either key is nil, or locale, scope or key do not exist as a key in the + # nested translations hash. Splits keys or scopes containing dots + # into multiple keys, i.e. currency.format is regarded the same as + # %w(currency format). + def lookup(locale, key, scope = [], options = EMPTY_HASH) + init_translations unless initialized? + keys = I18n.normalize_keys(locale, key, scope, options[:separator]) + + keys.inject(translations) do |result, _key| + _key = _key.to_sym + return nil unless result.is_a?(Hash) && result.has_key?(_key) + result = result[_key] + result = resolve(locale, _key, result, options.merge(:scope => nil)) if result.is_a?(Symbol) + result + end + end + end + + include Implementation + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/transliterator.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/transliterator.rb new file mode 100644 index 0000000000..bb704ab7a0 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/backend/transliterator.rb @@ -0,0 +1,108 @@ +# encoding: utf-8 +# frozen_string_literal: true + +module I18n + module Backend + module Transliterator + DEFAULT_REPLACEMENT_CHAR = "?" + + # Given a locale and a UTF-8 string, return the locale's ASCII + # approximation for the string. + def transliterate(locale, string, replacement = nil) + @transliterators ||= {} + @transliterators[locale] ||= Transliterator.get I18n.t(:'i18n.transliterate.rule', + :locale => locale, :resolve => false, :default => {}) + @transliterators[locale].transliterate(string, replacement) + end + + # Get a transliterator instance. + def self.get(rule = nil) + if !rule || rule.kind_of?(Hash) + HashTransliterator.new(rule) + elsif rule.kind_of? Proc + ProcTransliterator.new(rule) + else + raise I18n::ArgumentError, "Transliteration rule must be a proc or a hash." + end + end + + # A transliterator which accepts a Proc as its transliteration rule. + class ProcTransliterator + def initialize(rule) + @rule = rule + end + + def transliterate(string, replacement = nil) + @rule.call(string) + end + end + + # A transliterator which accepts a Hash of characters as its translation + # rule. + class HashTransliterator + DEFAULT_APPROXIMATIONS = { + "À"=>"A", "Á"=>"A", "Â"=>"A", "Ã"=>"A", "Ä"=>"A", "Å"=>"A", "Æ"=>"AE", + "Ç"=>"C", "È"=>"E", "É"=>"E", "Ê"=>"E", "Ë"=>"E", "Ì"=>"I", "Í"=>"I", + "Î"=>"I", "Ï"=>"I", "Ð"=>"D", "Ñ"=>"N", "Ò"=>"O", "Ó"=>"O", "Ô"=>"O", + "Õ"=>"O", "Ö"=>"O", "×"=>"x", "Ø"=>"O", "Ù"=>"U", "Ú"=>"U", "Û"=>"U", + "Ü"=>"U", "Ý"=>"Y", "Þ"=>"Th", "ß"=>"ss", "à"=>"a", "á"=>"a", "â"=>"a", + "ã"=>"a", "ä"=>"a", "å"=>"a", "æ"=>"ae", "ç"=>"c", "è"=>"e", "é"=>"e", + "ê"=>"e", "ë"=>"e", "ì"=>"i", "í"=>"i", "î"=>"i", "ï"=>"i", "ð"=>"d", + "ñ"=>"n", "ò"=>"o", "ó"=>"o", "ô"=>"o", "õ"=>"o", "ö"=>"o", "ø"=>"o", + "ù"=>"u", "ú"=>"u", "û"=>"u", "ü"=>"u", "ý"=>"y", "þ"=>"th", "ÿ"=>"y", + "Ā"=>"A", "ā"=>"a", "Ă"=>"A", "ă"=>"a", "Ą"=>"A", "ą"=>"a", "Ć"=>"C", + "ć"=>"c", "Ĉ"=>"C", "ĉ"=>"c", "Ċ"=>"C", "ċ"=>"c", "Č"=>"C", "č"=>"c", + "Ď"=>"D", "ď"=>"d", "Đ"=>"D", "đ"=>"d", "Ē"=>"E", "ē"=>"e", "Ĕ"=>"E", + "ĕ"=>"e", "Ė"=>"E", "ė"=>"e", "Ę"=>"E", "ę"=>"e", "Ě"=>"E", "ě"=>"e", + "Ĝ"=>"G", "ĝ"=>"g", "Ğ"=>"G", "ğ"=>"g", "Ġ"=>"G", "ġ"=>"g", "Ģ"=>"G", + "ģ"=>"g", "Ĥ"=>"H", "ĥ"=>"h", "Ħ"=>"H", "ħ"=>"h", "Ĩ"=>"I", "ĩ"=>"i", + "Ī"=>"I", "ī"=>"i", "Ĭ"=>"I", "ĭ"=>"i", "Į"=>"I", "į"=>"i", "İ"=>"I", + "ı"=>"i", "IJ"=>"IJ", "ij"=>"ij", "Ĵ"=>"J", "ĵ"=>"j", "Ķ"=>"K", "ķ"=>"k", + "ĸ"=>"k", "Ĺ"=>"L", "ĺ"=>"l", "Ļ"=>"L", "ļ"=>"l", "Ľ"=>"L", "ľ"=>"l", + "Ŀ"=>"L", "ŀ"=>"l", "Ł"=>"L", "ł"=>"l", "Ń"=>"N", "ń"=>"n", "Ņ"=>"N", + "ņ"=>"n", "Ň"=>"N", "ň"=>"n", "ʼn"=>"'n", "Ŋ"=>"NG", "ŋ"=>"ng", + "Ō"=>"O", "ō"=>"o", "Ŏ"=>"O", "ŏ"=>"o", "Ő"=>"O", "ő"=>"o", "Œ"=>"OE", + "œ"=>"oe", "Ŕ"=>"R", "ŕ"=>"r", "Ŗ"=>"R", "ŗ"=>"r", "Ř"=>"R", "ř"=>"r", + "Ś"=>"S", "ś"=>"s", "Ŝ"=>"S", "ŝ"=>"s", "Ş"=>"S", "ş"=>"s", "Š"=>"S", + "š"=>"s", "Ţ"=>"T", "ţ"=>"t", "Ť"=>"T", "ť"=>"t", "Ŧ"=>"T", "ŧ"=>"t", + "Ũ"=>"U", "ũ"=>"u", "Ū"=>"U", "ū"=>"u", "Ŭ"=>"U", "ŭ"=>"u", "Ů"=>"U", + "ů"=>"u", "Ű"=>"U", "ű"=>"u", "Ų"=>"U", "ų"=>"u", "Ŵ"=>"W", "ŵ"=>"w", + "Ŷ"=>"Y", "ŷ"=>"y", "Ÿ"=>"Y", "Ź"=>"Z", "ź"=>"z", "Ż"=>"Z", "ż"=>"z", + "Ž"=>"Z", "ž"=>"z" + }.freeze + + def initialize(rule = nil) + @rule = rule + add_default_approximations + add rule if rule + end + + def transliterate(string, replacement = nil) + replacement ||= DEFAULT_REPLACEMENT_CHAR + string.gsub(/[^\x00-\x7f]/u) do |char| + approximations[char] || replacement + end + end + + private + + def approximations + @approximations ||= {} + end + + def add_default_approximations + DEFAULT_APPROXIMATIONS.each do |key, value| + approximations[key] = value + end + end + + # Add transliteration rules to the approximations hash. + def add(hash) + hash.each do |key, value| + approximations[key.to_s] = value.to_s + end + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/config.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/config.rb new file mode 100644 index 0000000000..9c4221c731 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/config.rb @@ -0,0 +1,149 @@ +# frozen_string_literal: true + +require 'set' + +module I18n + class Config + # The only configuration value that is not global and scoped to thread is :locale. + # It defaults to the default_locale. + def locale + defined?(@locale) && @locale ? @locale : default_locale + end + + # Sets the current locale pseudo-globally, i.e. in the Thread.current hash. + def locale=(locale) + I18n.enforce_available_locales!(locale) + @locale = locale && locale.to_sym + end + + # Returns the current backend. Defaults to +Backend::Simple+. + def backend + @@backend ||= Backend::Simple.new + end + + # Sets the current backend. Used to set a custom backend. + def backend=(backend) + @@backend = backend + end + + # Returns the current default locale. Defaults to :'en' + def default_locale + @@default_locale ||= :en + end + + # Sets the current default locale. Used to set a custom default locale. + def default_locale=(locale) + I18n.enforce_available_locales!(locale) + @@default_locale = locale && locale.to_sym + end + + # Returns an array of locales for which translations are available. + # Unless you explicitely set these through I18n.available_locales= + # the call will be delegated to the backend. + def available_locales + @@available_locales ||= nil + @@available_locales || backend.available_locales + end + + # Caches the available locales list as both strings and symbols in a Set, so + # that we can have faster lookups to do the available locales enforce check. + def available_locales_set #:nodoc: + @@available_locales_set ||= available_locales.inject(Set.new) do |set, locale| + set << locale.to_s << locale.to_sym + end + end + + # Sets the available locales. + def available_locales=(locales) + @@available_locales = Array(locales).map { |locale| locale.to_sym } + @@available_locales = nil if @@available_locales.empty? + @@available_locales_set = nil + end + + # Returns true if the available_locales have been initialized + def available_locales_initialized? + ( !!defined?(@@available_locales) && !!@@available_locales ) + end + + # Clears the available locales set so it can be recomputed again after I18n + # gets reloaded. + def clear_available_locales_set #:nodoc: + @@available_locales_set = nil + end + + # Returns the current default scope separator. Defaults to '.' + def default_separator + @@default_separator ||= '.' + end + + # Sets the current default scope separator. + def default_separator=(separator) + @@default_separator = separator + end + + # Returns the current exception handler. Defaults to an instance of + # I18n::ExceptionHandler. + def exception_handler + @@exception_handler ||= ExceptionHandler.new + end + + # Sets the exception handler. + def exception_handler=(exception_handler) + @@exception_handler = exception_handler + end + + # Returns the current handler for situations when interpolation argument + # is missing. MissingInterpolationArgument will be raised by default. + def missing_interpolation_argument_handler + @@missing_interpolation_argument_handler ||= lambda do |missing_key, provided_hash, string| + raise MissingInterpolationArgument.new(missing_key, provided_hash, string) + end + end + + # Sets the missing interpolation argument handler. It can be any + # object that responds to #call. The arguments that will be passed to #call + # are the same as for MissingInterpolationArgument initializer. Use +Proc.new+ + # if you don't care about arity. + # + # == Example: + # You can supress raising an exception and return string instead: + # + # I18n.config.missing_interpolation_argument_handler = Proc.new do |key| + # "#{key} is missing" + # end + def missing_interpolation_argument_handler=(exception_handler) + @@missing_interpolation_argument_handler = exception_handler + end + + # Allow clients to register paths providing translation data sources. The + # backend defines acceptable sources. + # + # E.g. the provided SimpleBackend accepts a list of paths to translation + # files which are either named *.rb and contain plain Ruby Hashes or are + # named *.yml and contain YAML data. So for the SimpleBackend clients may + # register translation files like this: + # I18n.load_path << 'path/to/locale/en.yml' + def load_path + @@load_path ||= [] + end + + # Sets the load path instance. Custom implementations are expected to + # behave like a Ruby Array. + def load_path=(load_path) + @@load_path = load_path + @@available_locales_set = nil + backend.reload! + end + + # Whether or not to verify if locales are in the list of available locales. + # Defaults to true. + @@enforce_available_locales = true + def enforce_available_locales + @@enforce_available_locales + end + + def enforce_available_locales=(enforce_available_locales) + @@enforce_available_locales = enforce_available_locales + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/exceptions.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/exceptions.rb new file mode 100644 index 0000000000..a9d59dd60b --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/exceptions.rb @@ -0,0 +1,97 @@ +# frozen_string_literal: true + +require 'cgi' + +module I18n + class ExceptionHandler + def call(exception, _locale, _key, _options) + if exception.is_a?(MissingTranslation) + exception.message + else + raise exception + end + end + end + + class ArgumentError < ::ArgumentError; end + + class InvalidLocale < ArgumentError + attr_reader :locale + def initialize(locale) + @locale = locale + super "#{locale.inspect} is not a valid locale" + end + end + + class InvalidLocaleData < ArgumentError + attr_reader :filename + def initialize(filename, exception_message) + @filename, @exception_message = filename, exception_message + super "can not load translations from #{filename}: #{exception_message}" + end + end + + class MissingTranslation < ArgumentError + module Base + attr_reader :locale, :key, :options + + def initialize(locale, key, options = EMPTY_HASH) + @key, @locale, @options = key, locale, options.dup + options.each { |k, v| self.options[k] = v.inspect if v.is_a?(Proc) } + end + + def keys + @keys ||= I18n.normalize_keys(locale, key, options[:scope]).tap do |keys| + keys << 'no key' if keys.size < 2 + end + end + + def message + "translation missing: #{keys.join('.')}" + end + alias :to_s :message + + def to_exception + MissingTranslationData.new(locale, key, options) + end + end + + include Base + end + + class MissingTranslationData < ArgumentError + include MissingTranslation::Base + end + + class InvalidPluralizationData < ArgumentError + attr_reader :entry, :count, :key + def initialize(entry, count, key) + @entry, @count, @key = entry, count, key + super "translation data #{entry.inspect} can not be used with :count => #{count}. key '#{key}' is missing." + end + end + + class MissingInterpolationArgument < ArgumentError + attr_reader :key, :values, :string + def initialize(key, values, string) + @key, @values, @string = key, values, string + super "missing interpolation argument #{key.inspect} in #{string.inspect} (#{values.inspect} given)" + end + end + + class ReservedInterpolationKey < ArgumentError + attr_reader :key, :string + def initialize(key, string) + @key, @string = key, string + super "reserved key #{key.inspect} used in #{string.inspect}" + end + end + + class UnknownFileType < ArgumentError + attr_reader :type, :filename + def initialize(type, filename) + @type, @filename = type, filename + super "can not load translations from #{filename}, the file type #{type} is not known" + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/interpolate/ruby.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/interpolate/ruby.rb new file mode 100644 index 0000000000..d2fdda75ec --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/interpolate/ruby.rb @@ -0,0 +1,37 @@ +# heavily based on Masao Mutoh's gettext String interpolation extension +# http://github.com/mutoh/gettext/blob/f6566738b981fe0952548c421042ad1e0cdfb31e/lib/gettext/core_ext/string.rb + +module I18n + INTERPOLATION_PATTERN = Regexp.union( + /%%/, + /%\{(\w+)\}/, # matches placeholders like "%{foo}" + /%<(\w+)>(.*?\d*\.?\d*[bBdiouxXeEfgGcps])/ # matches placeholders like "%.d" + ) + + class << self + # Return String or raises MissingInterpolationArgument exception. + # Missing argument's logic is handled by I18n.config.missing_interpolation_argument_handler. + def interpolate(string, values) + raise ReservedInterpolationKey.new($1.to_sym, string) if string =~ RESERVED_KEYS_PATTERN + raise ArgumentError.new('Interpolation values must be a Hash.') unless values.kind_of?(Hash) + interpolate_hash(string, values) + end + + def interpolate_hash(string, values) + string.gsub(INTERPOLATION_PATTERN) do |match| + if match == '%%' + '%' + else + key = ($1 || $2 || match.tr("%{}", "")).to_sym + value = if values.key?(key) + values[key] + else + config.missing_interpolation_argument_handler.call(key, values, string) + end + value = value.call(values) if value.respond_to?(:call) + $3 ? sprintf("%#{$3}", value) : value + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/version.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/version.rb new file mode 100644 index 0000000000..6491d1809b --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/version.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module I18n + VERSION = "1.1.0" +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/thread_safe-0.3.6/lib/thread_safe.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/thread_safe-0.3.6/lib/thread_safe.rb new file mode 100644 index 0000000000..5b8fb273cd --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/thread_safe-0.3.6/lib/thread_safe.rb @@ -0,0 +1,65 @@ +require 'thread_safe/version' +require 'thread_safe/synchronized_delegator' + +module ThreadSafe + autoload :Cache, 'thread_safe/cache' + autoload :Util, 'thread_safe/util' + + # Various classes within allows for +nil+ values to be stored, so a special +NULL+ token is required to indicate the "nil-ness". + NULL = Object.new + + if defined?(JRUBY_VERSION) + require 'jruby/synchronized' + + # A thread-safe subclass of Array. This version locks + # against the object itself for every method call, + # ensuring only one thread can be reading or writing + # at a time. This includes iteration methods like + # #each. + class Array < ::Array + include JRuby::Synchronized + end + + # A thread-safe subclass of Hash. This version locks + # against the object itself for every method call, + # ensuring only one thread can be reading or writing + # at a time. This includes iteration methods like + # #each. + class Hash < ::Hash + include JRuby::Synchronized + end + elsif !defined?(RUBY_ENGINE) || RUBY_ENGINE == 'ruby' + # Because MRI never runs code in parallel, the existing + # non-thread-safe structures should usually work fine. + Array = ::Array + Hash = ::Hash + elsif defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx' + require 'monitor' + + class Hash < ::Hash; end + class Array < ::Array; end + + [Hash, Array].each do |klass| + klass.class_eval do + private + def _mon_initialize + @_monitor = Monitor.new unless @_monitor # avoid double initialisation + end + + def self.allocate + obj = super + obj.send(:_mon_initialize) + obj + end + end + + klass.superclass.instance_methods(false).each do |method| + klass.class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1 + def #{method}(*args) + @_monitor.synchronize { super } + end + RUBY_EVAL + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/thread_safe-0.3.6/lib/thread_safe/cache.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/thread_safe-0.3.6/lib/thread_safe/cache.rb new file mode 100644 index 0000000000..265c0e5e33 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/thread_safe-0.3.6/lib/thread_safe/cache.rb @@ -0,0 +1,161 @@ +require 'thread' + +module ThreadSafe + autoload :JRubyCacheBackend, 'thread_safe/jruby_cache_backend' + autoload :MriCacheBackend, 'thread_safe/mri_cache_backend' + autoload :NonConcurrentCacheBackend, 'thread_safe/non_concurrent_cache_backend' + autoload :AtomicReferenceCacheBackend, 'thread_safe/atomic_reference_cache_backend' + autoload :SynchronizedCacheBackend, 'thread_safe/synchronized_cache_backend' + + ConcurrentCacheBackend = if defined?(RUBY_ENGINE) + case RUBY_ENGINE + when 'jruby'; JRubyCacheBackend + when 'ruby'; MriCacheBackend + when 'rbx'; AtomicReferenceCacheBackend + else + warn 'ThreadSafe: unsupported Ruby engine, using a fully synchronized ThreadSafe::Cache implementation' if $VERBOSE + SynchronizedCacheBackend + end + else + MriCacheBackend + end + + class Cache < ConcurrentCacheBackend + def initialize(options = nil, &block) + if options.kind_of?(::Hash) + validate_options_hash!(options) + else + options = nil + end + + super(options) + @default_proc = block + end + + def [](key) + if value = super # non-falsy value is an existing mapping, return it right away + value + # re-check is done with get_or_default(key, NULL) instead of a simple !key?(key) in order to avoid a race condition, whereby by the time the current thread gets to the key?(key) call + # a key => value mapping might have already been created by a different thread (key?(key) would then return true, this elsif branch wouldn't be taken and an incorrent +nil+ value + # would be returned) + # note: nil == value check is not technically necessary + elsif @default_proc && nil == value && NULL == (value = get_or_default(key, NULL)) + @default_proc.call(self, key) + else + value + end + end + + alias_method :get, :[] + alias_method :put, :[]= + + def fetch(key, default_value = NULL) + if NULL != (value = get_or_default(key, NULL)) + value + elsif block_given? + yield key + elsif NULL != default_value + default_value + else + raise_fetch_no_key + end + end + + def fetch_or_store(key, default_value = NULL) + fetch(key) do + put(key, block_given? ? yield(key) : (NULL == default_value ? raise_fetch_no_key : default_value)) + end + end + + def put_if_absent(key, value) + computed = false + result = compute_if_absent(key) do + computed = true + value + end + computed ? nil : result + end unless method_defined?(:put_if_absent) + + def value?(value) + each_value do |v| + return true if value.equal?(v) + end + false + end unless method_defined?(:value?) + + def keys + arr = [] + each_pair {|k, v| arr << k} + arr + end unless method_defined?(:keys) + + def values + arr = [] + each_pair {|k, v| arr << v} + arr + end unless method_defined?(:values) + + def each_key + each_pair {|k, v| yield k} + end unless method_defined?(:each_key) + + def each_value + each_pair {|k, v| yield v} + end unless method_defined?(:each_value) + + def key(value) + each_pair {|k, v| return k if v == value} + nil + end unless method_defined?(:key) + alias_method :index, :key if RUBY_VERSION < '1.9' + + def empty? + each_pair {|k, v| return false} + true + end unless method_defined?(:empty?) + + def size + count = 0 + each_pair {|k, v| count += 1} + count + end unless method_defined?(:size) + + def marshal_dump + raise TypeError, "can't dump hash with default proc" if @default_proc + h = {} + each_pair {|k, v| h[k] = v} + h + end + + def marshal_load(hash) + initialize + populate_from(hash) + end + + undef :freeze + + private + def raise_fetch_no_key + raise KeyError, 'key not found' + end + + def initialize_copy(other) + super + populate_from(other) + end + + def populate_from(hash) + hash.each_pair {|k, v| self[k] = v} + self + end + + def validate_options_hash!(options) + if (initial_capacity = options[:initial_capacity]) && (!initial_capacity.kind_of?(0.class) || initial_capacity < 0) + raise ArgumentError, ":initial_capacity must be a positive #{0.class}" + end + if (load_factor = options[:load_factor]) && (!load_factor.kind_of?(Numeric) || load_factor <= 0 || load_factor > 1) + raise ArgumentError, ":load_factor must be a number between 0 and 1" + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/thread_safe-0.3.6/lib/thread_safe/mri_cache_backend.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/thread_safe-0.3.6/lib/thread_safe/mri_cache_backend.rb new file mode 100644 index 0000000000..13e57b335a --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/thread_safe-0.3.6/lib/thread_safe/mri_cache_backend.rb @@ -0,0 +1,60 @@ +module ThreadSafe + class MriCacheBackend < NonConcurrentCacheBackend + # We can get away with a single global write lock (instead of a per-instance + # one) because of the GVL/green threads. + # + # NOTE: a neat idea of writing a c-ext to manually perform atomic + # put_if_absent, while relying on Ruby not releasing a GVL while calling a + # c-ext will not work because of the potentially Ruby implemented `#hash` + # and `#eql?` key methods. + WRITE_LOCK = Mutex.new + + def []=(key, value) + WRITE_LOCK.synchronize { super } + end + + def compute_if_absent(key) + if stored_value = _get(key) # fast non-blocking path for the most likely case + stored_value + else + WRITE_LOCK.synchronize { super } + end + end + + def compute_if_present(key) + WRITE_LOCK.synchronize { super } + end + + def compute(key) + WRITE_LOCK.synchronize { super } + end + + def merge_pair(key, value) + WRITE_LOCK.synchronize { super } + end + + def replace_pair(key, old_value, new_value) + WRITE_LOCK.synchronize { super } + end + + def replace_if_exists(key, new_value) + WRITE_LOCK.synchronize { super } + end + + def get_and_set(key, value) + WRITE_LOCK.synchronize { super } + end + + def delete(key) + WRITE_LOCK.synchronize { super } + end + + def delete_pair(key, value) + WRITE_LOCK.synchronize { super } + end + + def clear + WRITE_LOCK.synchronize { super } + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/thread_safe-0.3.6/lib/thread_safe/non_concurrent_cache_backend.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/thread_safe-0.3.6/lib/thread_safe/non_concurrent_cache_backend.rb new file mode 100644 index 0000000000..111ae63e58 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/thread_safe-0.3.6/lib/thread_safe/non_concurrent_cache_backend.rb @@ -0,0 +1,135 @@ +module ThreadSafe + class NonConcurrentCacheBackend + # WARNING: all public methods of the class must operate on the @backend + # directly without calling each other. This is important because of the + # SynchronizedCacheBackend which uses a non-reentrant mutex for perfomance + # reasons. + def initialize(options = nil) + @backend = {} + end + + def [](key) + @backend[key] + end + + def []=(key, value) + @backend[key] = value + end + + def compute_if_absent(key) + if NULL != (stored_value = @backend.fetch(key, NULL)) + stored_value + else + @backend[key] = yield + end + end + + def replace_pair(key, old_value, new_value) + if pair?(key, old_value) + @backend[key] = new_value + true + else + false + end + end + + def replace_if_exists(key, new_value) + if NULL != (stored_value = @backend.fetch(key, NULL)) + @backend[key] = new_value + stored_value + end + end + + def compute_if_present(key) + if NULL != (stored_value = @backend.fetch(key, NULL)) + store_computed_value(key, yield(stored_value)) + end + end + + def compute(key) + store_computed_value(key, yield(@backend[key])) + end + + def merge_pair(key, value) + if NULL == (stored_value = @backend.fetch(key, NULL)) + @backend[key] = value + else + store_computed_value(key, yield(stored_value)) + end + end + + def get_and_set(key, value) + stored_value = @backend[key] + @backend[key] = value + stored_value + end + + def key?(key) + @backend.key?(key) + end + + def value?(value) + @backend.value?(value) + end + + def delete(key) + @backend.delete(key) + end + + def delete_pair(key, value) + if pair?(key, value) + @backend.delete(key) + true + else + false + end + end + + def clear + @backend.clear + self + end + + def each_pair + dupped_backend.each_pair do |k, v| + yield k, v + end + self + end + + def size + @backend.size + end + + def get_or_default(key, default_value) + @backend.fetch(key, default_value) + end + + alias_method :_get, :[] + alias_method :_set, :[]= + private :_get, :_set + private + def initialize_copy(other) + super + @backend = {} + self + end + + def dupped_backend + @backend.dup + end + + def pair?(key, expected_value) + NULL != (stored_value = @backend.fetch(key, NULL)) && expected_value.equal?(stored_value) + end + + def store_computed_value(key, new_value) + if new_value.nil? + @backend.delete(key) + nil + else + @backend[key] = new_value + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/thread_safe-0.3.6/lib/thread_safe/synchronized_delegator.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/thread_safe-0.3.6/lib/thread_safe/synchronized_delegator.rb new file mode 100644 index 0000000000..2fc351d91e --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/thread_safe-0.3.6/lib/thread_safe/synchronized_delegator.rb @@ -0,0 +1,43 @@ +require 'delegate' +require 'monitor' + +# This class provides a trivial way to synchronize all calls to a given object +# by wrapping it with a `Delegator` that performs `Monitor#enter/exit` calls +# around the delegated `#send`. Example: +# +# array = [] # not thread-safe on many impls +# array = SynchronizedDelegator.new([]) # thread-safe +# +# A simple `Monitor` provides a very coarse-grained way to synchronize a given +# object, in that it will cause synchronization for methods that have no need +# for it, but this is a trivial way to get thread-safety where none may exist +# currently on some implementations. +# +# This class is currently being considered for inclusion into stdlib, via +# https://bugs.ruby-lang.org/issues/8556 +class SynchronizedDelegator < SimpleDelegator + def setup + @old_abort = Thread.abort_on_exception + Thread.abort_on_exception = true + end + + def teardown + Thread.abort_on_exception = @old_abort + end + + def initialize(obj) + __setobj__(obj) + @monitor = Monitor.new + end + + def method_missing(method, *args, &block) + monitor = @monitor + begin + monitor.enter + super + ensure + monitor.exit + end + end + +end unless defined?(SynchronizedDelegator) diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/thread_safe-0.3.6/lib/thread_safe/version.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/thread_safe-0.3.6/lib/thread_safe/version.rb new file mode 100644 index 0000000000..88821f6dc7 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/thread_safe-0.3.6/lib/thread_safe/version.rb @@ -0,0 +1,21 @@ +module ThreadSafe + VERSION = "0.3.6" +end + +# NOTE: <= 0.2.0 used Threadsafe::VERSION +# @private +module Threadsafe + + # @private + def self.const_missing(name) + name = name.to_sym + if ThreadSafe.const_defined?(name) + warn "[DEPRECATION] `Threadsafe::#{name}' is deprecated, use `ThreadSafe::#{name}' instead." + ThreadSafe.const_get(name) + else + warn "[DEPRECATION] the `Threadsafe' module is deprecated, please use `ThreadSafe` instead." + super + end + end + +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo.rb new file mode 100644 index 0000000000..0b64589bec --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo.rb @@ -0,0 +1,40 @@ +# Top level module for TZInfo. +module TZInfo +end + +require 'tzinfo/ruby_core_support' +require 'tzinfo/offset_rationals' +require 'tzinfo/time_or_datetime' + +require 'tzinfo/timezone_definition' + +require 'tzinfo/timezone_offset' +require 'tzinfo/timezone_transition' +require 'tzinfo/timezone_transition_definition' + +require 'tzinfo/timezone_index_definition' + +require 'tzinfo/timezone_info' +require 'tzinfo/data_timezone_info' +require 'tzinfo/linked_timezone_info' +require 'tzinfo/transition_data_timezone_info' +require 'tzinfo/zoneinfo_timezone_info' + +require 'tzinfo/data_source' +require 'tzinfo/ruby_data_source' +require 'tzinfo/zoneinfo_data_source' + +require 'tzinfo/timezone_period' +require 'tzinfo/timezone' +require 'tzinfo/info_timezone' +require 'tzinfo/data_timezone' +require 'tzinfo/linked_timezone' +require 'tzinfo/timezone_proxy' + +require 'tzinfo/country_index_definition' +require 'tzinfo/country_info' +require 'tzinfo/ruby_country_info' +require 'tzinfo/zoneinfo_country_info' + +require 'tzinfo/country' +require 'tzinfo/country_timezone' diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/country.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/country.rb new file mode 100644 index 0000000000..0dccebd5c9 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/country.rb @@ -0,0 +1,196 @@ +require 'thread_safe' + +module TZInfo + # Raised by Country#get if the code given is not valid. + class InvalidCountryCode < StandardError + end + + # The Country class represents an ISO 3166-1 country. It can be used to + # obtain a list of Timezones for a country. For example: + # + # us = Country.get('US') + # us.zone_identifiers + # us.zones + # us.zone_info + # + # The Country class is thread-safe. It is safe to use class and instance + # methods of Country in concurrently executing threads. Instances of Country + # can be shared across thread boundaries. + # + # Country information available through TZInfo is intended as an aid for + # users, to help them select time zone data appropriate for their practical + # needs. It is not intended to take or endorse any position on legal or + # territorial claims. + class Country + include Comparable + + # Defined countries. + # + # @!visibility private + @@countries = nil + + # Whether the countries index has been loaded yet. + # + # @!visibility private + @@index_loaded = false + + # Gets a Country by its ISO 3166-1 alpha-2 code. Raises an + # InvalidCountryCode exception if it couldn't be found. + def self.get(identifier) + instance = @@countries[identifier] + + unless instance + # Thread-safety: It is possible that multiple equivalent Country + # instances could be created here in concurrently executing threads. + # The consequences of this are that the data may be loaded more than + # once (depending on the data source) and memoized calculations could + # be discarded. The performance benefit of ensuring that only a single + # instance is created is unlikely to be worth the overhead of only + # allowing one Country to be loaded at a time. + info = data_source.load_country_info(identifier) + instance = Country.new(info) + @@countries[identifier] = instance + end + + instance + end + + # If identifier is a CountryInfo object, initializes the Country instance, + # otherwise calls get(identifier). + def self.new(identifier) + if identifier.kind_of?(CountryInfo) + instance = super() + instance.send :setup, identifier + instance + else + get(identifier) + end + end + + # Returns an Array of all the valid country codes. + def self.all_codes + data_source.country_codes + end + + # Returns an Array of all the defined Countries. + def self.all + data_source.country_codes.collect {|code| get(code)} + end + + # The ISO 3166-1 alpha-2 country code. + def code + @info.code + end + + # The name of the country. + def name + @info.name + end + + # Alias for name. + def to_s + name + end + + # Returns internal object state as a programmer-readable string. + def inspect + "#<#{self.class}: #{@info.code}>" + end + + # Returns a frozen array of all the zone identifiers for the country. These + # are in an order that + # + # 1. makes some geographical sense, and + # 2. puts the most populous zones first, where that does not contradict 1. + # + # Returned zone identifiers may refer to cities and regions outside of the + # country. This will occur if the zone covers multiple countries. Any zones + # referring to a city or region in a different country will be listed after + # those relating to this country. + def zone_identifiers + @info.zone_identifiers + end + alias zone_names zone_identifiers + + # An array of all the Timezones for this country. Returns TimezoneProxy + # objects to avoid the overhead of loading Timezone definitions until + # a conversion is actually required. The Timezones are returned in an order + # that + # + # 1. makes some geographical sense, and + # 2. puts the most populous zones first, where that does not contradict 1. + # + # Identifiers of the zones returned may refer to cities and regions outside + # of the country. This will occur if the zone covers multiple countries. Any + # zones referring to a city or region in a different country will be listed + # after those relating to this country. + def zones + zone_identifiers.collect {|id| + Timezone.get_proxy(id) + } + end + + # Returns a frozen array of all the timezones for the for the country as + # CountryTimezone instances (containing extra information about each zone). + # These are in an order that + # + # 1. makes some geographical sense, and + # 2. puts the most populous zones first, where that does not contradict 1. + # + # Identifiers and descriptions of the zones returned may refer to cities and + # regions outside of the country. This will occur if the zone covers + # multiple countries. Any zones referring to a city or region in a different + # country will be listed after those relating to this country. + def zone_info + @info.zones + end + + # Compare two Countries based on their code. Returns -1 if c is less + # than self, 0 if c is equal to self and +1 if c is greater than self. + # + # Returns nil if c is not comparable with Country instances. + def <=>(c) + return nil unless c.is_a?(Country) + code <=> c.code + end + + # Returns true if and only if the code of c is equal to the code of this + # Country. + def eql?(c) + self == c + end + + # Returns a hash value for this Country. + def hash + code.hash + end + + # Dumps this Country for marshalling. + def _dump(limit) + code + end + + # Loads a marshalled Country. + def self._load(data) + Country.get(data) + end + + private + # Called by Country.new to initialize a new Country instance. The info + # parameter is a CountryInfo that defines the country. + def setup(info) + @info = info + end + + # Initializes @@countries. + def self.init_countries + @@countries = ThreadSafe::Cache.new + end + init_countries + + # Returns the current DataSource + def self.data_source + DataSource.get + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/country_index_definition.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/country_index_definition.rb new file mode 100644 index 0000000000..431790b3d1 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/country_index_definition.rb @@ -0,0 +1,31 @@ +module TZInfo + # The country index file includes CountryIndexDefinition which provides + # a country method used to define each country in the index. + # + # @private + module CountryIndexDefinition #:nodoc: + def self.append_features(base) + super + base.extend(ClassMethods) + base.instance_eval { @countries = {} } + end + + # Class methods for inclusion. + # + # @private + module ClassMethods #:nodoc: + # Defines a country with an ISO 3166 country code, name and block. The + # block will be evaluated to obtain all the timezones for the country. + # Calls Country.country_defined with the definition of each country. + def country(code, name, &block) + @countries[code] = RubyCountryInfo.new(code, name, &block) + end + + # Returns a frozen hash of all the countries that have been defined in + # the index. + def countries + @countries.freeze + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/country_info.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/country_info.rb new file mode 100644 index 0000000000..e9d71c7719 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/country_info.rb @@ -0,0 +1,42 @@ +module TZInfo + # Represents a country and references to its timezones as returned by a + # DataSource. + class CountryInfo + # The ISO 3166 country code. + attr_reader :code + + # The name of the country. + attr_reader :name + + # Constructs a new CountryInfo with an ISO 3166 country code and name + def initialize(code, name) + @code = code + @name = name + end + + # Returns internal object state as a programmer-readable string. + def inspect + "#<#{self.class}: #@code>" + end + + # Returns a frozen array of all the zone identifiers for the country. + # The identifiers are ordered by importance according to the DataSource. + def zone_identifiers + raise_not_implemented('zone_identifiers') + end + + # Returns a frozen array of all the timezones for the for the country as + # CountryTimezone instances. + # + # The timezones are ordered by importance according to the DataSource. + def zones + raise_not_implemented('zones') + end + + private + + def raise_not_implemented(method_name) + raise NotImplementedError, "Subclasses must override #{method_name}" + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/country_timezone.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/country_timezone.rb new file mode 100644 index 0000000000..d46bec0d05 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/country_timezone.rb @@ -0,0 +1,135 @@ +module TZInfo + # A Timezone within a Country. This contains extra information about the + # Timezone that is specific to the Country (a Timezone could be used by + # multiple countries). + class CountryTimezone + # The zone identifier. + attr_reader :identifier + + # A description of this timezone in relation to the country, e.g. + # "Eastern Time". This is usually nil for countries having only a single + # Timezone. + attr_reader :description + + class << self + # Creates a new CountryTimezone with a timezone identifier, latitude, + # longitude and description. The latitude and longitude are specified as + # rationals - a numerator and denominator. For performance reasons, the + # numerators and denominators must be specified in their lowest form. + # + # For use internally within TZInfo. + # + # @!visibility private + alias :new! :new + + # Creates a new CountryTimezone with a timezone identifier, latitude, + # longitude and description. The latitude and longitude must be specified + # as instances of Rational. + # + # CountryTimezone instances should normally only be constructed when + # creating new DataSource implementations. + def new(identifier, latitude, longitude, description = nil) + super(identifier, latitude, nil, longitude, nil, description) + end + end + + # Creates a new CountryTimezone with a timezone identifier, latitude, + # longitude and description. The latitude and longitude are specified as + # rationals - a numerator and denominator. For performance reasons, the + # numerators and denominators must be specified in their lowest form. + # + # @!visibility private + def initialize(identifier, latitude_numerator, latitude_denominator, + longitude_numerator, longitude_denominator, description = nil) #:nodoc: + @identifier = identifier + + if latitude_numerator.kind_of?(Rational) + @latitude = latitude_numerator + else + @latitude = nil + @latitude_numerator = latitude_numerator + @latitude_denominator = latitude_denominator + end + + if longitude_numerator.kind_of?(Rational) + @longitude = longitude_numerator + else + @longitude = nil + @longitude_numerator = longitude_numerator + @longitude_denominator = longitude_denominator + end + + @description = description + end + + # The Timezone (actually a TimezoneProxy for performance reasons). + def timezone + Timezone.get_proxy(@identifier) + end + + # if description is not nil, this method returns description; otherwise it + # returns timezone.friendly_identifier(true). + def description_or_friendly_identifier + description || timezone.friendly_identifier(true) + end + + # The latitude of this timezone in degrees as a Rational. + def latitude + # Thread-safety: It is possible that the value of @latitude may be + # calculated multiple times in concurrently executing threads. It is not + # worth the overhead of locking to ensure that @latitude is only + # calculated once. + unless @latitude + result = RubyCoreSupport.rational_new!(@latitude_numerator, @latitude_denominator) + return result if frozen? + @latitude = result + end + + @latitude + end + + # The longitude of this timezone in degrees as a Rational. + def longitude + # Thread-safety: It is possible that the value of @longitude may be + # calculated multiple times in concurrently executing threads. It is not + # worth the overhead of locking to ensure that @longitude is only + # calculated once. + unless @longitude + result = RubyCoreSupport.rational_new!(@longitude_numerator, @longitude_denominator) + return result if frozen? + @longitude = result + end + + @longitude + end + + # Returns true if and only if the given CountryTimezone is equal to the + # current CountryTimezone (has the same identifer, latitude, longitude + # and description). + def ==(ct) + ct.kind_of?(CountryTimezone) && + identifier == ct.identifier && latitude == ct.latitude && + longitude == ct.longitude && description == ct.description + end + + # Returns true if and only if the given CountryTimezone is equal to the + # current CountryTimezone (has the same identifer, latitude, longitude + # and description). + def eql?(ct) + self == ct + end + + # Returns a hash of this CountryTimezone. + def hash + @identifier.hash ^ + (@latitude ? @latitude.numerator.hash ^ @latitude.denominator.hash : @latitude_numerator.hash ^ @latitude_denominator.hash) ^ + (@longitude ? @longitude.numerator.hash ^ @longitude.denominator.hash : @longitude_numerator.hash ^ @longitude_denominator.hash) ^ + @description.hash + end + + # Returns internal object state as a programmer-readable string. + def inspect + "#<#{self.class}: #@identifier>" + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/data_source.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/data_source.rb new file mode 100644 index 0000000000..c7d4a11707 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/data_source.rb @@ -0,0 +1,190 @@ +require 'thread' + +module TZInfo + # InvalidDataSource is raised if the DataSource is used doesn't implement one + # of the required methods. + class InvalidDataSource < StandardError + end + + # DataSourceNotFound is raised if no data source could be found (i.e. + # if 'tzinfo/data' cannot be found on the load path and no valid zoneinfo + # directory can be found on the system). + class DataSourceNotFound < StandardError + end + + # The base class for data sources of timezone and country data. + # + # Use DataSource.set to change the data source being used. + class DataSource + # The currently selected data source. + @@instance = nil + + # Mutex used to ensure the default data source is only created once. + @@default_mutex = Mutex.new + + # Returns the currently selected DataSource instance. + def self.get + # If a DataSource hasn't been manually set when the first request is + # made to obtain a DataSource, then a Default data source is created. + + # This is done at the first request rather than when TZInfo is loaded to + # avoid unnecessary (or in some cases potentially harmful) attempts to + # find a suitable DataSource. + + # A Mutex is used to ensure that only a single default instance is + # created (having two different DataSources in use simultaneously could + # cause unexpected results). + + unless @@instance + @@default_mutex.synchronize do + set(create_default_data_source) unless @@instance + end + end + + @@instance + end + + # Sets the currently selected data source for Timezone and Country data. + # + # This should usually be set to one of the two standard data source types: + # + # * +:ruby+ - read data from the Ruby modules included in the TZInfo::Data + # library (tzinfo-data gem). + # * +:zoneinfo+ - read data from the zoneinfo files included with most + # Unix-like operating sytems (e.g. in /usr/share/zoneinfo). + # + # To set TZInfo to use one of the standard data source types, call + # \TZInfo::DataSource.set in one of the following ways: + # + # TZInfo::DataSource.set(:ruby) + # TZInfo::DataSource.set(:zoneinfo) + # TZInfo::DataSource.set(:zoneinfo, zoneinfo_dir) + # TZInfo::DataSource.set(:zoneinfo, zoneinfo_dir, iso3166_tab_file) + # + # \DataSource.set(:zoneinfo) will automatically search for the zoneinfo + # directory by checking the paths specified in + # ZoneinfoDataSource.search_paths. ZoneinfoDirectoryNotFound will be raised + # if no valid zoneinfo directory could be found. + # + # \DataSource.set(:zoneinfo, zoneinfo_dir) uses the specified zoneinfo + # directory as the data source. If the directory is not a valid zoneinfo + # directory, an InvalidZoneinfoDirectory exception will be raised. + # + # \DataSource.set(:zoneinfo, zoneinfo_dir, iso3166_tab_file) uses the + # specified zoneinfo directory as the data source, but loads the iso3166.tab + # file from an alternate path. If the directory is not a valid zoneinfo + # directory, an InvalidZoneinfoDirectory exception will be raised. + # + # Custom data sources can be created by subclassing TZInfo::DataSource and + # implementing the following methods: + # + # * \load_timezone_info + # * \timezone_identifiers + # * \data_timezone_identifiers + # * \linked_timezone_identifiers + # * \load_country_info + # * \country_codes + # + # To have TZInfo use the custom data source, call \DataSource.set + # as follows: + # + # TZInfo::DataSource.set(CustomDataSource.new) + # + # To avoid inconsistent data, \DataSource.set should be called before + # accessing any Timezone or Country data. + # + # If \DataSource.set is not called, TZInfo will by default use TZInfo::Data + # as the data source. If TZInfo::Data is not available (i.e. if require + # 'tzinfo/data' fails), then TZInfo will search for a zoneinfo directory + # instead (using the search path specified by + # TZInfo::ZoneinfoDataSource::DEFAULT_SEARCH_PATH). + def self.set(data_source_or_type, *args) + if data_source_or_type.kind_of?(DataSource) + @@instance = data_source_or_type + elsif data_source_or_type == :ruby + @@instance = RubyDataSource.new + elsif data_source_or_type == :zoneinfo + @@instance = ZoneinfoDataSource.new(*args) + else + raise ArgumentError, 'data_source_or_type must be a DataSource instance or a data source type (:ruby)' + end + end + + # Returns a TimezoneInfo instance for a given identifier. The TimezoneInfo + # instance should derive from either DataTimzoneInfo for timezones that + # define their own data or LinkedTimezoneInfo for links or aliases to + # other timezones. + # + # Raises InvalidTimezoneIdentifier if the timezone is not found or the + # identifier is invalid. + def load_timezone_info(identifier) + raise_invalid_data_source('load_timezone_info') + end + + # Returns an array of all the available timezone identifiers. + def timezone_identifiers + raise_invalid_data_source('timezone_identifiers') + end + + # Returns an array of all the available timezone identifiers for + # data timezones (i.e. those that actually contain definitions). + def data_timezone_identifiers + raise_invalid_data_source('data_timezone_identifiers') + end + + # Returns an array of all the available timezone identifiers that + # are links to other timezones. + def linked_timezone_identifiers + raise_invalid_data_source('linked_timezone_identifiers') + end + + # Returns a CountryInfo instance for the given ISO 3166-1 alpha-2 + # country code. Raises InvalidCountryCode if the country could not be found + # or the code is invalid. + def load_country_info(code) + raise_invalid_data_source('load_country_info') + end + + # Returns an array of all the available ISO 3166-1 alpha-2 + # country codes. + def country_codes + raise_invalid_data_source('country_codes') + end + + # Returns the name of this DataSource. + def to_s + "Default DataSource" + end + + # Returns internal object state as a programmer-readable string. + def inspect + "#<#{self.class}>" + end + + private + + # Creates a DataSource instance for use as the default. Used if + # no preference has been specified manually. + def self.create_default_data_source + has_tzinfo_data = false + + begin + require 'tzinfo/data' + has_tzinfo_data = true + rescue LoadError + end + + return RubyDataSource.new if has_tzinfo_data + + begin + return ZoneinfoDataSource.new + rescue ZoneinfoDirectoryNotFound + raise DataSourceNotFound, "No source of timezone data could be found.\nPlease refer to http://tzinfo.github.io/datasourcenotfound for help resolving this error." + end + end + + def raise_invalid_data_source(method_name) + raise InvalidDataSource, "#{method_name} not defined" + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/data_timezone.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/data_timezone.rb new file mode 100644 index 0000000000..94958c931c --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/data_timezone.rb @@ -0,0 +1,58 @@ +module TZInfo + + # A Timezone based on a DataTimezoneInfo. + # + # @private + class DataTimezone < InfoTimezone #:nodoc: + + # Returns the TimezonePeriod for the given UTC time. utc can either be + # a DateTime, Time or integer timestamp (Time.to_i). Any timezone + # information in utc is ignored (it is treated as a UTC time). + # + # If no TimezonePeriod could be found, PeriodNotFound is raised. + def period_for_utc(utc) + info.period_for_utc(utc) + end + + # Returns the set of TimezonePeriod instances that are valid for the given + # local time as an array. If you just want a single period, use + # period_for_local instead and specify how abiguities should be resolved. + # Raises PeriodNotFound if no periods are found for the given time. + def periods_for_local(local) + info.periods_for_local(local) + end + + # Returns an Array of TimezoneTransition instances representing the times + # where the UTC offset of the timezone changes. + # + # Transitions are returned up to a given date and time up to a given date + # and time, specified in UTC (utc_to). + # + # A from date and time may also be supplied using the utc_from parameter + # (also specified in UTC). If utc_from is not nil, only transitions from + # that date and time onwards will be returned. + # + # Comparisons with utc_to are exclusive. Comparisons with utc_from are + # inclusive. If a transition falls precisely on utc_to, it will be excluded. + # If a transition falls on utc_from, it will be included. + # + # Transitions returned are ordered by when they occur, from earliest to + # latest. + # + # utc_to and utc_from can be specified using either DateTime, Time or + # integer timestamps (Time.to_i). + # + # If utc_from is specified and utc_to is not greater than utc_from, then + # transitions_up_to raises an ArgumentError exception. + def transitions_up_to(utc_to, utc_from = nil) + info.transitions_up_to(utc_to, utc_from) + end + + # Returns the canonical zone for this Timezone. + # + # For a DataTimezone, this is always self. + def canonical_zone + self + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/data_timezone_info.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/data_timezone_info.rb new file mode 100644 index 0000000000..7d0fa5f371 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/data_timezone_info.rb @@ -0,0 +1,55 @@ +module TZInfo + # Represents a defined timezone containing transition data. + class DataTimezoneInfo < TimezoneInfo + + # Returns the TimezonePeriod for the given UTC time. + def period_for_utc(utc) + raise_not_implemented('period_for_utc') + end + + # Returns the set of TimezonePeriods for the given local time as an array. + # Results returned are ordered by increasing UTC start date. + # Returns an empty array if no periods are found for the given time. + def periods_for_local(local) + raise_not_implemented('periods_for_local') + end + + # Returns an Array of TimezoneTransition instances representing the times + # where the UTC offset of the timezone changes. + # + # Transitions are returned up to a given date and time up to a given date + # and time, specified in UTC (utc_to). + # + # A from date and time may also be supplied using the utc_from parameter + # (also specified in UTC). If utc_from is not nil, only transitions from + # that date and time onwards will be returned. + # + # Comparisons with utc_to are exclusive. Comparisons with utc_from are + # inclusive. If a transition falls precisely on utc_to, it will be excluded. + # If a transition falls on utc_from, it will be included. + # + # Transitions returned are ordered by when they occur, from earliest to + # latest. + # + # utc_to and utc_from can be specified using either DateTime, Time or + # integer timestamps (Time.to_i). + # + # If utc_from is specified and utc_to is not greater than utc_from, then + # transitions_up_to raises an ArgumentError exception. + def transitions_up_to(utc_to, utc_from = nil) + raise_not_implemented('transitions_up_to') + end + + # Constructs a Timezone instance for the timezone represented by this + # DataTimezoneInfo. + def create_timezone + DataTimezone.new(self) + end + + private + + def raise_not_implemented(method_name) + raise NotImplementedError, "Subclasses must override #{method_name}" + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/info_timezone.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/info_timezone.rb new file mode 100644 index 0000000000..4eb014be6a --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/info_timezone.rb @@ -0,0 +1,30 @@ +module TZInfo + + # A Timezone based on a TimezoneInfo. + # + # @private + class InfoTimezone < Timezone #:nodoc: + + # Constructs a new InfoTimezone with a TimezoneInfo instance. + def self.new(info) + tz = super() + tz.send(:setup, info) + tz + end + + # The identifier of the timezone, e.g. "Europe/Paris". + def identifier + @info.identifier + end + + protected + # The TimezoneInfo for this Timezone. + def info + @info + end + + def setup(info) + @info = info + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/linked_timezone.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/linked_timezone.rb new file mode 100644 index 0000000000..c4f4a0d4bb --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/linked_timezone.rb @@ -0,0 +1,63 @@ +module TZInfo + + # A Timezone based on a LinkedTimezoneInfo. + # + # @private + class LinkedTimezone < InfoTimezone #:nodoc: + # Returns the TimezonePeriod for the given UTC time. utc can either be + # a DateTime, Time or integer timestamp (Time.to_i). Any timezone + # information in utc is ignored (it is treated as a UTC time). + # + # If no TimezonePeriod could be found, PeriodNotFound is raised. + def period_for_utc(utc) + @linked_timezone.period_for_utc(utc) + end + + # Returns the set of TimezonePeriod instances that are valid for the given + # local time as an array. If you just want a single period, use + # period_for_local instead and specify how abiguities should be resolved. + # Raises PeriodNotFound if no periods are found for the given time. + def periods_for_local(local) + @linked_timezone.periods_for_local(local) + end + + # Returns an Array of TimezoneTransition instances representing the times + # where the UTC offset of the timezone changes. + # + # Transitions are returned up to a given date and time up to a given date + # and time, specified in UTC (utc_to). + # + # A from date and time may also be supplied using the utc_from parameter + # (also specified in UTC). If utc_from is not nil, only transitions from + # that date and time onwards will be returned. + # + # Comparisons with utc_to are exclusive. Comparisons with utc_from are + # inclusive. If a transition falls precisely on utc_to, it will be excluded. + # If a transition falls on utc_from, it will be included. + # + # Transitions returned are ordered by when they occur, from earliest to + # latest. + # + # utc_to and utc_from can be specified using either DateTime, Time or + # integer timestamps (Time.to_i). + # + # If utc_from is specified and utc_to is not greater than utc_from, then + # transitions_up_to raises an ArgumentError exception. + def transitions_up_to(utc_to, utc_from = nil) + @linked_timezone.transitions_up_to(utc_to, utc_from) + end + + # Returns the canonical zone for this Timezone. + # + # For a LinkedTimezone, this is the canonical zone of the link target. + def canonical_zone + @linked_timezone.canonical_zone + end + + protected + def setup(info) + super(info) + @linked_timezone = Timezone.get(info.link_to_identifier) + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/linked_timezone_info.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/linked_timezone_info.rb new file mode 100644 index 0000000000..f7961d5596 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/linked_timezone_info.rb @@ -0,0 +1,26 @@ +module TZInfo + # Represents a timezone that is defined as a link or alias to another zone. + class LinkedTimezoneInfo < TimezoneInfo + + # The zone that provides the data (that this zone is an alias for). + attr_reader :link_to_identifier + + # Constructs a new LinkedTimezoneInfo with an identifier and the identifier + # of the zone linked to. + def initialize(identifier, link_to_identifier) + super(identifier) + @link_to_identifier = link_to_identifier + end + + # Returns internal object state as a programmer-readable string. + def inspect + "#<#{self.class}: #@identifier,#@link_to_identifier>" + end + + # Constructs a Timezone instance for the timezone represented by this + # DataTimezoneInfo. + def create_timezone + LinkedTimezone.new(self) + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/offset_rationals.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/offset_rationals.rb new file mode 100644 index 0000000000..2a50a08767 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/offset_rationals.rb @@ -0,0 +1,77 @@ +require 'rational' unless defined?(Rational) + +module TZInfo + + # Provides a method for getting Rationals for a timezone offset in seconds. + # Pre-reduced rationals are returned for all the half-hour intervals between + # -14 and +14 hours to avoid having to call gcd at runtime. + # + # @private + module OffsetRationals #:nodoc: + @@rational_cache = { + -50400 => RubyCoreSupport.rational_new!(-7,12), + -48600 => RubyCoreSupport.rational_new!(-9,16), + -46800 => RubyCoreSupport.rational_new!(-13,24), + -45000 => RubyCoreSupport.rational_new!(-25,48), + -43200 => RubyCoreSupport.rational_new!(-1,2), + -41400 => RubyCoreSupport.rational_new!(-23,48), + -39600 => RubyCoreSupport.rational_new!(-11,24), + -37800 => RubyCoreSupport.rational_new!(-7,16), + -36000 => RubyCoreSupport.rational_new!(-5,12), + -34200 => RubyCoreSupport.rational_new!(-19,48), + -32400 => RubyCoreSupport.rational_new!(-3,8), + -30600 => RubyCoreSupport.rational_new!(-17,48), + -28800 => RubyCoreSupport.rational_new!(-1,3), + -27000 => RubyCoreSupport.rational_new!(-5,16), + -25200 => RubyCoreSupport.rational_new!(-7,24), + -23400 => RubyCoreSupport.rational_new!(-13,48), + -21600 => RubyCoreSupport.rational_new!(-1,4), + -19800 => RubyCoreSupport.rational_new!(-11,48), + -18000 => RubyCoreSupport.rational_new!(-5,24), + -16200 => RubyCoreSupport.rational_new!(-3,16), + -14400 => RubyCoreSupport.rational_new!(-1,6), + -12600 => RubyCoreSupport.rational_new!(-7,48), + -10800 => RubyCoreSupport.rational_new!(-1,8), + -9000 => RubyCoreSupport.rational_new!(-5,48), + -7200 => RubyCoreSupport.rational_new!(-1,12), + -5400 => RubyCoreSupport.rational_new!(-1,16), + -3600 => RubyCoreSupport.rational_new!(-1,24), + -1800 => RubyCoreSupport.rational_new!(-1,48), + 0 => RubyCoreSupport.rational_new!(0,1), + 1800 => RubyCoreSupport.rational_new!(1,48), + 3600 => RubyCoreSupport.rational_new!(1,24), + 5400 => RubyCoreSupport.rational_new!(1,16), + 7200 => RubyCoreSupport.rational_new!(1,12), + 9000 => RubyCoreSupport.rational_new!(5,48), + 10800 => RubyCoreSupport.rational_new!(1,8), + 12600 => RubyCoreSupport.rational_new!(7,48), + 14400 => RubyCoreSupport.rational_new!(1,6), + 16200 => RubyCoreSupport.rational_new!(3,16), + 18000 => RubyCoreSupport.rational_new!(5,24), + 19800 => RubyCoreSupport.rational_new!(11,48), + 21600 => RubyCoreSupport.rational_new!(1,4), + 23400 => RubyCoreSupport.rational_new!(13,48), + 25200 => RubyCoreSupport.rational_new!(7,24), + 27000 => RubyCoreSupport.rational_new!(5,16), + 28800 => RubyCoreSupport.rational_new!(1,3), + 30600 => RubyCoreSupport.rational_new!(17,48), + 32400 => RubyCoreSupport.rational_new!(3,8), + 34200 => RubyCoreSupport.rational_new!(19,48), + 36000 => RubyCoreSupport.rational_new!(5,12), + 37800 => RubyCoreSupport.rational_new!(7,16), + 39600 => RubyCoreSupport.rational_new!(11,24), + 41400 => RubyCoreSupport.rational_new!(23,48), + 43200 => RubyCoreSupport.rational_new!(1,2), + 45000 => RubyCoreSupport.rational_new!(25,48), + 46800 => RubyCoreSupport.rational_new!(13,24), + 48600 => RubyCoreSupport.rational_new!(9,16), + 50400 => RubyCoreSupport.rational_new!(7,12)}.freeze + + # Returns a Rational expressing the fraction of a day that offset in + # seconds represents (i.e. equivalent to Rational(offset, 86400)). + def rational_for_offset(offset) + @@rational_cache[offset] || Rational(offset, 86400) + end + module_function :rational_for_offset + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/ruby_core_support.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/ruby_core_support.rb new file mode 100644 index 0000000000..c97819e11e --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/ruby_core_support.rb @@ -0,0 +1,146 @@ +require 'date' +require 'rational' unless defined?(Rational) + +module TZInfo + + # Methods to support different versions of Ruby. + # + # @private + module RubyCoreSupport #:nodoc: + + # Use Rational.new! for performance reasons in Ruby 1.8. + # This has been removed from 1.9, but Rational performs better. + if Rational.respond_to? :new! + def self.rational_new!(numerator, denominator = 1) + Rational.new!(numerator, denominator) + end + else + def self.rational_new!(numerator, denominator = 1) + Rational(numerator, denominator) + end + end + + # Ruby 1.8.6 introduced new! and deprecated new0. + # Ruby 1.9.0 removed new0. + # Ruby trunk revision 31668 removed the new! method. + # Still support new0 for better performance on older versions of Ruby (new0 indicates + # that the rational has already been reduced to its lowest terms). + # Fallback to jd with conversion from ajd if new! and new0 are unavailable. + if DateTime.respond_to? :new! + def self.datetime_new!(ajd = 0, of = 0, sg = Date::ITALY) + DateTime.new!(ajd, of, sg) + end + elsif DateTime.respond_to? :new0 + def self.datetime_new!(ajd = 0, of = 0, sg = Date::ITALY) + DateTime.new0(ajd, of, sg) + end + else + HALF_DAYS_IN_DAY = rational_new!(1, 2) + + def self.datetime_new!(ajd = 0, of = 0, sg = Date::ITALY) + # Convert from an Astronomical Julian Day number to a civil Julian Day number. + jd = ajd + of + HALF_DAYS_IN_DAY + + # Ruby trunk revision 31862 changed the behaviour of DateTime.jd so that it will no + # longer accept a fractional civil Julian Day number if further arguments are specified. + # Calculate the hours, minutes and seconds to pass to jd. + + jd_i = jd.to_i + jd_i -= 1 if jd < 0 + hours = (jd - jd_i) * 24 + hours_i = hours.to_i + minutes = (hours - hours_i) * 60 + minutes_i = minutes.to_i + seconds = (minutes - minutes_i) * 60 + + DateTime.jd(jd_i, hours_i, minutes_i, seconds, of, sg) + end + end + + # DateTime in Ruby 1.8.6 doesn't consider times within the 60th second to be + # valid. When attempting to specify such a DateTime, subtract the fractional + # part and then add it back later + if Date.respond_to?(:valid_time?) && !Date.valid_time?(0, 0, rational_new!(59001, 1000)) # 0:0:59.001 + def self.datetime_new(y=-4712, m=1, d=1, h=0, min=0, s=0, of=0, sg=Date::ITALY) + if !s.kind_of?(Integer) && s > 59 + dt = DateTime.new(y, m, d, h, min, 59, of, sg) + dt + (s - 59) / 86400 + else + DateTime.new(y, m, d, h, min, s, of, sg) + end + end + else + def self.datetime_new(y=-4712, m=1, d=1, h=0, min=0, s=0, of=0, sg=Date::ITALY) + DateTime.new(y, m, d, h, min, s, of, sg) + end + end + + # Returns true if Time on the runtime platform supports Times defined + # by negative 32-bit timestamps, otherwise false. + begin + Time.at(-1) + Time.at(-2147483648) + + def self.time_supports_negative + true + end + rescue ArgumentError + def self.time_supports_negative + false + end + end + + # Returns true if Time on the runtime platform supports Times defined by + # 64-bit timestamps, otherwise false. + begin + Time.at(-2147483649) + Time.at(2147483648) + + def self.time_supports_64bit + true + end + rescue RangeError + def self.time_supports_64bit + false + end + end + + # Return the result of Time#nsec if it exists, otherwise return the + # result of Time#usec * 1000. + if Time.method_defined?(:nsec) + def self.time_nsec(time) + time.nsec + end + else + def self.time_nsec(time) + time.usec * 1000 + end + end + + # Call String#force_encoding if this version of Ruby has encoding support + # otherwise treat as a no-op. + if String.method_defined?(:force_encoding) + def self.force_encoding(str, encoding) + str.force_encoding(encoding) + end + else + def self.force_encoding(str, encoding) + str + end + end + + + # Wrapper for File.open that supports passing hash options for specifying + # encodings on Ruby 1.9+. The options are ignored on earlier versions of + # Ruby. + if RUBY_VERSION =~ /\A1\.[0-8]\./ + def self.open_file(file_name, mode, opts, &block) + File.open(file_name, mode, &block) + end + else + def self.open_file(file_name, mode, opts, &block) + File.open(file_name, mode, opts, &block) + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/ruby_country_info.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/ruby_country_info.rb new file mode 100644 index 0000000000..e51915d628 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/ruby_country_info.rb @@ -0,0 +1,74 @@ +module TZInfo + # Represents information about a country returned by RubyDataSource. + # + # @private + class RubyCountryInfo < CountryInfo #:nodoc: + # Constructs a new CountryInfo with an ISO 3166 country code, name and + # block. The block will be evaluated to obtain the timezones for the + # country when the zones are first needed. + def initialize(code, name, &block) + super(code, name) + @block = block + @zones = nil + @zone_identifiers = nil + end + + # Returns a frozen array of all the zone identifiers for the country. These + # are in the order they were added using the timezone method. + def zone_identifiers + # Thread-safety: It is possible that the value of @zone_identifiers may be + # calculated multiple times in concurrently executing threads. It is not + # worth the overhead of locking to ensure that @zone_identifiers is only + # calculated once. + + unless @zone_identifiers + result = zones.collect {|zone| zone.identifier}.freeze + return result if frozen? + @zone_identifiers = result + end + + @zone_identifiers + end + + # Returns a frozen array of all the timezones for the for the country as + # CountryTimezone instances. These are in the order they were added using + # the timezone method. + def zones + # Thread-safety: It is possible that the value of @zones may be + # calculated multiple times in concurrently executing threads. It is not + # worth the overhead of locking to ensure that @zones is only + # calculated once. + + unless @zones + zones = Zones.new + @block.call(zones) if @block + result = zones.list.freeze + return result if frozen? + @block = nil + @zones = result + end + + @zones + end + + # An instance of the Zones class is passed to the block used to define + # timezones. + # + # @private + class Zones #:nodoc: + attr_reader :list + + def initialize + @list = [] + end + + # Called by the index data to define a timezone for the country. + def timezone(identifier, latitude_numerator, latitude_denominator, + longitude_numerator, longitude_denominator, description = nil) + @list << CountryTimezone.new!(identifier, latitude_numerator, + latitude_denominator, longitude_numerator, longitude_denominator, + description) + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/ruby_data_source.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/ruby_data_source.rb new file mode 100644 index 0000000000..2635c26465 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/ruby_data_source.rb @@ -0,0 +1,136 @@ +module TZInfo + # A DataSource that loads data from the set of Ruby modules included in the + # TZInfo::Data library (tzinfo-data gem). + # + # To have TZInfo use this DataSource, call TZInfo::DataSource.set as follows: + # + # TZInfo::DataSource.set(:ruby) + class RubyDataSource < DataSource + # Base path for require. + REQUIRE_PATH = File.join('tzinfo', 'data', 'definitions') + + # Whether the timezone index has been loaded yet. + @@timezone_index_loaded = false + + # Whether the country index has been loaded yet. + @@country_index_loaded = false + + # Returns a TimezoneInfo instance for a given identifier. + # Raises InvalidTimezoneIdentifier if the timezone is not found or the + # identifier is invalid. + def load_timezone_info(identifier) + raise InvalidTimezoneIdentifier, 'Invalid identifier' if identifier !~ /^[A-Za-z0-9\+\-_]+(\/[A-Za-z0-9\+\-_]+)*$/ + + identifier = identifier.gsub(/-/, '__m__').gsub(/\+/, '__p__') + + # Untaint identifier after it has been reassigned to a new string. We + # don't want to modify the original identifier. identifier may also be + # frozen and therefore cannot be untainted. + identifier.untaint + + identifier = identifier.split('/') + begin + require_definition(identifier) + + m = Data::Definitions + identifier.each {|part| + m = m.const_get(part) + } + + m.get + rescue LoadError, NameError => e + raise InvalidTimezoneIdentifier, e.message + end + end + + # Returns an array of all the available timezone identifiers. + def timezone_identifiers + load_timezone_index + Data::Indexes::Timezones.timezones + end + + # Returns an array of all the available timezone identifiers for + # data timezones (i.e. those that actually contain definitions). + def data_timezone_identifiers + load_timezone_index + Data::Indexes::Timezones.data_timezones + end + + # Returns an array of all the available timezone identifiers that + # are links to other timezones. + def linked_timezone_identifiers + load_timezone_index + Data::Indexes::Timezones.linked_timezones + end + + # Returns a CountryInfo instance for the given ISO 3166-1 alpha-2 + # country code. Raises InvalidCountryCode if the country could not be found + # or the code is invalid. + def load_country_info(code) + load_country_index + info = Data::Indexes::Countries.countries[code] + raise InvalidCountryCode, 'Invalid country code' unless info + info + end + + # Returns an array of all the available ISO 3166-1 alpha-2 + # country codes. + def country_codes + load_country_index + Data::Indexes::Countries.countries.keys.freeze + end + + # Returns the name of this DataSource. + def to_s + "Ruby DataSource" + end + + private + + # Requires a zone definition by its identifier (split on /). + def require_definition(identifier) + require_data(*(['definitions'] + identifier)) + end + + # Requires an index by its name. + def self.require_index(name) + require_data(*['indexes', name]) + end + + # Requires a file from tzinfo/data. + def require_data(*file) + self.class.require_data(*file) + end + + # Requires a file from tzinfo/data. + def self.require_data(*file) + require File.join('tzinfo', 'data', *file) + end + + # Loads in the index of timezones if it hasn't already been loaded. + def load_timezone_index + self.class.load_timezone_index + end + + # Loads in the index of timezones if it hasn't already been loaded. + def self.load_timezone_index + unless @@timezone_index_loaded + require_index('timezones') + @@timezone_index_loaded = true + end + end + + # Loads in the index of countries if it hasn't already been loaded. + def load_country_index + self.class.load_country_index + end + + # Loads in the index of countries if it hasn't already been loaded. + def self.load_country_index + unless @@country_index_loaded + require_index('countries') + @@country_index_loaded = true + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/time_or_datetime.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/time_or_datetime.rb new file mode 100644 index 0000000000..f358005f8e --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/time_or_datetime.rb @@ -0,0 +1,340 @@ +require 'date' +require 'rational' unless defined?(Rational) +require 'time' + +module TZInfo + # Used by TZInfo internally to represent either a Time, DateTime or + # an Integer timestamp (seconds since 1970-01-01 00:00:00). + class TimeOrDateTime + include Comparable + + # Constructs a new TimeOrDateTime. timeOrDateTime can be a Time, DateTime + # or Integer. If using a Time or DateTime, any time zone information + # is ignored. + # + # Integer timestamps must be within the range supported by Time on the + # platform being used. + def initialize(timeOrDateTime) + @time = nil + @datetime = nil + @timestamp = nil + + if timeOrDateTime.is_a?(Time) + @time = timeOrDateTime + + # Avoid using the slower Rational class unless necessary. + nsec = RubyCoreSupport.time_nsec(@time) + usec = nsec % 1000 == 0 ? nsec / 1000 : Rational(nsec, 1000) + + @time = Time.utc(@time.year, @time.mon, @time.mday, @time.hour, @time.min, @time.sec, usec) unless @time.utc? + @orig = @time + elsif timeOrDateTime.is_a?(DateTime) + @datetime = timeOrDateTime + @datetime = @datetime.new_offset(0) unless @datetime.offset == 0 + @orig = @datetime + else + @timestamp = timeOrDateTime.to_i + + if !RubyCoreSupport.time_supports_64bit && (@timestamp > 2147483647 || @timestamp < -2147483648 || (@timestamp < 0 && !RubyCoreSupport.time_supports_negative)) + raise RangeError, 'Timestamp is outside the supported range of Time on this platform' + end + + @orig = @timestamp + end + end + + # Returns the time as a Time. + # + # When converting from a DateTime, the result is truncated to microsecond + # precision. + def to_time + # Thread-safety: It is possible that the value of @time may be + # calculated multiple times in concurrently executing threads. It is not + # worth the overhead of locking to ensure that @time is only + # calculated once. + + unless @time + result = if @timestamp + Time.at(@timestamp).utc + else + Time.utc(year, mon, mday, hour, min, sec, usec) + end + + return result if frozen? + @time = result + end + + @time + end + + # Returns the time as a DateTime. + # + # When converting from a Time, the result is truncated to microsecond + # precision. + def to_datetime + # Thread-safety: It is possible that the value of @datetime may be + # calculated multiple times in concurrently executing threads. It is not + # worth the overhead of locking to ensure that @datetime is only + # calculated once. + + unless @datetime + # Avoid using Rational unless necessary. + u = usec + s = u == 0 ? sec : Rational(sec * 1000000 + u, 1000000) + result = RubyCoreSupport.datetime_new(year, mon, mday, hour, min, s) + return result if frozen? + @datetime = result + end + + @datetime + end + + # Returns the time as an integer timestamp. + def to_i + # Thread-safety: It is possible that the value of @timestamp may be + # calculated multiple times in concurrently executing threads. It is not + # worth the overhead of locking to ensure that @timestamp is only + # calculated once. + + unless @timestamp + result = to_time.to_i + return result if frozen? + @timestamp = result + end + + @timestamp + end + + # Returns the time as the original time passed to new. + def to_orig + @orig + end + + # Returns a string representation of the TimeOrDateTime. + def to_s + if @orig.is_a?(Time) + "Time: #{@orig.to_s}" + elsif @orig.is_a?(DateTime) + "DateTime: #{@orig.to_s}" + else + "Timestamp: #{@orig.to_s}" + end + end + + # Returns internal object state as a programmer-readable string. + def inspect + "#<#{self.class}: #{@orig.inspect}>" + end + + # Returns the year. + def year + if @time + @time.year + elsif @datetime + @datetime.year + else + to_time.year + end + end + + # Returns the month of the year (1..12). + def mon + if @time + @time.mon + elsif @datetime + @datetime.mon + else + to_time.mon + end + end + alias :month :mon + + # Returns the day of the month (1..n). + def mday + if @time + @time.mday + elsif @datetime + @datetime.mday + else + to_time.mday + end + end + alias :day :mday + + # Returns the hour of the day (0..23). + def hour + if @time + @time.hour + elsif @datetime + @datetime.hour + else + to_time.hour + end + end + + # Returns the minute of the hour (0..59). + def min + if @time + @time.min + elsif @datetime + @datetime.min + else + to_time.min + end + end + + # Returns the second of the minute (0..60). (60 for a leap second). + def sec + if @time + @time.sec + elsif @datetime + @datetime.sec + else + to_time.sec + end + end + + # Returns the number of microseconds for the time. + def usec + if @time + @time.usec + elsif @datetime + # Ruby 1.8 has sec_fraction (of which the documentation says + # 'I do NOT recommend you to use this method'). sec_fraction no longer + # exists in Ruby 1.9. + + # Calculate the sec_fraction from the day_fraction. + ((@datetime.day_fraction - OffsetRationals.rational_for_offset(@datetime.hour * 3600 + @datetime.min * 60 + @datetime.sec)) * 86400000000).to_i + else + 0 + end + end + + # Compares this TimeOrDateTime with another Time, DateTime, timestamp + # (Integer) or TimeOrDateTime. Returns -1, 0 or +1 depending + # whether the receiver is less than, equal to, or greater than + # timeOrDateTime. + # + # Returns nil if the passed in timeOrDateTime is not comparable with + # TimeOrDateTime instances. + # + # Comparisons involving a DateTime will be performed using DateTime#<=>. + # Comparisons that don't involve a DateTime, but include a Time will be + # performed with Time#<=>. Otherwise comparisons will be performed with + # Integer#<=>. + def <=>(timeOrDateTime) + return nil unless timeOrDateTime.is_a?(TimeOrDateTime) || + timeOrDateTime.is_a?(Time) || + timeOrDateTime.is_a?(DateTime) || + timeOrDateTime.respond_to?(:to_i) + + unless timeOrDateTime.is_a?(TimeOrDateTime) + timeOrDateTime = TimeOrDateTime.wrap(timeOrDateTime) + end + + orig = timeOrDateTime.to_orig + + if @orig.is_a?(DateTime) || orig.is_a?(DateTime) + # If either is a DateTime, assume it is there for a reason + # (i.e. for its larger range of acceptable values on 32-bit systems). + to_datetime <=> timeOrDateTime.to_datetime + elsif @orig.is_a?(Time) || orig.is_a?(Time) + to_time <=> timeOrDateTime.to_time + else + to_i <=> timeOrDateTime.to_i + end + end + + # Adds a number of seconds to the TimeOrDateTime. Returns a new + # TimeOrDateTime, preserving what the original constructed type was. + # If the original type is a Time and the resulting calculation goes out of + # range for Times, then an exception will be raised by the Time class. + def +(seconds) + if seconds == 0 + self + else + if @orig.is_a?(DateTime) + TimeOrDateTime.new(@orig + OffsetRationals.rational_for_offset(seconds)) + else + # + defined for Time and Integer + TimeOrDateTime.new(@orig + seconds) + end + end + end + + # Subtracts a number of seconds from the TimeOrDateTime. Returns a new + # TimeOrDateTime, preserving what the original constructed type was. + # If the original type is a Time and the resulting calculation goes out of + # range for Times, then an exception will be raised by the Time class. + def -(seconds) + self + (-seconds) + end + + # Similar to the + operator, but converts to a DateTime based TimeOrDateTime + # where the Time or Integer timestamp to go out of the allowed range for a + # Time, converts to a DateTime based TimeOrDateTime. + # + # Note that the range of Time varies based on the platform. + def add_with_convert(seconds) + if seconds == 0 + self + else + if @orig.is_a?(DateTime) + TimeOrDateTime.new(@orig + OffsetRationals.rational_for_offset(seconds)) + else + # A Time or timestamp. + result = to_i + seconds + + if ((result > 2147483647 || result < -2147483648) && !RubyCoreSupport.time_supports_64bit) || (result < 0 && !RubyCoreSupport.time_supports_negative) + result = TimeOrDateTime.new(to_datetime + OffsetRationals.rational_for_offset(seconds)) + else + result = TimeOrDateTime.new(@orig + seconds) + end + end + end + end + + # Returns true if todt represents the same time and was originally + # constructed with the same type (DateTime, Time or timestamp) as this + # TimeOrDateTime. + def eql?(todt) + todt.kind_of?(TimeOrDateTime) && to_orig.eql?(todt.to_orig) + end + + # Returns a hash of this TimeOrDateTime. + def hash + @orig.hash + end + + # If no block is given, returns a TimeOrDateTime wrapping the given + # timeOrDateTime. If a block is specified, a TimeOrDateTime is constructed + # and passed to the block. The result of the block must be a TimeOrDateTime. + # + # The result of the block will be converted to the type of the originally + # passed in timeOrDateTime and then returned as the result of wrap. + # + # timeOrDateTime can be a Time, DateTime, timestamp (Integer) or + # TimeOrDateTime. If a TimeOrDateTime is passed in, no new TimeOrDateTime + # will be constructed and the value passed to wrap will be used when + # calling the block. + def self.wrap(timeOrDateTime) + t = timeOrDateTime.is_a?(TimeOrDateTime) ? timeOrDateTime : TimeOrDateTime.new(timeOrDateTime) + + if block_given? + t = yield t + + if timeOrDateTime.is_a?(TimeOrDateTime) + t + elsif timeOrDateTime.is_a?(Time) + t.to_time + elsif timeOrDateTime.is_a?(DateTime) + t.to_datetime + else + t.to_i + end + else + t + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone.rb new file mode 100644 index 0000000000..518fe220cd --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone.rb @@ -0,0 +1,669 @@ +require 'date' +require 'set' +require 'thread_safe' + +module TZInfo + # AmbiguousTime is raised to indicates that a specified time in a local + # timezone has more than one possible equivalent UTC time. This happens when + # transitioning from daylight savings time to standard time where the clocks + # are rolled back. + # + # AmbiguousTime is raised by period_for_local and local_to_utc when using an + # ambiguous time and not specifying any means to resolve the ambiguity. + class AmbiguousTime < StandardError + end + + # PeriodNotFound is raised to indicate that no TimezonePeriod matching a given + # time could be found. + class PeriodNotFound < StandardError + end + + # Raised by Timezone#get if the identifier given is not valid. + class InvalidTimezoneIdentifier < StandardError + end + + # Raised if an attempt is made to use a timezone created with + # Timezone.new(nil). + class UnknownTimezone < StandardError + end + + # Timezone is the base class of all timezones. It provides a factory method, + # 'get', to access timezones by identifier. Once a specific Timezone has been + # retrieved, DateTimes, Times and timestamps can be converted between the UTC + # and the local time for the zone. For example: + # + # tz = TZInfo::Timezone.get('America/New_York') + # puts tz.utc_to_local(DateTime.new(2005,8,29,15,35,0)).to_s + # puts tz.local_to_utc(Time.utc(2005,8,29,11,35,0)).to_s + # puts tz.utc_to_local(1125315300).to_s + # + # Each time conversion method returns an object of the same type it was + # passed. + # + # The Timezone class is thread-safe. It is safe to use class and instance + # methods of Timezone in concurrently executing threads. Instances of Timezone + # can be shared across thread boundaries. + class Timezone + include Comparable + + # Cache of loaded zones by identifier to avoid using require if a zone + # has already been loaded. + # + # @!visibility private + @@loaded_zones = nil + + # Default value of the dst parameter of the local_to_utc and + # period_for_local methods. + # + # @!visibility private + @@default_dst = nil + + # Sets the default value of the optional dst parameter of the + # local_to_utc and period_for_local methods. Can be set to nil, true or + # false. + # + # The value of default_dst defaults to nil if unset. + def self.default_dst=(value) + @@default_dst = value.nil? ? nil : !!value + end + + # Gets the default value of the optional dst parameter of the + # local_to_utc and period_for_local methods. Can be set to nil, true or + # false. + def self.default_dst + @@default_dst + end + + # Returns a timezone by its identifier (e.g. "Europe/London", + # "America/Chicago" or "UTC"). + # + # Raises InvalidTimezoneIdentifier if the timezone couldn't be found. + def self.get(identifier) + instance = @@loaded_zones[identifier] + + unless instance + # Thread-safety: It is possible that multiple equivalent Timezone + # instances could be created here in concurrently executing threads. + # The consequences of this are that the data may be loaded more than + # once (depending on the data source) and memoized calculations could + # be discarded. The performance benefit of ensuring that only a single + # instance is created is unlikely to be worth the overhead of only + # allowing one Timezone to be loaded at a time. + info = data_source.load_timezone_info(identifier) + instance = info.create_timezone + @@loaded_zones[instance.identifier] = instance + end + + instance + end + + # Returns a proxy for the Timezone with the given identifier. The proxy + # will cause the real timezone to be loaded when an attempt is made to + # find a period or convert a time. get_proxy will not validate the + # identifier. If an invalid identifier is specified, no exception will be + # raised until the proxy is used. + def self.get_proxy(identifier) + TimezoneProxy.new(identifier) + end + + # If identifier is nil calls super(), otherwise calls get. An identfier + # should always be passed in when called externally. + def self.new(identifier = nil) + if identifier + get(identifier) + else + super() + end + end + + # Returns an array containing all the available Timezones. + # + # Returns TimezoneProxy objects to avoid the overhead of loading Timezone + # definitions until a conversion is actually required. + def self.all + get_proxies(all_identifiers) + end + + # Returns an array containing the identifiers of all the available + # Timezones. + def self.all_identifiers + data_source.timezone_identifiers + end + + # Returns an array containing all the available Timezones that are based + # on data (are not links to other Timezones). + # + # Returns TimezoneProxy objects to avoid the overhead of loading Timezone + # definitions until a conversion is actually required. + def self.all_data_zones + get_proxies(all_data_zone_identifiers) + end + + # Returns an array containing the identifiers of all the available + # Timezones that are based on data (are not links to other Timezones).. + def self.all_data_zone_identifiers + data_source.data_timezone_identifiers + end + + # Returns an array containing all the available Timezones that are links + # to other Timezones. + # + # Returns TimezoneProxy objects to avoid the overhead of loading Timezone + # definitions until a conversion is actually required. + def self.all_linked_zones + get_proxies(all_linked_zone_identifiers) + end + + # Returns an array containing the identifiers of all the available + # Timezones that are links to other Timezones. + def self.all_linked_zone_identifiers + data_source.linked_timezone_identifiers + end + + # Returns all the Timezones defined for all Countries. This is not the + # complete set of Timezones as some are not country specific (e.g. + # 'Etc/GMT'). + # + # Returns TimezoneProxy objects to avoid the overhead of loading Timezone + # definitions until a conversion is actually required. + def self.all_country_zones + Country.all_codes.inject([]) do |zones,country| + zones += Country.get(country).zones + end.uniq + end + + # Returns all the zone identifiers defined for all Countries. This is not the + # complete set of zone identifiers as some are not country specific (e.g. + # 'Etc/GMT'). You can obtain a Timezone instance for a given identifier + # with the get method. + def self.all_country_zone_identifiers + Country.all_codes.inject([]) do |zones,country| + zones += Country.get(country).zone_identifiers + end.uniq + end + + # Returns all US Timezone instances. A shortcut for + # TZInfo::Country.get('US').zones. + # + # Returns TimezoneProxy objects to avoid the overhead of loading Timezone + # definitions until a conversion is actually required. + def self.us_zones + Country.get('US').zones + end + + # Returns all US zone identifiers. A shortcut for + # TZInfo::Country.get('US').zone_identifiers. + def self.us_zone_identifiers + Country.get('US').zone_identifiers + end + + # The identifier of the timezone, e.g. "Europe/Paris". + def identifier + raise_unknown_timezone + end + + # An alias for identifier. + def name + # Don't use alias, as identifier gets overridden. + identifier + end + + # Returns a friendlier version of the identifier. + def to_s + friendly_identifier + end + + # Returns internal object state as a programmer-readable string. + def inspect + "#<#{self.class}: #{identifier}>" + end + + # Returns a friendlier version of the identifier. Set skip_first_part to + # omit the first part of the identifier (typically a region name) where + # there is more than one part. + # + # For example: + # + # Timezone.get('Europe/Paris').friendly_identifier(false) #=> "Europe - Paris" + # Timezone.get('Europe/Paris').friendly_identifier(true) #=> "Paris" + # Timezone.get('America/Indiana/Knox').friendly_identifier(false) #=> "America - Knox, Indiana" + # Timezone.get('America/Indiana/Knox').friendly_identifier(true) #=> "Knox, Indiana" + def friendly_identifier(skip_first_part = false) + parts = identifier.split('/') + if parts.empty? + # shouldn't happen + identifier + elsif parts.length == 1 + parts[0] + else + prefix = skip_first_part ? nil : "#{parts[0]} - " + + parts = parts.drop(1).map do |part| + part.gsub!(/_/, ' ') + + if part.index(/[a-z]/) + # Missing a space if a lower case followed by an upper case and the + # name isn't McXxxx. + part.gsub!(/([^M][a-z])([A-Z])/, '\1 \2') + part.gsub!(/([M][a-bd-z])([A-Z])/, '\1 \2') + + # Missing an apostrophe if two consecutive upper case characters. + part.gsub!(/([A-Z])([A-Z])/, '\1\'\2') + end + + part + end + + "#{prefix}#{parts.reverse.join(', ')}" + end + end + + # Returns the TimezonePeriod for the given UTC time. utc can either be + # a DateTime, Time or integer timestamp (Time.to_i). Any timezone + # information in utc is ignored (it is treated as a UTC time). + def period_for_utc(utc) + raise_unknown_timezone + end + + # Returns the set of TimezonePeriod instances that are valid for the given + # local time as an array. If you just want a single period, use + # period_for_local instead and specify how ambiguities should be resolved. + # Returns an empty array if no periods are found for the given time. + def periods_for_local(local) + raise_unknown_timezone + end + + # Returns an Array of TimezoneTransition instances representing the times + # where the UTC offset of the timezone changes. + # + # Transitions are returned up to a given date and time up to a given date + # and time, specified in UTC (utc_to). + # + # A from date and time may also be supplied using the utc_from parameter + # (also specified in UTC). If utc_from is not nil, only transitions from + # that date and time onwards will be returned. + # + # Comparisons with utc_to are exclusive. Comparisons with utc_from are + # inclusive. If a transition falls precisely on utc_to, it will be excluded. + # If a transition falls on utc_from, it will be included. + # + # Transitions returned are ordered by when they occur, from earliest to + # latest. + # + # utc_to and utc_from can be specified using either DateTime, Time or + # integer timestamps (Time.to_i). + # + # If utc_from is specified and utc_to is not greater than utc_from, then + # transitions_up_to raises an ArgumentError exception. + def transitions_up_to(utc_to, utc_from = nil) + raise_unknown_timezone + end + + # Returns the canonical Timezone instance for this Timezone. + # + # The IANA Time Zone database contains two types of definition: Zones and + # Links. Zones are defined by rules that set out when transitions occur. + # Links are just references to fully defined Zone, creating an alias for + # that Zone. + # + # Links are commonly used where a time zone has been renamed in a + # release of the Time Zone database. For example, the Zone US/Eastern was + # renamed as America/New_York. A US/Eastern Link was added in its place, + # linking to (and creating an alias for) for America/New_York. + # + # Links are also used for time zones that are currently identical to a full + # Zone, but that are administered seperately. For example, Europe/Vatican is + # a Link to (and alias for) Europe/Rome. + # + # For a full Zone, canonical_zone returns self. + # + # For a Link, canonical_zone returns a Timezone instance representing the + # full Zone that the link targets. + # + # TZInfo can be used with different data sources (see the documentation for + # TZInfo::DataSource). Please note that some DataSource implementations may + # not support distinguishing between full Zones and Links and will treat all + # time zones as full Zones. In this case, the canonical_zone will always + # return self. + # + # There are two built-in DataSource implementations. RubyDataSource (which + # will be used if the tzinfo-data gem is available) supports Link zones. + # ZoneinfoDataSource returns Link zones as if they were full Zones. If the + # canonical_zone or canonical_identifier methods are required, the + # tzinfo-data gem should be installed. + # + # The TZInfo::DataSource.get method can be used to check which DataSource + # implementation is being used. + def canonical_zone + raise_unknown_timezone + end + + # Returns the TimezonePeriod for the given local time. local can either be + # a DateTime, Time or integer timestamp (Time.to_i). Any timezone + # information in local is ignored (it is treated as a time in the current + # timezone). + # + # Warning: There are local times that have no equivalent UTC times (e.g. + # in the transition from standard time to daylight savings time). There are + # also local times that have more than one UTC equivalent (e.g. in the + # transition from daylight savings time to standard time). + # + # In the first case (no equivalent UTC time), a PeriodNotFound exception + # will be raised. + # + # In the second case (more than one equivalent UTC time), an AmbiguousTime + # exception will be raised unless the optional dst parameter or block + # handles the ambiguity. + # + # If the ambiguity is due to a transition from daylight savings time to + # standard time, the dst parameter can be used to select whether the + # daylight savings time or local time is used. For example, + # + # Timezone.get('America/New_York').period_for_local(DateTime.new(2004,10,31,1,30,0)) + # + # would raise an AmbiguousTime exception. + # + # Specifying dst=true would the daylight savings period from April to + # October 2004. Specifying dst=false would return the standard period + # from October 2004 to April 2005. + # + # If the dst parameter does not resolve the ambiguity, and a block is + # specified, it is called. The block must take a single parameter - an + # array of the periods that need to be resolved. The block can select and + # return a single period or return nil or an empty array + # to cause an AmbiguousTime exception to be raised. + # + # The default value of the dst parameter can be specified by setting + # Timezone.default_dst. If default_dst is not set, or is set to nil, then + # an AmbiguousTime exception will be raised in ambiguous situations unless + # a block is given to resolve the ambiguity. + def period_for_local(local, dst = Timezone.default_dst) + results = periods_for_local(local) + + if results.empty? + raise PeriodNotFound + elsif results.size < 2 + results.first + else + # ambiguous result try to resolve + + if !dst.nil? + matches = results.find_all {|period| period.dst? == dst} + results = matches if !matches.empty? + end + + if results.size < 2 + results.first + else + # still ambiguous, try the block + + if block_given? + results = yield results + end + + if results.is_a?(TimezonePeriod) + results + elsif results && results.size == 1 + results.first + else + raise AmbiguousTime, "#{local} is an ambiguous local time." + end + end + end + end + + # Converts a time in UTC to the local timezone. utc can either be + # a DateTime, Time or timestamp (Time.to_i). The returned time has the same + # type as utc. Any timezone information in utc is ignored (it is treated as + # a UTC time). + def utc_to_local(utc) + TimeOrDateTime.wrap(utc) {|wrapped| + period_for_utc(wrapped).to_local(wrapped) + } + end + + # Converts a time in the local timezone to UTC. local can either be + # a DateTime, Time or timestamp (Time.to_i). The returned time has the same + # type as local. Any timezone information in local is ignored (it is treated + # as a local time). + # + # Warning: There are local times that have no equivalent UTC times (e.g. + # in the transition from standard time to daylight savings time). There are + # also local times that have more than one UTC equivalent (e.g. in the + # transition from daylight savings time to standard time). + # + # In the first case (no equivalent UTC time), a PeriodNotFound exception + # will be raised. + # + # In the second case (more than one equivalent UTC time), an AmbiguousTime + # exception will be raised unless the optional dst parameter or block + # handles the ambiguity. + # + # If the ambiguity is due to a transition from daylight savings time to + # standard time, the dst parameter can be used to select whether the + # daylight savings time or local time is used. For example, + # + # Timezone.get('America/New_York').local_to_utc(DateTime.new(2004,10,31,1,30,0)) + # + # would raise an AmbiguousTime exception. + # + # Specifying dst=true would return 2004-10-31 5:30:00. Specifying dst=false + # would return 2004-10-31 6:30:00. + # + # If the dst parameter does not resolve the ambiguity, and a block is + # specified, it is called. The block must take a single parameter - an + # array of the periods that need to be resolved. The block can return a + # single period to use to convert the time or return nil or an empty array + # to cause an AmbiguousTime exception to be raised. + # + # The default value of the dst parameter can be specified by setting + # Timezone.default_dst. If default_dst is not set, or is set to nil, then + # an AmbiguousTime exception will be raised in ambiguous situations unless + # a block is given to resolve the ambiguity. + def local_to_utc(local, dst = Timezone.default_dst) + TimeOrDateTime.wrap(local) {|wrapped| + if block_given? + period = period_for_local(wrapped, dst) {|periods| yield periods } + else + period = period_for_local(wrapped, dst) + end + + period.to_utc(wrapped) + } + end + + # Returns information about offsets used by the Timezone up to a given + # date and time, specified using UTC (utc_to). The information is returned + # as an Array of TimezoneOffset instances. + # + # A from date and time may also be supplied using the utc_from parameter + # (also specified in UTC). If utc_from is not nil, only offsets used from + # that date and time forward will be returned. + # + # Comparisons with utc_to are exclusive. Comparisons with utc_from are + # inclusive. + # + # Offsets may be returned in any order. + # + # utc_to and utc_from can be specified using either DateTime, Time or + # integer timestamps (Time.to_i). + # + # If utc_from is specified and utc_to is not greater than utc_from, then + # offsets_up_to raises an ArgumentError exception. + def offsets_up_to(utc_to, utc_from = nil) + utc_to = TimeOrDateTime.wrap(utc_to) + transitions = transitions_up_to(utc_to, utc_from) + + if transitions.empty? + # No transitions in the range, find the period that covers it. + + if utc_from + # Use the from date as it is inclusive. + period = period_for_utc(utc_from) + else + # utc_to is exclusive, so this can't be used with period_for_utc. + # However, any time earlier than utc_to can be used. + + # Subtract 1 hour (since this is one of the cached OffsetRationals). + # Use add_with_convert so that conversion to DateTime is performed if + # required. + period = period_for_utc(utc_to.add_with_convert(-3600)) + end + + [period.offset] + else + result = Set.new + + first = transitions.first + result << first.previous_offset unless utc_from && first.at == utc_from + + transitions.each do |t| + result << t.offset + end + + result.to_a + end + end + + # Returns the canonical identifier for this Timezone. + # + # This is a shortcut for calling canonical_zone.identifier. Please refer + # to the canonical_zone documentation for further information. + def canonical_identifier + canonical_zone.identifier + end + + # Returns the current time in the timezone as a Time. + def now + utc_to_local(Time.now.utc) + end + + # Returns the TimezonePeriod for the current time. + def current_period + period_for_utc(Time.now.utc) + end + + # Returns the current Time and TimezonePeriod as an array. The first element + # is the time, the second element is the period. + def current_period_and_time + utc = Time.now.utc + period = period_for_utc(utc) + [period.to_local(utc), period] + end + + alias :current_time_and_period :current_period_and_time + + # Converts a time in UTC to local time and returns it as a string according + # to the given format. + # + # The formatting is identical to Time.strftime and DateTime.strftime, except + # %Z and %z are replaced with the timezone abbreviation (for example, EST or + # EDT) and offset for the specified Timezone and time. + # + # The offset can be formatted as follows: + # + # - %z - hour and minute (e.g. +0500) + # - %:z - hour and minute separated with a colon (e.g. +05:00) + # - %::z - hour minute and second separated with colons (e.g. +05:00:00) + # - %:::z - hour only (e.g. +05) + # + # Timezone#strftime currently handles the replacement of %z. From TZInfo + # version 2.0.0, %z will be passed to Time#strftime and DateTime#strftime + # instead. Some of the formatting options may cease to be available + # depending on the version of Ruby in use (for example, %:::z is only + # supported by Time#strftime from MRI version 2.0.0 onwards.) + def strftime(format, utc = Time.now.utc) + period = period_for_utc(utc) + local = period.to_local(utc) + local = Time.at(local).utc unless local.kind_of?(Time) || local.kind_of?(DateTime) + abbreviation = period.abbreviation.to_s.gsub(/%/, '%%') + + format = format.gsub(/%(%*)(Z|:*z)/) do + if $1.length.odd? + # Escaped literal percent or series of percents. Pass on to strftime. + "#$1%#$2" + elsif $2 == "Z" + "#$1#{abbreviation}" + else + m, s = period.utc_total_offset.divmod(60) + h, m = m.divmod(60) + case $2.length + when 1 + "#$1#{'%+03d%02d' % [h,m]}" + when 2 + "#$1#{'%+03d:%02d' % [h,m]}" + when 3 + "#$1#{'%+03d:%02d:%02d' % [h,m,s]}" + when 4 + "#$1#{'%+03d' % [h]}" + else # more than 3 colons - not a valid option + # Passing the invalid format string through to Time#strftime or + # DateTime#strtime would normally result in it being returned in the + # result. However, with Ruby 1.8.7 on Windows (as tested with Ruby + # 1.8.7-p374 from http://rubyinstaller.org/downloads/archives), this + # causes Time#strftime to always return an empty string (e.g. + # Time.now.strftime('a %::::z b') returns ''). + # + # Escape the percent to force it to be evaluated as a literal. + "#$1%%#$2" + end + end + end + + local.strftime(format) + end + + # Compares two Timezones based on their identifier. Returns -1 if tz is less + # than self, 0 if tz is equal to self and +1 if tz is greater than self. + # + # Returns nil if tz is not comparable with Timezone instances. + def <=>(tz) + return nil unless tz.is_a?(Timezone) + identifier <=> tz.identifier + end + + # Returns true if and only if the identifier of tz is equal to the + # identifier of this Timezone. + def eql?(tz) + self == tz + end + + # Returns a hash of this Timezone. + def hash + identifier.hash + end + + # Dumps this Timezone for marshalling. + def _dump(limit) + identifier + end + + # Loads a marshalled Timezone. + def self._load(data) + Timezone.get(data) + end + + private + # Initializes @@loaded_zones. + def self.init_loaded_zones + @@loaded_zones = ThreadSafe::Cache.new + end + init_loaded_zones + + # Returns an array of proxies corresponding to the given array of + # identifiers. + def self.get_proxies(identifiers) + identifiers.collect {|identifier| get_proxy(identifier)} + end + + # Returns the current DataSource. + def self.data_source + DataSource.get + end + + # Raises an UnknownTimezone exception. + def raise_unknown_timezone + raise UnknownTimezone, 'TZInfo::Timezone constructed directly' + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone_definition.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone_definition.rb new file mode 100644 index 0000000000..5ceb686e44 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone_definition.rb @@ -0,0 +1,36 @@ +module TZInfo + + # TimezoneDefinition is included into Timezone definition modules. + # TimezoneDefinition provides the methods for defining timezones. + # + # @private + module TimezoneDefinition #:nodoc: + # Add class methods to the includee. + def self.append_features(base) + super + base.extend(ClassMethods) + end + + # Class methods for inclusion. + # + # @private + module ClassMethods #:nodoc: + # Returns and yields a TransitionDataTimezoneInfo object to define a + # timezone. + def timezone(identifier) + yield @timezone = TransitionDataTimezoneInfo.new(identifier) + end + + # Defines a linked timezone. + def linked_timezone(identifier, link_to_identifier) + @timezone = LinkedTimezoneInfo.new(identifier, link_to_identifier) + end + + # Returns the last TimezoneInfo to be defined with timezone or + # linked_timezone. + def get + @timezone + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone_index_definition.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone_index_definition.rb new file mode 100644 index 0000000000..59dc9530c5 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone_index_definition.rb @@ -0,0 +1,54 @@ +module TZInfo + # The timezone index file includes TimezoneIndexDefinition which provides + # methods used to define timezones in the index. + # + # @private + module TimezoneIndexDefinition #:nodoc: + # Add class methods to the includee and initialize class instance variables. + def self.append_features(base) + super + base.extend(ClassMethods) + base.instance_eval do + @timezones = [] + @data_timezones = [] + @linked_timezones = [] + end + end + + # Class methods for inclusion. + # + # @private + module ClassMethods #:nodoc: + # Defines a timezone based on data. + def timezone(identifier) + @timezones << identifier + @data_timezones << identifier + end + + # Defines a timezone which is a link to another timezone. + def linked_timezone(identifier) + @timezones << identifier + @linked_timezones << identifier + end + + # Returns a frozen array containing the identifiers of all the timezones. + # Identifiers appear in the order they were defined in the index. + def timezones + @timezones.freeze + end + + # Returns a frozen array containing the identifiers of all data timezones. + # Identifiers appear in the order they were defined in the index. + def data_timezones + @data_timezones.freeze + end + + # Returns a frozen array containing the identifiers of all linked + # timezones. Identifiers appear in the order they were defined in + # the index. + def linked_timezones + @linked_timezones.freeze + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone_info.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone_info.rb new file mode 100644 index 0000000000..13f66bad5c --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone_info.rb @@ -0,0 +1,30 @@ +module TZInfo + # Represents a timezone defined by a data source. + class TimezoneInfo + + # The timezone identifier. + attr_reader :identifier + + # Constructs a new TimezoneInfo with an identifier. + def initialize(identifier) + @identifier = identifier + end + + # Returns internal object state as a programmer-readable string. + def inspect + "#<#{self.class}: #@identifier>" + end + + # Constructs a Timezone instance for the timezone represented by this + # TimezoneInfo. + def create_timezone + raise_not_implemented('create_timezone') + end + + private + + def raise_not_implemented(method_name) + raise NotImplementedError, "Subclasses must override #{method_name}" + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone_offset.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone_offset.rb new file mode 100644 index 0000000000..dbce0e92f4 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone_offset.rb @@ -0,0 +1,101 @@ +module TZInfo + # Represents an offset defined in a Timezone data file. + class TimezoneOffset + # The base offset of the timezone from UTC in seconds. This does not include + # any adjustment made for daylight savings time and will typically remain + # constant throughout the year. + # + # To obtain the currently observed offset from UTC, including the effect of + # daylight savings time, use utc_total_offset instead. + # + # Note that zoneinfo files only include the value of utc_total_offset and a + # DST flag. When using ZoneinfoDataSource, the utc_offset will be derived + # from changes to the UTC total offset and the DST flag. As a consequence, + # utc_total_offset will always be correct, but utc_offset may be inaccurate. + # + # If you require utc_offset to be accurate, install the tzinfo-data gem and + # set RubyDataSource as the DataSource. + attr_reader :utc_offset + + # The offset from the time zone's standard time in seconds. Zero + # when daylight savings time is not in effect. Non-zero (usually 3600 = 1 + # hour) if daylight savings is being observed. + # + # Note that zoneinfo files only include the value of utc_total_offset and + # a DST flag. When using DataSources::ZoneinfoDataSource, the std_offset + # will be derived from changes to the UTC total offset and the DST flag. As + # a consequence, utc_total_offset will always be correct, but std_offset + # may be inaccurate. + # + # If you require std_offset to be accurate, install the tzinfo-data gem + # and set RubyDataSource as the DataSource. + attr_reader :std_offset + + # The total offset of this observance from UTC in seconds + # (utc_offset + std_offset). + attr_reader :utc_total_offset + + # The abbreviation that identifies this observance, e.g. "GMT" + # (Greenwich Mean Time) or "BST" (British Summer Time) for "Europe/London". The returned identifier is a + # symbol. + attr_reader :abbreviation + + # Constructs a new TimezoneOffset. utc_offset and std_offset are specified + # in seconds. + def initialize(utc_offset, std_offset, abbreviation) + @utc_offset = utc_offset + @std_offset = std_offset + @abbreviation = abbreviation + + @utc_total_offset = @utc_offset + @std_offset + end + + # True if std_offset is non-zero. + def dst? + @std_offset != 0 + end + + # Converts a UTC Time, DateTime or integer timestamp to local time, based on + # the offset of this period. + # + # Deprecation warning: this method will be removed in TZInfo version 2.0.0. + def to_local(utc) + TimeOrDateTime.wrap(utc) {|wrapped| + wrapped + @utc_total_offset + } + end + + # Converts a local Time, DateTime or integer timestamp to UTC, based on the + # offset of this period. + # + # Deprecation warning: this method will be removed in TZInfo version 2.0.0. + def to_utc(local) + TimeOrDateTime.wrap(local) {|wrapped| + wrapped - @utc_total_offset + } + end + + # Returns true if and only if toi has the same utc_offset, std_offset + # and abbreviation as this TimezoneOffset. + def ==(toi) + toi.kind_of?(TimezoneOffset) && + utc_offset == toi.utc_offset && std_offset == toi.std_offset && abbreviation == toi.abbreviation + end + + # Returns true if and only if toi has the same utc_offset, std_offset + # and abbreviation as this TimezoneOffset. + def eql?(toi) + self == toi + end + + # Returns a hash of this TimezoneOffset. + def hash + utc_offset.hash ^ std_offset.hash ^ abbreviation.hash + end + + # Returns internal object state as a programmer-readable string. + def inspect + "#<#{self.class}: #@utc_offset,#@std_offset,#@abbreviation>" + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone_period.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone_period.rb new file mode 100644 index 0000000000..28058412ec --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone_period.rb @@ -0,0 +1,245 @@ +module TZInfo + # A period of time in a timezone where the same offset from UTC applies. + # + # All the methods that take times accept instances of Time or DateTime as well + # as Integer timestamps. + class TimezonePeriod + # The TimezoneTransition that defines the start of this TimezonePeriod + # (may be nil if unbounded). + attr_reader :start_transition + + # The TimezoneTransition that defines the end of this TimezonePeriod + # (may be nil if unbounded). + attr_reader :end_transition + + # The TimezoneOffset for this period. + attr_reader :offset + + # Initializes a new TimezonePeriod. + # + # TimezonePeriod instances should not normally be constructed manually. + def initialize(start_transition, end_transition, offset = nil) + @start_transition = start_transition + @end_transition = end_transition + + if offset + raise ArgumentError, 'Offset specified with transitions' if @start_transition || @end_transition + @offset = offset + else + if @start_transition + @offset = @start_transition.offset + elsif @end_transition + @offset = @end_transition.previous_offset + else + raise ArgumentError, 'No offset specified and no transitions to determine it from' + end + end + + @utc_total_offset_rational = nil + end + + # The base offset of the timezone from UTC in seconds. This does not include + # any adjustment made for daylight savings time and will typically remain + # constant throughout the year. + # + # To obtain the currently observed offset from UTC, including the effect of + # daylight savings time, use utc_total_offset instead. + # + # Note that zoneinfo files only include the value of utc_total_offset and a + # DST flag. When using ZoneinfoDataSource, the utc_offset will be derived + # from changes to the UTC total offset and the DST flag. As a consequence, + # utc_total_offset will always be correct, but utc_offset may be inaccurate. + # + # If you require utc_offset to be accurate, install the tzinfo-data gem and + # set RubyDataSource as the DataSource. + def utc_offset + @offset.utc_offset + end + + # The offset from the time zone's standard time in seconds. Zero + # when daylight savings time is not in effect. Non-zero (usually 3600 = 1 + # hour) if daylight savings is being observed. + # + # Note that zoneinfo files only include the value of utc_total_offset and + # a DST flag. When using DataSources::ZoneinfoDataSource, the std_offset + # will be derived from changes to the UTC total offset and the DST flag. As + # a consequence, utc_total_offset will always be correct, but std_offset + # may be inaccurate. + # + # If you require std_offset to be accurate, install the tzinfo-data gem + # and set RubyDataSource as the DataSource. + def std_offset + @offset.std_offset + end + + # The identifier of this period, e.g. "GMT" (Greenwich Mean Time) or "BST" + # (British Summer Time) for "Europe/London". The returned identifier is a + # symbol. + def abbreviation + @offset.abbreviation + end + alias :zone_identifier :abbreviation + + # Total offset from UTC (seconds). Equal to utc_offset + std_offset. + def utc_total_offset + @offset.utc_total_offset + end + + # Total offset from UTC (days). Result is a Rational. + def utc_total_offset_rational + # Thread-safety: It is possible that the value of + # @utc_total_offset_rational may be calculated multiple times in + # concurrently executing threads. It is not worth the overhead of locking + # to ensure that @zone_identifiers is only calculated once. + + unless @utc_total_offset_rational + result = OffsetRationals.rational_for_offset(utc_total_offset) + return result if frozen? + @utc_total_offset_rational = result + end + @utc_total_offset_rational + end + + # The start time of the period in UTC as a DateTime. May be nil if unbounded. + def utc_start + @start_transition ? @start_transition.at.to_datetime : nil + end + + # The start time of the period in UTC as a Time. May be nil if unbounded. + def utc_start_time + @start_transition ? @start_transition.at.to_time : nil + end + + # The end time of the period in UTC as a DateTime. May be nil if unbounded. + def utc_end + @end_transition ? @end_transition.at.to_datetime : nil + end + + # The end time of the period in UTC as a Time. May be nil if unbounded. + def utc_end_time + @end_transition ? @end_transition.at.to_time : nil + end + + # The start time of the period in local time as a DateTime. May be nil if + # unbounded. + def local_start + @start_transition ? @start_transition.local_start_at.to_datetime : nil + end + + # The start time of the period in local time as a Time. May be nil if + # unbounded. + def local_start_time + @start_transition ? @start_transition.local_start_at.to_time : nil + end + + # The end time of the period in local time as a DateTime. May be nil if + # unbounded. + def local_end + @end_transition ? @end_transition.local_end_at.to_datetime : nil + end + + # The end time of the period in local time as a Time. May be nil if + # unbounded. + def local_end_time + @end_transition ? @end_transition.local_end_at.to_time : nil + end + + # true if daylight savings is in effect for this period; otherwise false. + def dst? + @offset.dst? + end + + # true if this period is valid for the given UTC DateTime; otherwise false. + # + # Deprecation warning: this method will be removed in TZInfo version 2.0.0. + def valid_for_utc?(utc) + utc_after_start?(utc) && utc_before_end?(utc) + end + + # true if the given UTC DateTime is after the start of the period + # (inclusive); otherwise false. + # + # Deprecation warning: this method will be removed in TZInfo version 2.0.0. + def utc_after_start?(utc) + !@start_transition || @start_transition.at <= utc + end + + # true if the given UTC DateTime is before the end of the period + # (exclusive); otherwise false. + # + # Deprecation warning: this method will be removed in TZInfo version 2.0.0. + def utc_before_end?(utc) + !@end_transition || @end_transition.at > utc + end + + # true if this period is valid for the given local DateTime; otherwise + # false. + # + # Deprecation warning: this method will be removed in TZInfo version 2.0.0. + def valid_for_local?(local) + local_after_start?(local) && local_before_end?(local) + end + + # true if the given local DateTime is after the start of the period + # (inclusive); otherwise false. + # + # Deprecation warning: this method will be removed in TZInfo version 2.0.0. + def local_after_start?(local) + !@start_transition || @start_transition.local_start_at <= local + end + + # true if the given local DateTime is before the end of the period + # (exclusive); otherwise false. + # + # Deprecation warning: this method will be removed in TZInfo version 2.0.0. + def local_before_end?(local) + !@end_transition || @end_transition.local_end_at > local + end + + # Converts a UTC DateTime to local time based on the offset of this period. + # + # Deprecation warning: this method will be removed in TZInfo version 2.0.0. + def to_local(utc) + @offset.to_local(utc) + end + + # Converts a local DateTime to UTC based on the offset of this period. + # + # Deprecation warning: this method will be removed in TZInfo version 2.0.0. + def to_utc(local) + @offset.to_utc(local) + end + + # Returns true if this TimezonePeriod is equal to p. This compares the + # start_transition, end_transition and offset using ==. + def ==(p) + p.kind_of?(TimezonePeriod) && + start_transition == p.start_transition && + end_transition == p.end_transition && + offset == p.offset + end + + # Returns true if this TimezonePeriods is equal to p. This compares the + # start_transition, end_transition and offset using eql? + def eql?(p) + p.kind_of?(TimezonePeriod) && + start_transition.eql?(p.start_transition) && + end_transition.eql?(p.end_transition) && + offset.eql?(p.offset) + end + + # Returns a hash of this TimezonePeriod. + def hash + result = @start_transition.hash ^ @end_transition.hash + result ^= @offset.hash unless @start_transition || @end_transition + result + end + + # Returns internal object state as a programmer-readable string. + def inspect + result = "#<#{self.class}: #{@start_transition.inspect},#{@end_transition.inspect}" + result << ",#{@offset.inspect}>" unless @start_transition || @end_transition + result + '>' + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone_proxy.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone_proxy.rb new file mode 100644 index 0000000000..c913011cea --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone_proxy.rb @@ -0,0 +1,105 @@ +module TZInfo + + # A proxy class representing a timezone with a given identifier. TimezoneProxy + # inherits from Timezone and can be treated like any Timezone loaded with + # Timezone.get. + # + # The first time an attempt is made to access the data for the timezone, the + # real Timezone is loaded. If the proxy's identifier was not valid, then an + # exception will be raised at this point. + class TimezoneProxy < Timezone + # Construct a new TimezoneProxy for the given identifier. The identifier + # is not checked when constructing the proxy. It will be validated on the + # when the real Timezone is loaded. + def self.new(identifier) + # Need to override new to undo the behaviour introduced in Timezone#new. + tzp = super() + tzp.send(:setup, identifier) + tzp + end + + # The identifier of the timezone, e.g. "Europe/Paris". + def identifier + @real_timezone ? @real_timezone.identifier : @identifier + end + + # Returns the TimezonePeriod for the given UTC time. utc can either be + # a DateTime, Time or integer timestamp (Time.to_i). Any timezone + # information in utc is ignored (it is treated as a UTC time). + def period_for_utc(utc) + real_timezone.period_for_utc(utc) + end + + # Returns the set of TimezonePeriod instances that are valid for the given + # local time as an array. If you just want a single period, use + # period_for_local instead and specify how abiguities should be resolved. + # Returns an empty array if no periods are found for the given time. + def periods_for_local(local) + real_timezone.periods_for_local(local) + end + + # Returns an Array of TimezoneTransition instances representing the times + # where the UTC offset of the timezone changes. + # + # Transitions are returned up to a given date and time up to a given date + # and time (to). + # + # A from date and time may also be supplied using the from parameter. If + # from is not nil, only transitions from that date and time onwards will be + # returned. + # + # Comparisons with to are exclusive. Comparisons with from are inclusive. + # If a transition falls precisely on to, it will be excluded. If a + # transition falls on from, it will be included. + # + # Transitions returned are ordered by when they occur, from earliest to + # latest. + # + # to and from can be specified using either a Time, DateTime, Time or + # Timestamp. + # + # If from is specified and to is not greater than from, then an + # ArgumentError exception is raised. + # + # ArgumentError is raised if to is nil or of either to or from are + # Timestamps with unspecified offsets. + def transitions_up_to(to, from = nil) + real_timezone.transitions_up_to(to, from) + end + + # Returns the canonical zone for this Timezone. + def canonical_zone + real_timezone.canonical_zone + end + + # Dumps this TimezoneProxy for marshalling. + def _dump(limit) + identifier + end + + # Loads a marshalled TimezoneProxy. + def self._load(data) + TimezoneProxy.new(data) + end + + private + def setup(identifier) + @identifier = identifier + @real_timezone = nil + end + + def real_timezone + # Thread-safety: It is possible that the value of @real_timezone may be + # calculated multiple times in concurrently executing threads. It is not + # worth the overhead of locking to ensure that @real_timezone is only + # calculated once. + unless @real_timezone + result = Timezone.get(@identifier) + return result if frozen? + @real_timezone = result + end + + @real_timezone + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone_transition.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone_transition.rb new file mode 100644 index 0000000000..b905c627ae --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone_transition.rb @@ -0,0 +1,130 @@ +module TZInfo + # Represents a transition from one timezone offset to another at a particular + # date and time. + class TimezoneTransition + # The offset this transition changes to (a TimezoneOffset instance). + attr_reader :offset + + # The offset this transition changes from (a TimezoneOffset instance). + attr_reader :previous_offset + + # Initializes a new TimezoneTransition. + # + # TimezoneTransition instances should not normally be constructed manually. + def initialize(offset, previous_offset) + @offset = offset + @previous_offset = previous_offset + @local_end_at = nil + @local_start_at = nil + end + + # A TimeOrDateTime instance representing the UTC time when this transition + # occurs. + def at + raise_not_implemented('at') + end + + # The UTC time when this transition occurs, returned as a DateTime instance. + def datetime + at.to_datetime + end + + # The UTC time when this transition occurs, returned as a Time instance. + def time + at.to_time + end + + # A TimeOrDateTime instance representing the local time when this transition + # causes the previous observance to end (calculated from at using + # previous_offset). + def local_end_at + # Thread-safety: It is possible that the value of @local_end_at may be + # calculated multiple times in concurrently executing threads. It is not + # worth the overhead of locking to ensure that @local_end_at is only + # calculated once. + + unless @local_end_at + result = at.add_with_convert(@previous_offset.utc_total_offset) + return result if frozen? + @local_end_at = result + end + + @local_end_at + end + + # The local time when this transition causes the previous observance to end, + # returned as a DateTime instance. + def local_end + local_end_at.to_datetime + end + + # The local time when this transition causes the previous observance to end, + # returned as a Time instance. + def local_end_time + local_end_at.to_time + end + + # A TimeOrDateTime instance representing the local time when this transition + # causes the next observance to start (calculated from at using offset). + def local_start_at + # Thread-safety: It is possible that the value of @local_start_at may be + # calculated multiple times in concurrently executing threads. It is not + # worth the overhead of locking to ensure that @local_start_at is only + # calculated once. + + unless @local_start_at + result = at.add_with_convert(@offset.utc_total_offset) + return result if frozen? + @local_start_at = result + end + + @local_start_at + end + + # The local time when this transition causes the next observance to start, + # returned as a DateTime instance. + def local_start + local_start_at.to_datetime + end + + # The local time when this transition causes the next observance to start, + # returned as a Time instance. + def local_start_time + local_start_at.to_time + end + + # Returns true if this TimezoneTransition is equal to the given + # TimezoneTransition. Two TimezoneTransition instances are + # considered to be equal by == if offset, previous_offset and at are all + # equal. + def ==(tti) + tti.kind_of?(TimezoneTransition) && + offset == tti.offset && previous_offset == tti.previous_offset && at == tti.at + end + + # Returns true if this TimezoneTransition is equal to the given + # TimezoneTransition. Two TimezoneTransition instances are + # considered to be equal by eql? if offset, previous_offset and at are all + # equal and the type used to define at in both instances is the same. + def eql?(tti) + tti.kind_of?(TimezoneTransition) && + offset == tti.offset && previous_offset == tti.previous_offset && at.eql?(tti.at) + end + + # Returns a hash of this TimezoneTransition instance. + def hash + @offset.hash ^ @previous_offset.hash ^ at.hash + end + + # Returns internal object state as a programmer-readable string. + def inspect + "#<#{self.class}: #{at.inspect},#{@offset.inspect}>" + end + + private + + def raise_not_implemented(method_name) + raise NotImplementedError, "Subclasses must override #{method_name}" + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone_transition_definition.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone_transition_definition.rb new file mode 100644 index 0000000000..016816b850 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone_transition_definition.rb @@ -0,0 +1,104 @@ +module TZInfo + # A TimezoneTransition defined by as integer timestamp, as a rational to + # create a DateTime or as both. + # + # @private + class TimezoneTransitionDefinition < TimezoneTransition #:nodoc: + # The numerator of the DateTime if the transition time is defined as a + # DateTime, otherwise the transition time as a timestamp. + attr_reader :numerator_or_time + protected :numerator_or_time + + # Either the denominator of the DateTime if the transition time is defined + # as a DateTime, otherwise nil. + attr_reader :denominator + protected :denominator + + # Creates a new TimezoneTransitionDefinition with the given offset, + # previous_offset (both TimezoneOffset instances) and UTC time. + # + # The time can be specified as a timestamp, as a rational to create a + # DateTime, or as both. + # + # If both a timestamp and rational are given, then the rational will only + # be used if the timestamp falls outside of the range of Time on the + # platform being used at runtime. + # + # DateTimes are created from the rational as follows: + # + # RubyCoreSupport.datetime_new!(RubyCoreSupport.rational_new!(numerator, denominator), 0, Date::ITALY) + # + # For performance reasons, the numerator and denominator must be specified + # in their lowest form. + def initialize(offset, previous_offset, numerator_or_timestamp, denominator_or_numerator = nil, denominator = nil) + super(offset, previous_offset) + + if denominator + numerator = denominator_or_numerator + timestamp = numerator_or_timestamp + elsif denominator_or_numerator + numerator = numerator_or_timestamp + denominator = denominator_or_numerator + timestamp = nil + else + numerator = nil + denominator = nil + timestamp = numerator_or_timestamp + end + + # Determine whether to use the timestamp or the numerator and denominator. + if numerator && ( + !timestamp || + (timestamp < 0 && !RubyCoreSupport.time_supports_negative) || + ((timestamp < -2147483648 || timestamp > 2147483647) && !RubyCoreSupport.time_supports_64bit) + ) + + @numerator_or_time = numerator + @denominator = denominator + else + @numerator_or_time = timestamp + @denominator = nil + end + + @at = nil + end + + # A TimeOrDateTime instance representing the UTC time when this transition + # occurs. + def at + # Thread-safety: It is possible that the value of @at may be calculated + # multiple times in concurrently executing threads. It is not worth the + # overhead of locking to ensure that @at is only calculated once. + + unless @at + result = unless @denominator + TimeOrDateTime.new(@numerator_or_time) + else + r = RubyCoreSupport.rational_new!(@numerator_or_time, @denominator) + dt = RubyCoreSupport.datetime_new!(r, 0, Date::ITALY) + TimeOrDateTime.new(dt) + end + + return result if frozen? + @at = result + end + + @at + end + + # Returns true if this TimezoneTransitionDefinition is equal to the given + # TimezoneTransitionDefinition. Two TimezoneTransitionDefinition instances + # are considered to be equal by eql? if offset, previous_offset, + # numerator_or_time and denominator are all equal. + def eql?(tti) + tti.kind_of?(TimezoneTransitionDefinition) && + offset == tti.offset && previous_offset == tti.previous_offset && + numerator_or_time == tti.numerator_or_time && denominator == tti.denominator + end + + # Returns a hash of this TimezoneTransitionDefinition instance. + def hash + @offset.hash ^ @previous_offset.hash ^ @numerator_or_time.hash ^ @denominator.hash + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/transition_data_timezone_info.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/transition_data_timezone_info.rb new file mode 100644 index 0000000000..026bf227a7 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/transition_data_timezone_info.rb @@ -0,0 +1,274 @@ +module TZInfo + # Raised if no offsets have been defined when calling period_for_utc or + # periods_for_local. Indicates an error in the timezone data. + class NoOffsetsDefined < StandardError + end + + # Represents a data timezone defined by a set of offsets and a set + # of transitions. + # + # @private + class TransitionDataTimezoneInfo < DataTimezoneInfo #:nodoc: + + # Constructs a new TransitionDataTimezoneInfo with its identifier. + def initialize(identifier) + super(identifier) + @offsets = {} + @transitions = [] + @previous_offset = nil + @transitions_index = nil + end + + # Defines a offset. The id uniquely identifies this offset within the + # timezone. utc_offset and std_offset define the offset in seconds of + # standard time from UTC and daylight savings from standard time + # respectively. abbreviation describes the timezone offset (e.g. GMT, BST, + # EST or EDT). + # + # The first offset to be defined is treated as the offset that applies + # until the first transition. This will usually be in Local Mean Time (LMT). + # + # ArgumentError will be raised if the id is already defined. + def offset(id, utc_offset, std_offset, abbreviation) + raise ArgumentError, 'Offset already defined' if @offsets.has_key?(id) + + offset = TimezoneOffset.new(utc_offset, std_offset, abbreviation) + @offsets[id] = offset + @previous_offset = offset unless @previous_offset + end + + # Defines a transition. Transitions must be defined in chronological order. + # ArgumentError will be raised if a transition is added out of order. + # offset_id refers to an id defined with offset. ArgumentError will be + # raised if the offset_id cannot be found. numerator_or_time and + # denomiator specify the time the transition occurs as. See + # TimezoneTransition for more detail about specifying times. + def transition(year, month, offset_id, numerator_or_timestamp, denominator_or_numerator = nil, denominator = nil) + offset = @offsets[offset_id] + raise ArgumentError, 'Offset not found' unless offset + + if @transitions_index + if year < @last_year || (year == @last_year && month < @last_month) + raise ArgumentError, 'Transitions must be increasing date order' + end + + # Record the position of the first transition with this index. + index = transition_index(year, month) + @transitions_index[index] ||= @transitions.length + + # Fill in any gaps + (index - 1).downto(0) do |i| + break if @transitions_index[i] + @transitions_index[i] = @transitions.length + end + else + @transitions_index = [@transitions.length] + @start_year = year + @start_month = month + end + + @transitions << TimezoneTransitionDefinition.new(offset, @previous_offset, + numerator_or_timestamp, denominator_or_numerator, denominator) + @last_year = year + @last_month = month + @previous_offset = offset + end + + # Returns the TimezonePeriod for the given UTC time. + # Raises NoOffsetsDefined if no offsets have been defined. + def period_for_utc(utc) + unless @transitions.empty? + utc = TimeOrDateTime.wrap(utc) + index = transition_index(utc.year, utc.mon) + + start_transition = nil + start = transition_before_end(index) + if start + start.downto(0) do |i| + if @transitions[i].at <= utc + start_transition = @transitions[i] + break + end + end + end + + end_transition = nil + start = transition_after_start(index) + if start + start.upto(@transitions.length - 1) do |i| + if @transitions[i].at > utc + end_transition = @transitions[i] + break + end + end + end + + if start_transition || end_transition + TimezonePeriod.new(start_transition, end_transition) + else + # Won't happen since there are transitions. Must always find one + # transition that is either >= or < the specified time. + raise 'No transitions found in search' + end + else + raise NoOffsetsDefined, 'No offsets have been defined' unless @previous_offset + TimezonePeriod.new(nil, nil, @previous_offset) + end + end + + # Returns the set of TimezonePeriods for the given local time as an array. + # Results returned are ordered by increasing UTC start date. + # Returns an empty array if no periods are found for the given time. + # Raises NoOffsetsDefined if no offsets have been defined. + def periods_for_local(local) + unless @transitions.empty? + local = TimeOrDateTime.wrap(local) + index = transition_index(local.year, local.mon) + + result = [] + + start_index = transition_after_start(index - 1) + if start_index && @transitions[start_index].local_end_at > local + if start_index > 0 + if @transitions[start_index - 1].local_start_at <= local + result << TimezonePeriod.new(@transitions[start_index - 1], @transitions[start_index]) + end + else + result << TimezonePeriod.new(nil, @transitions[start_index]) + end + end + + end_index = transition_before_end(index + 1) + + if end_index + start_index = end_index unless start_index + + start_index.upto(transition_before_end(index + 1)) do |i| + if @transitions[i].local_start_at <= local + if i + 1 < @transitions.length + if @transitions[i + 1].local_end_at > local + result << TimezonePeriod.new(@transitions[i], @transitions[i + 1]) + end + else + result << TimezonePeriod.new(@transitions[i], nil) + end + end + end + end + + result + else + raise NoOffsetsDefined, 'No offsets have been defined' unless @previous_offset + [TimezonePeriod.new(nil, nil, @previous_offset)] + end + end + + # Returns an Array of TimezoneTransition instances representing the times + # where the UTC offset of the timezone changes. + # + # Transitions are returned up to a given date and time up to a given date + # and time, specified in UTC (utc_to). + # + # A from date and time may also be supplied using the utc_from parameter + # (also specified in UTC). If utc_from is not nil, only transitions from + # that date and time onwards will be returned. + # + # Comparisons with utc_to are exclusive. Comparisons with utc_from are + # inclusive. If a transition falls precisely on utc_to, it will be excluded. + # If a transition falls on utc_from, it will be included. + # + # Transitions returned are ordered by when they occur, from earliest to + # latest. + # + # utc_to and utc_from can be specified using either DateTime, Time or + # integer timestamps (Time.to_i). + # + # If utc_from is specified and utc_to is not greater than utc_from, then + # transitions_up_to raises an ArgumentError exception. + def transitions_up_to(utc_to, utc_from = nil) + utc_to = TimeOrDateTime.wrap(utc_to) + utc_from = utc_from ? TimeOrDateTime.wrap(utc_from) : nil + + if utc_from && utc_to <= utc_from + raise ArgumentError, 'utc_to must be greater than utc_from' + end + + unless @transitions.empty? + if utc_from + from = transition_after_start(transition_index(utc_from.year, utc_from.mon)) + + if from + while from < @transitions.length && @transitions[from].at < utc_from + from += 1 + end + + if from >= @transitions.length + return [] + end + else + # utc_from is later than last transition. + return [] + end + else + from = 0 + end + + to = transition_before_end(transition_index(utc_to.year, utc_to.mon)) + + if to + while to >= 0 && @transitions[to].at >= utc_to + to -= 1 + end + + if to < 0 + return [] + end + else + # utc_to is earlier than first transition. + return [] + end + + @transitions[from..to] + else + [] + end + end + + private + # Returns the index into the @transitions_index array for a given year + # and month. + def transition_index(year, month) + index = (year - @start_year) * 2 + index += 1 if month > 6 + index -= 1 if @start_month > 6 + index + end + + # Returns the index into @transitions of the first transition that occurs + # on or after the start of the given index into @transitions_index. + # Returns nil if there are no such transitions. + def transition_after_start(index) + if index >= @transitions_index.length + nil + else + index = 0 if index < 0 + @transitions_index[index] + end + end + + # Returns the index into @transitions of the first transition that occurs + # before the end of the given index into @transitions_index. + # Returns nil if there are no such transitions. + def transition_before_end(index) + index = index + 1 + + if index <= 0 + nil + elsif index >= @transitions_index.length + @transitions.length - 1 + else + @transitions_index[index] - 1 + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/zoneinfo_country_info.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/zoneinfo_country_info.rb new file mode 100644 index 0000000000..c99acaa8ed --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/zoneinfo_country_info.rb @@ -0,0 +1,37 @@ +module TZInfo + # Represents information about a country returned by ZoneinfoDataSource. + # + # @private + class ZoneinfoCountryInfo < CountryInfo #:nodoc: + # Constructs a new CountryInfo with an ISO 3166 country code, name and + # an array of CountryTimezones. + def initialize(code, name, zones) + super(code, name) + @zones = zones.dup.freeze + @zone_identifiers = nil + end + + # Returns a frozen array of all the zone identifiers for the country ordered + # geographically, most populous first. + def zone_identifiers + # Thread-safety: It is possible that the value of @zone_identifiers may be + # calculated multiple times in concurrently executing threads. It is not + # worth the overhead of locking to ensure that @zone_identifiers is only + # calculated once. + + unless @zone_identifiers + result = zones.collect {|zone| zone.identifier}.freeze + return result if frozen? + @zone_identifiers = result + end + + @zone_identifiers + end + + # Returns a frozen array of all the timezones for the for the country + # ordered geographically, most populous first. + def zones + @zones + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/zoneinfo_data_source.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/zoneinfo_data_source.rb new file mode 100644 index 0000000000..b38fbf68df --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/zoneinfo_data_source.rb @@ -0,0 +1,488 @@ +module TZInfo + # An InvalidZoneinfoDirectory exception is raised if the DataSource is + # set to a specific zoneinfo path, which is not a valid zoneinfo directory + # (i.e. a directory containing index files named iso3166.tab and zone.tab + # as well as other timezone files). + class InvalidZoneinfoDirectory < StandardError + end + + # A ZoneinfoDirectoryNotFound exception is raised if no valid zoneinfo + # directory could be found when checking the paths listed in + # ZoneinfoDataSource.search_path. A valid zoneinfo directory is one that + # contains timezone files, a country code index file named iso3166.tab and a + # timezone index file named zone1970.tab or zone.tab. + class ZoneinfoDirectoryNotFound < StandardError + end + + # A DataSource that loads data from a 'zoneinfo' directory containing + # compiled "TZif" version 3 (or earlier) files in addition to iso3166.tab and + # zone1970.tab or zone.tab index files. + # + # To have TZInfo load the system zoneinfo files, call TZInfo::DataSource.set + # as follows: + # + # TZInfo::DataSource.set(:zoneinfo) + # + # To load zoneinfo files from a particular directory, pass the directory to + # TZInfo::DataSource.set: + # + # TZInfo::DataSource.set(:zoneinfo, directory) + # + # Note that the platform used at runtime may limit the range of available + # transition data that can be loaded from zoneinfo files. There are two + # factors to consider: + # + # First of all, the zoneinfo support in TZInfo makes use of Ruby's Time class. + # On 32-bit builds of Ruby 1.8, the Time class only supports 32-bit + # timestamps. This means that only Times between 1901-12-13 20:45:52 and + # 2038-01-19 03:14:07 can be represented. Furthermore, certain platforms only + # allow for positive 32-bit timestamps (notably Windows), making the earliest + # representable time 1970-01-01 00:00:00. + # + # 64-bit builds of Ruby 1.8 and all builds of Ruby 1.9 support 64-bit + # timestamps. This means that there is no practical restriction on the range + # of the Time class on these platforms. + # + # TZInfo will only load transitions that fall within the supported range of + # the Time class. Any queries performed on times outside of this range may + # give inaccurate results. + # + # The second factor concerns the zoneinfo files. Versions of the 'zic' tool + # (used to build zoneinfo files) that were released prior to February 2006 + # created zoneinfo files that used 32-bit integers for transition timestamps. + # Later versions of zic produce zoneinfo files that use 64-bit integers. If + # you have 32-bit zoneinfo files on your system, then any queries falling + # outside of the range 1901-12-13 20:45:52 to 2038-01-19 03:14:07 may be + # inaccurate. + # + # Most modern platforms include 64-bit zoneinfo files. However, Mac OS X (up + # to at least 10.8.4) still uses 32-bit zoneinfo files. + # + # To check whether your zoneinfo files contain 32-bit or 64-bit transition + # data, you can run the following code (substituting the identifier of the + # zone you want to test for zone_identifier): + # + # TZInfo::DataSource.set(:zoneinfo) + # dir = TZInfo::DataSource.get.zoneinfo_dir + # File.open(File.join(dir, zone_identifier), 'r') {|f| f.read(5) } + # + # If the last line returns "TZif\\x00", then you have a 32-bit zoneinfo file. + # If it returns "TZif2" or "TZif3" then you have a 64-bit zoneinfo file. + # + # If you require support for 64-bit transitions, but are restricted to 32-bit + # zoneinfo support, then you may want to consider using TZInfo::RubyDataSource + # instead. + class ZoneinfoDataSource < DataSource + # The default value of ZoneinfoDataSource.search_path. + DEFAULT_SEARCH_PATH = ['/usr/share/zoneinfo', '/usr/share/lib/zoneinfo', '/etc/zoneinfo'].freeze + + # The default value of ZoneinfoDataSource.alternate_iso3166_tab_search_path. + DEFAULT_ALTERNATE_ISO3166_TAB_SEARCH_PATH = ['/usr/share/misc/iso3166.tab', '/usr/share/misc/iso3166'].freeze + + # Paths to be checked to find the system zoneinfo directory. + @@search_path = DEFAULT_SEARCH_PATH.dup + + # Paths to possible alternate iso3166.tab files (used to locate the + # system-wide iso3166.tab files on FreeBSD and OpenBSD). + @@alternate_iso3166_tab_search_path = DEFAULT_ALTERNATE_ISO3166_TAB_SEARCH_PATH.dup + + # An Array of directories that will be checked to find the system zoneinfo + # directory. + # + # Directories are checked in the order they appear in the Array. + # + # The default value is ['/usr/share/zoneinfo', '/usr/share/lib/zoneinfo', '/etc/zoneinfo']. + def self.search_path + @@search_path + end + + # Sets the directories to be checked when locating the system zoneinfo + # directory. + # + # Can be set to an Array of directories or a String containing directories + # separated with File::PATH_SEPARATOR. + # + # Directories are checked in the order they appear in the Array or String. + # + # Set to nil to revert to the default paths. + def self.search_path=(search_path) + @@search_path = process_search_path(search_path, DEFAULT_SEARCH_PATH) + end + + # An Array of paths that will be checked to find an alternate iso3166.tab + # file if one was not included in the zoneinfo directory (for example, on + # FreeBSD and OpenBSD systems). + # + # Paths are checked in the order they appear in the array. + # + # The default value is ['/usr/share/misc/iso3166.tab', '/usr/share/misc/iso3166']. + def self.alternate_iso3166_tab_search_path + @@alternate_iso3166_tab_search_path + end + + # Sets the paths to check to locate an alternate iso3166.tab file if one was + # not included in the zoneinfo directory. + # + # Can be set to an Array of directories or a String containing directories + # separated with File::PATH_SEPARATOR. + # + # Paths are checked in the order they appear in the array. + # + # Set to nil to revert to the default paths. + def self.alternate_iso3166_tab_search_path=(alternate_iso3166_tab_search_path) + @@alternate_iso3166_tab_search_path = process_search_path(alternate_iso3166_tab_search_path, DEFAULT_ALTERNATE_ISO3166_TAB_SEARCH_PATH) + end + + # The zoneinfo directory being used. + attr_reader :zoneinfo_dir + + # Creates a new ZoneinfoDataSource. + # + # If zoneinfo_dir is specified, it will be checked and used as the source + # of zoneinfo files. + # + # The directory must contain a file named iso3166.tab and a file named + # either zone1970.tab or zone.tab. These may either be included in the root + # of the directory or in a 'tab' sub-directory and named 'country.tab' and + # 'zone_sun.tab' respectively (as is the case on Solaris. + # + # Additionally, the path to iso3166.tab can be overridden using the + # alternate_iso3166_tab_path parameter. + # + # InvalidZoneinfoDirectory will be raised if the iso3166.tab and + # zone1970.tab or zone.tab files cannot be found using the zoneinfo_dir and + # alternate_iso3166_tab_path parameters. + # + # If zoneinfo_dir is not specified or nil, the paths referenced in + # search_path are searched in order to find a valid zoneinfo directory + # (one that contains zone1970.tab or zone.tab and iso3166.tab files as + # above). + # + # The paths referenced in alternate_iso3166_tab_search_path are also + # searched to find an iso3166.tab file if one of the searched zoneinfo + # directories doesn't contain an iso3166.tab file. + # + # If no valid directory can be found by searching, ZoneinfoDirectoryNotFound + # will be raised. + def initialize(zoneinfo_dir = nil, alternate_iso3166_tab_path = nil) + if zoneinfo_dir + iso3166_tab_path, zone_tab_path = validate_zoneinfo_dir(zoneinfo_dir, alternate_iso3166_tab_path) + + unless iso3166_tab_path && zone_tab_path + raise InvalidZoneinfoDirectory, "#{zoneinfo_dir} is not a directory or doesn't contain a iso3166.tab file and a zone1970.tab or zone.tab file." + end + + @zoneinfo_dir = zoneinfo_dir + else + @zoneinfo_dir, iso3166_tab_path, zone_tab_path = find_zoneinfo_dir + + unless @zoneinfo_dir && iso3166_tab_path && zone_tab_path + raise ZoneinfoDirectoryNotFound, "None of the paths included in TZInfo::ZoneinfoDataSource.search_path are valid zoneinfo directories." + end + end + + @zoneinfo_dir = File.expand_path(@zoneinfo_dir).freeze + @timezone_index = load_timezone_index.freeze + @country_index = load_country_index(iso3166_tab_path, zone_tab_path).freeze + end + + # Returns a TimezoneInfo instance for a given identifier. + # Raises InvalidTimezoneIdentifier if the timezone is not found or the + # identifier is invalid. + def load_timezone_info(identifier) + begin + if @timezone_index.include?(identifier) + path = File.join(@zoneinfo_dir, identifier) + + # Untaint path rather than identifier. We don't want to modify + # identifier. identifier may also be frozen and therefore cannot be + # untainted. + path.untaint + + begin + ZoneinfoTimezoneInfo.new(identifier, path) + rescue InvalidZoneinfoFile => e + raise InvalidTimezoneIdentifier, e.message + end + else + raise InvalidTimezoneIdentifier, 'Invalid identifier' + end + rescue Errno::ENOENT, Errno::ENAMETOOLONG, Errno::ENOTDIR + raise InvalidTimezoneIdentifier, 'Invalid identifier' + rescue Errno::EACCES => e + raise InvalidTimezoneIdentifier, e.message + end + end + + # Returns an array of all the available timezone identifiers. + def timezone_identifiers + @timezone_index + end + + # Returns an array of all the available timezone identifiers for + # data timezones (i.e. those that actually contain definitions). + # + # For ZoneinfoDataSource, this will always be identical to + # timezone_identifers. + def data_timezone_identifiers + @timezone_index + end + + # Returns an array of all the available timezone identifiers that + # are links to other timezones. + # + # For ZoneinfoDataSource, this will always be an empty array. + def linked_timezone_identifiers + [].freeze + end + + # Returns a CountryInfo instance for the given ISO 3166-1 alpha-2 + # country code. Raises InvalidCountryCode if the country could not be found + # or the code is invalid. + def load_country_info(code) + info = @country_index[code] + raise InvalidCountryCode, 'Invalid country code' unless info + info + end + + # Returns an array of all the available ISO 3166-1 alpha-2 + # country codes. + def country_codes + @country_index.keys.freeze + end + + # Returns the name and information about this DataSource. + def to_s + "Zoneinfo DataSource: #{@zoneinfo_dir}" + end + + # Returns internal object state as a programmer-readable string. + def inspect + "#<#{self.class}: #{@zoneinfo_dir}>" + end + + private + + # Processes a path for use as the search_path or + # alternate_iso3166_tab_search_path. + def self.process_search_path(path, default) + if path + if path.kind_of?(String) + path.split(File::PATH_SEPARATOR) + else + path.collect {|p| p.to_s} + end + else + default.dup + end + end + + # Validates a zoneinfo directory and returns the paths to the iso3166.tab + # and zone1970.tab or zone.tab files if valid. If the directory is not + # valid, returns nil. + # + # The path to the iso3166.tab file may be overriden by passing in a path. + # This is treated as either absolute or relative to the current working + # directory. + def validate_zoneinfo_dir(path, iso3166_tab_path = nil) + if File.directory?(path) + if iso3166_tab_path + return nil unless File.file?(iso3166_tab_path) + else + iso3166_tab_path = resolve_tab_path(path, ['iso3166.tab'], 'country.tab') + return nil unless iso3166_tab_path + end + + zone_tab_path = resolve_tab_path(path, ['zone1970.tab', 'zone.tab'], 'zone_sun.tab') + return nil unless zone_tab_path + + [iso3166_tab_path, zone_tab_path] + else + nil + end + end + + # Attempts to resolve the path to a tab file given its standard names and + # tab sub-directory name (as used on Solaris). + def resolve_tab_path(zoneinfo_path, standard_names, tab_name) + standard_names.each do |standard_name| + path = File.join(zoneinfo_path, standard_name) + return path if File.file?(path) + end + + path = File.join(zoneinfo_path, 'tab', tab_name) + return path if File.file?(path) + + nil + end + + # Finds a zoneinfo directory using search_path and + # alternate_iso3166_tab_search_path. Returns the paths to the directory, + # the iso3166.tab file and the zone.tab file or nil if not found. + def find_zoneinfo_dir + alternate_iso3166_tab_path = self.class.alternate_iso3166_tab_search_path.detect do |path| + File.file?(path) + end + + self.class.search_path.each do |path| + # Try without the alternate_iso3166_tab_path first. + iso3166_tab_path, zone_tab_path = validate_zoneinfo_dir(path) + return path, iso3166_tab_path, zone_tab_path if iso3166_tab_path && zone_tab_path + + if alternate_iso3166_tab_path + iso3166_tab_path, zone_tab_path = validate_zoneinfo_dir(path, alternate_iso3166_tab_path) + return path, iso3166_tab_path, zone_tab_path if iso3166_tab_path && zone_tab_path + end + end + + # Not found. + nil + end + + # Scans @zoneinfo_dir and returns an Array of available timezone + # identifiers. + def load_timezone_index + index = [] + + # Ignoring particular files: + # +VERSION is included on Mac OS X. + # leapseconds is a list of leap seconds. + # localtime is the current local timezone (may be a link). + # posix, posixrules and right are directories containing other versions of the zoneinfo files. + # src is a directory containing the tzdata source included on Solaris. + # timeconfig is a symlink included on Slackware. + + enum_timezones(nil, ['+VERSION', 'leapseconds', 'localtime', 'posix', 'posixrules', 'right', 'src', 'timeconfig']) do |identifier| + index << identifier + end + + index.sort + end + + # Recursively scans a directory of timezones, calling the passed in block + # for each identifier found. + def enum_timezones(dir, exclude = [], &block) + Dir.foreach(dir ? File.join(@zoneinfo_dir, dir) : @zoneinfo_dir) do |entry| + unless entry =~ /\./ || exclude.include?(entry) + entry.untaint + path = dir ? File.join(dir, entry) : entry + full_path = File.join(@zoneinfo_dir, path) + + if File.directory?(full_path) + enum_timezones(path, [], &block) + elsif File.file?(full_path) + yield path + end + end + end + end + + # Uses the iso3166.tab and zone1970.tab or zone.tab files to build an index + # of the available countries and their timezones. + def load_country_index(iso3166_tab_path, zone_tab_path) + + # Handle standard 3 to 4 column zone.tab files as well as the 4 to 5 + # column format used by Solaris. + # + # On Solaris, an extra column before the comment gives an optional + # linked/alternate timezone identifier (or '-' if not set). + # + # Additionally, there is a section at the end of the file for timezones + # covering regions. These are given lower-case "country" codes. The timezone + # identifier column refers to a continent instead of an identifier. These + # lines will be ignored by TZInfo. + # + # Since the last column is optional in both formats, testing for the + # Solaris format is done in two passes. The first pass identifies if there + # are any lines using 5 columns. + + + # The first column is allowed to be a comma separated list of country + # codes, as used in zone1970.tab (introduced in tzdata 2014f). + # + # The first country code in the comma-separated list is the country that + # contains the city the zone identifer is based on. The first country + # code on each line is considered to be primary with the others + # secondary. + # + # The zones for each country are ordered primary first, then secondary. + # Within the primary and secondary groups, the zones are ordered by their + # order in the file. + + file_is_5_column = false + zone_tab = [] + + RubyCoreSupport.open_file(zone_tab_path, 'r', :external_encoding => 'UTF-8', :internal_encoding => 'UTF-8') do |file| + file.each_line do |line| + line.chomp! + + if line =~ /\A([A-Z]{2}(?:,[A-Z]{2})*)\t(?:([+\-])(\d{2})(\d{2})([+\-])(\d{3})(\d{2})|([+\-])(\d{2})(\d{2})(\d{2})([+\-])(\d{3})(\d{2})(\d{2}))\t([^\t]+)(?:\t([^\t]+))?(?:\t([^\t]+))?\z/ + codes = $1 + + if $2 + latitude = dms_to_rational($2, $3, $4) + longitude = dms_to_rational($5, $6, $7) + else + latitude = dms_to_rational($8, $9, $10, $11) + longitude = dms_to_rational($12, $13, $14, $15) + end + + zone_identifier = $16 + column4 = $17 + column5 = $18 + + file_is_5_column = true if column5 + + zone_tab << [codes.split(','.freeze), zone_identifier, latitude, longitude, column4, column5] + end + end + end + + primary_zones = {} + secondary_zones = {} + + zone_tab.each do |codes, zone_identifier, latitude, longitude, column4, column5| + description = file_is_5_column ? column5 : column4 + country_timezone = CountryTimezone.new(zone_identifier, latitude, longitude, description) + + # codes will always have at least one element + + (primary_zones[codes.first] ||= []) << country_timezone + + codes[1..-1].each do |code| + (secondary_zones[code] ||= []) << country_timezone + end + end + + countries = {} + + RubyCoreSupport.open_file(iso3166_tab_path, 'r', :external_encoding => 'UTF-8', :internal_encoding => 'UTF-8') do |file| + file.each_line do |line| + line.chomp! + + # Handle both the two column alpha-2 and name format used in the tz + # database as well as the 4 column alpha-2, alpha-3, numeric-3 and + # name format used by FreeBSD and OpenBSD. + + if line =~ /\A([A-Z]{2})(?:\t[A-Z]{3}\t[0-9]{3})?\t(.+)\z/ + code = $1 + name = $2 + zones = (primary_zones[code] || []) + (secondary_zones[code] || []) + + countries[code] = ZoneinfoCountryInfo.new(code, name, zones) + end + end + end + + countries + end + + # Converts degrees, minutes and seconds to a Rational. + def dms_to_rational(sign, degrees, minutes, seconds = nil) + result = degrees.to_i + Rational(minutes.to_i, 60) + result += Rational(seconds.to_i, 3600) if seconds + result = -result if sign == '-'.freeze + result + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/zoneinfo_timezone_info.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/zoneinfo_timezone_info.rb new file mode 100644 index 0000000000..d145614d60 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/tzinfo-1.2.5/lib/tzinfo/zoneinfo_timezone_info.rb @@ -0,0 +1,296 @@ +module TZInfo + # An InvalidZoneinfoFile exception is raised if an attempt is made to load an + # invalid zoneinfo file. + class InvalidZoneinfoFile < StandardError + end + + # Represents a timezone defined by a compiled zoneinfo TZif (\0, 2 or 3) file. + # + # @private + class ZoneinfoTimezoneInfo < TransitionDataTimezoneInfo #:nodoc: + + # Minimum supported timestamp (inclusive). + # + # Time.utc(1700, 1, 1).to_i + MIN_TIMESTAMP = -8520336000 + + # Maximum supported timestamp (exclusive). + # + # Time.utc(2500, 1, 1).to_i + MAX_TIMESTAMP = 16725225600 + + # Constructs the new ZoneinfoTimezoneInfo with an identifier and path + # to the file. + def initialize(identifier, file_path) + super(identifier) + + File.open(file_path, 'rb') do |file| + parse(file) + end + end + + private + # Unpack will return unsigned 32-bit integers. Translate to + # signed 32-bit. + def make_signed_int32(long) + long >= 0x80000000 ? long - 0x100000000 : long + end + + # Unpack will return a 64-bit integer as two unsigned 32-bit integers + # (most significant first). Translate to signed 64-bit + def make_signed_int64(high, low) + unsigned = (high << 32) | low + unsigned >= 0x8000000000000000 ? unsigned - 0x10000000000000000 : unsigned + end + + # Read bytes from file and check that the correct number of bytes could + # be read. Raises InvalidZoneinfoFile if the number of bytes didn't match + # the number requested. + def check_read(file, bytes) + result = file.read(bytes) + + unless result && result.length == bytes + raise InvalidZoneinfoFile, "Expected #{bytes} bytes reading '#{file.path}', but got #{result ? result.length : 0} bytes" + end + + result + end + + # Zoneinfo files don't include the offset from standard time (std_offset) + # for DST periods. Derive the base offset (utc_offset) where DST is + # observed from either the previous or next non-DST period. + # + # Returns the index of the offset to be used prior to the first + # transition. + def derive_offsets(transitions, offsets) + # The first non-DST offset (if there is one) is the offset observed + # before the first transition. Fallback to the first DST offset if there + # are no non-DST offsets. + first_non_dst_offset_index = offsets.index {|o| !o[:is_dst] } + first_offset_index = first_non_dst_offset_index || 0 + return first_offset_index if transitions.empty? + + # Determine the utc_offset of the next non-dst offset at each transition. + utc_offset_from_next = nil + + transitions.reverse_each do |transition| + offset = offsets[transition[:offset]] + if offset[:is_dst] + transition[:utc_offset_from_next] = utc_offset_from_next if utc_offset_from_next + else + utc_offset_from_next = offset[:utc_total_offset] + end + end + + utc_offset_from_previous = first_non_dst_offset_index ? offsets[first_non_dst_offset_index][:utc_total_offset] : nil + defined_offsets = {} + + transitions.each do |transition| + offset_index = transition[:offset] + offset = offsets[offset_index] + utc_total_offset = offset[:utc_total_offset] + + if offset[:is_dst] + utc_offset_from_next = transition[:utc_offset_from_next] + + difference_to_previous = (utc_total_offset - (utc_offset_from_previous || utc_total_offset)).abs + difference_to_next = (utc_total_offset - (utc_offset_from_next || utc_total_offset)).abs + + utc_offset = if difference_to_previous == 3600 + utc_offset_from_previous + elsif difference_to_next == 3600 + utc_offset_from_next + elsif difference_to_previous > 0 && difference_to_next > 0 + difference_to_previous < difference_to_next ? utc_offset_from_previous : utc_offset_from_next + elsif difference_to_previous > 0 + utc_offset_from_previous + elsif difference_to_next > 0 + utc_offset_from_next + else + # No difference, assume a 1 hour offset from standard time. + utc_total_offset - 3600 + end + + if !offset[:utc_offset] + offset[:utc_offset] = utc_offset + defined_offsets[offset] = offset_index + elsif offset[:utc_offset] != utc_offset + # An earlier transition has already derived a different + # utc_offset. Define a new offset or reuse an existing identically + # defined offset. + new_offset = offset.dup + new_offset[:utc_offset] = utc_offset + + offset_index = defined_offsets[new_offset] + + unless offset_index + offsets << new_offset + offset_index = offsets.length - 1 + defined_offsets[new_offset] = offset_index + end + + transition[:offset] = offset_index + end + else + utc_offset_from_previous = utc_total_offset + end + end + + first_offset_index + end + + # Defines an offset for the timezone based on the given index and offset + # Hash. + def define_offset(index, offset) + utc_total_offset = offset[:utc_total_offset] + utc_offset = offset[:utc_offset] + + if utc_offset + # DST offset with base utc_offset derived by derive_offsets. + std_offset = utc_total_offset - utc_offset + elsif offset[:is_dst] + # DST offset unreferenced by a transition (offset in use before the + # first transition). No derived base UTC offset, so assume 1 hour + # DST. + utc_offset = utc_total_offset - 3600 + std_offset = 3600 + else + # Non-DST offset. + utc_offset = utc_total_offset + std_offset = 0 + end + + offset index, utc_offset, std_offset, offset[:abbr].untaint.to_sym + end + + # Parses a zoneinfo file and intializes the DataTimezoneInfo structures. + def parse(file) + magic, version, ttisgmtcnt, ttisstdcnt, leapcnt, timecnt, typecnt, charcnt = + check_read(file, 44).unpack('a4 a x15 NNNNNN') + + if magic != 'TZif' + raise InvalidZoneinfoFile, "The file '#{file.path}' does not start with the expected header." + end + + if (version == '2' || version == '3') && RubyCoreSupport.time_supports_64bit + # Skip the first 32-bit section and read the header of the second 64-bit section + file.seek(timecnt * 5 + typecnt * 6 + charcnt + leapcnt * 8 + ttisgmtcnt + ttisstdcnt, IO::SEEK_CUR) + + prev_version = version + + magic, version, ttisgmtcnt, ttisstdcnt, leapcnt, timecnt, typecnt, charcnt = + check_read(file, 44).unpack('a4 a x15 NNNNNN') + + unless magic == 'TZif' && (version == prev_version) + raise InvalidZoneinfoFile, "The file '#{file.path}' contains an invalid 64-bit section header." + end + + using_64bit = true + elsif version != '3' && version != '2' && version != "\0" + raise InvalidZoneinfoFile, "The file '#{file.path}' contains a version of the zoneinfo format that is not currently supported." + else + using_64bit = false + end + + unless leapcnt == 0 + raise InvalidZoneinfoFile, "The zoneinfo file '#{file.path}' contains leap second data. TZInfo requires zoneinfo files that omit leap seconds." + end + + transitions = [] + + if using_64bit + timecnt.times do |i| + high, low = check_read(file, 8).unpack('NN'.freeze) + transition_time = make_signed_int64(high, low) + transitions << {:at => transition_time} + end + else + timecnt.times do |i| + transition_time = make_signed_int32(check_read(file, 4).unpack('N'.freeze)[0]) + transitions << {:at => transition_time} + end + end + + timecnt.times do |i| + localtime_type = check_read(file, 1).unpack('C'.freeze)[0] + transitions[i][:offset] = localtime_type + end + + offsets = [] + + typecnt.times do |i| + gmtoff, isdst, abbrind = check_read(file, 6).unpack('NCC'.freeze) + gmtoff = make_signed_int32(gmtoff) + isdst = isdst == 1 + offset = {:utc_total_offset => gmtoff, :is_dst => isdst, :abbr_index => abbrind} + + unless isdst + offset[:utc_offset] = gmtoff + offset[:std_offset] = 0 + end + + offsets << offset + end + + abbrev = check_read(file, charcnt) + + offsets.each do |o| + abbrev_start = o[:abbr_index] + raise InvalidZoneinfoFile, "Abbreviation index is out of range in file '#{file.path}'" unless abbrev_start < abbrev.length + + abbrev_end = abbrev.index("\0", abbrev_start) + raise InvalidZoneinfoFile, "Missing abbreviation null terminator in file '#{file.path}'" unless abbrev_end + + o[:abbr] = RubyCoreSupport.force_encoding(abbrev[abbrev_start...abbrev_end], 'UTF-8') + end + + transitions.each do |t| + if t[:offset] < 0 || t[:offset] >= offsets.length + raise InvalidZoneinfoFile, "Invalid offset referenced by transition in file '#{file.path}'." + end + end + + # Derive the offsets from standard time (std_offset). + first_offset_index = derive_offsets(transitions, offsets) + + define_offset(first_offset_index, offsets[first_offset_index]) + + offsets.each_with_index do |o, i| + define_offset(i, o) unless i == first_offset_index + end + + if !using_64bit && !RubyCoreSupport.time_supports_negative + # Filter out transitions that are not supported by Time on this + # platform. + + # Move the last transition before the epoch up to the epoch. This + # allows for accurate conversions for all supported timestamps on the + # platform. + + before_epoch, after_epoch = transitions.partition {|t| t[:at] < 0} + + if before_epoch.length > 0 && after_epoch.length > 0 && after_epoch.first[:at] != 0 + last_before = before_epoch.last + last_before[:at] = 0 + transitions = [last_before] + after_epoch + else + transitions = after_epoch + end + end + + # Ignore transitions that occur outside of a defined window. The + # transition index cannot handle a large range of transition times. + # + # This is primarily intended to ignore the far in the past transition + # added in zic 2014c (at timestamp -2**63 in zic 2014c and at the + # approximate time of the big bang from zic 2014d). + transitions.each do |t| + at = t[:at] + if at >= MIN_TIMESTAMP && at < MAX_TIMESTAMP + time = Time.at(at).utc + transition time.year, time.mon, t[:offset], at + end + end + end + end +end From 72f350e7578022f9a0b7bec4a86b948b203721fc Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 17 Sep 2018 19:30:00 +0200 Subject: [PATCH 2/5] =?UTF-8?q?Use=20ActiveSupport=E2=80=99s=20`#second=5F?= =?UTF-8?q?to=5Flast`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Library/Homebrew/global.rb | 1 + Library/Homebrew/tab.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb index 2ca701c870..3ed18d7229 100644 --- a/Library/Homebrew/global.rb +++ b/Library/Homebrew/global.rb @@ -8,6 +8,7 @@ require "pp" require_relative "load_path" require "active_support/core_ext/numeric/time" +require "active_support/core_ext/array/access" require "config" require "os" require "extend/ARGV" diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb index 76ba9ebb0f..daac01b7e5 100644 --- a/Library/Homebrew/tab.rb +++ b/Library/Homebrew/tab.rb @@ -78,7 +78,7 @@ class Tab < OpenStruct end if attributes["source"]["spec"].nil? - version = PkgVersion.parse path.to_s.split("/")[-2] + version = PkgVersion.parse path.to_s.split("/").second_to_last if version.head? attributes["source"]["spec"] = "head" else From c4d418e1266302d5af11009b4d1f8f068e6a609b Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 17 Sep 2018 19:44:12 +0200 Subject: [PATCH 3/5] =?UTF-8?q?Use=20ActiveSupport=E2=80=99s=20`#second`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Library/Homebrew/brew.rb | 4 +--- Library/Homebrew/cask/artifact/abstract_uninstall.rb | 6 ++---- Library/Homebrew/cask/dsl/version.rb | 8 ++++---- Library/Homebrew/cmd/switch.rb | 2 +- Library/Homebrew/cmd/tap.rb | 4 ++-- Library/Homebrew/dev-cmd/audit.rb | 4 ++-- Library/Homebrew/dev-cmd/extract.rb | 2 +- Library/Homebrew/dev-cmd/release-notes.rb | 2 +- Library/Homebrew/dev-cmd/update-test.rb | 4 ++-- Library/Homebrew/exceptions.rb | 2 +- Library/Homebrew/formula.rb | 6 +++--- Library/Homebrew/language/haskell.rb | 4 +--- Library/Homebrew/tap.rb | 4 ++-- Library/Homebrew/test/cask/dsl_spec.rb | 8 ++++---- Library/Homebrew/test/patch_spec.rb | 4 ++-- .../helper/spec/shared_context/integration_test.rb | 5 +++-- Library/Homebrew/utils/bottles.rb | 2 +- Library/Homebrew/utils/tty.rb | 4 ++-- Library/Homebrew/version.rb | 2 +- 19 files changed, 36 insertions(+), 41 deletions(-) diff --git a/Library/Homebrew/brew.rb b/Library/Homebrew/brew.rb index e1058ef5f6..ba8e445c8d 100644 --- a/Library/Homebrew/brew.rb +++ b/Library/Homebrew/brew.rb @@ -5,9 +5,7 @@ end std_trap = trap("INT") { exit! 130 } # no backtrace thanks # check ruby version before requiring any modules. -RUBY_VERSION_SPLIT = RUBY_VERSION.split "." -RUBY_X = RUBY_VERSION_SPLIT[0].to_i -RUBY_Y = RUBY_VERSION_SPLIT[1].to_i +RUBY_X, RUBY_Y, = RUBY_VERSION.split(".").map(&:to_i) if RUBY_X < 2 || (RUBY_X == 2 && RUBY_Y < 3) raise "Homebrew must be run under Ruby 2.3! You're running #{RUBY_VERSION}." end diff --git a/Library/Homebrew/cask/artifact/abstract_uninstall.rb b/Library/Homebrew/cask/artifact/abstract_uninstall.rb index d325618631..6c5e295539 100644 --- a/Library/Homebrew/cask/artifact/abstract_uninstall.rb +++ b/Library/Homebrew/cask/artifact/abstract_uninstall.rb @@ -115,10 +115,8 @@ module Cask command.run!("/bin/launchctl", args: ["list"]).stdout.lines .map { |line| line.chomp.split("\t") } .map { |pid, state, id| [pid.to_i, state.to_i, id] } - .select do |fields| - next if fields[0].zero? - - fields[2] =~ /^#{Regexp.escape(bundle_id)}($|\.\d+)/ + .select do |(pid, _, id)| + pid.nonzero? && id.match?(/^#{Regexp.escape(bundle_id)}($|\.\d+)/) end end diff --git a/Library/Homebrew/cask/dsl/version.rb b/Library/Homebrew/cask/dsl/version.rb index 263ef60006..8941854fe3 100644 --- a/Library/Homebrew/cask/dsl/version.rb +++ b/Library/Homebrew/cask/dsl/version.rb @@ -89,19 +89,19 @@ module Cask end def before_comma - version { split(",", 2)[0] } + version { split(",", 2).first } end def after_comma - version { split(",", 2)[1] } + version { split(",", 2).second } end def before_colon - version { split(":", 2)[0] } + version { split(":", 2).first } end def after_colon - version { split(":", 2)[1] } + version { split(":", 2).second } end def no_dividers diff --git a/Library/Homebrew/cmd/switch.rb b/Library/Homebrew/cmd/switch.rb index 1393e3052f..bf22f484a5 100644 --- a/Library/Homebrew/cmd/switch.rb +++ b/Library/Homebrew/cmd/switch.rb @@ -28,7 +28,7 @@ module Homebrew .map { |d| Keg.new(d).version } .sort .join(", ") - version = ARGV[1] + version = ARGV.second if !version || ARGV.named.length > 2 onoe usage diff --git a/Library/Homebrew/cmd/tap.rb b/Library/Homebrew/cmd/tap.rb index 86406910c1..3b723a73ec 100644 --- a/Library/Homebrew/cmd/tap.rb +++ b/Library/Homebrew/cmd/tap.rb @@ -45,9 +45,9 @@ module Homebrew elsif ARGV.named.empty? puts Tap.names else - tap = Tap.fetch(ARGV.named[0]) + tap = Tap.fetch(ARGV.named.first) begin - tap.install clone_target: ARGV.named[1], + tap.install clone_target: ARGV.named.second, force_auto_update: force_auto_update?, full_clone: full_clone?, quiet: ARGV.quieter? diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 6e76a4b542..c4fa8b4097 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -512,7 +512,7 @@ module Homebrew # Formulae names can legitimately be uppercase/lowercase/both. name = Regexp.new(formula.name, Regexp::IGNORECASE) reason.sub!(name, "") - first_word = reason.split[0] + first_word = reason.split.first if reason =~ /\A[A-Z]/ && !reason.start_with?(*whitelist) problem <<~EOS @@ -724,7 +724,7 @@ module Homebrew version = Version.parse(stable.url) if version >= Version.create("1.0") - minor_version = version.to_s.split(".", 3)[1].to_i + _, minor_version, = version.to_s.split(".", 3).map(&:to_i) if minor_version.odd? problem "#{stable.version} is a development release" end diff --git a/Library/Homebrew/dev-cmd/extract.rb b/Library/Homebrew/dev-cmd/extract.rb index ae199ceaa6..3e4813fdd8 100644 --- a/Library/Homebrew/dev-cmd/extract.rb +++ b/Library/Homebrew/dev-cmd/extract.rb @@ -120,7 +120,7 @@ module Homebrew # Expect exactly two named arguments: formula and tap raise UsageError if ARGV.named.length != 2 - destination_tap = Tap.fetch(ARGV.named[1]) + destination_tap = Tap.fetch(ARGV.named.second) odie "Cannot extract formula to homebrew/core!" if destination_tap.core_tap? destination_tap.install unless destination_tap.installed? diff --git a/Library/Homebrew/dev-cmd/release-notes.rb b/Library/Homebrew/dev-cmd/release-notes.rb index 8445ee2d58..2a990a8617 100644 --- a/Library/Homebrew/dev-cmd/release-notes.rb +++ b/Library/Homebrew/dev-cmd/release-notes.rb @@ -33,7 +33,7 @@ module Homebrew ).lines.first.chomp odie "Could not find any previous tags!" unless previous_tag - end_ref = ARGV.named[1] || "origin/master" + end_ref = ARGV.named.second || "origin/master" [previous_tag, end_ref].each do |ref| next if quiet_system "git", "-C", HOMEBREW_REPOSITORY, "rev-parse", "--verify", "--quiet", ref diff --git a/Library/Homebrew/dev-cmd/update-test.rb b/Library/Homebrew/dev-cmd/update-test.rb index 7a1ffef27f..c9aec5b31a 100644 --- a/Library/Homebrew/dev-cmd/update-test.rb +++ b/Library/Homebrew/dev-cmd/update-test.rb @@ -61,7 +61,7 @@ module Homebrew Utils.popen_read("git", "rev-list", "-n1", "--before=#{date}", "origin/master").chomp elsif args.to_tag? tags = Utils.popen_read("git", "tag", "--list", "--sort=-version:refname") - previous_tag = tags.lines[1] + previous_tag = tags.lines.second previous_tag ||= begin if (HOMEBREW_REPOSITORY/".git/shallow").exist? safe_system "git", "fetch", "--tags", "--depth=1" @@ -69,7 +69,7 @@ module Homebrew elsif OS.linux? tags = Utils.popen_read("git tag --list | sort -rV") end - tags.lines[1] + tags.lines.second end previous_tag = previous_tag.to_s.chomp odie "Could not find previous tag in:\n#{tags}" if previous_tag.empty? diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index a72e448b2f..087e95b87c 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -105,7 +105,7 @@ module FormulaClassUnavailableErrorModule end def format_list(class_list) - class_list.map { |klass| klass.name.split("::")[-1] }.join(", ") + class_list.map { |klass| klass.name.split("::").last }.join(", ") end end diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index df3fe7d924..290187466d 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -417,7 +417,7 @@ class Formula def aliases @aliases ||= if tap tap.alias_reverse_table[full_name].to_a.map do |a| - a.split("/")[-1] + a.split("/").last end else [] @@ -1371,7 +1371,7 @@ class Formula # an array of all {Formula} names # @private def self.names - @names ||= (core_names + tap_names.map { |name| name.split("/")[-1] }).uniq.sort + @names ||= (core_names + tap_names.map { |name| name.split("/").last }).uniq.sort end # an array of all {Formula} files @@ -1462,7 +1462,7 @@ class Formula # an array of all aliases # @private def self.aliases - @aliases ||= (core_aliases + tap_aliases.map { |name| name.split("/")[-1] }).uniq.sort + @aliases ||= (core_aliases + tap_aliases.map { |name| name.split("/").last }).uniq.sort end # an array of all aliases, , which the tap formulae have the fully-qualified name diff --git a/Library/Homebrew/language/haskell.rb b/Library/Homebrew/language/haskell.rb index ee0a061624..dfe6a0dde6 100644 --- a/Library/Homebrew/language/haskell.rb +++ b/Library/Homebrew/language/haskell.rb @@ -71,9 +71,7 @@ module Language rm_rf Dir[".cabal-sandbox/*packages.conf.d/"] end - def install_cabal_package(*args) - options = args[-1].is_a?(Hash) ? args.pop : {} - + def install_cabal_package(*args, **options) cabal_sandbox do cabal_install_tools(*options[:using]) if options[:using] diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 5efae23011..0e73ff545d 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -17,8 +17,8 @@ class Tap when 1 user, repo = args.first.split("/", 2) when 2 - user = args[0] - repo = args[1] + user = args.first + repo = args.second end if [user, repo].any? { |part| part.nil? || part.include?("/") } diff --git a/Library/Homebrew/test/cask/dsl_spec.rb b/Library/Homebrew/test/cask/dsl_spec.rb index fb1d05c60e..2528563a75 100644 --- a/Library/Homebrew/test/cask/dsl_spec.rb +++ b/Library/Homebrew/test/cask/dsl_spec.rb @@ -419,10 +419,10 @@ describe Cask::DSL, :cask do let(:token) { "with-installer-script" } it "allows installer script to be specified" do - expect(cask.artifacts.to_a[0].path).to eq(Pathname("/usr/bin/true")) - expect(cask.artifacts.to_a[0].args[:args]).to eq(["--flag"]) - expect(cask.artifacts.to_a[1].path).to eq(Pathname("/usr/bin/false")) - expect(cask.artifacts.to_a[1].args[:args]).to eq(["--flag"]) + expect(cask.artifacts.to_a.first.path).to eq(Pathname("/usr/bin/true")) + expect(cask.artifacts.to_a.first.args[:args]).to eq(["--flag"]) + expect(cask.artifacts.to_a.second.path).to eq(Pathname("/usr/bin/false")) + expect(cask.artifacts.to_a.second.args[:args]).to eq(["--flag"]) end end diff --git a/Library/Homebrew/test/patch_spec.rb b/Library/Homebrew/test/patch_spec.rb index 1c4ba05a3a..dc1ec2b9b3 100644 --- a/Library/Homebrew/test/patch_spec.rb +++ b/Library/Homebrew/test/patch_spec.rb @@ -86,8 +86,8 @@ describe Patch do ) expect(patches.length).to eq(2) - expect(patches[0].strip).to eq(:p1) - expect(patches[1].strip).to eq(:p1) + expect(patches.first.strip).to eq(:p1) + expect(patches.second.strip).to eq(:p1) end it "can create patches from a :p0 hash" do diff --git a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb index e2e518c6c1..c09ae260b6 100644 --- a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb +++ b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb @@ -53,8 +53,9 @@ RSpec.shared_context "integration test" do def command_id_from_args(args) @command_count ||= 0 pretty_args = args.join(" ").gsub(TEST_TMPDIR, "@TMPDIR@") - file_and_line = caller[1].sub(/(.*\d+):.*/, '\1') - .sub("#{HOMEBREW_LIBRARY_PATH}/test/", "") + file_and_line = caller.second + .sub(/(.*\d+):.*/, '\1') + .sub("#{HOMEBREW_LIBRARY_PATH}/test/", "") "#{file_and_line}:brew #{pretty_args}:#{@command_count += 1}" end diff --git a/Library/Homebrew/utils/bottles.rb b/Library/Homebrew/utils/bottles.rb index 648c3d88b1..832b815ff4 100644 --- a/Library/Homebrew/utils/bottles.rb +++ b/Library/Homebrew/utils/bottles.rb @@ -54,7 +54,7 @@ module Utils end def resolve_version(bottle_file) - PkgVersion.parse receipt_path(bottle_file).split("/")[1] + PkgVersion.parse receipt_path(bottle_file).split("/").second end def formula_contents(bottle_file, diff --git a/Library/Homebrew/utils/tty.rb b/Library/Homebrew/utils/tty.rb index f52c874d97..8a98cf1a29 100644 --- a/Library/Homebrew/utils/tty.rb +++ b/Library/Homebrew/utils/tty.rb @@ -7,8 +7,8 @@ module Tty def width @width ||= begin - width = `/bin/stty size 2>/dev/null`.split[1] - width = `/usr/bin/tput cols 2>/dev/null`.split[0] if width.to_i.zero? + _, width = `/bin/stty size 2>/dev/null`.split + width, = `/usr/bin/tput cols 2>/dev/null`.split if width.to_i.zero? width ||= 80 width.to_i end diff --git a/Library/Homebrew/version.rb b/Library/Homebrew/version.rb index f1ac71cbac..b06624a8b6 100644 --- a/Library/Homebrew/version.rb +++ b/Library/Homebrew/version.rb @@ -351,7 +351,7 @@ class Version # e.g. https://github.com/JustArchi/ArchiSteamFarm/releases/download/2.3.2.0/ASF.zip # e.g. https://people.gnome.org/~newren/eg/download/1.7.5.2/eg m = %r{/([rvV]_?)?(\d\.\d+(\.\d+){,2})}.match(spec_s) - return m.captures[1] unless m.nil? + return m.captures.second unless m.nil? # e.g. https://www.ijg.org/files/jpegsrc.v8d.tar.gz m = /\.v(\d+[a-z]?)/.match(stem) From 16618d0fc771968855b1d94cae5743dd99e1eb64 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 17 Sep 2018 20:11:11 +0200 Subject: [PATCH 4/5] =?UTF-8?q?Use=20ActiveSupport=E2=80=99s=20`#pluralize?= =?UTF-8?q?`=20and=20`#to=5Fsentence`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Library/Homebrew/cask/auditor.rb | 2 +- Library/Homebrew/cask/cask_dependencies.rb | 2 +- Library/Homebrew/cask/cmd/doctor.rb | 12 +- Library/Homebrew/cask/cmd/uninstall.rb | 6 +- Library/Homebrew/cask/cmd/upgrade.rb | 2 +- Library/Homebrew/cmd/info.rb | 2 +- Library/Homebrew/cmd/tap-info.rb | 6 +- Library/Homebrew/cmd/uninstall.rb | 24 +--- Library/Homebrew/cmd/update-report.rb | 3 +- Library/Homebrew/cmd/upgrade.rb | 12 +- Library/Homebrew/dev-cmd/audit.rb | 6 +- Library/Homebrew/exceptions.rb | 14 +- Library/Homebrew/formula_installer.rb | 2 +- Library/Homebrew/global.rb | 12 ++ Library/Homebrew/tap.rb | 10 +- Library/Homebrew/test/formatter_spec.rb | 41 ------ Library/Homebrew/utils.rb | 4 +- Library/Homebrew/utils/formatter.rb | 24 ---- .../lib/active_support/locale/en.yml | 135 ++++++++++++++++++ .../gems/i18n-1.1.0/lib/i18n/core_ext/hash.rb | 29 ++++ .../i18n/core_ext/kernel/suppress_warnings.rb | 8 ++ 21 files changed, 228 insertions(+), 128 deletions(-) create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/locale/en.yml create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/core_ext/hash.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/core_ext/kernel/suppress_warnings.rb diff --git a/Library/Homebrew/cask/auditor.rb b/Library/Homebrew/cask/auditor.rb index c80aa39ce5..4de53cd573 100644 --- a/Library/Homebrew/cask/auditor.rb +++ b/Library/Homebrew/cask/auditor.rb @@ -48,7 +48,7 @@ module Cask end def audit_languages(languages) - ohai "Auditing language: #{languages.map { |lang| "'#{lang}'" }.join(", ")}" + ohai "Auditing language: #{languages.map { |lang| "'#{lang}'" }.to_sentence}" MacOS.instance_variable_set(:@languages, languages) audit_cask_instance(CaskLoader.load(cask.sourcefile_path)) ensure diff --git a/Library/Homebrew/cask/cask_dependencies.rb b/Library/Homebrew/cask/cask_dependencies.rb index bd8a822760..f40fc4fe97 100644 --- a/Library/Homebrew/cask/cask_dependencies.rb +++ b/Library/Homebrew/cask/cask_dependencies.rb @@ -32,7 +32,7 @@ module Cask rescue TSort::Cyclic strongly_connected_components = graph.strongly_connected_components.sort_by(&:count) cyclic_dependencies = strongly_connected_components.last - [cask] - raise CaskCyclicDependencyError.new(cask.token, cyclic_dependencies.join(", ")) + raise CaskCyclicDependencyError.new(cask.token, cyclic_dependencies.to_sentence) end end end diff --git a/Library/Homebrew/cask/cmd/doctor.rb b/Library/Homebrew/cask/cmd/doctor.rb index 82e917018b..b14c656f47 100644 --- a/Library/Homebrew/cask/cmd/doctor.rb +++ b/Library/Homebrew/cask/cmd/doctor.rb @@ -182,10 +182,14 @@ module Cask end def self.cask_count_for_tap(tap) - Formatter.pluralize(tap.cask_files.count, "cask") - rescue - add_error "Unable to read from Tap: #{tap.path}" - "0" + cask_count = begin + tap.cask_files.count + rescue + add_error "Unable to read from Tap: #{tap.path}" + 0 + end + + "#{cask_count} #{"cask".pluralize(cask_count)}" end def self.render_env_var(var) diff --git a/Library/Homebrew/cask/cmd/uninstall.rb b/Library/Homebrew/cask/cmd/uninstall.rb index e2fb0fe324..9b9f134347 100644 --- a/Library/Homebrew/cask/cmd/uninstall.rb +++ b/Library/Homebrew/cask/cmd/uninstall.rb @@ -23,11 +23,9 @@ module Cask next if (versions = cask.versions).empty? - single = versions.count == 1 - puts <<~EOS - #{cask} #{versions.join(", ")} #{single ? "is" : "are"} still installed. - Remove #{single ? "it" : "them all"} with `brew cask uninstall --force #{cask}`. + #{cask} #{versions.to_sentence} #{"is".pluralize(versions.count)} still installed. + Remove #{(versions.count == 1) ? "it" : "them all"} with `brew cask uninstall --force #{cask}`. EOS end end diff --git a/Library/Homebrew/cask/cmd/upgrade.rb b/Library/Homebrew/cask/cmd/upgrade.rb index 33d9d6380f..29e7281035 100644 --- a/Library/Homebrew/cask/cmd/upgrade.rb +++ b/Library/Homebrew/cask/cmd/upgrade.rb @@ -28,7 +28,7 @@ module Cask end ohai "Casks with `auto_updates` or `version :latest` will not be upgraded" if args.empty? && !greedy? - oh1 "Upgrading #{Formatter.pluralize(outdated_casks.length, "outdated package")}, with result:" + oh1 "Upgrading #{outdated_casks.count} #{"outdated package".pluralize(outdated_casks.count)}:" cask_upgrades = outdated_casks.map do |cask| if cask.installed_caskfile.nil? "#{cask.full_name} #{cask.version}" diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb index ef3c1288fa..be8398bdb5 100644 --- a/Library/Homebrew/cmd/info.rb +++ b/Library/Homebrew/cmd/info.rb @@ -49,7 +49,7 @@ module Homebrew if ARGV.named.empty? if HOMEBREW_CELLAR.exist? count = Formula.racks.length - puts "#{Formatter.pluralize(count, "keg")}, #{HOMEBREW_CELLAR.abv}" + puts "#{count} #{"keg".pluralize(count)}, #{HOMEBREW_CELLAR.abv}" end else ARGV.named.each_with_index do |f, i| diff --git a/Library/Homebrew/cmd/tap-info.rb b/Library/Homebrew/cmd/tap-info.rb index 0f63082a10..082deb611d 100644 --- a/Library/Homebrew/cmd/tap-info.rb +++ b/Library/Homebrew/cmd/tap-info.rb @@ -48,11 +48,11 @@ module Homebrew pinned_count += 1 if tap.pinned? private_count += 1 if tap.private? end - info = Formatter.pluralize(tap_count, "tap").to_s + info = "#{tap_count} #{"tap".pluralize(tap_count)}" info += ", #{pinned_count} pinned" info += ", #{private_count} private" - info += ", #{Formatter.pluralize(formula_count, "formula")}" - info += ", #{Formatter.pluralize(command_count, "command")}" + info += ", #{formula_count} #{"formula".pluralize(formula_count)}" + info += ", #{command_count} #{"command".pluralize(command_count)}" info += ", #{Tap::TAP_DIRECTORY.abv}" if Tap::TAP_DIRECTORY.directory? puts info else diff --git a/Library/Homebrew/cmd/uninstall.rb b/Library/Homebrew/cmd/uninstall.rb index b82d7e8155..0476f34329 100644 --- a/Library/Homebrew/cmd/uninstall.rb +++ b/Library/Homebrew/cmd/uninstall.rb @@ -66,8 +66,7 @@ module Homebrew if rack.directory? versions = rack.subdirs.map(&:basename) - verb = Formatter.pluralize(versions.length, "is", "are") - puts "#{keg.name} #{versions.join(", ")} #{verb} still installed." + puts "#{keg.name} #{versions.to_sentence} #{"is".pluralize(versions.count)} still installed." puts "Remove all versions with `brew uninstall --force #{keg.name}`." end end @@ -119,31 +118,20 @@ module Homebrew protected - def are(items) - Formatter.pluralize(items.count, "is", "are", show_count: false) - end - - def they(items) - Formatter.pluralize(items.count, "it", "they", show_count: false) - end - - def list(items) - items.join(", ") - end - def sample_command "brew uninstall --ignore-dependencies #{ARGV.named.join(" ")}" end def are_required_by_deps - "#{are reqs} required by #{list deps}, which #{are deps} currently installed" + "#{"is".pluralize(reqs.count)} required by #{deps.to_sentence}, " \ + "which #{"is".pluralize(deps.count)} currently installed" end end class DeveloperDependentsMessage < DependentsMessage def output opoo <<~EOS - #{list reqs} #{are_required_by_deps}. + #{reqs.to_sentence} #{are_required_by_deps}. You can silence this warning with: #{sample_command} EOS @@ -153,8 +141,8 @@ module Homebrew class NondeveloperDependentsMessage < DependentsMessage def output ofail <<~EOS - Refusing to uninstall #{list reqs} - because #{they reqs} #{are_required_by_deps}. + Refusing to uninstall #{reqs.to_sentence} + because #{"it".pluralize(reqs.count)} #{are_required_by_deps}. You can override this and force removal with: #{sample_command} EOS diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb index f13869b400..e71356d0e3 100644 --- a/Library/Homebrew/cmd/update-report.rb +++ b/Library/Homebrew/cmd/update-report.rb @@ -107,8 +107,7 @@ module Homebrew unless updated_taps.empty? update_preinstall_header - puts "Updated #{Formatter.pluralize(updated_taps.size, "tap")} " \ - "(#{updated_taps.join(", ")})." + puts "Updated #{updated_taps.count} #{"tap".pluralize(updated_taps.count)} (#{updated_taps.to_sentence})." updated = true end diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb index f02fe9ef26..3fbd3ed6fd 100644 --- a/Library/Homebrew/cmd/upgrade.rb +++ b/Library/Homebrew/cmd/upgrade.rb @@ -63,14 +63,14 @@ module Homebrew formulae_to_install = outdated.map(&:latest_formula) if !pinned.empty? && !ARGV.include?("--ignore-pinned") - ofail "Not upgrading #{Formatter.pluralize(pinned.length, "pinned package")}:" + ofail "Not upgrading #{pinned.count} pinned #{"package".pluralize(pinned.count)}:" puts pinned.map { |f| "#{f.full_specified_name} #{f.pkg_version}" } * ", " end if formulae_to_install.empty? oh1 "No packages to upgrade" else - oh1 "Upgrading #{Formatter.pluralize(formulae_to_install.length, "outdated package")}, with result:" + oh1 "Upgrading #{formulae_to_install.count} outdated #{"package".pluralize(formulae_to_install.count)}:" formulae_upgrades = formulae_to_install.map do |f| if f.optlinked? "#{f.full_specified_name} #{Keg.new(f.opt_prefix).version} -> #{f.pkg_version}" @@ -304,7 +304,7 @@ module Homebrew # Print the pinned dependents. unless pinned.empty? - ohai "Not upgrading #{Formatter.pluralize(pinned.length, "pinned dependent")}:" + ohai "Not upgrading #{pinned.count} pinned #{"dependent".pluralize(pinned.count)}:" puts pinned.map { |f| "#{f.full_specified_name} #{f.pkg_version}" } * ", " end @@ -312,7 +312,7 @@ module Homebrew if upgradable.empty? ohai "No dependents to upgrade" if ARGV.verbose? else - ohai "Upgrading #{Formatter.pluralize(upgradable.length, "dependent")}:" + ohai "Upgrading #{upgradable.count} #{"dependent".pluralize(upgradable.count)}:" formulae_upgrades = upgradable.map do |f| if f.optlinked? "#{f.full_specified_name} #{Keg.new(f.opt_prefix).version} -> #{f.pkg_version}" @@ -337,7 +337,7 @@ module Homebrew # Print the pinned dependents. unless pinned.empty? - onoe "Not reinstalling #{Formatter.pluralize(pinned.length, "broken and outdated, but pinned dependent")}:" + onoe "Not reinstalling #{pinned.count} broken and outdated, but pinned #{"dependent".pluralize(pinned.count)}:" $stderr.puts pinned.map { |f| "#{f.full_specified_name} #{f.pkg_version}" } * ", " end @@ -345,7 +345,7 @@ module Homebrew if reinstallable.empty? ohai "No broken dependents to reinstall" if ARGV.verbose? else - ohai "Reinstalling #{Formatter.pluralize(reinstallable.length, "broken dependent")} from source:" + ohai "Reinstalling #{reinstallable.count} broken #{"dependent".pluralize(reinstallable.count)} from source:" puts reinstallable.map(&:full_specified_name).join(", ") end diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index c4fa8b4097..07f492151f 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -186,9 +186,9 @@ module Homebrew end total_problems_count = problem_count + new_formula_problem_count - problem_plural = Formatter.pluralize(total_problems_count, "problem") - formula_plural = Formatter.pluralize(formula_count, "formula") - corrected_problem_plural = Formatter.pluralize(corrected_problem_count, "problem") + problem_plural = "#{total_problems_count} #{"problem".pluralize(total_problems_count)}" + formula_plural = "#{formula_count} #{"formula".pluralize(formula_count)}" + corrected_problem_plural = "#{corrected_problem_count} #{"problem".pluralize(corrected_problem_count)}" errors_summary = "#{problem_plural} in #{formula_plural} detected" if corrected_problem_count.positive? errors_summary += ", #{corrected_problem_plural} corrected" diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index 087e95b87c..6ad85aeb09 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -441,18 +441,10 @@ end # and are being installed on a system without necessary build tools class BuildToolsError < RuntimeError def initialize(formulae) - if formulae.length > 1 - formula_text = "formulae" - package_text = "binary packages" - else - formula_text = "formula" - package_text = "a binary package" - end - super <<~EOS - The following #{formula_text}: - #{formulae.join(", ")} - cannot be installed as #{package_text} and must be built from source. + The following #{"formula".pluralize(formulae.count)} + #{formulae.to_sentence} + cannot be installed as #{"binary package".pluralize(formulae.count)} and must be built from source. #{DevelopmentTools.installation_instructions} EOS end diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 22f81166ac..9a86aa085c 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -537,7 +537,7 @@ class FormulaInstaller puts "All dependencies for #{formula.full_name} are satisfied." elsif !deps.empty? oh1 "Installing dependencies for #{formula.full_name}: " \ - "#{deps.map(&:first).map(&Formatter.method(:identifier)).join(", ")}", + "#{deps.map(&:first).map(&Formatter.method(:identifier)).to_sentence}", truncate: false deps.each { |dep, options| install_dependency(dep, options) } end diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb index 3ed18d7229..70a35efc27 100644 --- a/Library/Homebrew/global.rb +++ b/Library/Homebrew/global.rb @@ -9,6 +9,18 @@ require_relative "load_path" require "active_support/core_ext/numeric/time" require "active_support/core_ext/array/access" +require "active_support/i18n" +require "active_support/inflector/inflections" + +I18n.backend.available_locales # Initialize locales so they can be overwritten. +I18n.backend.store_translations :en, support: { array: { last_word_connector: " and " } } + +ActiveSupport::Inflector.inflections(:en) do |inflect| + inflect.irregular "formula", "formulae" + inflect.irregular "is", "are" + inflect.irregular "it", "they" +end + require "config" require "os" require "extend/ARGV" diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 0e73ff545d..44d4c36e4b 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -297,7 +297,7 @@ class Tap link_completions_and_manpages - formatted_contents = Formatter.comma_and(*contents)&.prepend(" ") + formatted_contents = contents.presence&.to_sentence&.dup&.prepend(" ") puts "Tapped#{formatted_contents} (#{path.abv})." unless quiet Descriptions.cache_formulae(formula_names) @@ -328,7 +328,7 @@ class Tap puts "Untapping #{name}..." abv = path.abv - formatted_contents = Formatter.comma_and(*contents)&.prepend(" ") + formatted_contents = contents.presence&.to_sentence&.dup&.prepend(" ") unpin if pinned? Descriptions.uncache_formulae(formula_names) @@ -365,15 +365,15 @@ class Tap contents = [] if (command_count = command_files.count).positive? - contents << Formatter.pluralize(command_count, "command") + contents << "#{command_count} #{"command".pluralize(command_count)}" end if (cask_count = cask_files.count).positive? - contents << Formatter.pluralize(cask_count, "cask") + contents << "#{cask_count} #{"cask".pluralize(cask_count)}" end if (formula_count = formula_files.count).positive? - contents << Formatter.pluralize(formula_count, "formula") + contents << "#{formula_count} #{"formula".pluralize(formula_count)}" end contents diff --git a/Library/Homebrew/test/formatter_spec.rb b/Library/Homebrew/test/formatter_spec.rb index 1c97bf6f8f..168b80ba8d 100644 --- a/Library/Homebrew/test/formatter_spec.rb +++ b/Library/Homebrew/test/formatter_spec.rb @@ -53,45 +53,4 @@ describe Formatter do it { is_expected.to eq("\n") } end end - - describe "::pluralize" do - it "pluralizes words" do - expect(described_class.pluralize(0, "cask")).to eq("0 casks") - expect(described_class.pluralize(1, "cask")).to eq("1 cask") - expect(described_class.pluralize(2, "cask")).to eq("2 casks") - end - - it "allows specifying custom plural forms" do - expect(described_class.pluralize(1, "child", "children")).to eq("1 child") - expect(described_class.pluralize(2, "child", "children")).to eq("2 children") - end - - it "has plural forms of Homebrew jargon" do - expect(described_class.pluralize(1, "formula")).to eq("1 formula") - expect(described_class.pluralize(2, "formula")).to eq("2 formulae") - end - - it "pluralizes the last word of a string" do - expect(described_class.pluralize(1, "new formula")).to eq("1 new formula") - expect(described_class.pluralize(2, "new formula")).to eq("2 new formulae") - end - end - - describe "::comma_and" do - it "returns nil if given no arguments" do - expect(described_class.comma_and).to be nil - end - - it "returns the input as string if there is only one argument" do - expect(described_class.comma_and(1)).to eq("1") - end - - it "concatenates two items with “and”" do - expect(described_class.comma_and(1, 2)).to eq("1 and 2") - end - - it "concatenates all items with a comma and appends the last with “and”" do - expect(described_class.comma_and(1, 2, 3)).to eq("1, 2 and 3") - end - end end diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index cf1d45ec1d..c34ec720cf 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -152,13 +152,13 @@ def pretty_duration(s) if s > 59 m = s / 60 s %= 60 - res = Formatter.pluralize(m, "minute") + res = "#{m} #{"minute".pluralize(m)}" return res if s.zero? res << " " end - res << Formatter.pluralize(s, "second") + res << "#{s} #{"second".pluralize(s)}" end def interactive_shell(f = nil) diff --git a/Library/Homebrew/utils/formatter.rb b/Library/Homebrew/utils/formatter.rb index d8530414a0..b66570f74b 100644 --- a/Library/Homebrew/utils/formatter.rb +++ b/Library/Homebrew/utils/formatter.rb @@ -98,28 +98,4 @@ module Formatter output end - - def pluralize(count, singular, plural = nil, show_count: true) - return (show_count ? "#{count} #{singular}" : singular.to_s) if count == 1 - - *adjectives, noun = singular.to_s.split(" ") - - plural ||= { - "formula" => "formulae", - }.fetch(noun, "#{noun}s") - - words = adjectives.push(plural).join(" ") - - show_count ? "#{count} #{words}" : words - end - - def comma_and(*items) - # TODO: Remove when RuboCop 0.57.3 is released. - # False positive has been fixed and merged, but is not yet in a - # stable release: https://github.com/rubocop-hq/rubocop/pull/6038 - *items, last = items.map(&:to_s) # rubocop:disable Lint/ShadowedArgument - return last if items.empty? - - "#{items.join(", ")} and #{last}" - end end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/locale/en.yml b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/locale/en.yml new file mode 100644 index 0000000000..c64b7598ee --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/locale/en.yml @@ -0,0 +1,135 @@ +en: + date: + formats: + # Use the strftime parameters for formats. + # When no format has been given, it uses default. + # You can provide other formats here if you like! + default: "%Y-%m-%d" + short: "%b %d" + long: "%B %d, %Y" + + day_names: [Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday] + abbr_day_names: [Sun, Mon, Tue, Wed, Thu, Fri, Sat] + + # Don't forget the nil at the beginning; there's no such thing as a 0th month + month_names: [~, January, February, March, April, May, June, July, August, September, October, November, December] + abbr_month_names: [~, Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec] + # Used in date_select and datetime_select. + order: + - year + - month + - day + + time: + formats: + default: "%a, %d %b %Y %H:%M:%S %z" + short: "%d %b %H:%M" + long: "%B %d, %Y %H:%M" + am: "am" + pm: "pm" + +# Used in array.to_sentence. + support: + array: + words_connector: ", " + two_words_connector: " and " + last_word_connector: ", and " + number: + # Used in NumberHelper.number_to_delimited() + # These are also the defaults for 'currency', 'percentage', 'precision', and 'human' + format: + # Sets the separator between the units, for more precision (e.g. 1.0 / 2.0 == 0.5) + separator: "." + # Delimits thousands (e.g. 1,000,000 is a million) (always in groups of three) + delimiter: "," + # Number of decimals, behind the separator (the number 1 with a precision of 2 gives: 1.00) + precision: 3 + # If set to true, precision will mean the number of significant digits instead + # of the number of decimal digits (1234 with precision 2 becomes 1200, 1.23543 becomes 1.2) + significant: false + # If set, the zeros after the decimal separator will always be stripped (eg.: 1.200 will be 1.2) + strip_insignificant_zeros: false + + # Used in NumberHelper.number_to_currency() + currency: + format: + # Where is the currency sign? %u is the currency unit, %n the number (default: $5.00) + format: "%u%n" + unit: "$" + # These five are to override number.format and are optional + separator: "." + delimiter: "," + precision: 2 + significant: false + strip_insignificant_zeros: false + + # Used in NumberHelper.number_to_percentage() + percentage: + format: + # These five are to override number.format and are optional + # separator: + delimiter: "" + # precision: + # significant: false + # strip_insignificant_zeros: false + format: "%n%" + + # Used in NumberHelper.number_to_rounded() + precision: + format: + # These five are to override number.format and are optional + # separator: + delimiter: "" + # precision: + # significant: false + # strip_insignificant_zeros: false + + # Used in NumberHelper.number_to_human_size() and NumberHelper.number_to_human() + human: + format: + # These five are to override number.format and are optional + # separator: + delimiter: "" + precision: 3 + significant: true + strip_insignificant_zeros: true + # Used in number_to_human_size() + storage_units: + # Storage units output formatting. + # %u is the storage unit, %n is the number (default: 2 MB) + format: "%n %u" + units: + byte: + one: "Byte" + other: "Bytes" + kb: "KB" + mb: "MB" + gb: "GB" + tb: "TB" + pb: "PB" + eb: "EB" + # Used in NumberHelper.number_to_human() + decimal_units: + format: "%n %u" + # Decimal units output formatting + # By default we will only quantify some of the exponents + # but the commented ones might be defined or overridden + # by the user. + units: + # femto: Quadrillionth + # pico: Trillionth + # nano: Billionth + # micro: Millionth + # mili: Thousandth + # centi: Hundredth + # deci: Tenth + unit: "" + # ten: + # one: Ten + # other: Tens + # hundred: Hundred + thousand: Thousand + million: Million + billion: Billion + trillion: Trillion + quadrillion: Quadrillion diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/core_ext/hash.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/core_ext/hash.rb new file mode 100644 index 0000000000..895f41a43f --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/core_ext/hash.rb @@ -0,0 +1,29 @@ +class Hash + def slice(*keep_keys) + h = {} + keep_keys.each { |key| h[key] = fetch(key) if has_key?(key) } + h + end unless Hash.method_defined?(:slice) + + def except(*less_keys) + slice(*keys - less_keys) + end unless Hash.method_defined?(:except) + + def deep_symbolize_keys + inject({}) { |result, (key, value)| + value = value.deep_symbolize_keys if value.is_a?(Hash) + result[(key.to_sym rescue key) || key] = value + result + } + end unless Hash.method_defined?(:deep_symbolize_keys) + + # deep_merge_hash! by Stefan Rusterholz, see http://www.ruby-forum.com/topic/142809 + MERGER = proc do |key, v1, v2| + Hash === v1 && Hash === v2 ? v1.merge(v2, &MERGER) : v2 + end + + def deep_merge!(data) + merge!(data, &MERGER) + end unless Hash.method_defined?(:deep_merge!) +end + diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/core_ext/kernel/suppress_warnings.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/core_ext/kernel/suppress_warnings.rb new file mode 100644 index 0000000000..eec1435a71 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/i18n-1.1.0/lib/i18n/core_ext/kernel/suppress_warnings.rb @@ -0,0 +1,8 @@ +module Kernel + def suppress_warnings + original_verbosity, $VERBOSE = $VERBOSE, nil + yield + ensure + $VERBOSE = original_verbosity + end +end From 5dd571adebeb3ab749c3939af298acab5b374ec0 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 17 Sep 2018 22:02:00 +0200 Subject: [PATCH 5/5] =?UTF-8?q?Replace=20`#chuzzle`=20with=20ActiveSupport?= =?UTF-8?q?=E2=80=99s=20`#presence`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Library/Homebrew/cmd/analytics.rb | 10 +++++----- Library/Homebrew/cmd/update-report.rb | 16 ++++++++-------- Library/Homebrew/extend/git_repository.rb | 12 ++++++------ Library/Homebrew/extend/string.rb | 3 +++ Library/Homebrew/global.rb | 1 + Library/Homebrew/tap.rb | 2 +- Library/Homebrew/utils/git.rb | 2 +- 7 files changed, 25 insertions(+), 21 deletions(-) diff --git a/Library/Homebrew/cmd/analytics.rb b/Library/Homebrew/cmd/analytics.rb index da69de03b3..60ebb03da9 100644 --- a/Library/Homebrew/cmd/analytics.rb +++ b/Library/Homebrew/cmd/analytics.rb @@ -18,17 +18,17 @@ module Homebrew case ARGV.named.first when nil, "state" - analyticsdisabled = \ - Utils.popen_read("git config --file=#{config_file} --get homebrew.analyticsdisabled").chuzzle - uuid = \ - Utils.popen_read("git config --file=#{config_file} --get homebrew.analyticsuuid").chuzzle + analyticsdisabled = + Utils.popen_read("git config --file=#{config_file} --get homebrew.analyticsdisabled").chomp + uuid = + Utils.popen_read("git config --file=#{config_file} --get homebrew.analyticsuuid").chomp if ENV["HOMEBREW_NO_ANALYTICS"] puts "Analytics is disabled (by HOMEBREW_NO_ANALYTICS)." elsif analyticsdisabled == "true" puts "Analytics is disabled." else puts "Analytics is enabled." - puts "UUID: #{uuid}" if uuid + puts "UUID: #{uuid}" if uuid.present? end when "on" safe_system "git", "config", "--file=#{config_file}", diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb index e71356d0e3..36f64cb62e 100644 --- a/Library/Homebrew/cmd/update-report.rb +++ b/Library/Homebrew/cmd/update-report.rb @@ -22,14 +22,14 @@ module Homebrew def update_report HOMEBREW_REPOSITORY.cd do analytics_message_displayed = - Utils.popen_read("git", "config", "--local", "--get", "homebrew.analyticsmessage").chuzzle + Utils.popen_read("git", "config", "--local", "--get", "homebrew.analyticsmessage").chomp == "true" cask_analytics_message_displayed = - Utils.popen_read("git", "config", "--local", "--get", "homebrew.caskanalyticsmessage").chuzzle + Utils.popen_read("git", "config", "--local", "--get", "homebrew.caskanalyticsmessage").chomp == "true" analytics_disabled = - Utils.popen_read("git", "config", "--local", "--get", "homebrew.analyticsdisabled").chuzzle - if analytics_message_displayed != "true" && - cask_analytics_message_displayed != "true" && - analytics_disabled != "true" && + Utils.popen_read("git", "config", "--local", "--get", "homebrew.analyticsdisabled").chomp == "true" + if !analytics_message_displayed && + !cask_analytics_message_displayed && + !analytics_disabled && !ENV["HOMEBREW_NO_ANALYTICS"] && !ENV["HOMEBREW_NO_ANALYTICS_MESSAGE_OUTPUT"] @@ -53,8 +53,8 @@ module Homebrew end donation_message_displayed = - Utils.popen_read("git", "config", "--local", "--get", "homebrew.donationmessage").chuzzle - if donation_message_displayed != "true" + Utils.popen_read("git", "config", "--local", "--get", "homebrew.donationmessage").chomp == "true" + unless donation_message_displayed ohai "Homebrew is run entirely by unpaid volunteers. Please consider donating:" puts " #{Formatter.url("https://github.com/Homebrew/brew#donations")}\n" diff --git a/Library/Homebrew/extend/git_repository.rb b/Library/Homebrew/extend/git_repository.rb index 9bfb6cf43c..8cd389ddf2 100644 --- a/Library/Homebrew/extend/git_repository.rb +++ b/Library/Homebrew/extend/git_repository.rb @@ -9,7 +9,7 @@ module GitRepositoryExtension def git_origin return unless git? && Utils.git_available? - Utils.popen_read("git", "config", "--get", "remote.origin.url", chdir: self).chuzzle + Utils.popen_read("git", "config", "--get", "remote.origin.url", chdir: self).chomp.presence end def git_origin=(origin) @@ -21,30 +21,30 @@ module GitRepositoryExtension def git_head return unless git? && Utils.git_available? - Utils.popen_read("git", "rev-parse", "--verify", "-q", "HEAD", chdir: self).chuzzle + Utils.popen_read("git", "rev-parse", "--verify", "-q", "HEAD", chdir: self).chomp.presence end def git_short_head return unless git? && Utils.git_available? - Utils.popen_read("git", "rev-parse", "--short=4", "--verify", "-q", "HEAD", chdir: self).chuzzle + Utils.popen_read("git", "rev-parse", "--short=4", "--verify", "-q", "HEAD", chdir: self).chomp.presence end def git_last_commit return unless git? && Utils.git_available? - Utils.popen_read("git", "show", "-s", "--format=%cr", "HEAD", chdir: self).chuzzle + Utils.popen_read("git", "show", "-s", "--format=%cr", "HEAD", chdir: self).chomp.presence end def git_branch return unless git? && Utils.git_available? - Utils.popen_read("git", "rev-parse", "--abbrev-ref", "HEAD", chdir: self).chuzzle + Utils.popen_read("git", "rev-parse", "--abbrev-ref", "HEAD", chdir: self).chomp.presence end def git_last_commit_date return unless git? && Utils.git_available? - Utils.popen_read("git", "show", "-s", "--format=%cd", "--date=short", "HEAD", chdir: self).chuzzle + Utils.popen_read("git", "show", "-s", "--format=%cd", "--date=short", "HEAD", chdir: self).chomp.presence end end diff --git a/Library/Homebrew/extend/string.rb b/Library/Homebrew/extend/string.rb index e7777c8281..64be4d5620 100644 --- a/Library/Homebrew/extend/string.rb +++ b/Library/Homebrew/extend/string.rb @@ -1,10 +1,12 @@ # Contains backports from newer versions of Ruby require "backports/2.4.0/string/match" require "backports/2.5.0/string/delete_prefix" +require "active_support/core_ext/object/blank" class String # String.chomp, but if result is empty: returns nil instead. # Allows `chuzzle || foo` short-circuits. + # TODO: Deprecate. def chuzzle s = chomp s unless s.empty? @@ -12,6 +14,7 @@ class String end class NilClass + # TODO: Deprecate. def chuzzle; end end diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb index 70a35efc27..0057791b19 100644 --- a/Library/Homebrew/global.rb +++ b/Library/Homebrew/global.rb @@ -7,6 +7,7 @@ require "pp" require_relative "load_path" +require "active_support/core_ext/object/blank" require "active_support/core_ext/numeric/time" require "active_support/core_ext/array/access" require "active_support/i18n" diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 44d4c36e4b..46160175e5 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -722,7 +722,7 @@ class TapConfig return unless Utils.git_available? tap.path.cd do - Utils.popen_read("git", "config", "--local", "--get", "homebrew.#{key}").chuzzle + Utils.popen_read("git", "config", "--local", "--get", "homebrew.#{key}").chomp.presence end end diff --git a/Library/Homebrew/utils/git.rb b/Library/Homebrew/utils/git.rb index 5238c8ccca..e0bb176fed 100644 --- a/Library/Homebrew/utils/git.rb +++ b/Library/Homebrew/utils/git.rb @@ -36,7 +36,7 @@ module Utils @git_path ||= Utils.popen_read( HOMEBREW_SHIMS_PATH/"scm/git", "--homebrew=print-path" - ).chuzzle + ).chomp.presence end def self.git_version