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/CHANGELOG | 68 +++++++++++----------- 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 +- .../class_folder/nested_class.rb | 2 +- activesupport/test/clean_backtrace_test.rb | 14 ++--- activesupport/test/clean_logger_test.rb | 4 +- activesupport/test/core_ext/array_ext_test.rb | 12 ++-- .../test/core_ext/class/attribute_accessor_test.rb | 10 ++-- .../class/class_inheritable_attributes_test.rb | 22 +++---- activesupport/test/core_ext/date_ext_test.rb | 16 ++--- activesupport/test/core_ext/date_time_ext_test.rb | 2 +- activesupport/test/core_ext/duration_test.rb | 4 +- activesupport/test/core_ext/enumerable_test.rb | 2 +- activesupport/test/core_ext/hash_ext_test.rb | 42 ++++++------- activesupport/test/core_ext/kernel_test.rb | 2 +- .../test/core_ext/module/anonymous_test.rb | 2 +- .../module/attr_accessor_with_default_test.rb | 8 +-- .../core_ext/module/attribute_accessor_test.rb | 2 +- .../core_ext/module/attribute_aliasing_test.rb | 6 +- .../test/core_ext/module/reachable_test.rb | 16 ++--- activesupport/test/core_ext/numeric_ext_test.rb | 24 ++++---- .../test/core_ext/object_and_class_ext_test.rb | 2 +- activesupport/test/core_ext/string_ext_test.rb | 2 +- activesupport/test/core_ext/time_ext_test.rb | 20 +++---- activesupport/test/core_ext/time_with_zone_test.rb | 6 +- activesupport/test/i18n_test.rb | 34 +++++------ activesupport/test/message_encryptor_test.rb | 14 ++--- activesupport/test/multibyte_conformance.rb | 30 +++++----- activesupport/test/option_merger_test.rb | 2 +- activesupport/test/rescuable_test.rb | 8 +-- activesupport/test/test_test.rb | 20 +++---- activesupport/test/time_zone_test.rb | 2 +- 74 files changed, 344 insertions(+), 344 deletions(-) (limited to 'activesupport') diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG index 53e4d19804..c7f5d6f8b9 100644 --- a/activesupport/CHANGELOG +++ b/activesupport/CHANGELOG @@ -90,7 +90,7 @@ * Rename #metaclass to #singleton_class now that ruby-core has decided [JK] -* New assertions assert_blank and assert_present. #4299 [Juanjo Bazan] +* New assertions assert_blank and assert_present. #4299 [Juanjo Bazan] * Use Object#singleton_class instead of #metaclass. Prefer Ruby's choice. [Jeremy Kemper] @@ -243,7 +243,7 @@ ActiveSupport.escape_html_entities_in_json from true to false to match previousl * Fix Ruby's Time marshaling bug in pre-1.9 versions of Ruby: utc instances are now correctly unmarshaled with a utc zone instead of the system local zone [#900 state:resolved] [Luca Guidi, Geoff Buesing] * Add Array#in_groups which splits or iterates over the array in specified number of groups. #579. [Adrian Mugnolo] Example: - + a = (1..10).to_a a.in_groups(3) # => [[1, 2, 3, 4], [5, 6, 7, nil], [8, 9, 10, nil]] a.in_groups(3, false) # => [[1, 2, 3, 4], [5, 6, 7], [8, 9, 10]] @@ -331,7 +331,7 @@ ActiveSupport.escape_html_entities_in_json from true to false to match previousl * TZInfo: Removing unneeded TimezoneProxy class [Geoff Buesing] -* TZInfo: Removing unneeded TimezoneIndexDefinition, since we're not including Indexes::Timezones [Geoff Buesing] +* TZInfo: Removing unneeded TimezoneIndexDefinition, since we're not including Indexes::Timezones [Geoff Buesing] * Removing unnecessary uses_tzinfo helper from tests, given that TZInfo is now bundled [Geoff Buesing] @@ -339,7 +339,7 @@ ActiveSupport.escape_html_entities_in_json from true to false to match previousl * TimeWithZone#marshal_load does zone lookup via Time.get_zone, so that tzinfo/Olson identifiers are handled [Geoff Buesing] -* Time.zone= accepts TZInfo::Timezone instances and Olson identifiers; wraps result in TimeZone instance [Geoff Buesing] +* Time.zone= accepts TZInfo::Timezone instances and Olson identifiers; wraps result in TimeZone instance [Geoff Buesing] * TimeWithZone time conversions don't need to be wrapped in TimeOrDateTime, because TZInfo does this internally [Geoff Buesing] @@ -433,7 +433,7 @@ ActiveSupport.escape_html_entities_in_json from true to false to match previousl * TimeZone#to_s uses UTC rather than GMT; reapplying change that was undone in [8679]. #1689 [Cheah Chu Yeow] -* Time.days_in_month defaults to current year if no year is supplied as argument #10799 [Radar], uses Date.gregorian_leap? to determine leap year, and uses constant lookup to determine days in month [Geoff Buesing] +* Time.days_in_month defaults to current year if no year is supplied as argument #10799 [Radar], uses Date.gregorian_leap? to determine leap year, and uses constant lookup to determine days in month [Geoff Buesing] * Adding Time and DateTime #compare_with_coercion, which layers behavior on #<=> so that any combination of Time, DateTime and ActiveSupport::TimeWithZone instances can be chronologically compared [Geoff Buesing] @@ -510,7 +510,7 @@ ActiveSupport.escape_html_entities_in_json from true to false to match previousl * Introduce a base class for all test cases used by rails applications. ActiveSupport::TestCase [Michael Koziarski] - The intention is to use this to reduce the amount of monkeypatching / overriding that + The intention is to use this to reduce the amount of monkeypatching / overriding that is done to test/unit's classes. * Document Enumerable and Hash #to_json. #9970 [Cheah Chu Yeow] @@ -679,14 +679,14 @@ ActiveSupport.escape_html_entities_in_json from true to false to match previousl David R0lGODlhkACZAPUAAM5lcfjrtMQCG=\n - + ...becomes: - + attributes = { :person => { :name => "David", :avatar => # } } attributes[:person][:avatar].content_type # => "image/jpg" attributes[:person][:avatar].original_filename # => "me.jpg" attributes[:person][:avatar].read # => binary data of the file - + Which is duck-type compatible with the files that you get when doing multipart uploads through HTML. * Improved multibyte performance by relying less on exception raising #8159 [Blaine] @@ -889,11 +889,11 @@ public for compatibility. [Jeremy Kemper] class Content < ActiveRecord::Base # has a title attribute end - + class Email < ActiveRecord::Base alias_attribute :subject, :title end - + e = Email.find(1) e.title # => "Superstars" e.subject # => "Superstars" @@ -952,9 +952,9 @@ public for compatibility. [Jeremy Kemper] 2004-10-10 EOT - + ...would return: - + { :note => { :title => "This is a note", :created_at => Date.new(2004, 10, 10) } } * Added Jim Weirich's excellent FlexMock class to vendor (Copyright 2003, 2004 by Jim Weirich (jim@weriichhouse.org)) -- it's not automatically required, though, so require 'flexmock' is still necessary [David Heinemeier Hansson] @@ -966,28 +966,28 @@ public for compatibility. [Jeremy Kemper] * Add OrderedHash#values. [Sam Stephenson] * Added Array#to_s(:db) that'll produce a comma-separated list of ids [David Heinemeier Hansson]. Example: - + Purchase.find(:all, :conditions => "product_id IN (#{shops.products.to_s(:db)})" -* Normalize classify's argument to a String so that it plays nice with Symbols. [Marcel Molina Jr.] +* Normalize classify's argument to a String so that it plays nice with Symbols. [Marcel Molina Jr.] * Strip out leading schema name in classify. References #5139. [Michael Schoen] * Remove Enumerable#first_match since break(value) handles the use case well enough. [Nicholas Seckar] Enumerable#first_match was like detect, but instead of returning the matching element, the yielded value returned. For example: - + user_xml = adapters(:from => User, :to => Xml).first_match do |adapter| adapter.adapt @user end - + But this is just as easily done with: - + user_xml = adapters(:from => User, :to => Xml).each do break adapter.adapt(@user) end - -* Make Array#in_groups_of just return the grouped collection if a block isn't given. [Marcel Molina Jr.] + +* Make Array#in_groups_of just return the grouped collection if a block isn't given. [Marcel Molina Jr.] * Don't destroy a HashWithIndifferentAccess if symbolize_keys! or stringify_keys! is called on it. Closes #5076. [Marcel Molina Jr., guy.naor@famundo.com] @@ -999,7 +999,7 @@ public for compatibility. [Jeremy Kemper] * Replace Ruby's deprecated append_features in favor of included. [Marcel Molina Jr.] -* Allow default options in with_options to be overridden. Closes #4480. [murphy@cYcnus.de] +* Allow default options in with_options to be overridden. Closes #4480. [murphy@cYcnus.de] * Added Module#alias_method_chain [Jamis Buck] @@ -1050,7 +1050,7 @@ approximations and shouldn't be used for critical calculations. [Michael Koziars * Added Hash#to_xml and Array#to_xml that makes it much easier to produce XML from basic structures [David Heinemeier Hansson]. Examples: { :name => "David", :street_name => "Paulina", :age => 26, :moved_on => Date.new(2005, 11, 15) }.to_xml - + ...returns: @@ -1069,7 +1069,7 @@ approximations and shouldn't be used for critical calculations. [Michael Koziars ex. - latest_transcripts.group_by(&:day).each do |day, transcripts| + latest_transcripts.group_by(&:day).each do |day, transcripts| p "#{day} -> #{transcripts.map(&:class) * ', '}" end "2006-03-01 -> Transcript" @@ -1093,7 +1093,7 @@ approximations and shouldn't be used for critical calculations. [Michael Koziars * Add 'around' methods to Logger, to make it easy to log before and after messages for a given block as requested in #3809. [Michael Koziarski] Example: - logger.around_info("Start rendering component (#{options.inspect}): ", + logger.around_info("Start rendering component (#{options.inspect}): ", "\n\nEnd of component rendering") { yield } * Added Time#beginning_of_quarter #3607 [cohen.jeff@gmail.com] @@ -1111,7 +1111,7 @@ approximations and shouldn't be used for critical calculations. [Michael Koziars delegate :free?, :paying?, :to => :subscription delegate :overdue?, :to => "subscription.last_payment" end - + account.free? # => account.subscription.free? account.overdue? # => account.subscription.last_payment.overdue? @@ -1126,7 +1126,7 @@ approximations and shouldn't be used for critical calculations. [Michael Koziars * Add Reloadable::Subclasses which handles the common case where a base class should not be reloaded, but its subclasses should be. [Nicholas Seckar] * Further improvements to reloading code [Nicholas Seckar, Trevor Squires] - + - All classes/modules which include Reloadable can define reloadable? for fine grained control of reloading - Class.remove_class uses Module#parent to access the parent module - Class.remove_class expanded to handle multiple classes in a single call @@ -1138,7 +1138,7 @@ approximations and shouldn't be used for critical calculations. [Michael Koziars class Setting include Reloadable end - + Reloading a class is done by removing its constant which will cause it to be loaded again on the next reference. [David Heinemeier Hansson] * Added auto-loading support for classes in modules, so Conductor::Migration will look for conductor/migration.rb and Conductor::Database::Settings will look for conductor/database/settings.rb [Nicholas Seckar] @@ -1175,7 +1175,7 @@ approximations and shouldn't be used for critical calculations. [Michael Koziars * Add Symbol#to_proc, which allows for, e.g. [:foo, :bar].map(&:to_s). [Marcel Molina Jr.] * Added the following methods [Marcel Molina Jr., Sam Stephenson]: - * Object#copy_instance_variables_from(object) to copy instance variables from one object to another + * Object#copy_instance_variables_from(object) to copy instance variables from one object to another * Object#extended_by to get an instance's included/extended modules * Object#extend_with_included_modules_from(object) to extend an instance with the modules from another instance @@ -1226,7 +1226,7 @@ approximations and shouldn't be used for critical calculations. [Michael Koziars *1.2.0* (October 16th, 2005) -* Update Exception extension to show the first few framework frames in an application trace. [Nicholas Seckar] +* Update Exception extension to show the first few framework frames in an application trace. [Nicholas Seckar] * Added Exception extension to provide support for clean backtraces. [Nicholas Seckar] @@ -1275,9 +1275,9 @@ approximations and shouldn't be used for critical calculations. [Michael Koziars Inflector.inflections do |inflect| inflect.plural /^(ox)$/i, '\1\2en' inflect.singular /^(ox)en/i, '\1' - + inflect.irregular 'octopus', 'octopi' - + inflect.uncountable "equipment" end @@ -1360,9 +1360,9 @@ approximations and shouldn't be used for critical calculations. [Michael Koziars * Added Object#suppress which allows you to make a saner choice around with exceptions to swallow #980. Example: suppress(ZeroDivisionError) { 1/0 } - + ...instead of: - + 1/0 rescue nil # BAD, EVIL, DIRTY. @@ -1376,7 +1376,7 @@ approximations and shouldn't be used for critical calculations. [Michael Koziars values << 'baz' end end - + foo # => ['bar', 'baz'] 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? {} diff --git a/activesupport/test/autoloading_fixtures/class_folder/nested_class.rb b/activesupport/test/autoloading_fixtures/class_folder/nested_class.rb index 77ea230d2c..57a13d89ea 100644 --- a/activesupport/test/autoloading_fixtures/class_folder/nested_class.rb +++ b/activesupport/test/autoloading_fixtures/class_folder/nested_class.rb @@ -1,7 +1,7 @@ class ClassFolder class NestedClass end - + class SiblingClass end end diff --git a/activesupport/test/clean_backtrace_test.rb b/activesupport/test/clean_backtrace_test.rb index 86838a7f9a..32e346bb48 100644 --- a/activesupport/test/clean_backtrace_test.rb +++ b/activesupport/test/clean_backtrace_test.rb @@ -5,7 +5,7 @@ class BacktraceCleanerFilterTest < ActiveSupport::TestCase @bc = ActiveSupport::BacktraceCleaner.new @bc.add_filter { |line| line.gsub("/my/prefix", '') } end - + test "backtrace should not contain prefix when it has been filtered out" do assert_equal "/my/class.rb", @bc.clean([ "/my/prefix/my/class.rb" ]).first end @@ -14,14 +14,14 @@ class BacktraceCleanerFilterTest < ActiveSupport::TestCase @bc.remove_filters! assert_equal "/my/prefix/my/class.rb", @bc.clean(["/my/prefix/my/class.rb"]).first end - + test "backtrace should contain unaltered lines if they dont match a filter" do assert_equal "/my/other_prefix/my/class.rb", @bc.clean([ "/my/other_prefix/my/class.rb" ]).first end - + test "backtrace should filter all lines in a backtrace" do assert_equal \ - ["/my/class.rb", "/my/module.rb"], + ["/my/class.rb", "/my/module.rb"], @bc.clean([ "/my/prefix/my/class.rb", "/my/prefix/my/module.rb" ]) end end @@ -31,10 +31,10 @@ class BacktraceCleanerSilencerTest < ActiveSupport::TestCase @bc = ActiveSupport::BacktraceCleaner.new @bc.add_silencer { |line| line =~ /mongrel/ } end - + test "backtrace should not contain lines that match the silencer" do assert_equal \ - [ "/other/class.rb" ], + [ "/other/class.rb" ], @bc.clean([ "/mongrel/class.rb", "/other/class.rb", "/mongrel/stuff.rb" ]) end end @@ -45,7 +45,7 @@ class BacktraceCleanerFilterAndSilencerTest < ActiveSupport::TestCase @bc.add_filter { |line| line.gsub("/mongrel", "") } @bc.add_silencer { |line| line =~ /mongrel/ } end - + test "backtrace should not silence lines that has first had their silence hook filtered out" do assert_equal [ "/class.rb" ], @bc.clean([ "/mongrel/class.rb" ]) end diff --git a/activesupport/test/clean_logger_test.rb b/activesupport/test/clean_logger_test.rb index 6c4ec5ac46..2cc46904b4 100644 --- a/activesupport/test/clean_logger_test.rb +++ b/activesupport/test/clean_logger_test.rb @@ -41,7 +41,7 @@ class CleanLoggerTest < Test::Unit::TestCase assert_equal "error\nfatal\nerror\nfatal\nunsilenced\n", @out.string end - + def test_datetime_format @logger.formatter = Logger::Formatter.new @logger.datetime_format = "%Y-%m-%d" @@ -49,7 +49,7 @@ class CleanLoggerTest < Test::Unit::TestCase assert_equal "%Y-%m-%d", @logger.datetime_format assert_match(/D, \[\d\d\d\d-\d\d-\d\d#\d+\] DEBUG -- : debug/, @out.string) end - + def test_nonstring_formatting an_object = [1, 2, 3, 4, 5] @logger.debug an_object diff --git a/activesupport/test/core_ext/array_ext_test.rb b/activesupport/test/core_ext/array_ext_test.rb index 009a254c64..d14ae39737 100644 --- a/activesupport/test/core_ext/array_ext_test.rb +++ b/activesupport/test/core_ext/array_ext_test.rb @@ -18,10 +18,10 @@ class ArrayExtAccessTests < Test::Unit::TestCase assert_equal %w( a b c ), %w( a b c d ).to(2) assert_equal %w( a b c d ), %w( a b c d ).to(10) end - + def test_second_through_tenth array = (1..42).to_a - + assert_equal array[1], array.second assert_equal array[2], array.third assert_equal array[3], array.fourth @@ -319,7 +319,7 @@ class ArrayExtractOptionsTests < Test::Unit::TestCase assert_equal({}, options) assert_equal [hash], array end - + def test_extract_options_extracts_extractable_subclass hash = ExtractableHashSubclass.new hash[:foo] = 1 @@ -370,14 +370,14 @@ class ArrayExtRandomTests < ActiveSupport::TestCase assert_equal 2, s.size assert_equal 1, (a-s).size assert_equal [], a-(0..20).sum{a.sample(2)} - + o = Object.new def o.to_int; 1; end assert_equal [0], [0].sample(o) - + o = Object.new assert_raises(TypeError) { [0].sample(o) } - + o = Object.new def o.to_int; ''; end assert_raises(TypeError) { [0].sample(o) } diff --git a/activesupport/test/core_ext/class/attribute_accessor_test.rb b/activesupport/test/core_ext/class/attribute_accessor_test.rb index 2c896d0cdb..456f4b7948 100644 --- a/activesupport/test/core_ext/class/attribute_accessor_test.rb +++ b/activesupport/test/core_ext/class/attribute_accessor_test.rb @@ -10,27 +10,27 @@ class ClassAttributeAccessorTest < Test::Unit::TestCase end @object = @class.new end - + def test_should_use_mattr_default assert_nil @class.foo assert_nil @object.foo end - + def test_should_set_mattr_value @class.foo = :test assert_equal :test, @object.foo - + @object.foo = :test2 assert_equal :test2, @class.foo end - + def test_should_not_create_instance_writer assert_respond_to @class, :foo assert_respond_to @class, :foo= assert_respond_to @object, :bar assert !@object.respond_to?(:bar=) end - + def test_should_not_create_instance_reader assert_respond_to @class, :shaq assert !@object.respond_to?(:shaq) diff --git a/activesupport/test/core_ext/class/class_inheritable_attributes_test.rb b/activesupport/test/core_ext/class/class_inheritable_attributes_test.rb index 63ea46b564..b284e5ee1c 100644 --- a/activesupport/test/core_ext/class/class_inheritable_attributes_test.rb +++ b/activesupport/test/core_ext/class/class_inheritable_attributes_test.rb @@ -21,7 +21,7 @@ class ClassInheritableAttributesTest < Test::Unit::TestCase assert_respond_to @klass.new, :a= end end - + def test_writer_declaration_without_instance_writer assert_nothing_raised do @klass.class_inheritable_writer :a, :instance_writer => false @@ -39,7 +39,7 @@ class ClassInheritableAttributesTest < Test::Unit::TestCase assert_respond_to @klass.new, :a= end end - + def test_accessor_declaration_without_instance_writer assert_nothing_raised do @klass.class_inheritable_accessor :a, :instance_writer => false @@ -176,37 +176,37 @@ class ClassInheritableAttributesTest < Test::Unit::TestCase assert_equal 'b', @klass.b assert_equal 'B', @sub.b end - + def test_array_inheritance @klass.class_inheritable_accessor :a @klass.a = [] @sub = eval("class SubbyArray < @klass; end; SubbyArray") - + assert_equal [], @klass.a assert_equal [], @sub.a - + @sub.a << :first - + assert_equal [:first], @sub.a assert_equal [], @klass.a end - + def test_array_inheritance_ @klass.class_inheritable_accessor :a @klass.a = {} @sub = eval("class SubbyHash < @klass; end; SubbyHash") - + assert_equal Hash.new, @klass.a assert_equal Hash.new, @sub.a - + @sub.a[:first] = :first - + assert_equal 1, @sub.a.keys.size assert_equal 0, @klass.a.keys.size end - + def test_reset_inheritable_attributes @klass.class_inheritable_accessor :a @klass.a = 'a' diff --git a/activesupport/test/core_ext/date_ext_test.rb b/activesupport/test/core_ext/date_ext_test.rb index 59c168d33d..3141e895e6 100644 --- a/activesupport/test/core_ext/date_ext_test.rb +++ b/activesupport/test/core_ext/date_ext_test.rb @@ -26,7 +26,7 @@ class DateExtCalculationsTest < ActiveSupport::TestCase assert_equal year, Date.new(year).to_time(format).year end end - end + end end def test_to_datetime @@ -242,7 +242,7 @@ class DateExtCalculationsTest < ActiveSupport::TestCase def test_yesterday_constructor assert_equal Date.current - 1, Date.yesterday end - + def test_yesterday_constructor_when_zone_default_is_not_set with_env_tz 'UTC' do with_tz_default do @@ -286,7 +286,7 @@ class DateExtCalculationsTest < ActiveSupport::TestCase def test_since assert_equal Time.local(2005,2,21,0,0,45), Date.new(2005,2,21).since(45) end - + def test_since_when_zone_default_is_set zone = ActiveSupport::TimeZone['Eastern Time (US & Canada)'] with_env_tz 'UTC' do @@ -300,7 +300,7 @@ class DateExtCalculationsTest < ActiveSupport::TestCase def test_ago assert_equal Time.local(2005,2,20,23,59,15), Date.new(2005,2,21).ago(45) end - + def test_ago_when_zone_default_is_set zone = ActiveSupport::TimeZone['Eastern Time (US & Canada)'] with_env_tz 'UTC' do @@ -314,7 +314,7 @@ class DateExtCalculationsTest < ActiveSupport::TestCase def test_beginning_of_day assert_equal Time.local(2005,2,21,0,0,0), Date.new(2005,2,21).beginning_of_day end - + def test_beginning_of_day_when_zone_default_is_set zone = ActiveSupport::TimeZone['Eastern Time (US & Canada)'] with_env_tz 'UTC' do @@ -328,7 +328,7 @@ class DateExtCalculationsTest < ActiveSupport::TestCase def test_end_of_day assert_equal Time.local(2005,2,21,23,59,59,999999.999), Date.new(2005,2,21).end_of_day end - + def test_end_of_day_when_zone_default_is_set zone = ActiveSupport::TimeZone['Eastern Time (US & Canada)'] with_env_tz 'UTC' do @@ -338,7 +338,7 @@ class DateExtCalculationsTest < ActiveSupport::TestCase end end end - + def test_xmlschema with_env_tz 'US/Eastern' do assert_match(/^1980-02-28T00:00:00-05:?00$/, Date.new(1980, 2, 28).xmlschema) @@ -350,7 +350,7 @@ class DateExtCalculationsTest < ActiveSupport::TestCase end end end - + def test_xmlschema_when_zone_default_is_set with_env_tz 'UTC' do with_tz_default ActiveSupport::TimeZone['Eastern Time (US & Canada)'] do # UTC -5 diff --git a/activesupport/test/core_ext/date_time_ext_test.rb b/activesupport/test/core_ext/date_time_ext_test.rb index e8506f5222..cb290c541b 100644 --- a/activesupport/test/core_ext/date_time_ext_test.rb +++ b/activesupport/test/core_ext/date_time_ext_test.rb @@ -242,7 +242,7 @@ class DateTimeExtCalculationsTest < Test::Unit::TestCase assert_equal false, DateTime.civil(2005,2,10,15,30,45, Rational(-18000, 86400)).past? assert_equal false, DateTime.civil(2005,2,10,15,30,46, Rational(-18000, 86400)).past? end - + def test_past_without_offset DateTime.stubs(:current).returns(DateTime.civil(2005,2,10,15,30,45, Rational(-18000, 86400))) assert_equal true, DateTime.civil(2005,2,10,20,30,44).past? diff --git a/activesupport/test/core_ext/duration_test.rb b/activesupport/test/core_ext/duration_test.rb index 710c221fac..8469f78566 100644 --- a/activesupport/test/core_ext/duration_test.rb +++ b/activesupport/test/core_ext/duration_test.rb @@ -117,13 +117,13 @@ class DurationTest < ActiveSupport::TestCase ensure Time.zone_default = nil end - + def test_adding_hours_across_dst_boundary with_env_tz 'CET' do assert_equal Time.local(2009,3,29,0,0,0) + 24.hours, Time.local(2009,3,30,1,0,0) end end - + def test_adding_day_across_dst_boundary with_env_tz 'CET' do assert_equal Time.local(2009,3,29,0,0,0) + 1.day, Time.local(2009,3,30,0,0,0) diff --git a/activesupport/test/core_ext/enumerable_test.rb b/activesupport/test/core_ext/enumerable_test.rb index 4650b796b6..4655bfe519 100644 --- a/activesupport/test/core_ext/enumerable_test.rb +++ b/activesupport/test/core_ext/enumerable_test.rb @@ -89,7 +89,7 @@ class EnumerableTests < Test::Unit::TestCase assert ![ 1, 2 ].many? {|x| x > 1 } assert [ 1, 2, 2 ].many? {|x| x > 1 } end - + def test_exclude? assert [ 1 ].exclude?(2) assert ![ 1 ].exclude?(1) diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb index 5d9846a216..fc8d8170a1 100644 --- a/activesupport/test/core_ext/hash_ext_test.rb +++ b/activesupport/test/core_ext/hash_ext_test.rb @@ -640,12 +640,12 @@ class HashToXmlTest < Test::Unit::TestCase EOT expected_topic_hash = { - :title => nil, + :title => nil, :id => nil, :approved => nil, :written_on => nil, :viewed_at => nil, - :content => nil, + :content => nil, :parent_id => nil }.stringify_keys @@ -723,7 +723,7 @@ class HashToXmlTest < Test::Unit::TestCase assert_equal expected_topic_hash, Hash.from_xml(topic_xml)["rsp"]["photos"]["photo"] end - + def test_all_caps_key_from_xml test_xml = <<-EOT @@ -839,13 +839,13 @@ class HashToXmlTest < Test::Unit::TestCase assert_equal expected_bacon_hash, Hash.from_xml(bacon_xml)["bacon"] end - + def test_type_trickles_through_when_unknown product_xml = <<-EOT 0.5 image.gif - + EOT @@ -854,7 +854,7 @@ class HashToXmlTest < Test::Unit::TestCase :image => {'type' => 'ProductImage', 'filename' => 'image.gif' }, }.stringify_keys - assert_equal expected_product_hash, Hash.from_xml(product_xml)["product"] + assert_equal expected_product_hash, Hash.from_xml(product_xml)["product"] end def test_should_use_default_value_for_unknown_key @@ -888,41 +888,41 @@ class HashToXmlTest < Test::Unit::TestCase assert_equal expected, hash.to_xml(@xml_options) end end - - def test_empty_string_works_for_typecast_xml_value + + def test_empty_string_works_for_typecast_xml_value assert_nothing_raised do Hash.__send__(:typecast_xml_value, "") end end - + def test_escaping_to_xml - hash = { - :bare_string => 'First & Last Name', + hash = { + :bare_string => 'First & Last Name', :pre_escaped_string => 'First & Last Name' }.stringify_keys - + expected_xml = 'First & Last NameFirst &amp; Last Name' assert_equal expected_xml, hash.to_xml(@xml_options) end - + def test_unescaping_from_xml xml_string = 'First & Last NameFirst &amp; Last Name' - expected_hash = { - :bare_string => 'First & Last Name', + expected_hash = { + :bare_string => 'First & Last Name', :pre_escaped_string => 'First & Last Name' }.stringify_keys assert_equal expected_hash, Hash.from_xml(xml_string)['person'] end - + def test_roundtrip_to_xml_from_xml - hash = { - :bare_string => 'First & Last Name', + hash = { + :bare_string => 'First & Last Name', :pre_escaped_string => 'First & Last Name' }.stringify_keys assert_equal hash, Hash.from_xml(hash.to_xml(@xml_options))['person'] end - + def test_datetime_xml_type_with_utc_time alert_xml = <<-XML @@ -933,7 +933,7 @@ class HashToXmlTest < Test::Unit::TestCase assert alert_at.utc? assert_equal Time.utc(2008, 2, 10, 15, 30, 45), alert_at end - + def test_datetime_xml_type_with_non_utc_time alert_xml = <<-XML @@ -944,7 +944,7 @@ class HashToXmlTest < Test::Unit::TestCase assert alert_at.utc? assert_equal Time.utc(2008, 2, 10, 15, 30, 45), alert_at end - + def test_datetime_xml_type_with_far_future_date alert_xml = <<-XML diff --git a/activesupport/test/core_ext/kernel_test.rb b/activesupport/test/core_ext/kernel_test.rb index c22af89918..228b644c1a 100644 --- a/activesupport/test/core_ext/kernel_test.rb +++ b/activesupport/test/core_ext/kernel_test.rb @@ -46,7 +46,7 @@ class KernelTest < Test::Unit::TestCase o = Object.new assert_equal class << o; self end, o.singleton_class end - + def test_class_eval o = Object.new class << o; @x = 1; end diff --git a/activesupport/test/core_ext/module/anonymous_test.rb b/activesupport/test/core_ext/module/anonymous_test.rb index 7a78a3b012..cb556af772 100644 --- a/activesupport/test/core_ext/module/anonymous_test.rb +++ b/activesupport/test/core_ext/module/anonymous_test.rb @@ -6,7 +6,7 @@ class AnonymousTest < ActiveSupport::TestCase assert Module.new.anonymous? assert Class.new.anonymous? end - + test "a named class or module are not anonymous" do assert !Kernel.anonymous? assert !Object.anonymous? diff --git a/activesupport/test/core_ext/module/attr_accessor_with_default_test.rb b/activesupport/test/core_ext/module/attr_accessor_with_default_test.rb index 7c0d0bb242..9494ca9ef6 100644 --- a/activesupport/test/core_ext/module/attr_accessor_with_default_test.rb +++ b/activesupport/test/core_ext/module/attr_accessor_with_default_test.rb @@ -7,24 +7,24 @@ class AttrAccessorWithDefaultTest < Test::Unit::TestCase def helper 'helper' end - end + end @instance = @target.new end - + def test_default_arg @target.attr_accessor_with_default :foo, :bar assert_equal(:bar, @instance.foo) @instance.foo = nil assert_nil(@instance.foo) end - + def test_default_proc @target.attr_accessor_with_default(:foo) {helper.upcase} assert_equal('HELPER', @instance.foo) @instance.foo = nil assert_nil(@instance.foo) end - + def test_invalid_args assert_raise(RuntimeError) {@target.attr_accessor_with_default :foo} end diff --git a/activesupport/test/core_ext/module/attribute_accessor_test.rb b/activesupport/test/core_ext/module/attribute_accessor_test.rb index 67fcd437d0..118fb070a0 100644 --- a/activesupport/test/core_ext/module/attribute_accessor_test.rb +++ b/activesupport/test/core_ext/module/attribute_accessor_test.rb @@ -32,7 +32,7 @@ class ModuleAttributeAccessorTest < Test::Unit::TestCase assert_respond_to @object, :bar assert !@object.respond_to?(:bar=) end - + def test_should_not_create_instance_reader assert_respond_to @module, :shaq assert !@object.respond_to?(:shaq) diff --git a/activesupport/test/core_ext/module/attribute_aliasing_test.rb b/activesupport/test/core_ext/module/attribute_aliasing_test.rb index f17d031662..065c3531e0 100644 --- a/activesupport/test/core_ext/module/attribute_aliasing_test.rb +++ b/activesupport/test/core_ext/module/attribute_aliasing_test.rb @@ -44,14 +44,14 @@ class AttributeAliasingTest < Test::Unit::TestCase # upper-case attributes, and when people want to alias those names # to more sensible ones, everything goes *foof*. e = AttributeAliasing::Email.new - + assert !e.body? assert !e.Data? - + e.body = "No, really, this is not a joke." assert_equal "No, really, this is not a joke.", e.Data assert e.Data? - + e.Data = "Uppercased methods are teh suck" assert_equal "Uppercased methods are teh suck", e.body assert e.body? diff --git a/activesupport/test/core_ext/module/reachable_test.rb b/activesupport/test/core_ext/module/reachable_test.rb index 72892b77d5..80eb31a5c4 100644 --- a/activesupport/test/core_ext/module/reachable_test.rb +++ b/activesupport/test/core_ext/module/reachable_test.rb @@ -6,33 +6,33 @@ class AnonymousTest < ActiveSupport::TestCase assert !Module.new.reachable? assert !Class.new.reachable? end - + test "ordinary named classes or modules are reachable" do assert Kernel.reachable? assert Object.reachable? end - + test "a named class or module whose constant has gone is not reachable" do c = eval "class C; end; C" m = eval "module M; end; M" - + self.class.send(:remove_const, :C) self.class.send(:remove_const, :M) - + assert !c.reachable? assert !m.reachable? end - + test "a named class or module whose constants store different objects are not reachable" do c = eval "class C; end; C" m = eval "module M; end; M" - + self.class.send(:remove_const, :C) - self.class.send(:remove_const, :M) + self.class.send(:remove_const, :M) eval "class C; end" eval "module M; end" - + assert C.reachable? assert M.reachable? assert !c.reachable? diff --git a/activesupport/test/core_ext/numeric_ext_test.rb b/activesupport/test/core_ext/numeric_ext_test.rb index 992ec60302..e40b487753 100644 --- a/activesupport/test/core_ext/numeric_ext_test.rb +++ b/activesupport/test/core_ext/numeric_ext_test.rb @@ -38,7 +38,7 @@ class NumericExtTimeAndDateTimeTest < Test::Unit::TestCase assert seconds.from_now >= now + seconds end end - + def test_irregular_durations assert_equal @now.advance(:days => 3000), 3000.days.since(@now) assert_equal @now.advance(:months => 1), 1.month.since(@now) @@ -49,16 +49,16 @@ class NumericExtTimeAndDateTimeTest < Test::Unit::TestCase assert_equal @dtnow.advance(:months => -1), 1.month.until(@dtnow) assert_equal @dtnow.advance(:years => 20), 20.years.since(@dtnow) end - + def test_duration_addition assert_equal @now.advance(:days => 1).advance(:months => 1), (1.day + 1.month).since(@now) assert_equal @now.advance(:days => 7), (1.week + 5.seconds - 5.seconds).since(@now) assert_equal @now.advance(:years => 2), (4.years - 2.years).since(@now) assert_equal @dtnow.advance(:days => 1).advance(:months => 1), (1.day + 1.month).since(@dtnow) assert_equal @dtnow.advance(:days => 7), (1.week + 5.seconds - 5.seconds).since(@dtnow) - assert_equal @dtnow.advance(:years => 2), (4.years - 2.years).since(@dtnow) + assert_equal @dtnow.advance(:years => 2), (4.years - 2.years).since(@dtnow) end - + def test_time_plus_duration assert_equal @now + 8, @now + 8.seconds assert_equal @now + 22.9, @now + 22.9.seconds @@ -69,21 +69,21 @@ class NumericExtTimeAndDateTimeTest < Test::Unit::TestCase assert_equal @dtnow.advance(:days => 15), @dtnow + 15.days assert_equal @dtnow.advance(:months => 1), @dtnow + 1.month end - + def test_chaining_duration_operations assert_equal @now.advance(:days => 2).advance(:months => -3), @now + 2.days - 3.months assert_equal @now.advance(:days => 1).advance(:months => 2), @now + 1.day + 2.months assert_equal @dtnow.advance(:days => 2).advance(:months => -3), @dtnow + 2.days - 3.months - assert_equal @dtnow.advance(:days => 1).advance(:months => 2), @dtnow + 1.day + 2.months + assert_equal @dtnow.advance(:days => 1).advance(:months => 2), @dtnow + 1.day + 2.months end - + def test_duration_after_convertion_is_no_longer_accurate assert_equal 30.days.to_i.since(@now), 1.month.to_i.since(@now) assert_equal 365.25.days.to_f.since(@now), 1.year.to_f.since(@now) assert_equal 30.days.to_i.since(@dtnow), 1.month.to_i.since(@dtnow) - assert_equal 365.25.days.to_f.since(@dtnow), 1.year.to_f.since(@dtnow) + assert_equal 365.25.days.to_f.since(@dtnow), 1.year.to_f.since(@dtnow) end - + def test_add_one_year_to_leap_day assert_equal Time.utc(2005,2,28,15,15,10), Time.utc(2004,2,29,15,15,10) + 1.year assert_equal DateTime.civil(2005,2,28,15,15,10), DateTime.civil(2004,2,29,15,15,10) + 1.year @@ -102,12 +102,12 @@ class NumericExtDateTest < Test::Unit::TestCase assert_equal @today.to_time.since(60), @today + 1.minute assert_equal @today.to_time.since(60*60), @today + 1.hour end - + def test_chaining_duration_operations assert_equal @today.advance(:days => 2).advance(:months => -3), @today + 2.days - 3.months assert_equal @today.advance(:days => 1).advance(:months => 2), @today + 1.day + 2.months end - + def test_add_one_year_to_leap_day assert_equal Date.new(2005,2,28), Date.new(2004,2,29) + 1.year end @@ -132,7 +132,7 @@ class NumericExtSizeTest < Test::Unit::TestCase assert_equal right, left end end - + def test_units_as_bytes_independently assert_equal 3145728, 3.megabytes assert_equal 3145728, 3.megabyte diff --git a/activesupport/test/core_ext/object_and_class_ext_test.rb b/activesupport/test/core_ext/object_and_class_ext_test.rb index 6588f2e345..3ccf18f473 100644 --- a/activesupport/test/core_ext/object_and_class_ext_test.rb +++ b/activesupport/test/core_ext/object_and_class_ext_test.rb @@ -144,7 +144,7 @@ class ObjectTryTest < Test::Unit::TestCase assert !@string.respond_to?(method) assert_raise(NoMethodError) { @string.try(method) } end - + def test_valid_method assert_equal 5, @string.try(:size) end diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb index affa1b5e18..f7e2ecd357 100644 --- a/activesupport/test/core_ext/string_ext_test.rb +++ b/activesupport/test/core_ext/string_ext_test.rb @@ -218,7 +218,7 @@ class StringInflectionsTest < Test::Unit::TestCase # And changes the original string: assert_equal original, expected end - + def test_truncate assert_equal "Hello World!", "Hello World!".truncate(12) assert_equal "Hello Wor...", "Hello World!!".truncate(12) diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb index 1cf84df386..c43b3eb358 100644 --- a/activesupport/test/core_ext/time_ext_test.rb +++ b/activesupport/test/core_ext/time_ext_test.rb @@ -187,7 +187,7 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase assert_equal Time.local(2005,4,2,3,18,0), Time.local(2005,4,3,4,18,0).ago(24.hours), 'dt-24.hours=>st' assert_equal Time.local(2005,4,2,3,18,0), Time.local(2005,4,3,4,18,0).ago(86400), 'dt-86400=>st' assert_equal Time.local(2005,4,2,3,18,0), Time.local(2005,4,3,4,18,0).ago(86400.seconds), 'dt-86400.seconds=>st' - + assert_equal Time.local(2005,4,1,4,18,0), Time.local(2005,4,2,4,18,0).ago(24.hours), 'st-24.hours=>st' assert_equal Time.local(2005,4,1,4,18,0), Time.local(2005,4,2,4,18,0).ago(86400), 'st-86400=>st' assert_equal Time.local(2005,4,1,4,18,0), Time.local(2005,4,2,4,18,0).ago(86400.seconds), 'st-86400.seconds=>st' @@ -197,7 +197,7 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase assert_equal Time.local(2006,9,30,3,18,0), Time.local(2006,10,1,4,18,0).ago(24.hours), 'dt-24.hours=>st' assert_equal Time.local(2006,9,30,3,18,0), Time.local(2006,10,1,4,18,0).ago(86400), 'dt-86400=>st' assert_equal Time.local(2006,9,30,3,18,0), Time.local(2006,10,1,4,18,0).ago(86400.seconds), 'dt-86400.seconds=>st' - + assert_equal Time.local(2006,9,29,4,18,0), Time.local(2006,9,30,4,18,0).ago(24.hours), 'st-24.hours=>st' assert_equal Time.local(2006,9,29,4,18,0), Time.local(2006,9,30,4,18,0).ago(86400), 'st-86400=>st' assert_equal Time.local(2006,9,29,4,18,0), Time.local(2006,9,30,4,18,0).ago(86400.seconds), 'st-86400.seconds=>st' @@ -210,7 +210,7 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase assert_equal Time.local(2005,10,29,5,3), Time.local(2005,10,30,4,3,0).ago(24.hours), 'st-24.hours=>dt' assert_equal Time.local(2005,10,29,5,3), Time.local(2005,10,30,4,3,0).ago(86400), 'st-86400=>dt' assert_equal Time.local(2005,10,29,5,3), Time.local(2005,10,30,4,3,0).ago(86400.seconds), 'st-86400.seconds=>dt' - + assert_equal Time.local(2005,10,28,4,3), Time.local(2005,10,29,4,3,0).ago(24.hours), 'dt-24.hours=>dt' assert_equal Time.local(2005,10,28,4,3), Time.local(2005,10,29,4,3,0).ago(86400), 'dt-86400=>dt' assert_equal Time.local(2005,10,28,4,3), Time.local(2005,10,29,4,3,0).ago(86400.seconds), 'dt-86400.seconds=>dt' @@ -220,7 +220,7 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase assert_equal Time.local(2006,3,18,5,3), Time.local(2006,3,19,4,3,0).ago(24.hours), 'st-24.hours=>dt' assert_equal Time.local(2006,3,18,5,3), Time.local(2006,3,19,4,3,0).ago(86400), 'st-86400=>dt' assert_equal Time.local(2006,3,18,5,3), Time.local(2006,3,19,4,3,0).ago(86400.seconds), 'st-86400.seconds=>dt' - + assert_equal Time.local(2006,3,17,4,3), Time.local(2006,3,18,4,3,0).ago(24.hours), 'dt-24.hours=>dt' assert_equal Time.local(2006,3,17,4,3), Time.local(2006,3,18,4,3,0).ago(86400), 'dt-86400=>dt' assert_equal Time.local(2006,3,17,4,3), Time.local(2006,3,18,4,3,0).ago(86400.seconds), 'dt-86400.seconds=>dt' @@ -252,7 +252,7 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase assert_equal Time.local(2006,3,17,4,3), Time.local(2006,3,18,4,3,0).ago(1.day), 'dt-1.day=>dt' end end - + def test_since assert_equal Time.local(2005,2,22,10,10,11), Time.local(2005,2,22,10,10,10).since(1) assert_equal Time.local(2005,2,22,11,10,10), Time.local(2005,2,22,10,10,10).since(3600) @@ -268,7 +268,7 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase assert_equal Time.local(2005,4,3,20,27,0), Time.local(2005,4,2,19,27,0).since(24.hours), 'st+24.hours=>dt' assert_equal Time.local(2005,4,3,20,27,0), Time.local(2005,4,2,19,27,0).since(86400), 'st+86400=>dt' assert_equal Time.local(2005,4,3,20,27,0), Time.local(2005,4,2,19,27,0).since(86400.seconds), 'st+86400.seconds=>dt' - + assert_equal Time.local(2005,4,4,19,27,0), Time.local(2005,4,3,19,27,0).since(24.hours), 'dt+24.hours=>dt' assert_equal Time.local(2005,4,4,19,27,0), Time.local(2005,4,3,19,27,0).since(86400), 'dt+86400=>dt' assert_equal Time.local(2005,4,4,19,27,0), Time.local(2005,4,3,19,27,0).since(86400.seconds), 'dt+86400.seconds=>dt' @@ -278,7 +278,7 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase assert_equal Time.local(2006,10,1,20,27,0), Time.local(2006,9,30,19,27,0).since(24.hours), 'st+24.hours=>dt' assert_equal Time.local(2006,10,1,20,27,0), Time.local(2006,9,30,19,27,0).since(86400), 'st+86400=>dt' assert_equal Time.local(2006,10,1,20,27,0), Time.local(2006,9,30,19,27,0).since(86400.seconds), 'st+86400.seconds=>dt' - + assert_equal Time.local(2006,10,2,19,27,0), Time.local(2006,10,1,19,27,0).since(24.hours), 'dt+24.hours=>dt' assert_equal Time.local(2006,10,2,19,27,0), Time.local(2006,10,1,19,27,0).since(86400), 'dt+86400=>dt' assert_equal Time.local(2006,10,2,19,27,0), Time.local(2006,10,1,19,27,0).since(86400.seconds), 'dt+86400.seconds=>dt' @@ -330,7 +330,7 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase assert_equal Time.local(2005,10,30,23,45,0), Time.local(2005,10,30,0,45,0).since(24.hours), 'dt+24.hours=>st' assert_equal Time.local(2005,10,30,23,45,0), Time.local(2005,10,30,0,45,0).since(86400), 'dt+86400=>st' assert_equal Time.local(2005,10,30,23,45,0), Time.local(2005,10,30,0,45,0).since(86400.seconds), 'dt+86400.seconds=>st' - + assert_equal Time.local(2005,11, 1,0,45,0), Time.local(2005,10,31,0,45,0).since(24.hours), 'st+24.hours=>st' assert_equal Time.local(2005,11, 1,0,45,0), Time.local(2005,10,31,0,45,0).since(86400), 'st+86400=>st' assert_equal Time.local(2005,11, 1,0,45,0), Time.local(2005,10,31,0,45,0).since(86400.seconds), 'st+86400.seconds=>st' @@ -340,7 +340,7 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase assert_equal Time.local(2006,3,20,0,45,0), Time.local(2006,3,19,1,45,0).since(24.hours), 'dt+24.hours=>st' assert_equal Time.local(2006,3,20,0,45,0), Time.local(2006,3,19,1,45,0).since(86400), 'dt+86400=>st' assert_equal Time.local(2006,3,20,0,45,0), Time.local(2006,3,19,1,45,0).since(86400.seconds), 'dt+86400.seconds=>st' - + assert_equal Time.local(2006,3,21,1,45,0), Time.local(2006,3,20,1,45,0).since(24.hours), 'st+24.hours=>st' assert_equal Time.local(2006,3,21,1,45,0), Time.local(2006,3,20,1,45,0).since(86400), 'st+86400=>st' assert_equal Time.local(2006,3,21,1,45,0), Time.local(2006,3,20,1,45,0).since(86400.seconds), 'st+86400.seconds=>st' @@ -729,7 +729,7 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase def test_minus_with_time_with_zone assert_equal 86_400.0, Time.utc(2000, 1, 2) - ActiveSupport::TimeWithZone.new( Time.utc(2000, 1, 1), ActiveSupport::TimeZone['UTC'] ) end - + def test_minus_with_datetime assert_equal 86_400.0, Time.utc(2000, 1, 2) - DateTime.civil(2000, 1, 1) end diff --git a/activesupport/test/core_ext/time_with_zone_test.rb b/activesupport/test/core_ext/time_with_zone_test.rb index 5ce4277672..0bb2c4a39e 100644 --- a/activesupport/test/core_ext/time_with_zone_test.rb +++ b/activesupport/test/core_ext/time_with_zone_test.rb @@ -287,7 +287,7 @@ class TimeWithZoneTest < Test::Unit::TestCase assert_equal 946684800, result assert_kind_of Integer, result end - + def test_to_i_with_wrapped_datetime datetime = DateTime.civil(2000, 1, 1, 0) twz = ActiveSupport::TimeWithZone.new(datetime, @time_zone) @@ -328,7 +328,7 @@ class TimeWithZoneTest < Test::Unit::TestCase assert_kind_of Time, @twz assert_kind_of ActiveSupport::TimeWithZone, @twz end - + def test_class_name assert_equal 'Time', ActiveSupport::TimeWithZone.name end @@ -703,7 +703,7 @@ class TimeWithZoneTest < Test::Unit::TestCase assert_equal "Sun, 15 Jul 2007 10:30:00 EDT -04:00", twz.years_ago(1).inspect assert_equal "Sun, 15 Jul 2007 10:30:00 EDT -04:00", (twz - 1.year).inspect end - + protected def with_env_tz(new_tz = 'US/Eastern') old_tz, ENV['TZ'] = ENV['TZ'], new_tz diff --git a/activesupport/test/i18n_test.rb b/activesupport/test/i18n_test.rb index dfcd4f822d..34825c9b8f 100644 --- a/activesupport/test/i18n_test.rb +++ b/activesupport/test/i18n_test.rb @@ -7,68 +7,68 @@ class I18nTest < Test::Unit::TestCase @date = Date.parse("2008-7-2") @time = Time.utc(2008, 7, 2, 16, 47, 1) end - + def test_time_zone_localization_with_default_format now = Time.local(2000) assert_equal now.strftime("%a, %d %b %Y %H:%M:%S %z"), I18n.localize(now) end - + def test_date_localization_should_use_default_format assert_equal @date.strftime("%Y-%m-%d"), I18n.localize(@date) end - + def test_date_localization_with_default_format assert_equal @date.strftime("%Y-%m-%d"), I18n.localize(@date, :format => :default) end - + def test_date_localization_with_short_format assert_equal @date.strftime("%b %d"), I18n.localize(@date, :format => :short) end - + def test_date_localization_with_long_format assert_equal @date.strftime("%B %d, %Y"), I18n.localize(@date, :format => :long) end - - def test_time_localization_should_use_default_format + + def test_time_localization_should_use_default_format assert_equal @time.strftime("%a, %d %b %Y %H:%M:%S %z"), I18n.localize(@time) end - + def test_time_localization_with_default_format assert_equal @time.strftime("%a, %d %b %Y %H:%M:%S %z"), I18n.localize(@time, :format => :default) end - + def test_time_localization_with_short_format assert_equal @time.strftime("%d %b %H:%M"), I18n.localize(@time, :format => :short) end - + def test_time_localization_with_long_format assert_equal @time.strftime("%B %d, %Y %H:%M"), I18n.localize(@time, :format => :long) end - + def test_day_names assert_equal Date::DAYNAMES, I18n.translate(:'date.day_names') end - + def test_abbr_day_names assert_equal Date::ABBR_DAYNAMES, I18n.translate(:'date.abbr_day_names') end - + def test_month_names assert_equal Date::MONTHNAMES, I18n.translate(:'date.month_names') end - + def test_abbr_month_names assert_equal Date::ABBR_MONTHNAMES, I18n.translate(:'date.abbr_month_names') end - + def test_date_order assert_equal [:year, :month, :day], I18n.translate(:'date.order') end - + def test_time_am assert_equal 'am', I18n.translate(:'time.am') end - + def test_time_pm assert_equal 'pm', I18n.translate(:'time.pm') end diff --git a/activesupport/test/message_encryptor_test.rb b/activesupport/test/message_encryptor_test.rb index 684b931176..419ac14283 100644 --- a/activesupport/test/message_encryptor_test.rb +++ b/activesupport/test/message_encryptor_test.rb @@ -14,18 +14,18 @@ class MessageEncryptorTest < Test::Unit::TestCase @encryptor = ActiveSupport::MessageEncryptor.new(ActiveSupport::SecureRandom.hex(64)) @data = { :some => "data", :now => Time.local(2010) } end - + def test_simple_round_tripping message = @encryptor.encrypt(@data) assert_equal @data, @encryptor.decrypt(message) end - + def test_encrypting_twice_yields_differing_cipher_text first_messqage = @encryptor.encrypt(@data) second_message = @encryptor.encrypt(@data) assert_not_equal first_messqage, second_message end - + def test_messing_with_either_value_causes_failure text, iv = @encryptor.encrypt(@data).split("--") assert_not_decrypted([iv, text] * "--") @@ -33,20 +33,20 @@ class MessageEncryptorTest < Test::Unit::TestCase assert_not_decrypted([munge(text), iv] * "--") assert_not_decrypted([munge(text), munge(iv)] * "--") end - + def test_signed_round_tripping message = @encryptor.encrypt_and_sign(@data) assert_equal @data, @encryptor.decrypt_and_verify(message) end - - + + private def assert_not_decrypted(value) assert_raise(ActiveSupport::MessageEncryptor::InvalidMessage) do @encryptor.decrypt(value) end end - + def munge(base64_string) bits = ActiveSupport::Base64.decode64(base64_string) bits.reverse! diff --git a/activesupport/test/multibyte_conformance.rb b/activesupport/test/multibyte_conformance.rb index 6ec9a839af..b3b477bb75 100644 --- a/activesupport/test/multibyte_conformance.rb +++ b/activesupport/test/multibyte_conformance.rb @@ -27,21 +27,21 @@ end class MultibyteConformanceTest < Test::Unit::TestCase include MultibyteTestHelpers - + UNIDATA_URL = "http://www.unicode.org/Public/#{ActiveSupport::Multibyte::Unicode::UNICODE_VERSION}/ucd" UNIDATA_FILE = '/NormalizationTest.txt' CACHE_DIR = File.join(Dir.tmpdir, 'cache') - + def setup FileUtils.mkdir_p(CACHE_DIR) Downloader.download(UNIDATA_URL + UNIDATA_FILE, CACHE_DIR + UNIDATA_FILE) @proxy = ActiveSupport::Multibyte::Chars end - + def test_normalizations_C each_line_of_norm_tests do |*cols| col1, col2, col3, col4, col5, comment = *cols - + # CONFORMANCE: # 1. The following invariants must be true for all conformant implementations # @@ -56,7 +56,7 @@ class MultibyteConformanceTest < Test::Unit::TestCase assert_equal_codepoints col4, @proxy.new(col5).normalize(:c), "Form C - Col 4 has to be C(5) - #{comment}" end end - + def test_normalizations_D each_line_of_norm_tests do |*cols| col1, col2, col3, col4, col5, comment = *cols @@ -71,10 +71,10 @@ class MultibyteConformanceTest < Test::Unit::TestCase assert_equal_codepoints col5, @proxy.new(col5).normalize(:d), "Form D - Col 5 has to be NFD(5) - #{comment}" end end - + def test_normalizations_KC each_line_of_norm_tests do | *cols | - col1, col2, col3, col4, col5, comment = *cols + col1, col2, col3, col4, col5, comment = *cols # # NFKC # c4 == NFKC(c1) == NFKC(c2) == NFKC(c3) == NFKC(c4) == NFKC(c5) @@ -85,10 +85,10 @@ class MultibyteConformanceTest < Test::Unit::TestCase assert_equal_codepoints col4, @proxy.new(col5).normalize(:kc), "Form D - Col 4 has to be NFKC(5) - #{comment}" end end - + def test_normalizations_KD each_line_of_norm_tests do | *cols | - col1, col2, col3, col4, col5, comment = *cols + col1, col2, col3, col4, col5, comment = *cols # # NFKD # c5 == NFKD(c1) == NFKD(c2) == NFKD(c3) == NFKD(c4) == NFKD(c5) @@ -99,7 +99,7 @@ class MultibyteConformanceTest < Test::Unit::TestCase assert_equal_codepoints col5, @proxy.new(col5).normalize(:kd), "Form KD - Col 5 has to be NFKD(5) - #{comment}" end end - + protected def each_line_of_norm_tests(&block) lines = 0 @@ -108,21 +108,21 @@ class MultibyteConformanceTest < Test::Unit::TestCase until f.eof? || (max_test_lines > 38 and lines > max_test_lines) lines += 1 line = f.gets.chomp! - next if (line.empty? || line =~ /^\#/) - + next if (line.empty? || line =~ /^\#/) + cols, comment = line.split("#") cols = cols.split(";").map{|e| e.strip}.reject{|e| e.empty? } next unless cols.length == 5 - + # codepoints are in hex in the test suite, pack wants them as integers cols.map!{|c| c.split.map{|codepoint| codepoint.to_i(16)}.pack("U*") } cols << comment - + yield(*cols) end end end - + def inspect_codepoints(str) str.to_s.unpack("U*").map{|cp| cp.to_s(16) }.join(' ') end diff --git a/activesupport/test/option_merger_test.rb b/activesupport/test/option_merger_test.rb index 33e3e69666..5b2e16a212 100644 --- a/activesupport/test/option_merger_test.rb +++ b/activesupport/test/option_merger_test.rb @@ -65,7 +65,7 @@ class OptionMergerTest < Test::Unit::TestCase end end end - + def test_nested_method_with_options_using_lamdba local_lamdba = lambda { { :lambda => true } } with_options(@options) do |o| diff --git a/activesupport/test/rescuable_test.rb b/activesupport/test/rescuable_test.rb index 1c74ce8b2a..bf4f5265ef 100644 --- a/activesupport/test/rescuable_test.rb +++ b/activesupport/test/rescuable_test.rb @@ -24,7 +24,7 @@ class Stargate rescue_from NuclearExplosion do @result = 'alldead' end - + rescue_from MadRonon do |e| @result = e.message end @@ -80,16 +80,16 @@ class RescueableTest < Test::Unit::TestCase @stargate.dispatch :attack assert_equal 'killed', @stargate.result end - + def test_rescue_from_with_block @stargate.dispatch :nuke assert_equal 'alldead', @stargate.result end - + def test_rescue_from_with_block_with_args @stargate.dispatch :ronanize assert_equal 'dex', @stargate.result - end + end def test_rescues_defined_later_are_added_at_end_of_the_rescue_handlers_array expected = ["WraithAttack", "WraithAttack", "NuclearExplosion", "MadRonon"] diff --git a/activesupport/test/test_test.rb b/activesupport/test/test_test.rb index 633d3b212b..cdaf63961a 100644 --- a/activesupport/test/test_test.rb +++ b/activesupport/test/test_test.rb @@ -89,19 +89,19 @@ end class AssertBlankTest < ActiveSupport::TestCase BLANK = [ EmptyTrue.new, nil, false, '', ' ', " \n\t \r ", [], {} ] NOT_BLANK = [ EmptyFalse.new, Object.new, true, 0, 1, 'x', [nil], { nil => 0 } ] - + def test_assert_blank_true BLANK.each { |v| assert_blank v } end - + def test_assert_blank_false NOT_BLANK.each { |v| - begin + begin assert_blank v fail 'should not get to here' rescue Exception => e - assert_match(/is not blank/, e.message) - end + assert_match(/is not blank/, e.message) + end } end end @@ -109,19 +109,19 @@ end class AssertPresentTest < ActiveSupport::TestCase BLANK = [ EmptyTrue.new, nil, false, '', ' ', " \n\t \r ", [], {} ] NOT_BLANK = [ EmptyFalse.new, Object.new, true, 0, 1, 'x', [nil], { nil => 0 } ] - + def test_assert_blank_true NOT_BLANK.each { |v| assert_present v } end - + def test_assert_blank_false BLANK.each { |v| - begin + begin assert_present v fail 'should not get to here' rescue Exception => e - assert_match(/is blank/, e.message) - end + assert_match(/is blank/, e.message) + end } end end diff --git a/activesupport/test/time_zone_test.rb b/activesupport/test/time_zone_test.rb index af6eee69e5..49cefc6e82 100644 --- a/activesupport/test/time_zone_test.rb +++ b/activesupport/test/time_zone_test.rb @@ -216,7 +216,7 @@ class TimeZoneTest < Test::Unit::TestCase assert_equal "+0000", ActiveSupport::TimeZone.seconds_to_utc_offset(0, false) assert_equal "+0500", ActiveSupport::TimeZone.seconds_to_utc_offset(18_000, false) end - + def test_seconds_to_utc_offset_with_negative_offset assert_equal "-01:00", ActiveSupport::TimeZone.seconds_to_utc_offset(-3_600) assert_equal "-00:59", ActiveSupport::TimeZone.seconds_to_utc_offset(-3_599) -- cgit v1.2.3