From 8270dcd12e2892147002b23e80e3a25ab45a1e25 Mon Sep 17 00:00:00 2001 From: Ben Orenstein Date: Sat, 26 Feb 2011 12:59:27 -0500 Subject: Correct example that did not do what it claimed. Rework explanation. --- .../lib/active_support/core_ext/hash/reverse_merge.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb b/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb index a82cdfc360..87a7bebd7b 100644 --- a/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb +++ b/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb @@ -6,14 +6,14 @@ class Hash # options.reverse_merge! :size => 25, :velocity => 10 # end # - # Using merge, the above example would look as follows: + # The default :size and :velocity are only set if the +options+ hash passed in doesn't already + # have the respective key. + # + # As contrast, using Ruby's built in merge would require writing the following: # # def setup(options = {}) - # { :size => 25, :velocity => 10 }.merge(options) + # options = { :size => 25, :velocity => 10 }.merge(options) # end - # - # The default :size and :velocity are only set if the +options+ hash passed in doesn't already - # have the respective key. def reverse_merge(other_hash) other_hash.merge(self) end -- cgit v1.2.3 From e872a8f2a5c2f9127b9b15a60ba37d5a21e9f6cb Mon Sep 17 00:00:00 2001 From: Ben Orenstein Date: Sat, 26 Feb 2011 13:36:47 -0500 Subject: Example descriptions and their examples were flipped. Fix. --- activesupport/lib/active_support/core_ext/string/filters.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/core_ext/string/filters.rb b/activesupport/lib/active_support/core_ext/string/filters.rb index e15a1df9c9..d478ee0ef6 100644 --- a/activesupport/lib/active_support/core_ext/string/filters.rb +++ b/activesupport/lib/active_support/core_ext/string/filters.rb @@ -25,13 +25,13 @@ class String # "Once upon a time in a world far far away".truncate(27) # # => "Once upon a time in a wo..." # - # The last characters will be replaced with the :omission string (defaults to "...") - # for a total length not exceeding :length: + # Pass a :separator to truncate +text+ at a natural break: # # "Once upon a time in a world far far away".truncate(27, :separator => ' ') # # => "Once upon a time in a..." # - # Pass a :separator to truncate +text+ at a natural break: + # The last characters will be replaced with the :omission string (defaults to "...") + # for a total length not exceeding :length: # # "And they found that many people were sleeping better.".truncate(25, :omission => "... (continued)") # # => "And they f... (continued)" -- cgit v1.2.3 From 8f13a166ceda779357d1c356776a11086f7ee146 Mon Sep 17 00:00:00 2001 From: Ben Orenstein Date: Sat, 26 Feb 2011 14:29:22 -0500 Subject: Clarify comment by removing french reference ('a la'). Should improve readability for non-native english speakers. --- activesupport/lib/active_support/core_ext/enumerable.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/core_ext/enumerable.rb b/activesupport/lib/active_support/core_ext/enumerable.rb index 6ecedc26ef..6d7f771b5d 100644 --- a/activesupport/lib/active_support/core_ext/enumerable.rb +++ b/activesupport/lib/active_support/core_ext/enumerable.rb @@ -94,7 +94,7 @@ module Enumerable 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. + # Can be called with a block too, much like 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 -- cgit v1.2.3 From 9bbbae06c57da6a25c70e54877c4867310131db9 Mon Sep 17 00:00:00 2001 From: Ben Orenstein Date: Sun, 27 Feb 2011 16:45:57 -0500 Subject: Fix incorrect word. --- activesupport/lib/active_support/log_subscriber/test_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/log_subscriber/test_helper.rb b/activesupport/lib/active_support/log_subscriber/test_helper.rb index 52a64383a2..3227600078 100644 --- a/activesupport/lib/active_support/log_subscriber/test_helper.rb +++ b/activesupport/lib/active_support/log_subscriber/test_helper.rb @@ -27,7 +27,7 @@ module ActiveSupport # up the queue, subscriptions and turning colors in logs off. # # The messages are available in the @logger instance, which is a logger with limited - # powers (it actually do not send anything to your output), and you can collect them + # powers (it actually does not send anything to your output), and you can collect them # doing @logger.logged(level), where level is the level used in logging, like info, # debug, warn and so on. # -- cgit v1.2.3 From b95f8be594d64509bb251ecd8315474fab368073 Mon Sep 17 00:00:00 2001 From: Ben Orenstein Date: Sun, 27 Feb 2011 20:22:55 -0500 Subject: Fix incorrect example. --- activesupport/lib/active_support/ordered_options.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/ordered_options.rb b/activesupport/lib/active_support/ordered_options.rb index 124e1a74f8..f4c27ac935 100644 --- a/activesupport/lib/active_support/ordered_options.rb +++ b/activesupport/lib/active_support/ordered_options.rb @@ -2,13 +2,13 @@ require 'active_support/ordered_hash' # Usually key value pairs are handled something like this: # -# h = ActiveSupport::OrderedOptions.new +# h = {} # h[:boy] = 'John' # h[:girl] = 'Mary' # h[:boy] # => 'John' # h[:girl] # => 'Mary' # -# Using OrderedOptions above code could be reduced to: +# Using OrderedOptions, the above code could be reduced to: # # h = ActiveSupport::OrderedOptions.new # h.boy = 'John' -- cgit v1.2.3 From 108561f1cb73c0f600db6cad10b7cf03bf90f09f Mon Sep 17 00:00:00 2001 From: "Jonathon D. Jones" Date: Thu, 3 Mar 2011 18:10:33 -0500 Subject: Adds link to Object.blank? from Object.present? --- activesupport/lib/active_support/core_ext/object/blank.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/core_ext/object/blank.rb b/activesupport/lib/active_support/core_ext/object/blank.rb index 51670b148f..f70853073a 100644 --- a/activesupport/lib/active_support/core_ext/object/blank.rb +++ b/activesupport/lib/active_support/core_ext/object/blank.rb @@ -13,7 +13,7 @@ class Object respond_to?(:empty?) ? empty? : !self end - # An object is present if it's not blank. + # An object is present if it's not #blank?. def present? !blank? end -- cgit v1.2.3 From 80e3beb24b3fa7fad03486bd4f168f45377a8a60 Mon Sep 17 00:00:00 2001 From: "R.T. Lechow" Date: Thu, 3 Mar 2011 23:14:18 -0500 Subject: Active Support typos. --- activesupport/lib/active_support/core_ext/object/try.rb | 2 +- activesupport/lib/active_support/core_ext/string/multibyte.rb | 2 +- activesupport/lib/active_support/core_ext/string/output_safety.rb | 2 +- activesupport/lib/active_support/dependencies.rb | 2 +- activesupport/lib/active_support/log_subscriber/test_helper.rb | 2 +- activesupport/lib/active_support/multibyte/unicode.rb | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/core_ext/object/try.rb b/activesupport/lib/active_support/core_ext/object/try.rb index ff812234e3..04619124a1 100644 --- a/activesupport/lib/active_support/core_ext/object/try.rb +++ b/activesupport/lib/active_support/core_ext/object/try.rb @@ -21,7 +21,7 @@ class Object # Person.try(:find, 1) # @people.try(:collect) {|p| p.name} # - # Without a method argument try will yield to the block unless the reciever is nil. + # Without a method argument try will yield to the block unless the receiver is nil. # @person.try { |p| "#{p.first_name} #{p.last_name}" } #-- # +try+ behaves like +Object#send+, unless called on +NilClass+. diff --git a/activesupport/lib/active_support/core_ext/string/multibyte.rb b/activesupport/lib/active_support/core_ext/string/multibyte.rb index 0b974f5e0a..41de4d6435 100644 --- a/activesupport/lib/active_support/core_ext/string/multibyte.rb +++ b/activesupport/lib/active_support/core_ext/string/multibyte.rb @@ -9,7 +9,7 @@ class String # # In Ruby 1.8 and older it creates and returns an instance of the ActiveSupport::Multibyte::Chars class which # encapsulates the original string. A Unicode safe version of all the String methods are defined on this proxy - # class. If the proxy class doesn't respond to a certain method, it's forwarded to the encapsuled string. + # class. If the proxy class doesn't respond to a certain method, it's forwarded to the encapsulated string. # # name = 'Claus Müller' # name.reverse # => "rell??M sualC" diff --git a/activesupport/lib/active_support/core_ext/string/output_safety.rb b/activesupport/lib/active_support/core_ext/string/output_safety.rb index c930abc003..addd4dab95 100644 --- a/activesupport/lib/active_support/core_ext/string/output_safety.rb +++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb @@ -24,7 +24,7 @@ class ERB end end - # Aliasing twice issues a warning "dicarding old...". Remove first to avoid it. + # Aliasing twice issues a warning "discarding old...". Remove first to avoid it. remove_method(:h) alias h html_escape diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index dab6fdbac6..daa98162d0 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -515,7 +515,7 @@ module ActiveSupport #:nodoc: # to its class/module if it implements +before_remove_const+. # # The callback implementation should be restricted to cleaning up caches, etc. - # as the enviroment will be in an inconsistent state, e.g. other constants + # as the environment will be in an inconsistent state, e.g. other constants # may have already been unloaded and not accessible. def remove_unloadable_constants! autoloaded_constants.each { |const| remove_constant const } diff --git a/activesupport/lib/active_support/log_subscriber/test_helper.rb b/activesupport/lib/active_support/log_subscriber/test_helper.rb index 3227600078..392e33edbc 100644 --- a/activesupport/lib/active_support/log_subscriber/test_helper.rb +++ b/activesupport/lib/active_support/log_subscriber/test_helper.rb @@ -23,7 +23,7 @@ module ActiveSupport # end # # All you need to do is to ensure that your log subscriber is added to Rails::Subscriber, - # as in the second line of the code above. The test helpers is reponsible for setting + # as in the second line of the code above. The test helpers are responsible for setting # up the queue, subscriptions and turning colors in logs off. # # The messages are available in the @logger instance, which is a logger with limited diff --git a/activesupport/lib/active_support/multibyte/unicode.rb b/activesupport/lib/active_support/multibyte/unicode.rb index 1139783b65..513f83e445 100644 --- a/activesupport/lib/active_support/multibyte/unicode.rb +++ b/activesupport/lib/active_support/multibyte/unicode.rb @@ -247,7 +247,7 @@ module ActiveSupport if is_unused || is_restricted bytes[i] = tidy_byte(byte) elsif is_cont - # Not expecting contination byte? Clean up. Otherwise, now expect one less. + # Not expecting continuation byte? Clean up. Otherwise, now expect one less. conts_expected == 0 ? bytes[i] = tidy_byte(byte) : conts_expected -= 1 else if conts_expected > 0 -- cgit v1.2.3 From 9b96de6f3dfa31695c2fc27919e2989a98f6899d Mon Sep 17 00:00:00 2001 From: suchasurge Date: Sun, 6 Mar 2011 10:26:24 +0100 Subject: Some style changes --- activesupport/lib/active_support/backtrace_cleaner.rb | 2 +- activesupport/lib/active_support/configurable.rb | 6 ++++++ activesupport/lib/active_support/hash_with_indifferent_access.rb | 4 ++-- activesupport/lib/active_support/i18n_railtie.rb | 2 +- activesupport/lib/active_support/message_encryptor.rb | 2 +- 5 files changed, 11 insertions(+), 5 deletions(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/backtrace_cleaner.rb b/activesupport/lib/active_support/backtrace_cleaner.rb index 8465bc1e10..0e6bc30fa2 100644 --- a/activesupport/lib/active_support/backtrace_cleaner.rb +++ b/activesupport/lib/active_support/backtrace_cleaner.rb @@ -8,7 +8,7 @@ module ActiveSupport # filter or modify the paths of any lines of the backtrace, you can call BacktraceCleaner#remove_filters! These two methods # will give you a completely untouched backtrace. # - # Example: + # ==== Example: # # bc = BacktraceCleaner.new # bc.add_filter { |line| line.gsub(Rails.root, '') } diff --git a/activesupport/lib/active_support/configurable.rb b/activesupport/lib/active_support/configurable.rb index be19189c04..7bac3dbc91 100644 --- a/activesupport/lib/active_support/configurable.rb +++ b/activesupport/lib/active_support/configurable.rb @@ -41,6 +41,9 @@ module ActiveSupport # Allows you to add shortcut so that you don't have to refer to attribute through config. # Also look at the example for config to contrast. # + # + # ==== Example + # # class User # include ActiveSupport::Configurable # config_accessor :allowed_access @@ -65,6 +68,9 @@ module ActiveSupport # Reads and writes attributes from a configuration OrderedHash. # + # + # ==== Example + # # require 'active_support/configurable' # # class User diff --git a/activesupport/lib/active_support/hash_with_indifferent_access.rb b/activesupport/lib/active_support/hash_with_indifferent_access.rb index 6a344867ee..79a0de7940 100644 --- a/activesupport/lib/active_support/hash_with_indifferent_access.rb +++ b/activesupport/lib/active_support/hash_with_indifferent_access.rb @@ -1,7 +1,7 @@ require 'active_support/core_ext/hash/keys' # This class has dubious semantics and we only have it so that -# people can write params[:key] instead of params['key'] +# people can write params[:key] instead of params['key'] # and they get the same value for both keys. module ActiveSupport @@ -109,7 +109,7 @@ module ActiveSupport end # Performs the opposite of merge, with the keys and values from the first hash taking precedence over the second. - # This overloaded definition prevents returning a regular hash, if reverse_merge is called on a HashWithDifferentAccess. + # This overloaded definition prevents returning a regular hash, if reverse_merge is called on a HashWithDifferentAccess. def reverse_merge(other_hash) super self.class.new_from_hash_copying_default(other_hash) end diff --git a/activesupport/lib/active_support/i18n_railtie.rb b/activesupport/lib/active_support/i18n_railtie.rb index 4a9ee5a769..a25e951080 100644 --- a/activesupport/lib/active_support/i18n_railtie.rb +++ b/activesupport/lib/active_support/i18n_railtie.rb @@ -14,7 +14,7 @@ module I18n @reloader ||= ActiveSupport::FileUpdateChecker.new([]){ I18n.reload! } end - # Add I18n::Railtie.reloader to ActionDispatch callbacks. Since, at this + # Add I18n::Railtie.reloader to ActionDispatch callbacks. Since, at this # point, no path was added to the reloader, I18n.reload! is not triggered # on to_prepare callbacks. This will only happen on the config.after_initialize # callback below. diff --git a/activesupport/lib/active_support/message_encryptor.rb b/activesupport/lib/active_support/message_encryptor.rb index d21f90f8b7..4f7cd12d48 100644 --- a/activesupport/lib/active_support/message_encryptor.rb +++ b/activesupport/lib/active_support/message_encryptor.rb @@ -7,7 +7,7 @@ module ActiveSupport # # 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 + # This can be used in situations similar to the MessageVerifier, but where you don't # want users to be able to determine the value of the payload. class MessageEncryptor class InvalidMessage < StandardError; end -- cgit v1.2.3 From b99fb66fb75bcc6b42869caa28dc79781a1aa9c7 Mon Sep 17 00:00:00 2001 From: suchasurge Date: Sun, 6 Mar 2011 10:44:52 +0100 Subject: more style changes --- activesupport/lib/active_support/log_subscriber.rb | 2 +- activesupport/lib/active_support/message_verifier.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/log_subscriber.rb b/activesupport/lib/active_support/log_subscriber.rb index df335af841..10675edac5 100644 --- a/activesupport/lib/active_support/log_subscriber.rb +++ b/activesupport/lib/active_support/log_subscriber.rb @@ -21,7 +21,7 @@ module ActiveSupport # ActiveRecord::LogSubscriber.attach_to :active_record # # Since we need to know all instance methods before attaching the log subscriber, - # the line above should be called after your ActiveRecord::LogSubscriber definition. + # the line above should be called after your ActiveRecord::LogSubscriber definition. # # After configured, whenever a "sql.active_record" notification is published, # it will properly dispatch the event (ActiveSupport::Notifications::Event) to diff --git a/activesupport/lib/active_support/message_verifier.rb b/activesupport/lib/active_support/message_verifier.rb index 9a4468f73c..8f3946325a 100644 --- a/activesupport/lib/active_support/message_verifier.rb +++ b/activesupport/lib/active_support/message_verifier.rb @@ -2,7 +2,7 @@ require 'active_support/base64' require 'active_support/core_ext/object/blank' module ActiveSupport - # MessageVerifier makes it easy to generate and verify messages which are signed + # +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 -- cgit v1.2.3 From 6ce844a3c1d9c1de4ae54cbe73e0dbd0acbe688a Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sun, 6 Mar 2011 17:49:39 +0100 Subject: removes Examples headers introduced in 9b96de6 Example headers are discouraged in the API guidelines. Code just flows with the text. They may be good in places where there's a lot of stuff and structure may add clarity --- activesupport/lib/active_support/configurable.rb | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/configurable.rb b/activesupport/lib/active_support/configurable.rb index 7bac3dbc91..8c56a21ef7 100644 --- a/activesupport/lib/active_support/configurable.rb +++ b/activesupport/lib/active_support/configurable.rb @@ -41,9 +41,6 @@ module ActiveSupport # Allows you to add shortcut so that you don't have to refer to attribute through config. # Also look at the example for config to contrast. # - # - # ==== Example - # # class User # include ActiveSupport::Configurable # config_accessor :allowed_access @@ -67,24 +64,21 @@ module ActiveSupport end # Reads and writes attributes from a configuration OrderedHash. - # # - # ==== Example + # require 'active_support/configurable' # - # require 'active_support/configurable' - # # class User # include ActiveSupport::Configurable - # end + # end # # user = User.new - # + # # user.config.allowed_access = true # user.config.level = 1 # # user.config.allowed_access # => true # user.config.level # => 1 - # + # def config @_config ||= self.class.config.inheritable_copy end -- cgit v1.2.3