applies new string literal convention in activesupport/lib

The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
This commit is contained in:
Xavier Noria 2016-08-06 17:58:50 +02:00
parent 77eb40dab6
commit d66e7835be
176 changed files with 705 additions and 705 deletions

View File

@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#++
require 'securerandom'
require "securerandom"
require "active_support/dependencies/autoload"
require "active_support/version"
require "active_support/logger"

View File

@ -1,3 +1,3 @@
require 'active_support'
require 'active_support/time'
require 'active_support/core_ext'
require "active_support"
require "active_support/time"
require "active_support/core_ext"

View File

@ -32,11 +32,11 @@ module ActiveSupport
private
def respond_to_missing?(name, include_private = false)
name[-1] == '?'
name[-1] == "?"
end
def method_missing(name, *args)
if name[-1] == '?'
if name[-1] == "?"
any?(name[0..-2])
else
super

View File

@ -1,5 +1,5 @@
require 'active_support/core_ext/benchmark'
require 'active_support/core_ext/hash/keys'
require "active_support/core_ext/benchmark"
require "active_support/core_ext/hash/keys"
module ActiveSupport
module Benchmarkable
@ -39,7 +39,7 @@ module ActiveSupport
result = nil
ms = Benchmark.ms { result = options[:silence] ? logger.silence { yield } : yield }
logger.send(options[:level], '%s (%.1fms)' % [ message, ms ])
logger.send(options[:level], "%s (%.1fms)" % [ message, ms ])
result
else
yield

View File

@ -1,5 +1,5 @@
begin
require 'builder'
require "builder"
rescue LoadError => e
$stderr.puts "You don't have builder installed in your application. Please add it to your Gemfile and run bundle install"
raise e

View File

@ -1,29 +1,29 @@
require 'benchmark'
require 'zlib'
require 'active_support/core_ext/array/extract_options'
require 'active_support/core_ext/array/wrap'
require 'active_support/core_ext/benchmark'
require 'active_support/core_ext/module/attribute_accessors'
require 'active_support/core_ext/numeric/bytes'
require 'active_support/core_ext/numeric/time'
require 'active_support/core_ext/object/to_param'
require 'active_support/core_ext/string/inflections'
require 'active_support/core_ext/string/strip'
require "benchmark"
require "zlib"
require "active_support/core_ext/array/extract_options"
require "active_support/core_ext/array/wrap"
require "active_support/core_ext/benchmark"
require "active_support/core_ext/module/attribute_accessors"
require "active_support/core_ext/numeric/bytes"
require "active_support/core_ext/numeric/time"
require "active_support/core_ext/object/to_param"
require "active_support/core_ext/string/inflections"
require "active_support/core_ext/string/strip"
module ActiveSupport
# See ActiveSupport::Cache::Store for documentation.
module Cache
autoload :FileStore, 'active_support/cache/file_store'
autoload :MemoryStore, 'active_support/cache/memory_store'
autoload :MemCacheStore, 'active_support/cache/mem_cache_store'
autoload :NullStore, 'active_support/cache/null_store'
autoload :FileStore, "active_support/cache/file_store"
autoload :MemoryStore, "active_support/cache/memory_store"
autoload :MemCacheStore, "active_support/cache/mem_cache_store"
autoload :NullStore, "active_support/cache/null_store"
# These options mean something to all cache implementations. Individual cache
# implementations may support additional options.
UNIVERSAL_OPTIONS = [:namespace, :compress, :compress_threshold, :expires_in, :race_condition_ttl]
module Strategy
autoload :LocalCache, 'active_support/cache/strategy/local_cache'
autoload :LocalCache, "active_support/cache/strategy/local_cache"
end
class << self
@ -300,7 +300,7 @@ module ActiveSupport
save_block_result_to_cache(name, options) { |_name| yield _name }
end
elsif options && options[:force]
raise ArgumentError, 'Missing block: Calling `Cache#fetch` with `force: true` requires a block.'
raise ArgumentError, "Missing block: Calling `Cache#fetch` with `force: true` requires a block."
else
read(name, options)
end
@ -477,7 +477,7 @@ module ActiveSupport
prefix = options[:namespace].is_a?(Proc) ? options[:namespace].call : options[:namespace]
if prefix
source = pattern.source
if source.start_with?('^')
if source.start_with?("^")
source = source[1, source.length]
else
source = ".*#{source[0, source.length]}"

View File

@ -1,7 +1,7 @@
require 'active_support/core_ext/marshal'
require 'active_support/core_ext/file/atomic'
require 'active_support/core_ext/string/conversions'
require 'uri/common'
require "active_support/core_ext/marshal"
require "active_support/core_ext/file/atomic"
require "active_support/core_ext/string/conversions"
require "uri/common"
module ActiveSupport
module Cache
@ -16,8 +16,8 @@ module ActiveSupport
DIR_FORMATTER = "%03X"
FILENAME_MAX_SIZE = 228 # max filename size on file system is 255, minus room for timestamp and random characters appended by Tempfile (used by atomic write)
FILEPATH_MAX_SIZE = 900 # max is 1024, plus some room
EXCLUDED_DIRS = ['.', '..'].freeze
GITKEEP_FILES = ['.gitkeep', '.keep'].freeze
EXCLUDED_DIRS = [".", ".."].freeze
GITKEEP_FILES = [".gitkeep", ".keep"].freeze
def initialize(cache_path, options = nil)
super(options)
@ -102,7 +102,7 @@ module ActiveSupport
# Lock a file for a block so only one process can modify it at a time.
def lock_file(file_name, &block) # :nodoc:
if File.exist?(file_name)
File.open(file_name, 'r+') do |f|
File.open(file_name, "r+") do |f|
begin
f.flock File::LOCK_EX
yield

View File

@ -1,13 +1,13 @@
begin
require 'dalli'
require "dalli"
rescue LoadError => e
$stderr.puts "You don't have dalli installed in your application. Please add it to your Gemfile and run bundle install"
raise e
end
require 'digest/md5'
require 'active_support/core_ext/marshal'
require 'active_support/core_ext/array/extract_options'
require "digest/md5"
require "active_support/core_ext/marshal"
require "active_support/core_ext/array/extract_options"
module ActiveSupport
module Cache

View File

@ -1,4 +1,4 @@
require 'monitor'
require "monitor"
module ActiveSupport
module Cache

View File

@ -1,6 +1,6 @@
require 'active_support/core_ext/object/duplicable'
require 'active_support/core_ext/string/inflections'
require 'active_support/per_thread_registry'
require "active_support/core_ext/object/duplicable"
require "active_support/core_ext/string/inflections"
require "active_support/per_thread_registry"
module ActiveSupport
module Cache
@ -9,7 +9,7 @@ module ActiveSupport
# duration of a block. Repeated calls to the cache for the same key will hit the
# in-memory cache for faster access.
module LocalCache
autoload :Middleware, 'active_support/cache/strategy/local_cache_middleware'
autoload :Middleware, "active_support/cache/strategy/local_cache_middleware"
# Class for storing and registering the local caches.
class LocalCacheRegistry # :nodoc:
@ -146,7 +146,7 @@ module ActiveSupport
private
def local_cache_key
@local_cache_key ||= "#{self.class.name.underscore}_local_cache_#{object_id}".gsub(/[\/-]/, '_').to_sym
@local_cache_key ||= "#{self.class.name.underscore}_local_cache_#{object_id}".gsub(/[\/-]/, "_").to_sym
end
def local_cache

View File

@ -1,5 +1,5 @@
require 'rack/body_proxy'
require 'rack/utils'
require "rack/body_proxy"
require "rack/utils"
module ActiveSupport
module Cache

View File

@ -1,13 +1,13 @@
require 'active_support/concern'
require 'active_support/descendants_tracker'
require 'active_support/core_ext/array/extract_options'
require 'active_support/core_ext/class/attribute'
require 'active_support/core_ext/kernel/reporting'
require 'active_support/core_ext/kernel/singleton_class'
require 'active_support/core_ext/module/attribute_accessors'
require 'active_support/core_ext/string/filters'
require 'active_support/deprecation'
require 'thread'
require "active_support/concern"
require "active_support/descendants_tracker"
require "active_support/core_ext/array/extract_options"
require "active_support/core_ext/class/attribute"
require "active_support/core_ext/kernel/reporting"
require "active_support/core_ext/kernel/singleton_class"
require "active_support/core_ext/module/attribute_accessors"
require "active_support/core_ext/string/filters"
require "active_support/deprecation"
require "thread"
module ActiveSupport
# Callbacks are code hooks that are run at key points in an object's life cycle.

View File

@ -1,4 +1,4 @@
require 'concurrent/atomic/count_down_latch'
require "concurrent/atomic/count_down_latch"
module ActiveSupport
module Concurrency

View File

@ -1,5 +1,5 @@
require 'thread'
require 'monitor'
require "thread"
require "monitor"
module ActiveSupport
module Concurrency

View File

@ -1,7 +1,7 @@
require 'active_support/concern'
require 'active_support/ordered_options'
require 'active_support/core_ext/array/extract_options'
require 'active_support/core_ext/regexp'
require "active_support/concern"
require "active_support/ordered_options"
require "active_support/core_ext/array/extract_options"
require "active_support/core_ext/regexp"
module ActiveSupport
# Configurable provides a <tt>config</tt> method to store and retrieve
@ -108,7 +108,7 @@ module ActiveSupport
options = names.extract_options!
names.each do |name|
raise NameError.new('invalid config attribute name') unless /\A[_A-Za-z]\w*\z/.match?(name)
raise NameError.new("invalid config attribute name") unless /\A[_A-Za-z]\w*\z/.match?(name)
reader, reader_line = "def #{name}; config.#{name}; end", __LINE__
writer, writer_line = "def #{name}=(value); config.#{name} = value; end", __LINE__

View File

@ -1,7 +1,7 @@
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'
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"

View File

@ -1,8 +1,8 @@
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'
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
@ -66,9 +66,9 @@ class Array
options.assert_valid_keys(:words_connector, :two_words_connector, :last_word_connector, :locale, :fallback_string)
default_connectors = {
:words_connector => ', ',
:two_words_connector => ' and ',
:last_word_connector => ', and '
:words_connector => ", ",
:two_words_connector => " and ",
:last_word_connector => ", and "
}
if defined?(I18n)
i18n_connectors = I18n.translate(:'support.array', locale: options[:locale], default: {})
@ -98,9 +98,9 @@ class Array
case format
when :db
if empty?
'null'
"null"
else
collect(&:id).join(',')
collect(&:id).join(",")
end
else
to_default_s
@ -185,7 +185,7 @@ class Array
# </messages>
#
def to_xml(options = {})
require 'active_support/builder' unless defined?(Builder)
require "active_support/builder" unless defined?(Builder)
options = options.dup
options[:indent] ||= 2
@ -193,9 +193,9 @@ class Array
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('/', '_')
ActiveSupport::Inflector.pluralize(underscored).tr("/", "_")
else
'objects'
"objects"
end
builder = options[:builder]
@ -203,7 +203,7 @@ class Array
root = ActiveSupport::XmlMini.rename_key(options[:root].to_s, options)
children = options.delete(:children) || root.singularize
attributes = options[:skip_types] ? {} : { type: 'array' }
attributes = options[:skip_types] ? {} : { type: "array" }
if empty?
builder.tag!(root, attributes)

View File

@ -1,4 +1,4 @@
require 'active_support/array_inquirer'
require "active_support/array_inquirer"
class Array
# Wraps the array in an +ArrayInquirer+ object, which gives a friendlier way

View File

@ -1,4 +1,4 @@
require 'benchmark'
require "benchmark"
class << Benchmark
# Benchmark realtime in milliseconds.

View File

@ -1 +1 @@
require 'active_support/core_ext/big_decimal/conversions'
require "active_support/core_ext/big_decimal/conversions"

View File

@ -1,9 +1,9 @@
require 'bigdecimal'
require 'bigdecimal/util'
require "bigdecimal"
require "bigdecimal/util"
module ActiveSupport
module BigDecimalWithDefaultFormat #:nodoc:
def to_s(format = 'F')
def to_s(format = "F")
super(format)
end
end

View File

@ -1,2 +1,2 @@
require 'active_support/core_ext/class/attribute'
require 'active_support/core_ext/class/subclasses'
require "active_support/core_ext/class/attribute"
require "active_support/core_ext/class/subclasses"

View File

@ -1,6 +1,6 @@
require 'active_support/core_ext/kernel/singleton_class'
require 'active_support/core_ext/module/remove_method'
require 'active_support/core_ext/array/extract_options'
require "active_support/core_ext/kernel/singleton_class"
require "active_support/core_ext/module/remove_method"
require "active_support/core_ext/array/extract_options"
class Class
# Declare a class-level attribute whose value is inheritable by subclasses.

View File

@ -1,4 +1,4 @@
# 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'
require "active_support/core_ext/module/attribute_accessors"

View File

@ -1,5 +1,5 @@
require 'active_support/core_ext/module/anonymous'
require 'active_support/core_ext/module/reachable'
require "active_support/core_ext/module/anonymous"
require "active_support/core_ext/module/reachable"
class Class
begin

View File

@ -1,5 +1,5 @@
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'
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"

View File

@ -1,4 +1,4 @@
require 'active_support/core_ext/object/acts_like'
require "active_support/core_ext/object/acts_like"
class Date
# Duck-types as a Date-like class. See Object#acts_like?.

View File

@ -1,4 +1,4 @@
require 'date'
require "date"
class Date #:nodoc:
# No Date is blank:

View File

@ -1,9 +1,9 @@
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'
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

View File

@ -1,19 +1,19 @@
require 'date'
require 'active_support/inflector/methods'
require 'active_support/core_ext/date/zones'
require 'active_support/core_ext/module/remove_method'
require "date"
require "active_support/inflector/methods"
require "active_support/core_ext/date/zones"
require "active_support/core_ext/module/remove_method"
class Date
DATE_FORMATS = {
:short => '%d %b',
:long => '%B %d, %Y',
:db => '%Y-%m-%d',
:number => '%Y%m%d',
: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',
:rfc822 => "%d %b %Y",
:iso8601 => lambda { |date| date.iso8601 }
}
@ -65,7 +65,7 @@ class Date
# Overrides the default inspect method with a human readable one, e.g., "Mon, 21 Feb 2005"
def readable_inspect
strftime('%a, %d %b %Y')
strftime("%a, %d %b %Y")
end
alias_method :default_inspect, :inspect
alias_method :inspect, :readable_inspect

View File

@ -1,5 +1,5 @@
require 'date'
require 'active_support/core_ext/date_and_time/zones'
require "date"
require "active_support/core_ext/date_and_time/zones"
class Date
include DateAndTime::Zones

View File

@ -1,4 +1,4 @@
require 'active_support/core_ext/object/try'
require "active_support/core_ext/object/try"
module DateAndTime
module Calculations

View File

@ -1,4 +1,4 @@
require 'active_support/core_ext/module/attribute_accessors'
require "active_support/core_ext/module/attribute_accessors"
module DateAndTime
module Compatibility

View File

@ -1,5 +1,5 @@
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'
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"

View File

@ -1,5 +1,5 @@
require 'date'
require 'active_support/core_ext/object/acts_like'
require "date"
require "active_support/core_ext/object/acts_like"
class DateTime
# Duck-types as a Date-like class. See Object#acts_like?.

View File

@ -1,4 +1,4 @@
require 'date'
require "date"
class DateTime #:nodoc:
# No DateTime is ever blank:

View File

@ -1,4 +1,4 @@
require 'date'
require "date"
class DateTime
class << self

View File

@ -1,4 +1,4 @@
require 'active_support/core_ext/date_and_time/compatibility'
require "active_support/core_ext/date_and_time/compatibility"
class DateTime
prepend DateAndTime::Compatibility

View File

@ -1,8 +1,8 @@
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'
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.

View File

@ -1,4 +1,4 @@
require 'securerandom'
require "securerandom"
module Digest
module UUID
@ -26,7 +26,7 @@ module Digest
hash.update(uuid_namespace)
hash.update(name)
ary = hash.digest.unpack('NnnnnN')
ary = hash.digest.unpack("NnnnnN")
ary[2] = (ary[2] & 0x0FFF) | (version << 12)
ary[3] = (ary[3] & 0x3FFF) | 0x8000

View File

@ -1 +1 @@
require 'active_support/core_ext/file/atomic'
require "active_support/core_ext/file/atomic"

View File

@ -1,4 +1,4 @@
require 'fileutils'
require "fileutils"
class File
# Write to a file atomically. Useful for situations where you don't
@ -17,7 +17,7 @@ class File
# file.write('hello')
# end
def self.atomic_write(file_name, temp_dir = dirname(file_name))
require 'tempfile' unless defined?(Tempfile)
require "tempfile" unless defined?(Tempfile)
Tempfile.open(".#{basename(file_name)}", temp_dir) do |temp_file|
temp_file.binmode
@ -53,11 +53,11 @@ class File
# Private utility method.
def self.probe_stat_in(dir) #:nodoc:
basename = [
'.permissions_check',
".permissions_check",
Thread.current.object_id,
Process.pid,
rand(1000000)
].join('.')
].join(".")
file_name = join(dir, basename)
FileUtils.touch(file_name)

View File

@ -1,9 +1,9 @@
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'
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"

View File

@ -1,11 +1,11 @@
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'
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:
@ -71,11 +71,11 @@ class Hash
# configure your own builder with the <tt>:builder</tt> option. The method also accepts
# options like <tt>:dasherize</tt> and friends, they are forwarded to the builder.
def to_xml(options = {})
require 'active_support/builder' unless defined?(Builder)
require "active_support/builder" unless defined?(Builder)
options = options.dup
options[:indent] ||= 2
options[:root] ||= 'hash'
options[:root] ||= "hash"
options[:builder] ||= Builder::XmlMarkup.new(indent: options[:indent])
builder = options[:builder]
@ -160,7 +160,7 @@ module ActiveSupport
def normalize_keys(params)
case params
when Hash
Hash[params.map { |k,v| [k.to_s.tr('-', '_'), normalize_keys(v)] } ]
Hash[params.map { |k,v| [k.to_s.tr("-", "_"), normalize_keys(v)] } ]
when Array
params.map { |v| normalize_keys(v) }
else
@ -182,13 +182,13 @@ module ActiveSupport
end
def process_hash(value)
if value.include?('type') && !value['type'].is_a?(Hash) && @disallowed_types.include?(value['type'])
raise DisallowedType, value['type']
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?)
if entries.nil? || value["__content__"].try(:empty?)
[]
else
case entries
@ -204,28 +204,28 @@ module ActiveSupport
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: #<StringIO> } } into { files: #<StringIO> } so it is compatible with
# how multipart uploaded files from HTML appear
xml_value['file'].is_a?(StringIO) ? xml_value['file'] : xml_value
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?))
value["type"] == "file" || (value["__content__"] && (value.keys.size == 1 || value["__content__"].present?))
end
def become_array?(value)
value['type'] == 'array'
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'
value["type"] == "string" && value["nil"] != "true"
end
def become_hash?(value)
@ -234,19 +234,19 @@ module ActiveSupport
def nothing?(value)
# blank or nil parsed values are represented by nil
value.blank? || value['nil'] == 'true'
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
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']]
content = value["__content__"]
if parser = ActiveSupport::XmlMini::PARSING[value["type"]]
parser.arity == 1 ? parser.call(content) : parser.call(content, value)
else
content

View File

@ -1,4 +1,4 @@
require 'active_support/hash_with_indifferent_access'
require "active_support/hash_with_indifferent_access"
class Hash

View File

@ -1,3 +1,3 @@
require 'active_support/core_ext/integer/multiple'
require 'active_support/core_ext/integer/inflections'
require 'active_support/core_ext/integer/time'
require "active_support/core_ext/integer/multiple"
require "active_support/core_ext/integer/inflections"
require "active_support/core_ext/integer/time"

View File

@ -1,4 +1,4 @@
require 'active_support/inflector'
require "active_support/inflector"
class Integer
# Ordinalize turns a number into an ordinal string used to denote the

View File

@ -1,5 +1,5 @@
require 'active_support/duration'
require 'active_support/core_ext/numeric/time'
require "active_support/duration"
require "active_support/core_ext/numeric/time"
class Integer
# Enables the use of time calculations and declarations, like <tt>45.minutes +

View File

@ -1,4 +1,4 @@
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'
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"

View File

@ -1,4 +1,4 @@
require 'active_support/core_ext/module/concerning'
require "active_support/core_ext/module/concerning"
module Kernel
module_function

View File

@ -1,3 +1,3 @@
require 'active_support/deprecation'
require "active_support/deprecation"
ActiveSupport::Deprecation.warn("This file is deprecated and will be removed in Rails 5.1 with no replacement.")

View File

@ -1,4 +1,4 @@
require 'active_support/deprecation/proxy_wrappers'
require "active_support/deprecation/proxy_wrappers"
class LoadError
REGEXPS = [
@ -23,8 +23,8 @@ 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)
location.sub(/\.rb$/, "".freeze) == path.sub(/\.rb$/, "".freeze)
end
end
MissingSourceFile = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('MissingSourceFile', 'LoadError')
MissingSourceFile = ActiveSupport::Deprecation::DeprecatedConstantProxy.new("MissingSourceFile", "LoadError")

View File

@ -1,12 +1,12 @@
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/remove_method'
require 'active_support/core_ext/module/qualified_const'
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/remove_method"
require "active_support/core_ext/module/qualified_const"

View File

@ -28,7 +28,7 @@ class Module
# Strip out punctuation on predicates, bang or writer methods since
# e.g. target?_without_feature is not a valid method name.
aliased_target, punctuation = target.to_s.sub(/([?!=])$/, ''), $1
aliased_target, punctuation = target.to_s.sub(/([?!=])$/, ""), $1
yield(aliased_target, punctuation) if block_given?
with_method = "#{aliased_target}_with_#{feature}#{punctuation}"

View File

@ -18,7 +18,7 @@ class Module
alias_method :attr_internal, :attr_internal_accessor
class << self; attr_accessor :attr_internal_naming_format end
self.attr_internal_naming_format = '@_%s'
self.attr_internal_naming_format = "@_%s"
private
def attr_internal_ivar_name(attr)
@ -26,7 +26,7 @@ class Module
end
def attr_internal_define(attr_name, type)
internal_name = attr_internal_ivar_name(attr_name).sub(/\A@/, '')
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

View File

@ -1,5 +1,5 @@
require 'active_support/core_ext/array/extract_options'
require 'active_support/core_ext/regexp'
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

View File

@ -1,5 +1,5 @@
require 'active_support/core_ext/array/extract_options'
require 'active_support/core_ext/regexp'
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

View File

@ -1,4 +1,4 @@
require 'active_support/concern'
require "active_support/concern"
class Module
# = Bite-sized separation of concerns

View File

@ -1,5 +1,5 @@
require 'set'
require 'active_support/core_ext/regexp'
require "set"
require "active_support/core_ext/regexp"
class Module
# Error generated by +delegate+ when a method is called on +nil+ and +allow_nil+
@ -151,18 +151,18 @@ class Module
# 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).'
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.'
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
@ -174,7 +174,7 @@ class Module
methods.each do |method|
# Attribute writer methods only accept one argument. Makes sure []=
# methods still accept two arguments.
definition = /[^\]]=$/.match?(method) ? 'arg' : '*args, &block'
definition = /[^\]]=$/.match?(method) ? "arg" : "*args, &block"
# The following generated method calls the target exactly once, storing
# the returned value in a dummy variable.
@ -191,7 +191,7 @@ class Module
" _.#{method}(#{definition})",
"end",
"end"
].join ';'
].join ";"
else
exception = %(raise DelegationError, "#{self}##{method_prefix}#{method} delegated to #{to}.#{method}, but #{to} is nil: \#{self.inspect}")
@ -206,7 +206,7 @@ class Module
" raise",
" end",
"end"
].join ';'
].join ";"
end
module_eval(method_def, file, line)

View File

@ -1,4 +1,4 @@
require 'active_support/inflector'
require "active_support/inflector"
class Module
# Returns the name of the module containing this one.
@ -46,9 +46,9 @@ class Module
def parents
parents = []
if parent_name
parts = parent_name.split('::')
parts = parent_name.split("::")
until parts.empty?
parents << ActiveSupport::Inflector.constantize(parts * '::')
parents << ActiveSupport::Inflector.constantize(parts * "::")
parts.pop
end
end

View File

@ -1,3 +1,3 @@
require 'active_support/deprecation'
require "active_support/deprecation"
ActiveSupport::Deprecation.warn("This file is deprecated and will be removed in Rails 5.1 with no replacement.")

View File

@ -1,4 +1,4 @@
require 'active_support/core_ext/string/inflections'
require "active_support/core_ext/string/inflections"
#--
# Allows code reuse in the methods below without polluting Module.
@ -11,7 +11,7 @@ module ActiveSupport
end
def self.names(path)
path.split('::')
path.split("::")
end
end
end

View File

@ -1,5 +1,5 @@
require 'active_support/core_ext/module/anonymous'
require 'active_support/core_ext/string/inflections'
require "active_support/core_ext/module/anonymous"
require "active_support/core_ext/string/inflections"
class Module
def reachable? #:nodoc:

View File

@ -1,4 +1,4 @@
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'
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"

View File

@ -1,6 +1,6 @@
require 'active_support/core_ext/big_decimal/conversions'
require 'active_support/number_helper'
require 'active_support/core_ext/module/deprecation'
require "active_support/core_ext/big_decimal/conversions"
require "active_support/number_helper"
require "active_support/core_ext/module/deprecation"
module ActiveSupport::NumericWithFormat

View File

@ -1,8 +1,8 @@
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'
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
# Enables the use of time calculations and declarations, like 45.minutes + 2.hours + 4.years.

View File

@ -1,14 +1,14 @@
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/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/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'
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"

View File

@ -1,4 +1,4 @@
require 'active_support/core_ext/regexp'
require "active_support/core_ext/regexp"
class Object
# An object is blank if it's false, empty, or a whitespace string.

View File

@ -1,4 +1,4 @@
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'
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"

View File

@ -1,4 +1,4 @@
require 'active_support/core_ext/object/duplicable'
require "active_support/core_ext/object/duplicable"
class Object
# Returns a deep copy of object if it's duplicable. If it's

View File

@ -76,7 +76,7 @@ class Numeric
end
end
require 'bigdecimal'
require "bigdecimal"
class BigDecimal
# BigDecimals are duplicable:
#

View File

@ -1,16 +1,16 @@
# 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'
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,
@ -189,7 +189,7 @@ class DateTime
if ActiveSupport::JSON::Encoding.use_standard_json_time_format
xmlschema(ActiveSupport::JSON::Encoding.time_precision)
else
strftime('%Y/%m/%d %H:%M:%S %z')
strftime("%Y/%m/%d %H:%M:%S %z")
end
end
end

View File

@ -1 +1 @@
require 'active_support/core_ext/object/to_query'
require "active_support/core_ext/object/to_query"

View File

@ -1,4 +1,4 @@
require 'cgi'
require "cgi"
class Object
# Alias of <tt>to_s</tt>.
@ -38,7 +38,7 @@ class Array
# Calls <tt>to_param</tt> on all its elements and joins the result with
# slashes. This is used by <tt>url_for</tt> in Action Pack.
def to_param
collect(&:to_param).join '/'
collect(&:to_param).join "/"
end
# Converts an array into a string suitable for use as a URL query string,
@ -51,7 +51,7 @@ class Array
if empty?
nil.to_query(prefix)
else
collect { |value| value.to_query(prefix) }.join '&'
collect { |value| value.to_query(prefix) }.join "&"
end
end
end
@ -77,7 +77,7 @@ class Hash
unless (value.is_a?(Hash) || value.is_a?(Array)) && value.empty?
value.to_query(namespace ? "#{namespace}[#{key}]" : key)
end
end.compact.sort! * '&'
end.compact.sort! * "&"
end
alias_method :to_param, :to_query

View File

@ -1,4 +1,4 @@
require 'delegate'
require "delegate"
module ActiveSupport
module Tryable #:nodoc:

View File

@ -1,4 +1,4 @@
require 'active_support/option_merger'
require "active_support/option_merger"
class Object
# An elegant way to factor duplication out of options passed to a series of

View File

@ -1,4 +1,4 @@
require 'active_support/core_ext/range/conversions'
require 'active_support/core_ext/range/include_range'
require 'active_support/core_ext/range/overlaps'
require 'active_support/core_ext/range/each'
require "active_support/core_ext/range/conversions"
require "active_support/core_ext/range/include_range"
require "active_support/core_ext/range/overlaps"
require "active_support/core_ext/range/each"

View File

@ -1,7 +1,7 @@
require 'securerandom'
require "securerandom"
module SecureRandom
BASE58_ALPHABET = ('0'..'9').to_a + ('A'..'Z').to_a + ('a'..'z').to_a - ['0', 'O', 'I', 'l']
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.

View File

@ -1,13 +1,13 @@
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'
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"

View File

@ -74,7 +74,7 @@ class String
# str.first(6) # => "hello"
def first(limit = 1)
if limit == 0
''
""
elsif limit >= size
self.dup
else
@ -94,7 +94,7 @@ class String
# str.last(6) # => "hello"
def last(limit = 1)
if limit == 0
''
""
elsif limit >= size
self.dup
else

View File

@ -1,5 +1,5 @@
require 'date'
require 'active_support/core_ext/time/calculations'
require "date"
require "active_support/core_ext/time/calculations"
class String
# Converts a string to a Time value.

View File

@ -17,7 +17,7 @@ class String
# str.squish! # => "foo bar boo"
# str # => "foo bar boo"
def squish!
gsub!(/[[:space:]]+/, ' ')
gsub!(/[[:space:]]+/, " ")
strip!
self
end
@ -64,7 +64,7 @@ class String
def truncate(truncate_at, options = {})
return dup unless length > truncate_at
omission = options[:omission] || '...'
omission = options[:omission] || "..."
length_with_room_for_omission = truncate_at - omission.length
stop = \
if options[:separator]
@ -94,7 +94,7 @@ class String
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] || '...')
$1 + (options[:omission] || "...")
else
dup
end

View File

@ -3,7 +3,7 @@ class String
#
# 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]/] || ' '
indent_string = indent_string || self[/^[ \t]/] || " "
re = indent_empty_lines ? /^/ : /^(?!$)/
gsub!(re, indent_string * amount)
end

View File

@ -1,5 +1,5 @@
require 'active_support/inflector/methods'
require 'active_support/inflector/transliterate'
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.
@ -178,7 +178,7 @@ class String
#
# <%= link_to(@person.name, person_path) %>
# # => <a href="/person/1-Donald-E-Knuth">Donald E. Knuth</a>
def parameterize(sep = :unused, separator: '-', preserve_case: false)
def parameterize(sep = :unused, separator: "-", preserve_case: false)
unless sep == :unused
ActiveSupport::Deprecation.warn("Passing the separator argument as a positional parameter is deprecated and will soon be removed. Use `separator: '#{sep}'` instead.")
separator = sep

View File

@ -1,4 +1,4 @@
require 'active_support/string_inquirer'
require "active_support/string_inquirer"
class String
# Wraps the current string in the <tt>ActiveSupport::StringInquirer</tt> class,

View File

@ -1,4 +1,4 @@
require 'active_support/multibyte'
require "active_support/multibyte"
class String
# == Multibyte proxy

View File

@ -1,11 +1,11 @@
require 'erb'
require 'active_support/core_ext/kernel/singleton_class'
require 'active_support/multibyte/unicode'
require "erb"
require "active_support/core_ext/kernel/singleton_class"
require "active_support/multibyte/unicode"
class ERB
module Util
HTML_ESCAPE = { '&' => '&amp;', '>' => '&gt;', '<' => '&lt;', '"' => '&quot;', "'" => '&#39;' }
JSON_ESCAPE = { '&' => '\u0026', '>' => '\u003e', '<' => '\u003c', "\u2028" => '\u2028', "\u2029" => '\u2029' }
HTML_ESCAPE = { "&" => "&amp;", ">" => "&gt;", "<" => "&lt;", '"' => "&quot;", "'" => "&#39;" }
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
@ -145,7 +145,7 @@ module ActiveSupport #:nodoc:
# Raised when <tt>ActiveSupport::SafeBuffer#safe_concat</tt> is called on unsafe buffers.
class SafeConcatError < StandardError
def initialize
super 'Could not concatenate to the buffer because it is not html safe.'
super "Could not concatenate to the buffer because it is not html safe."
end
end
@ -172,7 +172,7 @@ module ActiveSupport #:nodoc:
original_concat(value)
end
def initialize(str = '')
def initialize(str = "")
@html_safe = true
super
end

View File

@ -18,6 +18,6 @@ class String
# 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)
gsub(/^#{scan(/^[ \t]*(?=\S)/).min}/, "".freeze)
end
end

View File

@ -1,5 +1,5 @@
require 'active_support/core_ext/string/conversions'
require 'active_support/core_ext/time/zones'
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

View File

@ -1,3 +1,3 @@
require 'active_support/deprecation'
require "active_support/deprecation"
ActiveSupport::Deprecation.warn("This file is deprecated and will be removed in Rails 5.1 with no replacement.")

View File

@ -1,5 +1,5 @@
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'
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"

View File

@ -1,4 +1,4 @@
require 'active_support/core_ext/object/acts_like'
require "active_support/core_ext/object/acts_like"
class Time
# Duck-types as a Time-like class. See Object#acts_like?.

View File

@ -1,9 +1,9 @@
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'
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
@ -112,7 +112,7 @@ class Time
elsif zone
::Time.local(new_year, new_month, new_day, new_hour, new_min, new_sec, new_usec)
else
raise ArgumentError, 'argument out of range' if new_usec >= 1000000
raise ArgumentError, "argument out of range" if new_usec >= 1000000
::Time.new(new_year, new_month, new_day, new_hour, new_min, new_sec + (new_usec.to_r / 1000000), utc_offset)
end
end

View File

@ -1,4 +1,4 @@
require 'active_support/core_ext/date_and_time/compatibility'
require "active_support/core_ext/date_and_time/compatibility"
class Time
prepend DateAndTime::Compatibility

View File

@ -1,15 +1,15 @@
require 'active_support/inflector/methods'
require 'active_support/values/time_zone'
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',
: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")

View File

@ -1,3 +1,3 @@
require 'active_support/deprecation'
require "active_support/deprecation"
ActiveSupport::Deprecation.warn("This is deprecated and will be removed in Rails 5.1 with no replacement.")

View File

@ -1,6 +1,6 @@
require 'active_support/time_with_zone'
require 'active_support/core_ext/time/acts_like'
require 'active_support/core_ext/date_and_time/zones'
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

View File

@ -1,4 +1,4 @@
require 'uri'
require "uri"
str = "\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E" # Ni-ho-nn-go in UTF-8, means Japanese.
parser = URI::Parser.new
@ -10,7 +10,7 @@ unless str == parser.unescape(parser.escape(str))
# 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)
str.gsub(escaped) { |match| [match[1, 2].hex].pack("C") }.force_encoding(enc)
end
end
end

View File

@ -1,19 +1,19 @@
require 'set'
require 'thread'
require 'concurrent/map'
require 'pathname'
require 'active_support/core_ext/module/aliasing'
require 'active_support/core_ext/module/attribute_accessors'
require 'active_support/core_ext/module/introspection'
require 'active_support/core_ext/module/anonymous'
require 'active_support/core_ext/module/qualified_const'
require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/kernel/reporting'
require 'active_support/core_ext/load_error'
require 'active_support/core_ext/name_error'
require 'active_support/core_ext/string/starts_ends_with'
require "set"
require "thread"
require "concurrent/map"
require "pathname"
require "active_support/core_ext/module/aliasing"
require "active_support/core_ext/module/attribute_accessors"
require "active_support/core_ext/module/introspection"
require "active_support/core_ext/module/anonymous"
require "active_support/core_ext/module/qualified_const"
require "active_support/core_ext/object/blank"
require "active_support/core_ext/kernel/reporting"
require "active_support/core_ext/load_error"
require "active_support/core_ext/name_error"
require "active_support/core_ext/string/starts_ends_with"
require "active_support/dependencies/interlock"
require 'active_support/inflector'
require "active_support/inflector"
module ActiveSupport #:nodoc:
module Dependencies #:nodoc:
@ -64,7 +64,7 @@ module ActiveSupport #:nodoc:
# Should we load files or require them?
mattr_accessor :mechanism
self.mechanism = ENV['NO_RELOAD'] ? :require : :load
self.mechanism = ENV["NO_RELOAD"] ? :require : :load
# The set of directories from which we may automatically load files. Files
# under these directories will be reloaded on each request in development mode,
@ -503,7 +503,7 @@ module ActiveSupport #:nodoc:
if file_path
expanded = File.expand_path(file_path)
expanded.sub!(/\.rb\z/, ''.freeze)
expanded.sub!(/\.rb\z/, "".freeze)
if loading.include?(expanded)
raise "Circular dependency detected while autoloading constant #{qualified_name}"
@ -591,7 +591,7 @@ module ActiveSupport #:nodoc:
def store(klass)
return self unless klass.respond_to?(:name)
raise(ArgumentError, 'anonymous classes cannot be cached') if klass.name.empty?
raise(ArgumentError, "anonymous classes cannot be cached") if klass.name.empty?
@store[klass.name] = klass
self
end
@ -675,7 +675,7 @@ module ActiveSupport #:nodoc:
# A module, class, symbol, or string may be provided.
def to_constant_name(desc) #:nodoc:
case desc
when String then desc.sub(/^::/, '')
when String then desc.sub(/^::/, "")
when Symbol then desc.to_s
when Module
desc.name ||
@ -686,17 +686,17 @@ module ActiveSupport #:nodoc:
def remove_constant(const) #:nodoc:
# Normalize ::Foo, ::Object::Foo, Object::Foo, Object::Object::Foo, etc. as Foo.
normalized = const.to_s.sub(/\A::/, '')
normalized.sub!(/\A(Object::)+/, '')
normalized = const.to_s.sub(/\A::/, "")
normalized.sub!(/\A(Object::)+/, "")
constants = normalized.split('::')
constants = normalized.split("::")
to_remove = constants.pop
# Remove the file path from the loaded list.
file_path = search_for_file(const.underscore)
if file_path
expanded = File.expand_path(file_path)
expanded.sub!(/\.rb\z/, '')
expanded.sub!(/\.rb\z/, "")
self.loaded.delete(expanded)
end
@ -710,7 +710,7 @@ module ActiveSupport #:nodoc:
# here than require the caller to be clever. We check the parent
# rather than the very const argument because we do not want to
# trigger Kernel#autoloads, see the comment below.
parent_name = constants.join('::')
parent_name = constants.join("::")
return unless qualified_const_defined?(parent_name)
parent = constantize(parent_name)
end

View File

@ -1,4 +1,4 @@
require 'active_support/concurrency/share_lock'
require "active_support/concurrency/share_lock"
module ActiveSupport #:nodoc:
module Dependencies #:nodoc:

Some files were not shown because too many files have changed in this diff Show More