From b95d6e84b00bd926b1118f6a820eca7a870b8c35 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Sat, 14 Aug 2010 02:13:00 -0300 Subject: Deletes trailing whitespaces (over text files only find * -type f -exec sed 's/[ \t]*$//' -i {} \;) --- activesupport/lib/active_support/base64.rb | 6 ++-- activesupport/lib/active_support/benchmarkable.rb | 6 ++-- activesupport/lib/active_support/cache.rb | 22 +++++++------- .../active_support/cache/strategy/local_cache.rb | 2 +- activesupport/lib/active_support/callbacks.rb | 2 +- .../active_support/core_ext/array/random_access.rb | 8 ++--- .../lib/active_support/core_ext/array/wrap.rb | 2 +- .../active_support/core_ext/date/calculations.rb | 4 +-- .../core_ext/date_time/conversions.rb | 12 ++++---- .../lib/active_support/core_ext/date_time/zones.rb | 2 +- .../lib/active_support/core_ext/enumerable.rb | 8 ++--- .../active_support/core_ext/hash/conversions.rb | 22 +++++++------- .../lib/active_support/core_ext/integer/time.rb | 4 +-- .../active_support/core_ext/module/anonymous.rb | 2 +- .../core_ext/module/attr_accessor_with_default.rb | 4 +-- .../core_ext/module/attribute_accessors.rb | 2 +- .../core_ext/module/remove_method.rb | 2 +- .../core_ext/module/synchronization.rb | 4 +-- .../lib/active_support/core_ext/numeric/time.rb | 18 ++++++------ .../lib/active_support/core_ext/object/blank.rb | 2 +- .../core_ext/object/instance_variables.rb | 10 +++---- .../active_support/core_ext/object/returning.rb | 4 +-- .../active_support/core_ext/range/conversions.rb | 2 +- .../lib/active_support/core_ext/string/access.rb | 14 ++++----- .../active_support/core_ext/string/inflections.rb | 12 ++++---- .../active_support/core_ext/time/calculations.rb | 4 +-- .../active_support/core_ext/time/conversions.rb | 2 +- .../lib/active_support/core_ext/time/zones.rb | 6 ++-- activesupport/lib/active_support/duration.rb | 2 +- activesupport/lib/active_support/i18n_railtie.rb | 2 +- .../lib/active_support/lazy_load_hooks.rb | 4 +-- activesupport/lib/active_support/locale/en.yml | 6 ++-- activesupport/lib/active_support/log_subscriber.rb | 2 +- .../active_support/log_subscriber/test_helper.rb | 2 +- .../lib/active_support/message_encryptor.rb | 34 +++++++++++----------- .../lib/active_support/message_verifier.rb | 14 ++++----- activesupport/lib/active_support/multibyte.rb | 2 +- activesupport/lib/active_support/ordered_hash.rb | 4 +-- .../lib/active_support/ordered_options.rb | 6 ++-- .../lib/active_support/testing/assertions.rb | 4 +-- .../lib/active_support/testing/declarative.rb | 8 ++--- .../lib/active_support/testing/pending.rb | 6 ++-- activesupport/lib/active_support/time_with_zone.rb | 4 +-- activesupport/lib/active_support/xml_mini/rexml.rb | 2 +- 44 files changed, 145 insertions(+), 145 deletions(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/base64.rb b/activesupport/lib/active_support/base64.rb index b8c01628ce..35014cb3d5 100644 --- a/activesupport/lib/active_support/base64.rb +++ b/activesupport/lib/active_support/base64.rb @@ -7,7 +7,7 @@ module ActiveSupport if defined? ::Base64 Base64 = ::Base64 else - # Base64 provides utility methods for encoding and de-coding binary data + # Base64 provides utility methods for encoding and de-coding binary data # using a base 64 representation. A base 64 representation of binary data # consists entirely of printable US-ASCII characters. The Base64 module # is included in Ruby 1.8, but has been removed in Ruby 1.9. @@ -15,7 +15,7 @@ module ActiveSupport # Encodes a string to its base 64 representation. Each 60 characters of # output is separated by a newline character. # - # ActiveSupport::Base64.encode64("Original unencoded string") + # ActiveSupport::Base64.encode64("Original unencoded string") # # => "T3JpZ2luYWwgdW5lbmNvZGVkIHN0cmluZw==\n" def self.encode64(data) [data].pack("m") @@ -23,7 +23,7 @@ module ActiveSupport # Decodes a base 64 encoded string to its original representation. # - # ActiveSupport::Base64.decode64("T3JpZ2luYWwgdW5lbmNvZGVkIHN0cmluZw==") + # ActiveSupport::Base64.decode64("T3JpZ2luYWwgdW5lbmNvZGVkIHN0cmluZw==") # # => "Original unencoded string" def self.decode64(data) data.unpack("m").first diff --git a/activesupport/lib/active_support/benchmarkable.rb b/activesupport/lib/active_support/benchmarkable.rb index ee02ecb043..df62c18f41 100644 --- a/activesupport/lib/active_support/benchmarkable.rb +++ b/activesupport/lib/active_support/benchmarkable.rb @@ -3,10 +3,10 @@ require 'active_support/core_ext/hash/keys' module ActiveSupport module Benchmarkable - # Allows you to measure the execution time of a block + # Allows you to measure the execution time of a block # in a template and records the result to the log. Wrap this block around # expensive operations or possible bottlenecks to get a time reading - # for the operation. For example, let's say you thought your file + # for the operation. For example, let's say you thought your file # processing method was taking too long; you could wrap it in a benchmark block. # # <% benchmark "Process data files" do %> @@ -23,7 +23,7 @@ module ActiveSupport # <%= lowlevel_files_operation %> # <% end %> # - # Finally, you can pass true as the third argument to silence all log activity + # Finally, you can pass true as the third argument to silence all log activity # inside the block. This is great for boiling down a noisy block to just a single statement: # # <% benchmark "Process data files", :level => :info, :silence => true do %> diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb index 30195bdea5..8153dd57de 100644 --- a/activesupport/lib/active_support/cache.rb +++ b/activesupport/lib/active_support/cache.rb @@ -200,26 +200,26 @@ module ActiveSupport # # Setting :expires_in will set an expiration time on the cache. All caches # support auto expiring content after a specified number of seconds. This value can - # be specified as an option to the construction in which call all entries will be + # be specified as an option to the construction in which call all entries will be # affected. Or it can be supplied to the +fetch+ or +write+ method for just one entry. # # cache = ActiveSupport::Cache::MemoryStore.new(:expire_in => 5.minutes) # cache.write(key, value, :expire_in => 1.minute) # Set a lower value for one entry # # Setting :race_condition_ttl is very useful in situations where a cache entry - # is used very frequently unver heavy load. If a cache expires and due to heavy load - # seven different processes will try to read data natively and then they all will try to - # write to cache. To avoid that case the first process to find an expired cache entry will + # is used very frequently unver heavy load. If a cache expires and due to heavy load + # seven different processes will try to read data natively and then they all will try to + # write to cache. To avoid that case the first process to find an expired cache entry will # bump the cache expiration time by the value set in :race_condition_ttl. Yes - # this process is extending the time for a stale value by another few seconds. Because + # this process is extending the time for a stale value by another few seconds. Because # of extended life of the previous cache, other processes will continue to use slightly # stale data for a just a big longer. In the meantime that first process will go ahead # and will write into cache the new value. After that all the processes will start # getting new value. The key is to keep :race_condition_ttl small. # # If the process regenerating the entry errors out, the entry will be regenerated - # after the specified number of seconds. Also note that the life of stale cache is - # extended only if it expired recently. Otherwise a new value is generated and + # after the specified number of seconds. Also note that the life of stale cache is + # extended only if it expired recently. Otherwise a new value is generated and # :race_condition_ttl does not play any role. # # # Set all values to expire after one minute. @@ -410,7 +410,7 @@ module ActiveSupport raise NotImplementedError.new("#{self.class.name} does not support decrement") end - # Cleanup the cache by removing expired entries. + # Cleanup the cache by removing expired entries. # # Options are passed to the underlying cache implementation. # @@ -419,7 +419,7 @@ module ActiveSupport raise NotImplementedError.new("#{self.class.name} does not support cleanup") end - # Clear the entire cache. Be careful with this method since it could + # Clear the entire cache. Be careful with this method since it could # affect other processes if shared cache is being used. # # Options are passed to the underlying cache implementation. @@ -473,8 +473,8 @@ module ActiveSupport end end - # Expand key to be a consistent string value. Invoke +cache_key+ if - # object responds to +cache_key+. Otherwise, to_param method will be + # Expand key to be a consistent string value. Invoke +cache_key+ if + # object responds to +cache_key+. Otherwise, to_param method will be # called. If the key is a Hash, then keys will be sorted alphabetically. def expanded_key(key) # :nodoc: if key.respond_to?(:cache_key) diff --git a/activesupport/lib/active_support/cache/strategy/local_cache.rb b/activesupport/lib/active_support/cache/strategy/local_cache.rb index 3edba52fc4..4dce35f1c9 100644 --- a/activesupport/lib/active_support/cache/strategy/local_cache.rb +++ b/activesupport/lib/active_support/cache/strategy/local_cache.rb @@ -16,7 +16,7 @@ module ActiveSupport @data = {} end - # Don't allow synchronizing since it isn't thread safe, + # Don't allow synchronizing since it isn't thread safe, def synchronize # :nodoc: yield end diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb index 24e407c253..09ddd7da83 100644 --- a/activesupport/lib/active_support/callbacks.rb +++ b/activesupport/lib/active_support/callbacks.rb @@ -479,7 +479,7 @@ module ActiveSupport end filters.each do |filter| - chain.delete_if {|c| c.matches?(type, filter) } + chain.delete_if {|c| c.matches?(type, filter) } end options[:prepend] ? chain.unshift(*mapped) : chain.push(*mapped) diff --git a/activesupport/lib/active_support/core_ext/array/random_access.rb b/activesupport/lib/active_support/core_ext/array/random_access.rb index edac7278bc..9a6b5e9b79 100644 --- a/activesupport/lib/active_support/core_ext/array/random_access.rb +++ b/activesupport/lib/active_support/core_ext/array/random_access.rb @@ -1,10 +1,10 @@ class Array # Backport of Array#sample based on Marc-Andre Lafortune's http://github.com/marcandre/backports/ - # Returns a random element or +n+ random elements from the array. + # Returns a random element or +n+ random elements from the array. # If the array is empty and +n+ is nil, returns nil. if +n+ is passed, returns []. - # - # [1,2,3,4,5,6].sample # => 4 - # [1,2,3,4,5,6].sample(3) # => [2, 4, 5] + # + # [1,2,3,4,5,6].sample # => 4 + # [1,2,3,4,5,6].sample(3) # => [2, 4, 5] # [].sample # => nil # [].sample(3) # => [] def sample(n=nil) diff --git a/activesupport/lib/active_support/core_ext/array/wrap.rb b/activesupport/lib/active_support/core_ext/array/wrap.rb index 06b2acd662..7fabae3138 100644 --- a/activesupport/lib/active_support/core_ext/array/wrap.rb +++ b/activesupport/lib/active_support/core_ext/array/wrap.rb @@ -10,7 +10,7 @@ class Array # 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 diff --git a/activesupport/lib/active_support/core_ext/date/calculations.rb b/activesupport/lib/active_support/core_ext/date/calculations.rb index c5b54318ce..1856b4dd8b 100644 --- a/activesupport/lib/active_support/core_ext/date/calculations.rb +++ b/activesupport/lib/active_support/core_ext/date/calculations.rb @@ -7,7 +7,7 @@ require 'active_support/core_ext/time/zones' class Date if RUBY_VERSION < '1.9' undef :>> - + # Backported from 1.9. The one in 1.8 leads to incorrect next_month and # friends for dates where the calendar reform is involved. It additionally # prevents an infinite loop fixed in r27013. @@ -156,7 +156,7 @@ class Date def next_year years_since(1) end unless method_defined?(:next_year) - + # Shorthand for months_ago(1) def prev_month months_ago(1) diff --git a/activesupport/lib/active_support/core_ext/date_time/conversions.rb b/activesupport/lib/active_support/core_ext/date_time/conversions.rb index 47b8aa59fb..8e267c76c4 100644 --- a/activesupport/lib/active_support/core_ext/date_time/conversions.rb +++ b/activesupport/lib/active_support/core_ext/date_time/conversions.rb @@ -9,12 +9,12 @@ class DateTime remove_method :to_time if instance_methods.include?(:to_time) # 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" @@ -50,7 +50,7 @@ class DateTime 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) @@ -83,8 +83,8 @@ class DateTime def xmlschema strftime("%Y-%m-%dT%H:%M:%S%Z") end unless instance_methods(false).include?(:xmlschema) - - # Converts self to a floating-point number of seconds since the Unix epoch + + # Converts self to a floating-point number of seconds since the Unix epoch def to_f seconds_since_unix_epoch.to_f end diff --git a/activesupport/lib/active_support/core_ext/date_time/zones.rb b/activesupport/lib/active_support/core_ext/date_time/zones.rb index a7411d54ae..82a4f7ac5a 100644 --- a/activesupport/lib/active_support/core_ext/date_time/zones.rb +++ b/activesupport/lib/active_support/core_ext/date_time/zones.rb @@ -9,7 +9,7 @@ class DateTime # 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, + # 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. # # DateTime.new(2000).in_time_zone('Alaska') # => Fri, 31 Dec 1999 15:00:00 AKST -09:00 diff --git a/activesupport/lib/active_support/core_ext/enumerable.rb b/activesupport/lib/active_support/core_ext/enumerable.rb index f76ed401cd..f1103029c8 100644 --- a/activesupport/lib/active_support/core_ext/enumerable.rb +++ b/activesupport/lib/active_support/core_ext/enumerable.rb @@ -9,7 +9,7 @@ module Enumerable # # Example: # - # latest_transcripts.group_by(&:day).each do |day, transcripts| + # latest_transcripts.group_by(&:day).each do |day, transcripts| # p "#{day} -> #{transcripts.map(&:class).join(', ')}" # end # "2006-03-01 -> Transcript" @@ -88,21 +88,21 @@ module Enumerable # => { "nextangle" => , "chade-" => , ...} # people.index_by { |person| "#{person.first_name} #{person.last_name}" } # => { "Chade- Fowlersburg-e" => , "David Heinemeier Hansson" => , ...} - # + # def index_by inject({}) do |accum, elem| accum[yield(elem)] = elem accum end end - + # Returns true if the collection has more than 1 element. Functionally equivalent to collection.size > 1. # Works with a block too ala any?, so people.many? { |p| p.age > 26 } # => returns true if more than 1 person is over 26. def many?(&block) size = block_given? ? select(&block).size : self.size size > 1 end - + # The negative of the Enumerable#include?. Returns true if the collection does not include the object. def exclude?(object) !include?(object) diff --git a/activesupport/lib/active_support/core_ext/hash/conversions.rb b/activesupport/lib/active_support/core_ext/hash/conversions.rb index 2763af6121..7e929848a9 100644 --- a/activesupport/lib/active_support/core_ext/hash/conversions.rb +++ b/activesupport/lib/active_support/core_ext/hash/conversions.rb @@ -7,7 +7,7 @@ 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 # # => # # @@ -15,22 +15,22 @@ class Hash # # 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. Its # return value becomes a new node. - # + # # * If +value+ responds to +to_xml+ the method is invoked with +key+ as :root. - # + # # * 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 @@ -48,9 +48,9 @@ class Hash # "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. @@ -108,7 +108,7 @@ class Hash # blank or nil parsed values are represented by nil elsif value.blank? || value['nil'] == 'true' nil - # If the type is the only element which makes it then + # If the type is the only element which makes it then # this still makes the value nil, except if type is # a XML node(where type['value'] is a Hash) elsif value['type'] && value.size == 1 && !value['type'].is_a?(::Hash) @@ -118,7 +118,7 @@ class Hash h[k] = typecast_xml_value(v) h end - + # 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 diff --git a/activesupport/lib/active_support/core_ext/integer/time.rb b/activesupport/lib/active_support/core_ext/integer/time.rb index a0ccf0e971..c677400396 100644 --- a/activesupport/lib/active_support/core_ext/integer/time.rb +++ b/activesupport/lib/active_support/core_ext/integer/time.rb @@ -1,7 +1,7 @@ class Integer # Enables the use of time calculations and declarations, like 45.minutes + 2.hours + 4.years. # - # These methods use Time#advance for precise date calculations when using from_now, ago, etc. + # These methods use Time#advance for precise date calculations when using from_now, ago, etc. # as well as adding or subtracting their results from a Time object. For example: # # # equivalent to Time.now.advance(:months => 1) @@ -12,7 +12,7 @@ class Integer # # # equivalent to Time.now.advance(:months => 4, :years => 5) # (4.months + 5.years).from_now - # + # # While these methods provide precise calculation when used as in the examples above, care # should be taken to note that this is not true if the result of `months', `years', etc is # converted before use: diff --git a/activesupport/lib/active_support/core_ext/module/anonymous.rb b/activesupport/lib/active_support/core_ext/module/anonymous.rb index df25a09ec9..3982c9c586 100644 --- a/activesupport/lib/active_support/core_ext/module/anonymous.rb +++ b/activesupport/lib/active_support/core_ext/module/anonymous.rb @@ -19,6 +19,6 @@ class Module def anonymous? # Uses blank? because the name of an anonymous class is an empty # string in 1.8, and nil in 1.9. - name.blank? + name.blank? end end diff --git a/activesupport/lib/active_support/core_ext/module/attr_accessor_with_default.rb b/activesupport/lib/active_support/core_ext/module/attr_accessor_with_default.rb index 28ac89dab9..bfedbbb256 100644 --- a/activesupport/lib/active_support/core_ext/module/attr_accessor_with_default.rb +++ b/activesupport/lib/active_support/core_ext/module/attr_accessor_with_default.rb @@ -2,7 +2,7 @@ class Module # Declare an attribute accessor with an initial default return value. # # To give attribute :age the initial value 25: - # + # # class Person # attr_accessor_with_default :age, 25 # end @@ -16,7 +16,7 @@ class Module # To give attribute :element_name a dynamic default value, evaluated # in scope of self: # - # attr_accessor_with_default(:element_name) { name.underscore } + # attr_accessor_with_default(:element_name) { name.underscore } # def attr_accessor_with_default(sym, default = nil, &block) raise 'Default value or block required' unless !default.nil? || block diff --git a/activesupport/lib/active_support/core_ext/module/attribute_accessors.rb b/activesupport/lib/active_support/core_ext/module/attribute_accessors.rb index 2d88cb57e5..871f5cef3b 100644 --- a/activesupport/lib/active_support/core_ext/module/attribute_accessors.rb +++ b/activesupport/lib/active_support/core_ext/module/attribute_accessors.rb @@ -11,7 +11,7 @@ class Module @@#{sym} end EOS - + unless options[:instance_reader] == false class_eval(<<-EOS, __FILE__, __LINE__ + 1) def #{sym} diff --git a/activesupport/lib/active_support/core_ext/module/remove_method.rb b/activesupport/lib/active_support/core_ext/module/remove_method.rb index b8c01aca0e..07d7c9b018 100644 --- a/activesupport/lib/active_support/core_ext/module/remove_method.rb +++ b/activesupport/lib/active_support/core_ext/module/remove_method.rb @@ -3,7 +3,7 @@ class Module remove_method(method) rescue NameError end - + def redefine_method(method, &block) remove_possible_method(method) define_method(method, &block) diff --git a/activesupport/lib/active_support/core_ext/module/synchronization.rb b/activesupport/lib/active_support/core_ext/module/synchronization.rb index de76a069d6..38ce55f26e 100644 --- a/activesupport/lib/active_support/core_ext/module/synchronization.rb +++ b/activesupport/lib/active_support/core_ext/module/synchronization.rb @@ -3,9 +3,9 @@ require 'active_support/core_ext/array/extract_options' class Module # Synchronize access around a method, delegating synchronization to a - # particular mutex. A mutex (either a Mutex, or any object that responds to + # particular mutex. A mutex (either a Mutex, or any object that responds to # #synchronize and yields to a block) must be provided as a final :with option. - # The :with option should be a symbol or string, and can represent a method, + # The :with option should be a symbol or string, and can represent a method, # constant, or instance or class variable. # Example: # class SharedCache diff --git a/activesupport/lib/active_support/core_ext/numeric/time.rb b/activesupport/lib/active_support/core_ext/numeric/time.rb index d1062805c5..d32a9e0531 100644 --- a/activesupport/lib/active_support/core_ext/numeric/time.rb +++ b/activesupport/lib/active_support/core_ext/numeric/time.rb @@ -3,7 +3,7 @@ require 'active_support/duration' class Numeric # Enables the use of time calculations and declarations, like 45.minutes + 2.hours + 4.years. # - # These methods use Time#advance for precise date calculations when using from_now, ago, etc. + # These methods use Time#advance for precise date calculations when using from_now, ago, etc. # as well as adding or subtracting their results from a Time object. For example: # # # equivalent to Time.now.advance(:months => 1) @@ -14,7 +14,7 @@ class Numeric # # # equivalent to Time.now.advance(:months => 4, :years => 5) # (4.months + 5.years).from_now - # + # # While these methods provide precise calculation when used as in the examples above, care # should be taken to note that this is not true if the result of `months', `years', etc is # converted before use: @@ -25,8 +25,8 @@ class Numeric # # equivalent to 365.25.days.to_f.from_now # 1.year.to_f.from_now # - # In such cases, Ruby's core - # Date[http://stdlib.rubyonrails.org/libdoc/date/rdoc/index.html] and + # In such cases, Ruby's core + # Date[http://stdlib.rubyonrails.org/libdoc/date/rdoc/index.html] and # Time[http://stdlib.rubyonrails.org/libdoc/time/rdoc/index.html] should be used for precision # date and time arithmetic def seconds @@ -37,13 +37,13 @@ class Numeric def minutes ActiveSupport::Duration.new(self * 60, [[:seconds, self * 60]]) end - alias :minute :minutes - + alias :minute :minutes + def hours ActiveSupport::Duration.new(self * 3600, [[:seconds, self * 3600]]) end alias :hour :hours - + def days ActiveSupport::Duration.new(self * 24.hours, [[:days, self]]) end @@ -53,12 +53,12 @@ class Numeric ActiveSupport::Duration.new(self * 7.days, [[:days, self * 7]]) end alias :week :weeks - + def fortnights ActiveSupport::Duration.new(self * 2.weeks, [[:days, self * 14]]) end alias :fortnight :fortnights - + # Reads best without arguments: 10.minutes.ago def ago(time = ::Time.now) time - self diff --git a/activesupport/lib/active_support/core_ext/object/blank.rb b/activesupport/lib/active_support/core_ext/object/blank.rb index eb99bb1a36..51670b148f 100644 --- a/activesupport/lib/active_support/core_ext/object/blank.rb +++ b/activesupport/lib/active_support/core_ext/object/blank.rb @@ -17,7 +17,7 @@ class Object def present? !blank? end - + # Returns object if it's #present? otherwise returns nil. # object.presence is equivalent to object.present? ? object : nil. # diff --git a/activesupport/lib/active_support/core_ext/object/instance_variables.rb b/activesupport/lib/active_support/core_ext/object/instance_variables.rb index 866317b17a..97b288c608 100644 --- a/activesupport/lib/active_support/core_ext/object/instance_variables.rb +++ b/activesupport/lib/active_support/core_ext/object/instance_variables.rb @@ -7,7 +7,7 @@ class Object # @x, @y = x, y # end # end - # + # # C.new(0, 1).instance_values # => {"x" => 0, "y" => 1} def instance_values #:nodoc: instance_variables.inject({}) do |values, name| @@ -24,7 +24,7 @@ class Object # @x, @y = x, y # end # end - # + # # C.new(0, 1).instance_variable_names # => ["@y", "@x"] if RUBY_VERSION >= '1.9' def instance_variable_names @@ -47,15 +47,15 @@ class Object # def initialize(x, y, z) # @x, @y, @z = x, y, z # end - # + # # def protected_instance_variables # %w(@z) # end # end - # + # # a = C.new(0, 1, 2) # b = C.new(3, 4, 5) - # + # # a.copy_instance_variables_from(b, [:@y]) # # a is now: @x = 3, @y = 1, @z = 2 def copy_instance_variables_from(object, exclude = []) #:nodoc: diff --git a/activesupport/lib/active_support/core_ext/object/returning.rb b/activesupport/lib/active_support/core_ext/object/returning.rb index 07250b2a27..c401992ccc 100644 --- a/activesupport/lib/active_support/core_ext/object/returning.rb +++ b/activesupport/lib/active_support/core_ext/object/returning.rb @@ -25,7 +25,7 @@ class Object # end # # foo # => ['bar', 'baz'] - # + # # # returning with a block argument # def foo # returning [] do |values| @@ -33,7 +33,7 @@ class Object # values << 'baz' # end # end - # + # # foo # => ['bar', 'baz'] def returning(value) ActiveSupport::Deprecation.warn('Object#returning has been deprecated in favor of Object#tap.', caller) diff --git a/activesupport/lib/active_support/core_ext/range/conversions.rb b/activesupport/lib/active_support/core_ext/range/conversions.rb index 11a7ff66de..544e63132d 100644 --- a/activesupport/lib/active_support/core_ext/range/conversions.rb +++ b/activesupport/lib/active_support/core_ext/range/conversions.rb @@ -6,7 +6,7 @@ class Range # Gives a human readable format of the range. # # ==== Example - # + # # [1..100].to_formatted_s # => "1..100" def to_formatted_s(format = :default) if formatter = RANGE_FORMATS[format] diff --git a/activesupport/lib/active_support/core_ext/string/access.rb b/activesupport/lib/active_support/core_ext/string/access.rb index 64bc8f6cea..c0d5cdf2d5 100644 --- a/activesupport/lib/active_support/core_ext/string/access.rb +++ b/activesupport/lib/active_support/core_ext/string/access.rb @@ -4,27 +4,27 @@ class String unless '1.9'.respond_to?(:force_encoding) # Returns the character at the +position+ treating the string as an array (where 0 is the first character). # - # Examples: + # Examples: # "hello".at(0) # => "h" # "hello".at(4) # => "o" # "hello".at(10) # => ERROR if < 1.9, nil in 1.9 def at(position) mb_chars[position, 1].to_s end - + # Returns the remaining of the string from the +position+ treating the string as an array (where 0 is the first character). # - # Examples: + # Examples: # "hello".from(0) # => "hello" # "hello".from(2) # => "llo" # "hello".from(10) # => "" if < 1.9, nil in 1.9 def from(position) mb_chars[position..-1].to_s end - + # Returns the beginning of the string up to the +position+ treating the string as an array (where 0 is the first character). # - # Examples: + # Examples: # "hello".to(0) # => "h" # "hello".to(2) # => "hel" # "hello".to(10) # => "hello" @@ -34,7 +34,7 @@ class String # Returns the first character of the string or the first +limit+ characters. # - # Examples: + # Examples: # "hello".first # => "h" # "hello".first(2) # => "he" # "hello".first(10) # => "hello" @@ -50,7 +50,7 @@ class String # Returns the last character of the string or the last +limit+ characters. # - # Examples: + # Examples: # "hello".last # => "o" # "hello".last(2) # => "lo" # "hello".last(10) # => "hello" diff --git a/activesupport/lib/active_support/core_ext/string/inflections.rb b/activesupport/lib/active_support/core_ext/string/inflections.rb index 32913a06ad..9a4e63672f 100644 --- a/activesupport/lib/active_support/core_ext/string/inflections.rb +++ b/activesupport/lib/active_support/core_ext/string/inflections.rb @@ -72,7 +72,7 @@ class String 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. # # "ActiveRecord".underscore # => "active_record" @@ -97,7 +97,7 @@ class String end # Replaces special characters in a string so that it may be used as part of a 'pretty' URL. - # + # # ==== Examples # # class Person @@ -105,10 +105,10 @@ class String # "#{id}-#{name.parameterize}" # end # end - # + # # @person = Person.find(1) # # => # - # + # # <%= link_to(@person.name, person_path %> # # => Donald E. Knuth def parameterize(sep = '-') @@ -138,11 +138,11 @@ class String def classify ActiveSupport::Inflector.classify(self) end - + # Capitalizes the first word, turns underscores into spaces, and strips '_id'. # Like +titleize+, this is meant for creating pretty output. # - # "employee_salary" # => "Employee salary" + # "employee_salary" # => "Employee salary" # "author_id" # => "Author" def humanize ActiveSupport::Inflector.humanize(self) diff --git a/activesupport/lib/active_support/core_ext/time/calculations.rb b/activesupport/lib/active_support/core_ext/time/calculations.rb index 90b6cd3685..d430751623 100644 --- a/activesupport/lib/active_support/core_ext/time/calculations.rb +++ b/activesupport/lib/active_support/core_ext/time/calculations.rb @@ -92,12 +92,12 @@ class Time options[:weeks], partial_weeks = options[:weeks].divmod(1) options[:days] = (options[:days] || 0) + 7 * partial_weeks end - + unless options[:days].nil? options[:days], partial_days = options[:days].divmod(1) options[:hours] = (options[:hours] || 0) + 24 * partial_days end - + d = to_date.advance(options) time_advanced_by_date = change(:year => d.year, :month => d.month, :day => d.day) seconds_to_advance = (options[:seconds] || 0) + (options[:minutes] || 0) * 60 + (options[:hours] || 0) * 3600 diff --git a/activesupport/lib/active_support/core_ext/time/conversions.rb b/activesupport/lib/active_support/core_ext/time/conversions.rb index 86103ebce2..025c619783 100644 --- a/activesupport/lib/active_support/core_ext/time/conversions.rb +++ b/activesupport/lib/active_support/core_ext/time/conversions.rb @@ -46,7 +46,7 @@ class Time end alias_method :to_default_s, :to_s alias_method :to_s, :to_formatted_s - + # Returns the UTC offset as an +HH:MM formatted string. # # Time.local(2000).formatted_offset # => "-06:00" diff --git a/activesupport/lib/active_support/core_ext/time/zones.rb b/activesupport/lib/active_support/core_ext/time/zones.rb index 6b9ee84d5c..ef401a6d18 100644 --- a/activesupport/lib/active_support/core_ext/time/zones.rb +++ b/activesupport/lib/active_support/core_ext/time/zones.rb @@ -4,13 +4,13 @@ class Time class << self attr_accessor :zone_default - # Returns the TimeZone for the current request, if this has been set (via Time.zone=). + # 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. + # Sets Time.zone to a TimeZone object for the current request/thread. # # This method accepts any of the following: # @@ -63,7 +63,7 @@ class Time # 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, + # 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 diff --git a/activesupport/lib/active_support/duration.rb b/activesupport/lib/active_support/duration.rb index 7da357730b..a535e2b668 100644 --- a/activesupport/lib/active_support/duration.rb +++ b/activesupport/lib/active_support/duration.rb @@ -3,7 +3,7 @@ require 'active_support/core_ext/array/conversions' require 'active_support/core_ext/object/acts_like' module ActiveSupport - # Provides accurate date and time measurements using Date#advance and + # Provides accurate date and time measurements using Date#advance and # Time#advance, respectively. It mainly supports the methods on Numeric. # Example: # diff --git a/activesupport/lib/active_support/i18n_railtie.rb b/activesupport/lib/active_support/i18n_railtie.rb index db09919fd3..f8a5616a76 100644 --- a/activesupport/lib/active_support/i18n_railtie.rb +++ b/activesupport/lib/active_support/i18n_railtie.rb @@ -66,7 +66,7 @@ module I18n I18n.fallbacks = I18n::Locale::Fallbacks.new(*args) end - + def self.validate_fallbacks(fallbacks) case fallbacks when ActiveSupport::OrderedOptions diff --git a/activesupport/lib/active_support/lazy_load_hooks.rb b/activesupport/lib/active_support/lazy_load_hooks.rb index ef43fc0431..3b8696b5c7 100644 --- a/activesupport/lib/active_support/lazy_load_hooks.rb +++ b/activesupport/lib/active_support/lazy_load_hooks.rb @@ -1,4 +1,4 @@ -# lazy_load_hooks allows rails to lazily load a lot of components and thus making the app boot faster. Because of +# 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. @@ -12,7 +12,7 @@ # end # end # -# When the entirety of +activerecord/lib/active_record/base.rb+ has been evaluated then +run_load_hooks+ is invoked. +# When the entirety of +activerecord/lib/active_record/base.rb+ has been evaluated then +run_load_hooks+ is invoked. # The very last line of +activerecord/lib/active_record/base.rb+ is: # # ActiveSupport.run_load_hooks(:active_record, ActiveRecord::Base) diff --git a/activesupport/lib/active_support/locale/en.yml b/activesupport/lib/active_support/locale/en.yml index 8f08f37a70..a1499bcc90 100644 --- a/activesupport/lib/active_support/locale/en.yml +++ b/activesupport/lib/active_support/locale/en.yml @@ -7,10 +7,10 @@ en: 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] @@ -27,7 +27,7 @@ en: long: "%B %d, %Y %H:%M" am: "am" pm: "pm" - + # Used in array.to_sentence. support: array: diff --git a/activesupport/lib/active_support/log_subscriber.rb b/activesupport/lib/active_support/log_subscriber.rb index 83930b3f0d..63c0470d3f 100644 --- a/activesupport/lib/active_support/log_subscriber.rb +++ b/activesupport/lib/active_support/log_subscriber.rb @@ -47,7 +47,7 @@ module ActiveSupport # Embed in a String to clear all previous ANSI sequences. CLEAR = "\e[0m" BOLD = "\e[1m" - + # Colors BLACK = "\e[30m" RED = "\e[31m" diff --git a/activesupport/lib/active_support/log_subscriber/test_helper.rb b/activesupport/lib/active_support/log_subscriber/test_helper.rb index 9e52cb97a9..5c24b9c759 100644 --- a/activesupport/lib/active_support/log_subscriber/test_helper.rb +++ b/activesupport/lib/active_support/log_subscriber/test_helper.rb @@ -12,7 +12,7 @@ module ActiveSupport # def setup # ActiveRecord::LogSubscriber.attach_to(:active_record) # end - # + # # def test_basic_query_logging # Developer.all # wait diff --git a/activesupport/lib/active_support/message_encryptor.rb b/activesupport/lib/active_support/message_encryptor.rb index 51fa626b45..d21f90f8b7 100644 --- a/activesupport/lib/active_support/message_encryptor.rb +++ b/activesupport/lib/active_support/message_encryptor.rb @@ -2,9 +2,9 @@ require 'openssl' require 'active_support/base64' module ActiveSupport - # MessageEncryptor is a simple way to encrypt values which get stored somewhere + # MessageEncryptor is a simple way to encrypt values which get stored somewhere # you don't trust. - # + # # The cipher text and initialization vector are base64 encoded and returned to you. # # This can be used in situations similar to the MessageVerifier, but where you don't @@ -17,53 +17,53 @@ module ActiveSupport @secret = secret @cipher = cipher end - + def encrypt(value) cipher = new_cipher # Rely on OpenSSL for the initialization vector iv = cipher.random_iv - - cipher.encrypt + + cipher.encrypt cipher.key = @secret cipher.iv = iv - - encrypted_data = cipher.update(Marshal.dump(value)) + + encrypted_data = cipher.update(Marshal.dump(value)) encrypted_data << cipher.final [encrypted_data, iv].map {|v| ActiveSupport::Base64.encode64s(v)}.join("--") end - + def decrypt(encrypted_message) cipher = new_cipher encrypted_data, iv = encrypted_message.split("--").map {|v| ActiveSupport::Base64.decode64(v)} - + cipher.decrypt cipher.key = @secret cipher.iv = iv decrypted_data = cipher.update(encrypted_data) decrypted_data << cipher.final - + Marshal.load(decrypted_data) rescue OpenSSLCipherError, TypeError raise InvalidMessage end - + def encrypt_and_sign(value) verifier.generate(encrypt(value)) end - + def decrypt_and_verify(value) decrypt(verifier.verify(value)) end - - - - private + + + + private def new_cipher OpenSSL::Cipher::Cipher.new(@cipher) end - + def verifier MessageVerifier.new(@secret) end diff --git a/activesupport/lib/active_support/message_verifier.rb b/activesupport/lib/active_support/message_verifier.rb index 6c46b68eaf..9a4468f73c 100644 --- a/activesupport/lib/active_support/message_verifier.rb +++ b/activesupport/lib/active_support/message_verifier.rb @@ -4,28 +4,28 @@ require 'active_support/core_ext/object/blank' module ActiveSupport # MessageVerifier makes it easy to generate and verify messages which are signed # to prevent tampering. - # + # # This is useful for cases like remember-me tokens and auto-unsubscribe links where the # session store isn't suitable or available. # # Remember Me: # cookies[:remember_me] = @verifier.generate([@user.id, 2.weeks.from_now]) - # + # # In the authentication filter: # # id, time = @verifier.verify(cookies[:remember_me]) # if time < Time.now # self.current_user = User.find(id) # end - # + # class MessageVerifier class InvalidSignature < StandardError; end - + def initialize(secret, digest = 'SHA1') @secret = secret @digest = digest end - + def verify(signed_message) raise InvalidSignature if signed_message.blank? @@ -36,12 +36,12 @@ module ActiveSupport raise InvalidSignature end end - + def generate(value) data = ActiveSupport::Base64.encode64s(Marshal.dump(value)) "#{data}--#{generate_digest(data)}" end - + private # constant-time comparison algorithm to prevent timing attacks def secure_compare(a, b) diff --git a/activesupport/lib/active_support/multibyte.rb b/activesupport/lib/active_support/multibyte.rb index 8ffdf5a1bf..57e8e24bf4 100644 --- a/activesupport/lib/active_support/multibyte.rb +++ b/activesupport/lib/active_support/multibyte.rb @@ -6,7 +6,7 @@ module ActiveSupport #:nodoc: autoload :EncodingError, 'active_support/multibyte/exceptions' 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. diff --git a/activesupport/lib/active_support/ordered_hash.rb b/activesupport/lib/active_support/ordered_hash.rb index 2e8d538d0b..dfc3f01fa2 100644 --- a/activesupport/lib/active_support/ordered_hash.rb +++ b/activesupport/lib/active_support/ordered_hash.rb @@ -8,12 +8,12 @@ module ActiveSupport # The order of iteration over hashes in Ruby 1.8 is undefined. For example, you do not know the # order in which +keys+ will return keys, or +each+ yield pairs. ActiveSupport::OrderedHash # implements a hash that preserves insertion order, as in Ruby 1.9: - # + # # oh = ActiveSupport::OrderedHash.new # oh[:a] = 1 # oh[:b] = 2 # oh.keys # => [:a, :b], this order is guaranteed - # + # # ActiveSupport::OrderedHash is namespaced to prevent conflicts with other implementations. class OrderedHash < ::Hash #:nodoc: def to_yaml_type diff --git a/activesupport/lib/active_support/ordered_options.rb b/activesupport/lib/active_support/ordered_options.rb index 7fc2b45b51..37e357552c 100644 --- a/activesupport/lib/active_support/ordered_options.rb +++ b/activesupport/lib/active_support/ordered_options.rb @@ -1,13 +1,13 @@ require 'active_support/ordered_hash' # Usually key value pairs are handled something like this: -# +# # h = ActiveSupport::OrderedOptions.new # h[:boy] = 'John' # h[:girl] = 'Mary' # h[:boy] # => 'John' # h[:girl] # => 'Mary' -# +# # Using OrderedOptions above code could be reduced to: # # h = ActiveSupport::OrderedOptions.new @@ -15,7 +15,7 @@ require 'active_support/ordered_hash' # h.girl = 'Mary' # h.boy # => 'John' # h.girl # => 'Mary' -# +# module ActiveSupport #:nodoc: class OrderedOptions < OrderedHash def []=(key, value) diff --git a/activesupport/lib/active_support/testing/assertions.rb b/activesupport/lib/active_support/testing/assertions.rb index 33793f0688..8c68f42781 100644 --- a/activesupport/lib/active_support/testing/assertions.rb +++ b/activesupport/lib/active_support/testing/assertions.rb @@ -63,14 +63,14 @@ module ActiveSupport def assert_no_difference(expression, message = nil, &block) assert_difference expression, 0, message, &block end - + # Test if an expression is blank. Passes if object.blank? is true. # # assert_blank [] # => true def assert_blank(object) assert object.blank?, "#{object.inspect} is not blank" end - + # Test if an expression is not blank. Passes if object.present? is true. # # assert_present {:data => 'x' } # => true diff --git a/activesupport/lib/active_support/testing/declarative.rb b/activesupport/lib/active_support/testing/declarative.rb index 70a6c2ca60..1c05d45888 100644 --- a/activesupport/lib/active_support/testing/declarative.rb +++ b/activesupport/lib/active_support/testing/declarative.rb @@ -1,10 +1,10 @@ module ActiveSupport module Testing module Declarative - + def self.extended(klass) klass.class_eval do - + unless method_defined?(:describe) def self.describe(text) class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1 @@ -14,9 +14,9 @@ module ActiveSupport RUBY_EVAL end end - + end - end + end unless defined?(Spec) # test "verify something" do diff --git a/activesupport/lib/active_support/testing/pending.rb b/activesupport/lib/active_support/testing/pending.rb index 21134ff9e2..39d1f50125 100644 --- a/activesupport/lib/active_support/testing/pending.rb +++ b/activesupport/lib/active_support/testing/pending.rb @@ -25,13 +25,13 @@ module ActiveSupport failed = true end - flunk("<#{description}> did not fail.") unless failed + flunk("<#{description}> did not fail.") unless failed end caller[0] =~ (/(.*):(.*):in `(.*)'/) @@pending_cases << "#{$3} at #{$1}, line #{$2}" print "P" - + @@at_exit ||= begin at_exit do puts "\nPending Cases:" @@ -42,7 +42,7 @@ module ActiveSupport end end end - + end end end \ No newline at end of file diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb index ad6c3de1f5..48c7990b1e 100644 --- a/activesupport/lib/active_support/time_with_zone.rb +++ b/activesupport/lib/active_support/time_with_zone.rb @@ -18,7 +18,7 @@ module ActiveSupport # # 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. + # TimeWithZone instances implement the same API as Ruby Time instances, so that Time and TimeWithZone instances are interchangeable. # Examples: # # t = Time.zone.now # => Sun, 18 May 2008 13:27:25 EDT -04:00 @@ -36,7 +36,7 @@ module ActiveSupport def self.name 'Time' # Report class name as 'Time' to thwart type checking end - + include Comparable attr_reader :time_zone diff --git a/activesupport/lib/active_support/xml_mini/rexml.rb b/activesupport/lib/active_support/xml_mini/rexml.rb index a58f22ee5d..36692af1d3 100644 --- a/activesupport/lib/active_support/xml_mini/rexml.rb +++ b/activesupport/lib/active_support/xml_mini/rexml.rb @@ -19,7 +19,7 @@ module ActiveSupport if !data.respond_to?(:read) data = StringIO.new(data || '') end - + char = data.getc if char.nil? {} -- cgit v1.2.3