}
end
--
cgit v1.2.3
From 5651e4c835a4a902c9fb7dea71be48a93e0d0eca Mon Sep 17 00:00:00 2001
From: Aaron Patterson
Date: Fri, 13 Aug 2010 12:28:41 -0700
Subject: symbol to proc is slow, we should avoid it
---
.../active_record/associations/has_and_belongs_to_many_association.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
index bec123e7a2..2838528a0c 100644
--- a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
+++ b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
@@ -79,7 +79,7 @@ module ActiveRecord
else
relation = Arel::Table.new(@reflection.options[:join_table])
relation.where(relation[@reflection.primary_key_name].eq(@owner.id).
- and(Arel::Predicates::In.new(relation[@reflection.association_foreign_key], records.map(&:id)))
+ and(Arel::Predicates::In.new(relation[@reflection.association_foreign_key], records.map { |x| x.id }))
).delete
end
end
--
cgit v1.2.3
From 4439e57ee09cf7b01fb1ef956626e6bfb6cb5fa7 Mon Sep 17 00:00:00 2001
From: Aaron Patterson
Date: Fri, 13 Aug 2010 12:30:58 -0700
Subject: do not use arel constants directly
---
.../active_record/associations/has_and_belongs_to_many_association.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
index 2838528a0c..be68affb3e 100644
--- a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
+++ b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
@@ -79,7 +79,7 @@ module ActiveRecord
else
relation = Arel::Table.new(@reflection.options[:join_table])
relation.where(relation[@reflection.primary_key_name].eq(@owner.id).
- and(Arel::Predicates::In.new(relation[@reflection.association_foreign_key], records.map { |x| x.id }))
+ and(relation[@reflection.association_foreign_key].in(records.map { |x| x.id }))
).delete
end
end
--
cgit v1.2.3
From e18bd86314184b6b4fb51a682d66e0a88172ce7a Mon Sep 17 00:00:00 2001
From: Aaron Patterson
Date: Fri, 13 Aug 2010 12:32:17 -0700
Subject: avoiding symbol to proc again
---
activerecord/lib/active_record/associations/has_many_association.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/activerecord/lib/active_record/associations/has_many_association.rb b/activerecord/lib/active_record/associations/has_many_association.rb
index c33bc6aa47..9a12a1866a 100644
--- a/activerecord/lib/active_record/associations/has_many_association.rb
+++ b/activerecord/lib/active_record/associations/has_many_association.rb
@@ -76,7 +76,7 @@ module ActiveRecord
else
relation = Arel::Table.new(@reflection.table_name)
relation.where(relation[@reflection.primary_key_name].eq(@owner.id).
- and(Arel::Predicates::In.new(relation[@reflection.klass.primary_key], records.map(&:id)))
+ and(Arel::Predicates::In.new(relation[@reflection.klass.primary_key], records.map { |r| r.id }))
).update(relation[@reflection.primary_key_name] => nil)
@owner.class.update_counters(@owner.id, cached_counter_attribute_name => -records.size) if has_cached_counter?
--
cgit v1.2.3
From af3e39358cacb93e39f6c7952314adb3892e3a6f Mon Sep 17 00:00:00 2001
From: Aaron Patterson
Date: Fri, 13 Aug 2010 12:33:54 -0700
Subject: removing references to arel constants
---
activerecord/lib/active_record/associations/has_many_association.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/activerecord/lib/active_record/associations/has_many_association.rb b/activerecord/lib/active_record/associations/has_many_association.rb
index 9a12a1866a..ccc01d2b57 100644
--- a/activerecord/lib/active_record/associations/has_many_association.rb
+++ b/activerecord/lib/active_record/associations/has_many_association.rb
@@ -76,7 +76,7 @@ module ActiveRecord
else
relation = Arel::Table.new(@reflection.table_name)
relation.where(relation[@reflection.primary_key_name].eq(@owner.id).
- and(Arel::Predicates::In.new(relation[@reflection.klass.primary_key], records.map { |r| r.id }))
+ and(relation[@reflection.klass.primary_key].in(records.map { |r| r.id }))
).update(relation[@reflection.primary_key_name] => nil)
@owner.class.update_counters(@owner.id, cached_counter_attribute_name => -records.size) if has_cached_counter?
--
cgit v1.2.3
From b9eec677c4ca28203124a9b5b160a57ca13b95f1 Mon Sep 17 00:00:00 2001
From: Aaron Patterson
Date: Fri, 13 Aug 2010 13:32:48 -0700
Subject: avoid direct use of arel constants
---
activerecord/lib/active_record/relation/spawn_methods.rb | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/activerecord/lib/active_record/relation/spawn_methods.rb b/activerecord/lib/active_record/relation/spawn_methods.rb
index f857e50dea..b4da8e4d1b 100644
--- a/activerecord/lib/active_record/relation/spawn_methods.rb
+++ b/activerecord/lib/active_record/relation/spawn_methods.rb
@@ -22,8 +22,10 @@ module ActiveRecord
merged_wheres = @where_values
r.where_values.each do |w|
- if w.is_a?(Arel::Predicates::Equality)
- merged_wheres = merged_wheres.reject {|p| p.is_a?(Arel::Predicates::Equality) && p.operand1.name == w.operand1.name }
+ if w.respond_to?(:operator) && w.operator == :==
+ merged_wheres = merged_wheres.reject { |p|
+ p.respond_to?(:operator) && p.operator == :== && p.operand1.name == w.operand1.name
+ }
end
merged_wheres += [w]
--
cgit v1.2.3
From 919888503d481c3bd21a33acd3cd1018fc48f500 Mon Sep 17 00:00:00 2001
From: Santiago Pastorino
Date: Fri, 13 Aug 2010 17:34:20 -0300
Subject: Moves local_request? to require.local?
[#5361 state:committed]
---
actionpack/lib/action_dispatch/http/request.rb | 7 +++++++
actionpack/lib/action_dispatch/middleware/show_exceptions.rb | 9 +--------
railties/lib/rails/info_controller.rb | 2 +-
railties/test/rails_info_controller_test.rb | 10 ++++++----
4 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/actionpack/lib/action_dispatch/http/request.rb b/actionpack/lib/action_dispatch/http/request.rb
index fd23b1df79..5606d6abfe 100644
--- a/actionpack/lib/action_dispatch/http/request.rb
+++ b/actionpack/lib/action_dispatch/http/request.rb
@@ -15,6 +15,8 @@ module ActionDispatch
include ActionDispatch::Http::Upload
include ActionDispatch::Http::URL
+ LOCALHOST = [/^127\.0\.0\.\d{1,3}$/, "::1", /^0:0:0:0:0:0:0:1(%.*)?$/].freeze
+
%w[ AUTH_TYPE GATEWAY_INTERFACE
PATH_TRANSLATED REMOTE_HOST
REMOTE_IDENT REMOTE_USER REMOTE_ADDR
@@ -231,5 +233,10 @@ module ActionDispatch
@env['X_HTTP_AUTHORIZATION'] ||
@env['REDIRECT_X_HTTP_AUTHORIZATION']
end
+
+ # True if the request came from localhost, 127.0.0.1.
+ def local?
+ LOCALHOST.any? { |local_ip| local_ip === remote_addr && local_ip === remote_ip }
+ end
end
end
diff --git a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
index e095b51342..a7d3cb473f 100644
--- a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
+++ b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
@@ -6,8 +6,6 @@ module ActionDispatch
# This middleware rescues any exception returned by the application and renders
# nice exception pages if it's being rescued locally.
class ShowExceptions
- LOCALHOST = [/^127\.0\.0\.\d{1,3}$/, "::1", /^0:0:0:0:0:0:0:1(%.*)?$/].freeze
-
RESCUES_TEMPLATE_PATH = File.join(File.dirname(__FILE__), 'templates')
cattr_accessor :rescue_responses
@@ -66,7 +64,7 @@ module ActionDispatch
log_error(exception)
request = Request.new(env)
- if @consider_all_requests_local || local_request?(request)
+ if @consider_all_requests_local || request.local?
rescue_action_locally(request, exception)
else
rescue_action_in_public(exception)
@@ -112,11 +110,6 @@ module ActionDispatch
end
end
- # True if the request came from localhost, 127.0.0.1.
- def local_request?(request)
- LOCALHOST.any? { |local_ip| local_ip === request.remote_addr && local_ip === request.remote_ip }
- end
-
def status_code(exception)
Rack::Utils.status_code(@@rescue_responses[exception.class.name])
end
diff --git a/railties/lib/rails/info_controller.rb b/railties/lib/rails/info_controller.rb
index 196eeb4a6c..6b4bdb2921 100644
--- a/railties/lib/rails/info_controller.rb
+++ b/railties/lib/rails/info_controller.rb
@@ -1,6 +1,6 @@
class Rails::InfoController < ActionController::Base
def properties
- if consider_all_requests_local? || local_request?
+ if consider_all_requests_local? || request.local?
render :inline => Rails::Info.to_html
else
render :text => '
For security purposes, this information is only available to local requests.
', :status => :forbidden
diff --git a/railties/test/rails_info_controller_test.rb b/railties/test/rails_info_controller_test.rb
index 687c2d1568..9d194f41a6 100644
--- a/railties/test/rails_info_controller_test.rb
+++ b/railties/test/rails_info_controller_test.rb
@@ -14,26 +14,28 @@ class InfoControllerTest < ActionController::TestCase
Rails.application.routes.draw do
match '/rails/info/properties' => "rails/info#properties"
end
- @controller.stubs(:consider_all_requests_local? => false, :local_request? => true)
+ @request.stubs(:local? => true)
+ @controller.stubs(:consider_all_requests_local? => false)
@routes = Rails.application.routes
Rails::InfoController.send(:include, @routes.url_helpers)
end
test "info controller does not allow remote requests" do
- @controller.stubs(:consider_all_requests_local? => false, :local_request? => false)
+ @request.stubs(:local? => false)
get :properties
assert_response :forbidden
end
test "info controller renders an error message when request was forbidden" do
- @controller.stubs(:consider_all_requests_local? => false, :local_request? => false)
+ @request.stubs(:local? => false)
get :properties
assert_select 'p'
end
test "info controller allows requests when all requests are considered local" do
- @controller.stubs(:consider_all_requests_local? => true, :local_request? => false)
+ @request.stubs(:local? => false)
+ @controller.stubs(:consider_all_requests_local? => true)
get :properties
assert_response :success
end
--
cgit v1.2.3
From 1f250415fe7ca2657f9d54a851e084b725c2e8ef Mon Sep 17 00:00:00 2001
From: Aaron Patterson
Date: Fri, 13 Aug 2010 14:44:58 -0700
Subject: removing a lolinject
---
actionpack/lib/action_view/helpers/form_options_helper.rb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/actionpack/lib/action_view/helpers/form_options_helper.rb b/actionpack/lib/action_view/helpers/form_options_helper.rb
index ee34452769..3c4d0b65f4 100644
--- a/actionpack/lib/action_view/helpers/form_options_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_options_helper.rb
@@ -300,12 +300,12 @@ module ActionView
container = container.to_a if Hash === container
selected, disabled = extract_selected_and_disabled(selected)
- options_for_select = container.inject([]) do |options, element|
+ options_for_select = container.map do |element|
html_attributes = option_html_attributes(element)
text, value = option_text_and_value(element)
selected_attribute = ' selected="selected"' if option_value_selected?(value, selected)
disabled_attribute = ' disabled="disabled"' if disabled && option_value_selected?(value, disabled)
- options << %()
+ %()
end
options_for_select.join("\n").html_safe
--
cgit v1.2.3
From a7eb8d97a44d65c68df2eed61a5375a8d8da32f1 Mon Sep 17 00:00:00 2001
From: Prem Sichanugrist
Date: Sat, 14 Aug 2010 05:59:15 +0700
Subject: Removing most of the symbol to proc usage in Active Record
This will hopefully make Active Record run a bit more faster.
---
activerecord/lib/active_record/associations.rb | 12 ++++++------
.../associations/has_and_belongs_to_many_association.rb | 2 +-
activerecord/lib/active_record/autosave_association.rb | 2 +-
activerecord/lib/active_record/base.rb | 6 +++---
.../connection_adapters/abstract/schema_definitions.rb | 2 +-
.../connection_adapters/abstract/schema_statements.rb | 2 +-
.../active_record/connection_adapters/postgresql_adapter.rb | 2 +-
.../lib/active_record/connection_adapters/sqlite_adapter.rb | 6 +++---
activerecord/lib/active_record/fixtures.rb | 4 ++--
activerecord/lib/active_record/migration.rb | 6 +++---
activerecord/lib/active_record/observer.rb | 2 +-
activerecord/lib/active_record/relation.rb | 4 ++--
activerecord/lib/active_record/relation/finder_methods.rb | 2 +-
activerecord/lib/active_record/schema_dumper.rb | 2 +-
activerecord/lib/active_record/test_case.rb | 2 +-
15 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index a987b174ed..bf278ecce7 100644
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -35,7 +35,7 @@ module ActiveRecord
through_reflection = reflection.through_reflection
source_reflection_names = reflection.source_reflection_names
source_associations = reflection.through_reflection.klass.reflect_on_all_associations.collect { |a| a.name.inspect }
- super("Could not find the source association(s) #{source_reflection_names.collect(&:inspect).to_sentence(:two_words_connector => ' or ', :last_word_connector => ', or ', :locale => :en)} in model #{through_reflection.klass}. Try 'has_many #{reflection.name.inspect}, :through => #{through_reflection.name.inspect}, :source => '. Is it one of #{source_associations.to_sentence(:two_words_connector => ' or ', :last_word_connector => ', or ', :locale => :en)}?")
+ super("Could not find the source association(s) #{source_reflection_names.collect{ |a| a.inspect }.to_sentence(:two_words_connector => ' or ', :last_word_connector => ', or ', :locale => :en)} in model #{through_reflection.klass}. Try 'has_many #{reflection.name.inspect}, :through => #{through_reflection.name.inspect}, :source => '. Is it one of #{source_associations.to_sentence(:two_words_connector => ' or ', :last_word_connector => ', or ', :locale => :en)}?")
end
end
@@ -1497,17 +1497,17 @@ module ActiveRecord
association
end
-
+
redefine_method("#{reflection.name.to_s.singularize}_ids") do
if send(reflection.name).loaded? || reflection.options[:finder_sql]
- send(reflection.name).map(&:id)
+ send(reflection.name).map { |r| r.id }
else
if reflection.through_reflection && reflection.source_reflection.belongs_to?
through = reflection.through_reflection
primary_key = reflection.source_reflection.primary_key_name
- send(through.name).select("DISTINCT #{through.quoted_table_name}.#{primary_key}").map!(&:"#{primary_key}")
+ send(through.name).select("DISTINCT #{through.quoted_table_name}.#{primary_key}").map! { |r| r.send(:"#{primary_key}") }
else
- send(reflection.name).select("#{reflection.quoted_table_name}.#{reflection.klass.primary_key}").except(:includes).map!(&:id)
+ send(reflection.name).select("#{reflection.quoted_table_name}.#{reflection.klass.primary_key}").except(:includes).map! { |r| r.id }
end
end
end
@@ -1529,7 +1529,7 @@ module ActiveRecord
pk_column = reflection.primary_key_column
ids = (new_value || []).reject { |nid| nid.blank? }
ids.map!{ |i| pk_column.type_cast(i) }
- send("#{reflection.name}=", reflection.klass.find(ids).index_by(&:id).values_at(*ids))
+ send("#{reflection.name}=", reflection.klass.find(ids).index_by{ |r| r.id }.values_at(*ids))
end
end
end
diff --git a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
index be68affb3e..4f9bd8f679 100644
--- a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
+++ b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
@@ -127,7 +127,7 @@ module ActiveRecord
def record_timestamp_columns(record)
if record.record_timestamps
- record.send(:all_timestamp_attributes).map(&:to_s)
+ record.send(:all_timestamp_attributes).map { |x| x.to_s }
else
[]
end
diff --git a/activerecord/lib/active_record/autosave_association.rb b/activerecord/lib/active_record/autosave_association.rb
index 5b890e5a04..5a35dc2a3b 100644
--- a/activerecord/lib/active_record/autosave_association.rb
+++ b/activerecord/lib/active_record/autosave_association.rb
@@ -231,7 +231,7 @@ module ActiveRecord
def nested_records_changed_for_autosave?
self.class.reflect_on_all_autosave_associations.any? do |reflection|
association = association_instance_get(reflection.name)
- association && Array.wrap(association.target).any?(&:changed_for_autosave?)
+ association && Array.wrap(association.target).any? { |a| a.changed_for_autosave? }
end
end
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 4b550eb446..15af7b4376 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -519,7 +519,7 @@ module ActiveRecord #:nodoc:
# Attributes listed as readonly will be used to create a new record but update operations will
# ignore these fields.
def attr_readonly(*attributes)
- write_inheritable_attribute(:attr_readonly, Set.new(attributes.map(&:to_s)) + (readonly_attributes || []))
+ write_inheritable_attribute(:attr_readonly, Set.new(attributes.map { |a| a.to_s }) + (readonly_attributes || []))
end
# Returns an array of all the attributes that have been specified as readonly.
@@ -1286,7 +1286,7 @@ MSG
table = Arel::Table.new(self.table_name, :engine => arel_engine, :as => default_table_name)
builder = PredicateBuilder.new(arel_engine)
- builder.build_from_hash(attrs, table).map(&:to_sql).join(' AND ')
+ builder.build_from_hash(attrs, table).map{ |b| b.to_sql }.join(' AND ')
end
alias_method :sanitize_sql_hash, :sanitize_sql_hash_for_conditions
@@ -1737,7 +1737,7 @@ MSG
klass = (self.class.reflect_on_aggregation(name.to_sym) || column_for_attribute(name)).klass
# in order to allow a date to be set without a year, we must keep the empty values.
# Otherwise, we wouldn't be able to distinguish it from a date with an empty day.
- values = values_with_empty_parameters.reject(&:nil?)
+ values = values_with_empty_parameters.reject { |v| v.nil? }
if values.empty?
send(name + "=", nil)
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
index 9118ceb33c..2472403282 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
@@ -528,7 +528,7 @@ module ActiveRecord
# concatenated together. This string can then be prepended and appended to
# to generate the final SQL to create the table.
def to_sql
- @columns.map(&:to_sql) * ', '
+ @columns.map { |c| c.to_sql } * ', '
end
private
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
index 7dee68502f..214038848f 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
@@ -450,7 +450,7 @@ module ActiveRecord
version = version.to_i
sm_table = quote_table_name(ActiveRecord::Migrator.schema_migrations_table_name)
- migrated = select_values("SELECT version FROM #{sm_table}").map(&:to_i)
+ migrated = select_values("SELECT version FROM #{sm_table}").map { |v| v.to_i }
versions = Dir["#{migrations_path}/[0-9]*_*.rb"].map do |filename|
filename.split('/').last.split('_').first.to_i
end
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index 6fae899e87..5046c2f5f6 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -879,7 +879,7 @@ module ActiveRecord
# Construct a clean list of column names from the ORDER BY clause, removing
# any ASC/DESC modifiers
order_columns = order_by.split(',').collect { |s| s.split.first }
- order_columns.delete_if(&:blank?)
+ order_columns.delete_if { |c| c.blank? }
order_columns = order_columns.zip((0...order_columns.size).to_a).map { |s,i| "#{s} AS alias_#{i}" }
# Return a DISTINCT ON() clause that's distinct on the columns we want but includes
diff --git a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
index 82ad0a3b8e..0de73c4cbc 100644
--- a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
@@ -40,11 +40,11 @@ module ActiveRecord
include Comparable
def initialize(version_string)
- @version = version_string.split('.').map(&:to_i)
+ @version = version_string.split('.').map { |v| v.to_i }
end
def <=>(version_string)
- @version <=> version_string.split('.').map(&:to_i)
+ @version <=> version_string.split('.').map { |v| v.to_i }
end
end
@@ -345,7 +345,7 @@ module ActiveRecord
name = name[5..-1]
end
- to_column_names = columns(to).map(&:name)
+ to_column_names = columns(to).map { |c| c.name }
columns = index.columns.map {|c| rename[c] || c }.select do |column|
to_column_names.include?(column)
end
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb
index 4e49e9f720..7cec560a86 100644
--- a/activerecord/lib/active_record/fixtures.rb
+++ b/activerecord/lib/active_record/fixtures.rb
@@ -690,7 +690,7 @@ class Fixtures < (RUBY_VERSION < '1.9' ? YAML::Omap : Hash)
end
def column_names
- @column_names ||= @connection.columns(@table_name).collect(&:name)
+ @column_names ||= @connection.columns(@table_name).collect { |c| c.name }
end
def read_fixture_files
@@ -908,7 +908,7 @@ module ActiveRecord
def uses_transaction(*methods)
@uses_transaction = [] unless defined?(@uses_transaction)
- @uses_transaction.concat methods.map(&:to_s)
+ @uses_transaction.concat methods.map { |m| m.to_s }
end
def uses_transaction?(method)
diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb
index 5e272f0ba4..7f26aa3f52 100644
--- a/activerecord/lib/active_record/migration.rb
+++ b/activerecord/lib/active_record/migration.rb
@@ -374,7 +374,7 @@ module ActiveRecord
end
def method_missing(method, *arguments, &block)
- arg_list = arguments.map(&:inspect) * ', '
+ arg_list = arguments.map{ |a| a.inspect } * ', '
say_with_time "#{method}(#{arg_list})" do
unless arguments.empty? || method == :execute
@@ -451,7 +451,7 @@ module ActiveRecord
def get_all_versions
table = Arel::Table.new(schema_migrations_table_name)
- Base.connection.select_values(table.project(table['version']).to_sql).map(&:to_i).sort
+ Base.connection.select_values(table.project(table['version']).to_sql).map{ |v| v.to_i }.sort
end
def current_version
@@ -569,7 +569,7 @@ module ActiveRecord
klasses << migration
end
- migrations = migrations.sort_by(&:version)
+ migrations = migrations.sort_by { |m| m.version }
down? ? migrations.reverse : migrations
end
end
diff --git a/activerecord/lib/active_record/observer.rb b/activerecord/lib/active_record/observer.rb
index 78bac55bf2..e7fe9c39e0 100644
--- a/activerecord/lib/active_record/observer.rb
+++ b/activerecord/lib/active_record/observer.rb
@@ -122,7 +122,7 @@ module ActiveRecord
end
def define_callbacks(klass)
- existing_methods = klass.instance_methods.map(&:to_sym)
+ existing_methods = klass.instance_methods.map { |m| m.to_sym }
observer = self
observer_name = observer.class.name.underscore.gsub('/', '__')
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index 30be723291..1db7f2abec 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -375,7 +375,7 @@ module ActiveRecord
def references_eager_loaded_tables?
# always convert table names to downcase as in Oracle quoted table names are in uppercase
- joined_tables = (tables_in_string(arel.joins(arel)) + [table.name, table.table_alias]).compact.map(&:downcase).uniq
+ joined_tables = (tables_in_string(arel.joins(arel)) + [table.name, table.table_alias]).compact.map{ |t| t.downcase }.uniq
(tables_in_string(to_sql) - joined_tables).any?
end
@@ -383,7 +383,7 @@ module ActiveRecord
return [] if string.blank?
# always convert table names to downcase as in Oracle quoted table names are in uppercase
# ignore raw_sql_ that is used by Oracle adapter as alias for limit/offset subqueries
- string.scan(/([a-zA-Z_][\.\w]+).?\./).flatten.map(&:downcase).uniq - ['raw_sql_']
+ string.scan(/([a-zA-Z_][\.\w]+).?\./).flatten.map{ |s| s.downcase }.uniq - ['raw_sql_']
end
end
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb
index 0c75acf723..fc6728bd18 100644
--- a/activerecord/lib/active_record/relation/finder_methods.rb
+++ b/activerecord/lib/active_record/relation/finder_methods.rb
@@ -348,7 +348,7 @@ module ActiveRecord
end
def using_limitable_reflections?(reflections)
- reflections.none?(&:collection?)
+ reflections.none? { |r| r.collection? }
end
end
diff --git a/activerecord/lib/active_record/schema_dumper.rb b/activerecord/lib/active_record/schema_dumper.rb
index e9af20e1b6..4566410206 100644
--- a/activerecord/lib/active_record/schema_dumper.rb
+++ b/activerecord/lib/active_record/schema_dumper.rb
@@ -123,7 +123,7 @@ HEADER
end.compact
# find all migration keys used in this table
- keys = [:name, :limit, :precision, :scale, :default, :null] & column_specs.map(&:keys).flatten
+ keys = [:name, :limit, :precision, :scale, :default, :null] & column_specs.map{ |k| k.keys }.flatten
# figure out the lengths for each column based on above keys
lengths = keys.map{ |key| column_specs.map{ |spec| spec[key] ? spec[key].length + 2 : 0 }.max }
diff --git a/activerecord/lib/active_record/test_case.rb b/activerecord/lib/active_record/test_case.rb
index e61a378d17..ec529ef79d 100644
--- a/activerecord/lib/active_record/test_case.rb
+++ b/activerecord/lib/active_record/test_case.rb
@@ -21,7 +21,7 @@ module ActiveRecord
patterns_to_match.each do |pattern|
failed_patterns << pattern unless $queries_executed.any?{ |sql| pattern === sql }
end
- assert failed_patterns.empty?, "Query pattern(s) #{failed_patterns.map(&:inspect).join(', ')} not found.#{$queries_executed.size == 0 ? '' : "\nQueries:\n#{$queries_executed.join("\n")}"}"
+ assert failed_patterns.empty?, "Query pattern(s) #{failed_patterns.map{ |p| p.inspect }.join(', ')} not found.#{$queries_executed.size == 0 ? '' : "\nQueries:\n#{$queries_executed.join("\n")}"}"
end
def assert_queries(num = 1)
--
cgit v1.2.3
From be5d1608cb57f86c53ee229f40f52aa8ffc2d86f Mon Sep 17 00:00:00 2001
From: Aaron Patterson
Date: Fri, 13 Aug 2010 16:50:22 -0700
Subject: converting to a symbol is not necessary
---
activerecord/lib/active_record/associations.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index bf278ecce7..096709e166 100644
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -1505,7 +1505,7 @@ module ActiveRecord
if reflection.through_reflection && reflection.source_reflection.belongs_to?
through = reflection.through_reflection
primary_key = reflection.source_reflection.primary_key_name
- send(through.name).select("DISTINCT #{through.quoted_table_name}.#{primary_key}").map! { |r| r.send(:"#{primary_key}") }
+ send(through.name).select("DISTINCT #{through.quoted_table_name}.#{primary_key}").map! { |r| r.send(primary_key) }
else
send(reflection.name).select("#{reflection.quoted_table_name}.#{reflection.klass.primary_key}").except(:includes).map! { |r| r.id }
end
--
cgit v1.2.3
From 27fb88aa22d7887138ec02f34eeb01f78043642d Mon Sep 17 00:00:00 2001
From: Santiago Pastorino
Date: Fri, 13 Aug 2010 21:18:36 -0300
Subject: This method is actually not used, it's implemented on the concrete
adapters
[#5331 state:committed]
---
.../lib/active_record/connection_adapters/abstract/query_cache.rb | 8 --------
1 file changed, 8 deletions(-)
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb b/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
index 78fffaff6e..0ee61d0b6f 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
@@ -57,14 +57,6 @@ module ActiveRecord
end
end
- def columns(*)
- if @query_cache_enabled
- @query_cache["SHOW FIELDS FROM #{args.first}"] ||= super
- else
- super
- end
- end
-
private
def cache_sql(sql)
result =
--
cgit v1.2.3
From 1590377886820e00b1a786616518a32f3b61ec0f Mon Sep 17 00:00:00 2001
From: Santiago Pastorino
Date: Fri, 13 Aug 2010 22:15:15 -0300
Subject: Makes AR use AMo to_key implementation
[#5249]
---
activerecord/lib/active_record/attribute_methods/primary_key.rb | 6 ------
activerecord/test/cases/primary_keys_test.rb | 2 +-
2 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/activerecord/lib/active_record/attribute_methods/primary_key.rb b/activerecord/lib/active_record/attribute_methods/primary_key.rb
index 82d94b848a..365fdeb55a 100644
--- a/activerecord/lib/active_record/attribute_methods/primary_key.rb
+++ b/activerecord/lib/active_record/attribute_methods/primary_key.rb
@@ -3,12 +3,6 @@ module ActiveRecord
module PrimaryKey
extend ActiveSupport::Concern
- # Returns this record's primary key value wrapped in an Array
- # or nil if the record is a new_record?
- def to_key
- new_record? ? nil : [ id ]
- end
-
module ClassMethods
# Defines the primary key field -- can be overridden in subclasses. Overwriting will negate any effect of the
# primary_key_prefix_type setting, though.
diff --git a/activerecord/test/cases/primary_keys_test.rb b/activerecord/test/cases/primary_keys_test.rb
index 1e44237e0a..5cdcb05902 100644
--- a/activerecord/test/cases/primary_keys_test.rb
+++ b/activerecord/test/cases/primary_keys_test.rb
@@ -26,7 +26,7 @@ class PrimaryKeysTest < ActiveRecord::TestCase
def test_to_key_with_primary_key_after_destroy
topic = Topic.find(1)
topic.destroy
- assert_equal [1], topic.to_key
+ assert_equal nil, topic.to_key
end
def test_integer_key
--
cgit v1.2.3
From b451de0d6de4df6bc66b274cec73b919f823d5ae 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 {} \;)
---
README.rdoc | 4 +-
actionmailer/CHANGELOG | 8 +-
actionmailer/README.rdoc | 22 +-
actionmailer/lib/action_mailer/base.rb | 22 +-
actionmailer/lib/action_mailer/delivery_methods.rb | 4 +-
actionmailer/lib/action_mailer/mail_helper.rb | 4 +-
actionmailer/lib/action_mailer/old_api.rb | 32 +-
actionmailer/lib/action_mailer/tmail_compat.rb | 6 +-
actionmailer/test/base_test.rb | 16 +-
actionmailer/test/delivery_methods_test.rb | 6 +-
actionmailer/test/fixtures/raw_email10 | 2 +-
actionmailer/test/fixtures/raw_email2 | 2 +-
actionmailer/test/fixtures/raw_email3 | 2 +-
actionmailer/test/fixtures/raw_email5 | 2 +-
actionmailer/test/fixtures/raw_email6 | 2 +-
actionmailer/test/fixtures/raw_email8 | 2 +-
actionmailer/test/fixtures/raw_email9 | 10 +-
actionmailer/test/fixtures/templates/signed_up.erb | 2 +-
.../custom_templating_extension.html.haml | 4 +-
.../custom_templating_extension.text.haml | 4 +-
.../test/fixtures/test_mailer/signed_up.html.erb | 2 +-
.../url_test_mailer/signed_up_with_url.erb | 2 +-
actionmailer/test/mailers/proc_mailer.rb | 6 +-
actionmailer/test/old_base/mail_service_test.rb | 30 +-
actionmailer/test/old_base/tmail_compat_test.rb | 2 +-
actionmailer/test/old_base/url_test.rb | 2 +-
actionmailer/test/test_helper_test.rb | 24 +-
actionpack/CHANGELOG | 4 +-
actionpack/README.rdoc | 4 +-
actionpack/RUNNING_UNIT_TESTS | 4 +-
actionpack/lib/abstract_controller/base.rb | 2 +-
.../action_controller/metal/http_authentication.rb | 4 +-
actionpack/lib/action_controller/middleware.rb | 2 +-
actionpack/lib/action_controller/test_case.rb | 2 +-
.../vendor/html-scanner/html/document.rb | 4 +-
.../vendor/html-scanner/html/node.rb | 58 ++--
.../vendor/html-scanner/html/sanitizer.rb | 50 +--
.../vendor/html-scanner/html/selector.rb | 2 +-
.../vendor/html-scanner/html/tokenizer.rb | 16 +-
actionpack/lib/action_dispatch/http/mime_type.rb | 20 +-
actionpack/lib/action_dispatch/middleware/stack.rb | 2 +-
actionpack/lib/action_dispatch/routing.rb | 8 +-
actionpack/lib/action_view/helpers/debug_helper.rb | 2 +-
.../lib/action_view/helpers/form_options_helper.rb | 16 +-
.../lib/action_view/helpers/form_tag_helper.rb | 16 +-
.../lib/action_view/helpers/number_helper.rb | 2 +-
.../lib/action_view/helpers/raw_output_helper.rb | 2 +-
.../lib/action_view/helpers/sanitize_helper.rb | 4 +-
actionpack/lib/action_view/helpers/text_helper.rb | 4 +-
.../lib/action_view/helpers/translation_helper.rb | 18 +-
actionpack/lib/action_view/log_subscriber.rb | 2 +-
actionpack/lib/action_view/template/handler.rb | 2 +-
actionpack/lib/action_view/template/handlers.rb | 2 +-
actionpack/lib/action_view/test_case.rb | 2 +-
actionpack/lib/action_view/testing/resolvers.rb | 2 +-
actionpack/test/abstract/callbacks_test.rb | 92 +++---
actionpack/test/abstract/helper_test.rb | 8 +-
actionpack/test/abstract/translation_test.rb | 8 +-
actionpack/test/abstract_unit.rb | 2 +-
actionpack/test/controller/assert_select_test.rb | 2 +-
actionpack/test/controller/base_test.rb | 12 +-
actionpack/test/controller/dispatcher_test.rb | 2 +-
actionpack/test/controller/filters_test.rb | 2 +-
actionpack/test/controller/helper_test.rb | 14 +-
.../controller/http_basic_authentication_test.rb | 6 +-
.../controller/http_token_authentication_test.rb | 6 +-
actionpack/test/controller/layout_test.rb | 4 +-
actionpack/test/controller/mime_responds_test.rb | 10 +-
actionpack/test/controller/new_base/etag_test.rb | 2 +-
.../new_base/render_implicit_action_test.rb | 4 +-
.../test/controller/new_base/render_layout_test.rb | 2 +-
.../controller/new_base/render_partial_test.rb | 14 +-
actionpack/test/controller/new_base/render_test.rb | 2 +-
.../test/controller/new_base/render_text_test.rb | 24 +-
.../test/controller/new_base/render_xml_test.rb | 2 +-
actionpack/test/controller/render_test.rb | 4 +-
actionpack/test/controller/rescue_test.rb | 2 +-
actionpack/test/controller/selector_test.rb | 8 +-
actionpack/test/controller/test_test.rb | 2 +-
actionpack/test/controller/view_paths_test.rb | 4 +-
actionpack/test/dispatch/callbacks_test.rb | 2 +-
actionpack/test/dispatch/mount_test.rb | 2 +-
actionpack/test/dispatch/request_test.rb | 2 +-
.../test/dispatch/session/cookie_store_test.rb | 8 +-
.../test/dispatch/session/mem_cache_store_test.rb | 2 +-
actionpack/test/fixtures/companies.yml | 2 +-
actionpack/test/fixtures/company.rb | 2 +-
actionpack/test/fixtures/db_definitions/sqlite.sql | 20 +-
actionpack/test/fixtures/replies.yml | 2 +-
.../test/fixtures/test/hello_xml_world.builder | 2 +-
actionpack/test/fixtures/topics.yml | 2 +-
.../test/template/compiled_templates_test.rb | 2 +-
actionpack/test/template/date_helper_i18n_test.rb | 2 +-
actionpack/test/template/date_helper_test.rb | 28 +-
actionpack/test/template/erb_util_test.rb | 2 +-
.../test/template/form_options_helper_test.rb | 12 +-
.../test/template/html-scanner/document_test.rb | 2 +-
actionpack/test/template/html-scanner/node_test.rb | 18 +-
.../test/template/html-scanner/sanitizer_test.rb | 34 +-
.../test/template/html-scanner/tag_node_test.rb | 46 +--
.../test/template/html-scanner/text_node_test.rb | 10 +-
.../test/template/html-scanner/tokenizer_test.rb | 20 +-
actionpack/test/template/number_helper_test.rb | 2 +-
actionpack/test/template/tag_helper_test.rb | 6 +-
actionpack/test/template/text_helper_test.rb | 12 +-
.../test/template/translation_helper_test.rb | 8 +-
actionpack/test/template/url_helper_test.rb | 4 +-
activemodel/CHANGELOG | 2 +-
activemodel/README.rdoc | 54 ++--
activemodel/lib/active_model/attribute_methods.rb | 84 ++---
activemodel/lib/active_model/callbacks.rb | 58 ++--
activemodel/lib/active_model/conversion.rb | 12 +-
activemodel/lib/active_model/dirty.rb | 36 +--
activemodel/lib/active_model/errors.rb | 60 ++--
activemodel/lib/active_model/lint.rb | 2 +-
activemodel/lib/active_model/naming.rb | 10 +-
activemodel/lib/active_model/observing.rb | 14 +-
activemodel/lib/active_model/serialization.rb | 44 +--
activemodel/lib/active_model/serializers/xml.rb | 2 +-
activemodel/lib/active_model/translation.rb | 14 +-
activemodel/lib/active_model/validations.rb | 32 +-
.../lib/active_model/validations/acceptance.rb | 22 +-
.../lib/active_model/validations/confirmation.rb | 20 +-
activemodel/lib/active_model/validations/length.rb | 2 +-
.../lib/active_model/validations/validates.rb | 10 +-
activemodel/lib/active_model/validator.rb | 22 +-
activemodel/test/cases/attribute_methods_test.rb | 4 +-
.../serializeration/json_serialization_test.rb | 10 +-
activemodel/test/cases/translation_test.rb | 4 +-
.../test/cases/validations/validates_test.rb | 8 +-
activemodel/test/cases/validations_test.rb | 2 +-
activemodel/test/models/custom_reader.rb | 4 +-
activemodel/test/models/person_with_validator.rb | 2 +-
activemodel/test/models/sheep.rb | 1 -
activerecord/README.rdoc | 18 +-
activerecord/RUNNING_UNIT_TESTS | 16 +-
activerecord/lib/active_record/aggregations.rb | 96 +++---
.../lib/active_record/association_preload.rb | 8 +-
activerecord/lib/active_record/associations.rb | 344 ++++++++++-----------
.../has_and_belongs_to_many_association.rb | 6 +-
.../associations/has_many_association.rb | 8 +-
.../associations/has_many_through_association.rb | 6 +-
.../attribute_methods/time_zone_conversion.rb | 2 +-
.../lib/active_record/attribute_methods/write.rb | 2 +-
.../lib/active_record/autosave_association.rb | 10 +-
activerecord/lib/active_record/base.rb | 174 +++++------
activerecord/lib/active_record/callbacks.rb | 48 +--
.../abstract/connection_pool.rb | 2 +-
.../abstract/schema_definitions.rb | 6 +-
.../abstract/schema_statements.rb | 4 +-
.../connection_adapters/mysql2_adapter.rb | 4 +-
.../connection_adapters/mysql_adapter.rb | 2 +-
.../connection_adapters/postgresql_adapter.rb | 8 +-
.../connection_adapters/sqlite_adapter.rb | 2 +-
.../lib/active_record/dynamic_finder_match.rb | 2 +-
.../lib/active_record/dynamic_scope_match.rb | 2 +-
activerecord/lib/active_record/errors.rb | 8 +-
activerecord/lib/active_record/fixtures.rb | 36 +--
activerecord/lib/active_record/locale/en.yml | 4 +-
activerecord/lib/active_record/migration.rb | 66 ++--
activerecord/lib/active_record/named_scope.rb | 24 +-
.../lib/active_record/nested_attributes.rb | 2 +-
activerecord/lib/active_record/observer.rb | 2 +-
activerecord/lib/active_record/reflection.rb | 26 +-
activerecord/lib/active_record/relation.rb | 8 +-
.../lib/active_record/relation/calculations.rb | 52 ++--
.../lib/active_record/relation/finder_methods.rb | 14 +-
.../lib/active_record/relation/spawn_methods.rb | 2 +-
activerecord/lib/active_record/schema_dumper.rb | 4 +-
activerecord/lib/active_record/serialization.rb | 2 +-
.../active_record/serializers/xml_serializer.rb | 2 +-
activerecord/lib/active_record/session_store.rb | 2 +-
activerecord/lib/active_record/test_case.rb | 2 +-
.../lib/active_record/validations/associated.rb | 4 +-
.../lib/active_record/validations/uniqueness.rb | 20 +-
.../has_many_through_associations_test.rb | 4 +-
.../has_one_through_associations_test.rb | 14 +-
.../test/cases/associations/join_model_test.rb | 10 +-
activerecord/test/cases/associations_test.rb | 6 +-
activerecord/test/cases/attribute_methods_test.rb | 8 +-
.../test/cases/autosave_association_test.rb | 2 +-
activerecord/test/cases/counter_cache_test.rb | 2 +-
activerecord/test/cases/defaults_test.rb | 6 +-
activerecord/test/cases/dirty_test.rb | 14 +-
activerecord/test/cases/fixtures_test.rb | 16 +-
activerecord/test/cases/i18n_test.rb | 4 +-
activerecord/test/cases/json_serialization_test.rb | 2 +-
activerecord/test/cases/migration_test.rb | 4 +-
activerecord/test/cases/modules_test.rb | 4 +-
activerecord/test/cases/nested_attributes_test.rb | 20 +-
activerecord/test/cases/persistence_test.rb | 4 +-
activerecord/test/cases/reflection_test.rb | 2 +-
activerecord/test/cases/relation_scoping_test.rb | 4 +-
activerecord/test/cases/relations_test.rb | 4 +-
activerecord/test/cases/serialization_test.rb | 2 +-
activerecord/test/cases/timestamp_test.rb | 28 +-
activerecord/test/fixtures/comments.yml | 4 +-
activerecord/test/fixtures/companies.yml | 10 +-
activerecord/test/fixtures/items.yml | 1 -
activerecord/test/fixtures/memberships.yml | 2 +-
activerecord/test/fixtures/mixins.yml | 2 +-
activerecord/test/fixtures/taggings.yml | 2 +-
activerecord/test/fixtures/tags.yml | 2 +-
activerecord/test/models/developer.rb | 2 +-
activerecord/test/models/minivan.rb | 4 +-
activerecord/test/models/post.rb | 2 +-
activerecord/test/models/shop.rb | 2 +-
activerecord/test/models/topic.rb | 2 +-
.../test/schema/postgresql_specific_schema.rb | 2 +-
activerecord/test/schema/schema.rb | 6 +-
activeresource/CHANGELOG | 22 +-
activeresource/README.rdoc | 8 +-
activeresource/lib/active_resource/http_mock.rb | 8 +-
activeresource/lib/active_resource/validations.rb | 16 +-
.../test/cases/base/custom_methods_test.rb | 10 +-
activeresource/test/cases/validations_test.rb | 2 +-
activeresource/test/connection_test.rb | 4 +-
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 +-
ci/ci_setup_notes.txt | 6 +-
ci/site_config.rb | 12 +-
railties/CHANGELOG | 150 ++++-----
railties/README.rdoc | 2 +-
railties/guides/assets/stylesheets/main.css | 28 +-
railties/guides/rails_guides/generator.rb | 14 +-
railties/guides/source/2_3_release_notes.textile | 10 +-
.../source/action_controller_overview.textile | 14 +-
.../guides/source/action_view_overview.textile | 88 +++---
.../guides/source/active_record_basics.textile | 4 +-
.../guides/source/active_record_querying.textile | 12 +-
.../active_record_validations_callbacks.textile | 40 +--
.../source/active_support_core_extensions.textile | 16 +-
railties/guides/source/ajax_on_rails.textile | 34 +-
.../source/api_documentation_guidelines.textile | 4 +-
railties/guides/source/association_basics.textile | 4 +-
railties/guides/source/caching_with_rails.textile | 10 +-
railties/guides/source/command_line.textile | 4 +-
railties/guides/source/configuring.textile | 10 +-
railties/guides/source/getting_started.textile | 22 +-
railties/guides/source/i18n.textile | 2 +-
railties/guides/source/initialization.textile | 110 +++----
.../guides/source/layouts_and_rendering.textile | 18 +-
railties/guides/source/nested_model_forms.textile | 14 +-
railties/guides/source/plugins.textile | 2 +-
.../source/rails_application_templates.textile | 4 +-
railties/guides/source/routing.textile | 4 +-
railties/guides/source/security.textile | 2 +-
railties/guides/w3c_validator.rb | 18 +-
railties/lib/rails/code_statistics.rb | 8 +-
railties/lib/rails/generators/base.rb | 2 +-
.../app/templates/public/javascripts/effects.js | 2 +-
.../lib/rails/generators/rails/generator/USAGE | 2 +-
.../lib/rails/generators/rails/migration/USAGE | 8 +-
railties/lib/rails/generators/rails/plugin/USAGE | 2 +-
.../rails/resource/resource_generator.rb | 4 +-
railties/lib/rails/plugin.rb | 2 +-
railties/lib/rails/railtie.rb | 4 +-
railties/lib/rails/script_rails_loader.rb | 4 +-
railties/lib/rails/tasks/documentation.rake | 8 +-
railties/test/application/loading_test.rb | 6 +-
railties/test/application/rake_test.rb | 2 +-
railties/test/generators/actions_test.rb | 4 +-
railties/test/generators/app_generator_test.rb | 2 +-
railties/test/railties/railtie_test.rb | 2 +-
railties/test/script_rails_loader_test.rb | 8 +-
337 files changed, 2122 insertions(+), 2124 deletions(-)
diff --git a/README.rdoc b/README.rdoc
index 090a6bb68c..2e5e72c0e4 100644
--- a/README.rdoc
+++ b/README.rdoc
@@ -34,7 +34,7 @@ link:files/vendor/rails/actionpack/README.html.
2. At the command prompt, create a new Rails application:
- rails new myapp
+ rails new myapp
where "myapp" is the application name.
@@ -48,7 +48,7 @@ link:files/vendor/rails/actionpack/README.html.
"Welcome aboard: You're riding Ruby on Rails!"
-5. Follow the guidelines to start developing your application. You can find
+5. Follow the guidelines to start developing your application. You can find
the following resources handy:
* The README file created within your application.
diff --git a/actionmailer/CHANGELOG b/actionmailer/CHANGELOG
index 76eab935e5..d2cc70fc85 100644
--- a/actionmailer/CHANGELOG
+++ b/actionmailer/CHANGELOG
@@ -181,7 +181,7 @@
* ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, Marcel Molina Jr.]
-* Replace alias method chaining with Module#alias_method_chain. [Marcel Molina Jr.]
+* Replace alias method chaining with Module#alias_method_chain. [Marcel Molina Jr.]
* Replace Ruby's deprecated append_features in favor of included. [Marcel Molina Jr.]
@@ -327,7 +327,7 @@
* Added that deliver_* will now return the email that was sent
-* Added that quoting to UTF-8 only happens if the characters used are in that range #955 [Jamis Buck]
+* Added that quoting to UTF-8 only happens if the characters used are in that range #955 [Jamis Buck]
* Fixed quoting for all address headers, not just to #955 [Jamis Buck]
@@ -366,7 +366,7 @@
@body = "Nothing to see here."
@charset = "iso-8859-1"
end
-
+
def unencoded_subject(recipient)
@recipients = recipient
@subject = "testing unencoded subject"
@@ -375,7 +375,7 @@
@encode_subject = false
@charset = "iso-8859-1"
end
-
+
*0.6.1* (January 18th, 2005)
diff --git a/actionmailer/README.rdoc b/actionmailer/README.rdoc
index 602326eef7..dfb696eb55 100644
--- a/actionmailer/README.rdoc
+++ b/actionmailer/README.rdoc
@@ -5,7 +5,7 @@ are used to consolidate code for sending out forgotten passwords, welcome
wishes on signup, invoices for billing, and any other use case that requires
a written notification to either a person or another system.
-Action Mailer is in essence a wrapper around Action Controller and the
+Action Mailer is in essence a wrapper around Action Controller and the
Mail gem. It provides a way to make emails using templates in the same
way that Action Controller renders views using templates.
@@ -23,7 +23,7 @@ This can be as simple as:
class Notifier < ActionMailer::Base
delivers_from 'system@loudthinking.com'
-
+
def welcome(recipient)
@recipient = recipient
mail(:to => recipient,
@@ -36,13 +36,13 @@ ERb) that has the instance variables that are declared in the mailer action.
So the corresponding body template for the method above could look like this:
- Hello there,
+ Hello there,
Mr. <%= @recipient %>
Thank you for signing up!
-
-And if the recipient was given as "david@loudthinking.com", the email
+
+And if the recipient was given as "david@loudthinking.com", the email
generated would look like this:
Date: Mon, 25 Jan 2010 22:48:09 +1100
@@ -55,7 +55,7 @@ generated would look like this:
charset="US-ASCII";
Content-Transfer-Encoding: 7bit
- Hello there,
+ Hello there,
Mr. david@loudthinking.com
@@ -75,7 +75,7 @@ Or you can just chain the methods together like:
== Receiving emails
To receive emails, you need to implement a public instance method called receive that takes a
-tmail object as its single parameter. The Action Mailer framework has a corresponding class method,
+tmail object as its single parameter. The Action Mailer framework has a corresponding class method,
which is also called receive, that accepts a raw, unprocessed email as a string, which it then turns
into the tmail object and calls the receive instance method.
@@ -90,7 +90,7 @@ Example:
if email.has_attachments?
for attachment in email.attachments
- page.attachments.create({
+ page.attachments.create({
:file => attachment, :description => email.subject
})
end
@@ -98,13 +98,13 @@ Example:
end
end
-This Mailman can be the target for Postfix or other MTAs. In Rails, you would use the runner in the
+This Mailman can be the target for Postfix or other MTAs. In Rails, you would use the runner in the
trivial case like this:
rails runner 'Mailman.receive(STDIN.read)'
-However, invoking Rails in the runner for each mail to be received is very resource intensive. A single
-instance of Rails should be run within a daemon if it is going to be utilized to process more than just
+However, invoking Rails in the runner for each mail to be received is very resource intensive. A single
+instance of Rails should be run within a daemon if it is going to be utilized to process more than just
a limited number of email.
== Configuration
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb
index f742f982f2..8fe5868d52 100644
--- a/actionmailer/lib/action_mailer/base.rb
+++ b/actionmailer/lib/action_mailer/base.rb
@@ -187,31 +187,31 @@ module ActionMailer #:nodoc:
# with the filename +free_book.pdf+.
#
# = Inline Attachments
- #
- # You can also specify that a file should be displayed inline with other HTML. This is useful
+ #
+ # You can also specify that a file should be displayed inline with other HTML. This is useful
# if you want to display a corporate logo or a photo.
- #
+ #
# class ApplicationMailer < ActionMailer::Base
# def welcome(recipient)
# attachments.inline['photo.png'] = File.read('path/to/photo.png')
# mail(:to => recipient, :subject => "Here is what we look like")
# end
# end
- #
+ #
# And then to reference the image in the view, you create a welcome.html.erb file and
- # make a call to +image_tag+ passing in the attachment you want to display and then call
+ # make a call to +image_tag+ passing in the attachment you want to display and then call
# +url+ on the attachment to get the relative content id path for the image source:
- #
+ #
#
Please Don't Cringe
- #
+ #
# <%= image_tag attachments['photo.png'].url -%>
- #
+ #
# As we are using Action View's +image_tag+ method, you can pass in any other options you want:
- #
+ #
#
@@ -1213,15 +1213,15 @@ Rails provides a very simple HTTP authentication system that will work nicely in
class ApplicationController < ActionController::Base
protect_from_forgery
-
+
private
-
+
def authenticate
authenticate_or_request_with_http_basic do |user_name, password|
user_name == 'admin' && password == 'password'
end
end
-
+
end
@@ -1381,7 +1381,7 @@ Finally, we will edit the app/views/posts/show.html.erb template to sho
@@ -1405,7 +1405,7 @@ Open up app/helpers/posts_helper.rb and add the following:
module PostsHelper
def join_tags(post)
- post.tags.map { |t| t.name }.join(", ")
+ post.tags.map { |t| t.name }.join(", ")
end
end
@@ -1436,7 +1436,7 @@ Now you can edit the view in app/views/posts/show.html.erb to look like
diff --git a/railties/guides/source/i18n.textile b/railties/guides/source/i18n.textile
index 63d22db485..1af51af80e 100644
--- a/railties/guides/source/i18n.textile
+++ b/railties/guides/source/i18n.textile
@@ -518,7 +518,7 @@ es:
title: "Título"
-you can look up the +books.index.title+ value *inside* +app/views/books/index.html.erb+ template like this (note the dot):
+you can look up the +books.index.title+ value *inside* +app/views/books/index.html.erb+ template like this (note the dot):
<%= t '.title' %>
diff --git a/railties/guides/source/initialization.textile b/railties/guides/source/initialization.textile
index f80c00b280..4e257d2e00 100644
--- a/railties/guides/source/initialization.textile
+++ b/railties/guides/source/initialization.textile
@@ -229,7 +229,7 @@ This file goes on to define some classes that will be automatically loaded using
require "active_support/inflector/methods"
require "active_support/lazy_load_hooks"
-
+
module ActiveSupport
module Autoload
def self.extended(base)
@@ -250,7 +250,7 @@ This file goes on to define some classes that will be automatically loaded using
end
super const_name, location
end
-
+
...
end
end
@@ -337,7 +337,7 @@ As you can see for the duration of the +eager_autoload+ block the class variable
autoload :I18n, "active_support/i18n"
-So we know the ones in +eager_autoload+ are eagerly loaded and it does this by storing them in an +@@autoloads+ hash object and then loading them via +eager_autoload!+ which is called via the +preload_frameworks+ initializer defined in _railties/lib/rails/application/bootstrap.rb_.
+So we know the ones in +eager_autoload+ are eagerly loaded and it does this by storing them in an +@@autoloads+ hash object and then loading them via +eager_autoload!+ which is called via the +preload_frameworks+ initializer defined in _railties/lib/rails/application/bootstrap.rb_.
The classes and modules that are not +eager_autoload+'d are automatically loaded as they are references
@@ -423,16 +423,16 @@ Now that Rails has required Action Dispatch and it has required Rack, Rails can
module Rails
class Server < ::Rack::Server
-
+
...
-
+
def initialize(*)
super
set_environment
end
-
+
...
-
+
def set_environment
ENV["RAILS_ENV"] ||= options[:environment]
end
@@ -486,7 +486,7 @@ And +default_options+ like this:
:AccessLog => [],
:config => "config.ru"
}
- end
+ end
Here it is important to note that the default environment is _development_. After +Rack::Server#initialize+ has done its thing it returns to +Rails::Server#initialize+ which calls +set_environment+:
@@ -752,7 +752,7 @@ If you wish to know more about how they're deprecated see the +require 'active_s
h4. +require 'rails/log_subscriber'+
-The +Rails::LogSubscriber+ provides a central location for logging in Rails 3 so as to not slow down the main thread. When you call one of the logging methods (+info+, +debug+, +warn+, +error+, +fatal+ or +unknown+) from the +Rails::LogSubscriber+ class or one of its subclasses this will notify the Rails logger to log this call in the fashion you specify, but will not write it to the file. The file writing is done at the end of the request, courtesy of the +Rails::Rack::Logger+ middleware.
+The +Rails::LogSubscriber+ provides a central location for logging in Rails 3 so as to not slow down the main thread. When you call one of the logging methods (+info+, +debug+, +warn+, +error+, +fatal+ or +unknown+) from the +Rails::LogSubscriber+ class or one of its subclasses this will notify the Rails logger to log this call in the fashion you specify, but will not write it to the file. The file writing is done at the end of the request, courtesy of the +Rails::Rack::Logger+ middleware.
Each Railtie defines its own class that descends from +Rails::LogSubscriber+ with each defining its own methods for logging individual tasks.
@@ -821,7 +821,7 @@ TODO: Quotify.
Active Record connects business objects and database tables to create a persistable domain model where logic and data are presented in one wrapping. It's an implementation of the object-relational mapping (ORM) pattern by the same name as described by Martin Fowler:
- "An object that wraps a row in a database table or view, encapsulates
+ "An object that wraps a row in a database table or view, encapsulates
the database access, and adds domain logic on that data."
Active Record's main contribution to the pattern is to relieve the original of two stunting problems:
@@ -910,7 +910,7 @@ h5. +require 'active_record'+
Back the initial require from the _railtie.rb_.
-The _active_support_ and _active_model_ requires are again just an insurance for if we're loading Active Record outside of the scope of Rails. In _active_record.rb_ the ActiveRecord +Module+ is initialized and in it there is defined a couple of +autoloads+ and +eager_autoloads+.
+The _active_support_ and _active_model_ requires are again just an insurance for if we're loading Active Record outside of the scope of Rails. In _active_record.rb_ the ActiveRecord +Module+ is initialized and in it there is defined a couple of +autoloads+ and +eager_autoloads+.
There's a new method here called +autoload_under+ which is defined in +ActiveSupport::Autoload+. This sets the autoload path to temporarily be the specified path, in this case +relation+ for the +autoload+'d classes inside the block.
@@ -935,7 +935,7 @@ Inside the Active Record Railtie the +ActiveRecord::Railtie+ class is defined:
module ActiveRecord
class Railtie < Rails::Railtie
-
+
...
end
end
@@ -964,8 +964,8 @@ This Railtie is +require+'d by Active Record's Railtie.
From the Active Model readme:
- Prior to Rails 3.0, if a plugin or gem developer wanted to be able to have an object interact with Action Pack helpers, it was required to either copy chunks of code from Rails, or monkey patch entire helpers to make them handle objects that did not look like Active Record. This generated code duplication and fragile applications that broke on upgrades.
-
+ Prior to Rails 3.0, if a plugin or gem developer wanted to be able to have an object interact with Action Pack helpers, it was required to either copy chunks of code from Rails, or monkey patch entire helpers to make them handle objects that did not look like Active Record. This generated code duplication and fragile applications that broke on upgrades.
+
Active Model is a solution for this problem.
Active Model provides a known set of interfaces that your objects can implement to then present a common interface to the Action Pack helpers.
@@ -999,7 +999,7 @@ This first makes a couple of requires:
require "action_view/railtie"
-The _action_controller_ file is explained in the very next section. The require to _rails_ is requiring the already-required _railties/lib/rails.rb_. If you wish to know about the require to _action_view/railtie_ this is explained in the Action View Railtie section.
+The _action_controller_ file is explained in the very next section. The require to _rails_ is requiring the already-required _railties/lib/rails.rb_. If you wish to know about the require to _action_view/railtie_ this is explained in the Action View Railtie section.
h5. +require 'action_controller+
@@ -1009,7 +1009,7 @@ h5. +require 'abstract_controller'+
+AbstractController+ provides the functionality of TODO.
-This file is in _actionpack/lib/abstract_controller.rb_ and begins by attempting to add the path to Active Support to the load path, which it would succeed in if it wasn't already set by anything loaded before it. In this case, it's not going to be set due to Arel already loading it in (TODO: right?).
+This file is in _actionpack/lib/abstract_controller.rb_ and begins by attempting to add the path to Active Support to the load path, which it would succeed in if it wasn't already set by anything loaded before it. In this case, it's not going to be set due to Arel already loading it in (TODO: right?).
The next thing in this file four +require+ calls:
@@ -1146,9 +1146,9 @@ For an explanation of this file _activesupport/lib/active_support/core_ext/class
h5. +require 'active_support/deprecation/proxy_wrappers'+
-This file, _activesupport/lib/active_support/deprecation/proxy_wrappers.rb_, defines a couple of deprecation classes, which are +DeprecationProxy+, +DeprecationObjectProxy+, +DeprecationInstanceVariableProxy+, +DeprecationConstantProxy+ which are all namespaced into +ActiveSupport::Deprecation+. These last three are all subclasses of +DeprecationProxy+.
+This file, _activesupport/lib/active_support/deprecation/proxy_wrappers.rb_, defines a couple of deprecation classes, which are +DeprecationProxy+, +DeprecationObjectProxy+, +DeprecationInstanceVariableProxy+, +DeprecationConstantProxy+ which are all namespaced into +ActiveSupport::Deprecation+. These last three are all subclasses of +DeprecationProxy+.
-Why do we mention them here? Beside the obvious-by-now fact that we're covering just about everything about the initialization process in this guide, if you're deprecating something in your library and you use Active Support, you too can use the +DeprecationProxy+ class (and it's subclasses) too.
+Why do we mention them here? Beside the obvious-by-now fact that we're covering just about everything about the initialization process in this guide, if you're deprecating something in your library and you use Active Support, you too can use the +DeprecationProxy+ class (and it's subclasses) too.
h6. +DeprecationProxy+
@@ -1177,7 +1177,7 @@ This class is used only in _railties/lib/rails/deprecation.rb_, loaded further o
end).new
-There is similar definitions for the other constants of +RAILS_ENV+ and +RAILS_DEFAULT_LOGGER+. All three of these constants are in the midst of being deprecated (most likely in Rails 3.1) so Rails will tell you if you reference them that they're deprecated using the +DeprecationProxy+ class. Whenever you call +RAILS_ROOT+ this will raise a warning, telling you: "RAILS_ROOT is deprecated! Use Rails.root instead".... TODO: investigate if simply calling it does raise this warning. This same rule applies to +RAILS_ENV+ and +RAILS_DEFAULT_LOGGER+, their new alternatives are +Rails.env+ and +Rails.logger+ respectively.
+There is similar definitions for the other constants of +RAILS_ENV+ and +RAILS_DEFAULT_LOGGER+. All three of these constants are in the midst of being deprecated (most likely in Rails 3.1) so Rails will tell you if you reference them that they're deprecated using the +DeprecationProxy+ class. Whenever you call +RAILS_ROOT+ this will raise a warning, telling you: "RAILS_ROOT is deprecated! Use Rails.root instead".... TODO: investigate if simply calling it does raise this warning. This same rule applies to +RAILS_ENV+ and +RAILS_DEFAULT_LOGGER+, their new alternatives are +Rails.env+ and +Rails.logger+ respectively.
h6. +DeprecatedObjectProxy+
@@ -1203,7 +1203,7 @@ This makes more sense in the wider scope of the initializer:
end
-+ActionController::Routing::Routes+ was the previous constant used in defining routes in Rails 2 applications, now it's simply a method on +Rails.application+ rather than it's own individual class: +Rails.application.routes+. Both of these still call the +draw+ method on the returned object to end up defining the routes.
++ActionController::Routing::Routes+ was the previous constant used in defining routes in Rails 2 applications, now it's simply a method on +Rails.application+ rather than it's own individual class: +Rails.application.routes+. Both of these still call the +draw+ method on the returned object to end up defining the routes.
h6. +DeprecatedInstanceVariableProxy+
@@ -1362,7 +1362,7 @@ Here again we have the addition of the path to Active Support to the load path a
And these have already been required. If you wish to know what these files do go to the explanation of each in the "Common Includes" section. TODO: link to them!
-This file goes on to +require 'action_pack'+ which consists of all this code (comments stripped):
+This file goes on to +require 'action_pack'+ which consists of all this code (comments stripped):
require 'action_pack/version'
@@ -1445,11 +1445,11 @@ After including +ActiveSupport::Benchmarkable+, the helpers which we have declar
h5. +ActionView::Rendering+
-This module, from _actionpack/lib/action_view/render/rendering.rb_ defines a method you may be a little too familiar with: +render+. This is the +render+ use for rendering all kinds of things, such as partials, templates and text.
+This module, from _actionpack/lib/action_view/render/rendering.rb_ defines a method you may be a little too familiar with: +render+. This is the +render+ use for rendering all kinds of things, such as partials, templates and text.
h5. +ActionView::Partials+
-This module, from _actionpack/lib/action_view/render/partials.rb_, defines +ActionView::Partials::PartialRenderer+ which you can probably guess is used for rendering partials.
+This module, from _actionpack/lib/action_view/render/partials.rb_, defines +ActionView::Partials::PartialRenderer+ which you can probably guess is used for rendering partials.
h5. +ActionView::Layouts+
@@ -1487,7 +1487,7 @@ Next, the Railtie itself is defined:
end
end
end
-
+
The +ActionView::LogSubscriber+ sets up a method called +render_template+ which is called when a template is rendered. TODO: Templates only or partials and layouts also? I would imagine these fall under the templates category, but there needs to research to ensure this is correct.
@@ -1502,7 +1502,7 @@ are used to consolidate code for sending out forgotten passwords, welcome
wishes on signup, invoices for billing, and any other use case that requires
a written notification to either a person or another system.
-Action Mailer is in essence a wrapper around Action Controller and the
+Action Mailer is in essence a wrapper around Action Controller and the
Mail gem. It provides a way to make emails using templates in the same
way that Action Controller renders views using templates.
@@ -1580,7 +1580,7 @@ which is used by the +ActionMailer::MailerHelper+ method +block_format+:
:columns => 72, :first_indent => 2, :body_indent => 2, :text => paragraph
).format
}.join("\n")
-
+
# Make list points stand on their own line
formatted.gsub!(/[ ]*([*]+) ([^*]*)/) { |s| " #{$1} #{$2.strip}\n" }
formatted.gsub!(/[ ]*([#]+) ([^#]*)/) { |s| " #{$1} #{$2.strip}\n" }
@@ -1687,7 +1687,7 @@ There is only one initializer defined here: +set_configs+. This is covered later
h4. ActionDispatch Railtie
-ActionDispatch handles all dispatch work for Rails. It interfaces with Action Controller to determine what action to undertake when a request comes in. TODO: I would quote the README but it is strangely absent. Flyin' blind here!
+ActionDispatch handles all dispatch work for Rails. It interfaces with Action Controller to determine what action to undertake when a request comes in. TODO: I would quote the README but it is strangely absent. Flyin' blind here!
The ActionDispatch Railtie was previously required when we called +require 'rails'+, but we will cover the Railtie here too.
@@ -1817,7 +1817,7 @@ This +called_from+ setting looks a little overwhelming to begin with, but the sh
base.send(:include, self::Configurable)
subclasses << base
end
- end
+ end
Again, +YourApp::Application+ will return false for +abstract_railtie+ and so the code inside the +unless+ will be ran. The first line:
@@ -1886,7 +1886,7 @@ Now that we've covered the boot process of Rails the next line best to cover wou
Rails::Server.start
-The keen-eyed observer will note that this +when+ also specifies the argument could also be simply +'s'+ thereby making the full command +rails s+. This is the same with the other commands with +generate+ becoming +g+, +console+ becoming +c+ and +dbconsole+ becoming +db+.
+The keen-eyed observer will note that this +when+ also specifies the argument could also be simply +'s'+ thereby making the full command +rails s+. This is the same with the other commands with +generate+ becoming +g+, +console+ becoming +c+ and +dbconsole+ becoming +db+.
This code here ensures we are at the +ROOT_PATH+ of our application (this constant was defined in _script/rails_) and then calls +Rails::Server.start+. +Rails::Server+ descends from +Rack::Server+ which is defined in the rack gem. The +Rails::Server.start+ method is defined like this:
@@ -1997,7 +1997,7 @@ Finally! We've arrived at +default_options+ which leads into our next point quit
end
-We're not debugging anything, so there goes the first 7 lines, we're not warning, nor are we including, requiring, daemonising or writing out a pid file. That's everything except the final line, which calls +run+ with the +wrapped_app+ which is then defined like this:
+We're not debugging anything, so there goes the first 7 lines, we're not warning, nor are we including, requiring, daemonising or writing out a pid file. That's everything except the final line, which calls +run+ with the +wrapped_app+ which is then defined like this:
def wrapped_app
@@ -2051,7 +2051,7 @@ First this reads your config file and checks it for +#\+ at the beginning. This
require ::File.expand_path('../config/environment', __FILE__)
run YourApp::Application.instance
-
+
TODO: Is the above correct? I am simply guessing!
@@ -2246,7 +2246,7 @@ The method +find_with_root_flag+ is defined on +Rails::Engine+ (the superclass o
Pathname.new(root).expand_path : Pathname.new(root).realpath
end
-
+
+called_from+ goes through the +caller+ which is the stacktrace of the current thread, in the case of your application it would go a little like this:
@@ -2274,7 +2274,7 @@ The method +find_with_root_flag+ is defined on +Rails::Engine+ (the superclass o
end
-The +call_stack+ here is the +caller+ output shown previously, minus everything after the first +:+ on all the lines. The first path that matches this is _/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta1/lib/rails_. Yours may vary slightly, but should always end in _railties-x.x.x/lib/rails_.
+The +call_stack+ here is the +caller+ output shown previously, minus everything after the first +:+ on all the lines. The first path that matches this is _/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta1/lib/rails_. Yours may vary slightly, but should always end in _railties-x.x.x/lib/rails_.
The code in +find_root_with_flag+ will go up this directory structure until it reaches the top, which in this case is +/+.
@@ -2302,7 +2302,7 @@ At the root of the system it looks for +config.ru+. TODO: Why? Obviously it's no
@serve_static_assets = true
@time_zone = "UTC"
@consider_all_requests_local = true
- end
+ end
The +super+ method here is the +initialize+ method in +Rails::Engine::Configuration+:
@@ -2604,7 +2604,7 @@ The +plugins+ method it calls is a little more complex:
When we call +@config.paths.vendor.plugins+ it will return +"vendor/plugins"+.
-
+
If you've defined specific plugin requirements for your application in _config/application.rb_ by using this code:
@@ -2725,7 +2725,7 @@ Now we finally have all the +initializers+ we can go through them and call +run+
end
-You may remember that the +@context+ in this code is +YourApp::Application+ and calling +instance_exec+ on this class will make a new instance of it and execute the code within the +&block+ passed to it. This code within the block is the code from all the initializers.
+You may remember that the +@context+ in this code is +YourApp::Application+ and calling +instance_exec+ on this class will make a new instance of it and execute the code within the +&block+ passed to it. This code within the block is the code from all the initializers.
h3. Bootstrap Initializers
@@ -2759,15 +2759,15 @@ We've seen +config.paths+ before when loading the plugins and they're explained
module Rails
class << self
-
+
...
-
+
def env
@_env ||= ActiveSupport::StringInquirer.new(ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development")
end
-
+
...
-
+
end
end
@@ -2953,7 +2953,7 @@ This is where it gets loaded. The +eager_autoload!+ method is defined like this:
end
-With +@@autoloads+ being
+With +@@autoloads+ being
* load_all_active_support
@@ -3144,9 +3144,9 @@ h4. +ActionDispatch::MiddlewareStack.new+
module ActionDispatch
class MiddlewareStack < Array
-
+
...
-
+
def initialize(*args, &block)
super(*args)
block.call(self) if block_given?
@@ -3188,9 +3188,9 @@ This +initialize+ method also is in a class who's ancestry is important so once
module ActionController
class Middleware < Metal
-
+
...
-
+
def initialize(app)
super()
@_app = app
@@ -3207,9 +3207,9 @@ This is another subclassed class, this time from +ActionController::AbstractCont
class Metal < AbstractController::Base
-
+
...
-
+
def initialize(*)
@_headers = {}
super
@@ -3217,7 +3217,7 @@ This is another subclassed class, this time from +ActionController::AbstractCont
end
-The single +*+ in the argument listing means we can accept any number of arguments, we just don't care what they are.
+The single +*+ in the argument listing means we can accept any number of arguments, we just don't care what they are.
h4. +AbstractController::Base.initialize+
@@ -3232,7 +3232,7 @@ This may be anti-climatic, but the initialize method here just returns an +Abstr
h4. +ActionDispatch::MiddlewareStack.use+
-Now we're back to this method, from our foray into the depths of how +Middleware.new+ works, we've showed that it is an instance of +AbstractController::Base+. Therefore it does
+Now we're back to this method, from our foray into the depths of how +Middleware.new+ works, we've showed that it is an instance of +AbstractController::Base+. Therefore it does
TODO: ELABORATE ON THIS SECTION, including explaining what all the pieces of middleware do. Then explain how the default_middleware_stack does what it does, whatever that is.
@@ -3309,7 +3309,7 @@ In a standard Rails application we have this in our _config/environments/develop
end
-It's a little bit sneaky here, but +configure+ is +alias+'d to +class_eval+ on subclasses of +Rails::Application+ which of course includes +YourApp::Application+. This means that the code inside the +configure do+ block will be evaled within the context of +YourApp::Application+. The +config+ method here is the one mentioned before: the +Rails::Application::Configuration+ object. The methods on it should look familiar too: they're the ones that had +attr_accessor+ and +attr_writer+ definitions.
+It's a little bit sneaky here, but +configure+ is +alias+'d to +class_eval+ on subclasses of +Rails::Application+ which of course includes +YourApp::Application+. This means that the code inside the +configure do+ block will be evaled within the context of +YourApp::Application+. The +config+ method here is the one mentioned before: the +Rails::Application::Configuration+ object. The methods on it should look familiar too: they're the ones that had +attr_accessor+ and +attr_writer+ definitions.
The ones down the bottom, +config.action_controller+, +config.action_view+ and +config.action_mailer+ aren't defined by +attr_accessor+ or +attr_writer+, rather they're undefined methods and therefore will trigger the +method_missing+ on the +Rails::Application::Configuration+ option.
@@ -3381,7 +3381,7 @@ I'm going to show you two methods since the third one, +self.plugin_name+, calls
@plugins ||= []
@plugins << klass unless klass == Plugin
end
-
+
def self.plugins
@plugins
end
@@ -3472,7 +3472,7 @@ h5. +Rack::Handler::WEBrick+
This class is subclassed from +WEBrick::HTTPServlet::AbstractServlet+ which is a class that comes with the Ruby standard library. This is the magical class that serves the requests and deals with the comings (requests) and goings (responses) for your server.
-+Rack::Server+ has handlers for the request and by default the handler for a _rails server_ server is
++Rack::Server+ has handlers for the request and by default the handler for a _rails server_ server is
h3. Cruft!
@@ -3706,7 +3706,7 @@ This file is _activesupport/lib/active_support/inflector.rb_ and makes a couple
require 'active_support/core_ext/string/inflections'
-The files included here define methods for modifying strings, such as +transliterate+ which will convert a Unicode string to its ASCII version, +parameterize+ for making strings into url-safe versions, +camelize+ for camel-casing a string such as +string_other+ into +StringOther+ and +ordinalize+ converting a string such as +101+ into +101st+. More information about these methods can be found in the Active Support Core Extensions Guide. TODO: Link to AS Guide.
+The files included here define methods for modifying strings, such as +transliterate+ which will convert a Unicode string to its ASCII version, +parameterize+ for making strings into url-safe versions, +camelize+ for camel-casing a string such as +string_other+ into +StringOther+ and +ordinalize+ converting a string such as +101+ into +101st+. More information about these methods can be found in the Active Support Core Extensions Guide. TODO: Link to AS Guide.
h4. +require 'active_support/core_ext/module/delegation'+
@@ -3715,7 +3715,7 @@ _activesupport/lib/active_support/core_ext/module/delegation.rb_ defines the +de
class Client < ActiveRecord::Base
has_one :address
-
+
delegate :address_line_1, :to => :address
end
@@ -3736,7 +3736,7 @@ h4. +require 'active_support/core_ext/class/attribute_accessors'+
The file, _activesupport/lib/active_support/core_ext/class/attribute_accessors.rb_, defines the class accessor methods +cattr_writer+, +cattr_reader+ and +cattr_accessor+. +cattr_accessor+ defines a +cattr_reader+ and +cattr_writer+ for the symbol passed in. These methods work by defining class variables when you call their dynamic methods.
-Throughout the Railties there a couple of common includes. They are listed here for your convenience.
+Throughout the Railties there a couple of common includes. They are listed here for your convenience.
h4. +require 'active_support/core_ext/module/attr_internal+
diff --git a/railties/guides/source/layouts_and_rendering.textile b/railties/guides/source/layouts_and_rendering.textile
index b9a201e5f0..fe5b4c8773 100644
--- a/railties/guides/source/layouts_and_rendering.textile
+++ b/railties/guides/source/layouts_and_rendering.textile
@@ -143,7 +143,7 @@ def update
end
-If the call to +update_attributes+ fails, calling the +update+ action in this controller will render the +edit.html.erb+ template belonging to the same controller.
+If the call to +update_attributes+ fails, calling the +update+ action in this controller will render the +edit.html.erb+ template belonging to the same controller.
If you prefer, you can use a symbol instead of a string to specify the action to render:
@@ -200,7 +200,7 @@ render "/u/apps/warehouse_app/current/app/views/products/show"
Rails determines that this is a file render because of the leading slash character. To be explicit, you can use the +:file+ option (which was required on Rails 2.2 and earlier):
-render :file =>
+render :file =>
"/u/apps/warehouse_app/current/app/views/products/show"
@@ -240,7 +240,7 @@ h5. Using +render+ with +:inline+
The +render+ method can do without a view completely, if you're willing to use the +:inline+ option to supply ERB as part of the method call. This is perfectly valid:
-render :inline =>
+render :inline =>
"<% products.each do |p| %>
<%= p.name %>
<% end %>"
@@ -249,7 +249,7 @@ WARNING: There is seldom any good reason to use this option. Mixing ERB into you
By default, inline rendering uses ERb. You can force it to use Builder instead with the +:type+ option:
-render :inline =>
+render :inline =>
"xml.p {'Horrid coding practice!'}", :type => :builder
@@ -676,7 +676,7 @@ h5. Linking to Feeds with +auto_discovery_link_tag+
The +auto_discovery_link_tag+ helper builds HTML that most browsers and newsreaders can use to detect the presences of RSS or ATOM feeds. It takes the type of the link (+:rss+ or +:atom+), a hash of options that are passed through to url_for, and a hash of options for the tag:
-<%= auto_discovery_link_tag(:rss, {:action => "feed"},
+<%= auto_discovery_link_tag(:rss, {:action => "feed"},
{:title => "RSS Feed"}) %>
@@ -739,7 +739,7 @@ If you're loading multiple javascript files, you can create a better user experi
By default, the combined file will be delivered as +javascripts/all.js+. You can specify a location for the cached asset file instead:
-<%= javascript_include_tag "main", "columns",
+<%= javascript_include_tag "main", "columns",
:cache => 'cache/main/display' %>
@@ -798,7 +798,7 @@ If you're loading multiple CSS files, you can create a better user experience by
By default, the combined file will be delivered as +stylesheets/all.css+. You can specify a location for the cached asset file instead:
-<%= stylesheet_link_tag "main", "columns",
+<%= stylesheet_link_tag "main", "columns",
:cache => 'cache/main/display' %>
@@ -1085,7 +1085,7 @@ Partials are very useful in rendering collections. When you pass a collection to
Product Name: <%= product.name %>
-When a partial is called with a pluralized collection, then the individual instances of the partial have access to the member of the collection being rendered via a variable named after the partial. In this case, the partial is +_product+, and within the +_product+ partial, you can refer to +product+ to get the instance that is being rendered.
+When a partial is called with a pluralized collection, then the individual instances of the partial have access to the member of the collection being rendered via a variable named after the partial. In this case, the partial is +_product+, and within the +_product+ partial, you can refer to +product+ to get the instance that is being rendered.
In Rails 3.0 there is also a shorthand for this, assuming +@posts+ is a collection of +post+ instances, you can simply do in the +index.html.erb+:
@@ -1132,7 +1132,7 @@ With this change, you can access an instance of the +@products+ collection as th
You can also pass in arbitrary local variables to any partial you are rendering with the +:locals => {}+ option:
-<%= render :partial => 'products', :collection => @products,
+<%= render :partial => 'products', :collection => @products,
:as => :item, :locals => {:title => "Products Page"} %>
diff --git a/railties/guides/source/nested_model_forms.textile b/railties/guides/source/nested_model_forms.textile
index 39b0c32f24..1d44da4df1 100644
--- a/railties/guides/source/nested_model_forms.textile
+++ b/railties/guides/source/nested_model_forms.textile
@@ -63,7 +63,7 @@ class Person
def address
Address.new
end
-
+
def address_attributes=(attributes)
# ...
end
@@ -77,7 +77,7 @@ class Person
def projects
[Project.new, Project.new]
end
-
+
def projects_attributes=(attributes)
# ...
end
@@ -101,7 +101,7 @@ class PeopleController < ActionController:Base
@person.built_address
2.times { @person.projects.build }
end
-
+
def create
@person = Person.new(params[:person])
if @person.save
@@ -142,7 +142,7 @@ Now add a nested form for the +address+ association:
<%= form_for @person do |f| %>
<%= f.text_field :name %>
-
+
<%= f.fields_for :address do |af| %>
<%= f.text_field :street %>
<% end %>
@@ -154,7 +154,7 @@ This generates:
@@ -183,7 +183,7 @@ The form code for an association collection is pretty similar to that of a singl
<%= form_for @person do |f| %>
<%= f.text_field :name %>
-
+
<%= f.fields_for :projects do |pf| %>
<%= f.text_field :name %>
<% end %>
@@ -195,7 +195,7 @@ Which generates:
diff --git a/railties/guides/source/plugins.textile b/railties/guides/source/plugins.textile
index 82f2276153..f89043f216 100644
--- a/railties/guides/source/plugins.textile
+++ b/railties/guides/source/plugins.textile
@@ -323,7 +323,7 @@ Finally, create the +core_ext.rb+ file and add the +to_squawk+ method:
# vendor/plugins/yaffle/lib/yaffle/core_ext.rb
-
+
String.class_eval do
def to_squawk
"squawk! #{self}".strip
diff --git a/railties/guides/source/rails_application_templates.textile b/railties/guides/source/rails_application_templates.textile
index 1bf9cfec33..bc7b151dfe 100644
--- a/railties/guides/source/rails_application_templates.textile
+++ b/railties/guides/source/rails_application_templates.textile
@@ -79,7 +79,7 @@ plugin 'authentication', :git => 'git://github.com/foor/bar.git'
You can even install plugins as git submodules :
-plugin 'authentication', :git => 'git://github.com/foor/bar.git',
+plugin 'authentication', :git => 'git://github.com/foor/bar.git',
:submodule => true
@@ -103,7 +103,7 @@ class Object
def not_nil?
!nil?
end
-
+
def not_blank?
!blank?
end
diff --git a/railties/guides/source/routing.textile b/railties/guides/source/routing.textile
index 625941ba31..d92c66cfd2 100644
--- a/railties/guides/source/routing.textile
+++ b/railties/guides/source/routing.textile
@@ -501,7 +501,7 @@ class BlacklistConstraint
end
TwitterClone::Application.routes.draw do
- match "*path" => "blacklist#index",
+ match "*path" => "blacklist#index",
:constraints => BlacklistConstraint.new
end
@@ -765,7 +765,7 @@ formatted_users GET /users.:format {:controller=>"users", :action=>"index"}
You may restrict the listing to the routes that map to a particular controller setting the +CONTROLLER+ environment variable:
-$ CONTROLLER=users rake routes
+$ CONTROLLER=users rake routes
TIP: You'll find that the output from +rake routes+ is much more readable if you widen your terminal window until the output lines don't wrap.
diff --git a/railties/guides/source/security.textile b/railties/guides/source/security.textile
index 6372c606b7..4656cf4e40 100644
--- a/railties/guides/source/security.textile
+++ b/railties/guides/source/security.textile
@@ -401,7 +401,7 @@ Note that this vulnerability is not restricted to database columns. Any setter
class Child < ActiveRecord::Base
belongs_to :person
- end
+ end
As a result, the vulnerability is extended beyond simply exposing column assignment, allowing attackers the ability to create entirely new records in referenced tables (children in this case).
diff --git a/railties/guides/w3c_validator.rb b/railties/guides/w3c_validator.rb
index 4da48bf3fb..da5200c0b7 100644
--- a/railties/guides/w3c_validator.rb
+++ b/railties/guides/w3c_validator.rb
@@ -21,7 +21,7 @@
#
# Separate many using commas:
#
-# # validates only
+# # validates only
# ONLY=assoc,migrations rake validate_guides
#
# ---------------------------------------------------------------------------
@@ -32,13 +32,13 @@ include W3CValidators
module RailsGuides
class Validator
-
+
def validate
validator = MarkupValidator.new
STDOUT.sync = true
errors_on_guides = {}
- guides_to_validate.each do |f|
+ guides_to_validate.each do |f|
results = validator.validate_file(f)
if results.validity
@@ -48,10 +48,10 @@ module RailsGuides
errors_on_guides[f] = results.errors
end
end
-
+
show_results(errors_on_guides)
end
-
+
private
def guides_to_validate
guides = Dir["./guides/output/*.html"]
@@ -65,13 +65,13 @@ module RailsGuides
prefixes.any? {|p| guide.start_with?("./guides/output/#{p}")}
end
end
-
+
def show_results(error_list)
if error_list.size == 0
puts "\n\nAll checked guides validate OK!"
else
error_summary = error_detail = ""
-
+
error_list.each_pair do |name, errors|
error_summary += "\n #{name}"
error_detail += "\n\n #{name} has #{errors.size} validation error(s):\n"
@@ -79,12 +79,12 @@ module RailsGuides
error_detail += "\n "+error.to_s.gsub("\n", "")
end
end
-
+
puts "\n\nThere are #{error_list.size} guides with validation errors:\n" + error_summary
puts "\nHere are the detailed errors for each guide:" + error_detail
end
end
-
+
end
end
diff --git a/railties/lib/rails/code_statistics.rb b/railties/lib/rails/code_statistics.rb
index 740d8a1767..57e29a0045 100644
--- a/railties/lib/rails/code_statistics.rb
+++ b/railties/lib/rails/code_statistics.rb
@@ -12,7 +12,7 @@ class CodeStatistics #:nodoc:
print_header
@pairs.each { |pair| print_line(pair.first, @statistics[pair.first]) }
print_splitter
-
+
if @total
print_line("Total", @total)
print_splitter
@@ -29,7 +29,7 @@ class CodeStatistics #:nodoc:
def calculate_directory_statistics(directory, pattern = /.*\.rb$/)
stats = { "lines" => 0, "codelines" => 0, "classes" => 0, "methods" => 0 }
- Dir.foreach(directory) do |file_name|
+ Dir.foreach(directory) do |file_name|
if File.stat(directory + "/" + file_name).directory? and (/^\./ !~ file_name)
newstats = calculate_directory_statistics(directory + "/" + file_name, pattern)
stats.each { |k, v| stats[k] += newstats[k] }
@@ -85,10 +85,10 @@ class CodeStatistics #:nodoc:
start = if TEST_TYPES.include? name
"| #{name.ljust(20)} "
else
- "| #{name.ljust(20)} "
+ "| #{name.ljust(20)} "
end
- puts start +
+ puts start +
"| #{statistics["lines"].to_s.rjust(5)} " +
"| #{statistics["codelines"].to_s.rjust(5)} " +
"| #{statistics["classes"].to_s.rjust(7)} " +
diff --git a/railties/lib/rails/generators/base.rb b/railties/lib/rails/generators/base.rb
index fdfceb14ce..f97f3db588 100644
--- a/railties/lib/rails/generators/base.rb
+++ b/railties/lib/rails/generators/base.rb
@@ -81,7 +81,7 @@ module Rails
# guessed based on class invokes hook_for, as noticed in the example above.
# This can be customized with two options: :base and :as.
#
- # Let's suppose you are creating a generator that needs to invoke the
+ # Let's suppose you are creating a generator that needs to invoke the
# controller generator from test unit. Your first attempt is:
#
# class AwesomeGenerator < Rails::Generators::Base
diff --git a/railties/lib/rails/generators/rails/app/templates/public/javascripts/effects.js b/railties/lib/rails/generators/rails/app/templates/public/javascripts/effects.js
index 066ee5909c..c81e6c7d5f 100644
--- a/railties/lib/rails/generators/rails/app/templates/public/javascripts/effects.js
+++ b/railties/lib/rails/generators/rails/app/templates/public/javascripts/effects.js
@@ -150,7 +150,7 @@ var Effect = {
toggle: function(element, effect, options) {
element = $(element);
effect = (effect || 'appear').toLowerCase();
-
+
return Effect[ Effect.PAIRS[ effect ][ element.visible() ? 1 : 0 ] ](element, Object.extend({
queue: { position:'end', scope:(element.id || 'global'), limit: 1 }
}, options || {}));
diff --git a/railties/lib/rails/generators/rails/generator/USAGE b/railties/lib/rails/generators/rails/generator/USAGE
index d8c3f7f634..d68539e4a6 100644
--- a/railties/lib/rails/generators/rails/generator/USAGE
+++ b/railties/lib/rails/generators/rails/generator/USAGE
@@ -1,6 +1,6 @@
Description:
Stubs out a new generator at lib/generators. Pass the generator name, either
- CamelCased or under_scored, as an argument.
+ CamelCased or under_scored, as an argument.
Example:
`rails generate generator Awesome`
diff --git a/railties/lib/rails/generators/rails/migration/USAGE b/railties/lib/rails/generators/rails/migration/USAGE
index d21c81b760..af74963b01 100644
--- a/railties/lib/rails/generators/rails/migration/USAGE
+++ b/railties/lib/rails/generators/rails/migration/USAGE
@@ -18,12 +18,12 @@ Example:
This will create the AddTitleBodyToPost in db/migrate/20080514090912_add_title_body_to_post.rb with
this in the Up migration:
- add_column :posts, :title, :string
- add_column :posts, :body, :text
+ add_column :posts, :title, :string
+ add_column :posts, :body, :text
add_column :posts, :published, :boolean
And this in the Down migration:
- remove_column :posts, :published
- remove_column :posts, :body
+ remove_column :posts, :published
+ remove_column :posts, :body
remove_column :posts, :title
diff --git a/railties/lib/rails/generators/rails/plugin/USAGE b/railties/lib/rails/generators/rails/plugin/USAGE
index 00a429c585..1bcfcf190d 100644
--- a/railties/lib/rails/generators/rails/plugin/USAGE
+++ b/railties/lib/rails/generators/rails/plugin/USAGE
@@ -1,6 +1,6 @@
Description:
Stubs out a new plugin at vendor/plugins. Pass the plugin name, either
- CamelCased or under_scored, as an argument.
+ CamelCased or under_scored, as an argument.
Example:
`rails generate plugin BrowserFilters`
diff --git a/railties/lib/rails/generators/rails/resource/resource_generator.rb b/railties/lib/rails/generators/rails/resource/resource_generator.rb
index fc070026d6..8a943013d3 100644
--- a/railties/lib/rails/generators/rails/resource/resource_generator.rb
+++ b/railties/lib/rails/generators/rails/resource/resource_generator.rb
@@ -16,9 +16,9 @@ module Rails
def add_resource_route
return if options[:actions].present?
- route_config = class_path.collect{|namespace| "namespace :#{namespace} do " }.join(" ")
+ route_config = class_path.collect{|namespace| "namespace :#{namespace} do " }.join(" ")
route_config << "resources :#{file_name.pluralize}"
- route_config << " end" * class_path.size
+ route_config << " end" * class_path.size
route route_config
end
end
diff --git a/railties/lib/rails/plugin.rb b/railties/lib/rails/plugin.rb
index be229cc9a2..8d5132a5ca 100644
--- a/railties/lib/rails/plugin.rb
+++ b/railties/lib/rails/plugin.rb
@@ -16,7 +16,7 @@ module Rails
# Besides this conceptual difference, the only difference between Rails::Engine and
# Rails::Plugin is that plugins automatically load the file "init.rb" at the plugin
# root during the boot process.
- #
+ #
class Plugin < Engine
def self.inherited(base)
raise "You cannot inherit from Rails::Plugin"
diff --git a/railties/lib/rails/railtie.rb b/railties/lib/rails/railtie.rb
index 8a6e2716dc..2684552701 100644
--- a/railties/lib/rails/railtie.rb
+++ b/railties/lib/rails/railtie.rb
@@ -48,7 +48,7 @@ module Rails
# # lib/my_gem/railtie.rb
# require 'my_gem'
# require 'rails'
- #
+ #
# module MyGem
# class Railtie < Rails::Railtie
# end
@@ -121,7 +121,7 @@ module Rails
# described here can be used in all three.
#
# Be sure to look at the documentation of those specific classes for more information.
- #
+ #
class Railtie
autoload :Configurable, "rails/railtie/configurable"
autoload :Configuration, "rails/railtie/configuration"
diff --git a/railties/lib/rails/script_rails_loader.rb b/railties/lib/rails/script_rails_loader.rb
index 91672e5d81..7054089614 100644
--- a/railties/lib/rails/script_rails_loader.rb
+++ b/railties/lib/rails/script_rails_loader.rb
@@ -17,11 +17,11 @@ module Rails
rescue SystemCallError
# could not chdir, no problem just return
end
-
+
def self.in_rails_application?
File.exists?(SCRIPT_RAILS)
end
-
+
def self.in_rails_application_subdirectory?(path = Pathname.new(Dir.pwd))
File.exists?(File.join(path, SCRIPT_RAILS)) || !path.root? && in_rails_application_subdirectory?(path.parent)
end
diff --git a/railties/lib/rails/tasks/documentation.rake b/railties/lib/rails/tasks/documentation.rake
index c1b1a41d48..7aefbb49b0 100644
--- a/railties/lib/rails/tasks/documentation.rake
+++ b/railties/lib/rails/tasks/documentation.rake
@@ -4,15 +4,15 @@ require 'rake/rdoctask'
class RDocTaskWithoutDescriptions < Rake::RDocTask
def define
task rdoc_task_name
-
+
task rerdoc_task_name => [clobber_task_name, rdoc_task_name]
-
+
task clobber_task_name do
rm_r rdoc_dir rescue nil
end
-
+
task :clobber => [clobber_task_name]
-
+
directory @rdoc_dir
task rdoc_task_name => [rdoc_target]
file rdoc_target => @rdoc_files + [Rake.application.rakefile] do
diff --git a/railties/test/application/loading_test.rb b/railties/test/application/loading_test.rb
index 340ce67511..ecf7904c39 100644
--- a/railties/test/application/loading_test.rb
+++ b/railties/test/application/loading_test.rb
@@ -18,10 +18,10 @@ class LoadingTest < Test::Unit::TestCase
validates_acceptance_of :title, :accept => "omg"
end
MODEL
-
+
require "#{rails_root}/config/environment"
setup_ar!
-
+
p = Post.create(:title => 'omg')
assert_equal 1, Post.count
assert_equal 'omg', p.title
@@ -73,7 +73,7 @@ class LoadingTest < Test::Unit::TestCase
end
protected
-
+
def setup_ar!
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
ActiveRecord::Migration.verbose = false
diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb
index d6e100ffe3..454c9511d8 100644
--- a/railties/test/application/rake_test.rb
+++ b/railties/test/application/rake_test.rb
@@ -14,7 +14,7 @@ module ApplicationTests
app_file "lib/tasks/app.rake", <<-RUBY
$task_loaded = Rake::Task.task_defined?("db:create:all")
RUBY
-
+
require "#{app_path}/config/environment"
::Rails.application.load_tasks
assert $task_loaded
diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb
index 0472ca73a8..f5473333ed 100644
--- a/railties/test/generators/actions_test.rb
+++ b/railties/test/generators/actions_test.rb
@@ -88,7 +88,7 @@ class ActionsTest < Rails::Generators::TestCase
assert_deprecated do
action :gem, 'thoughtbot-factory_girl', :require_as => 'factory_girl', :source => 'http://gems.github.com'
- end
+ end
assert_file 'Gemfile', /gem "mislav\-will\-paginate", :require => "will\-paginate"/
assert_file 'Gemfile', /source "http:\/\/gems\.github\.com"/
@@ -103,7 +103,7 @@ class ActionsTest < Rails::Generators::TestCase
end
assert_deprecated do
- action :gem, 'rspec-rails', :only => %w(development test)
+ action :gem, 'rspec-rails', :only => %w(development test)
end
assert_file 'Gemfile', /gem "rspec", :group => \["development", "test"\]/
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index 08cfb585f9..849c8001f4 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
@@ -79,7 +79,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
reserved_words = %w[application destroy plugin runner test]
reserved_words.each do |reserved|
content = capture(:stderr){ run_generator [File.join(destination_root, reserved)] }
- assert_equal "Invalid application name #{reserved}. Please give a name which does not match one of the reserved rails words.\n", content
+ assert_equal "Invalid application name #{reserved}. Please give a name which does not match one of the reserved rails words.\n", content
end
end
diff --git a/railties/test/railties/railtie_test.rb b/railties/test/railties/railtie_test.rb
index db0fd87491..6715003d3d 100644
--- a/railties/test/railties/railtie_test.rb
+++ b/railties/test/railties/railtie_test.rb
@@ -132,7 +132,7 @@ module RailtiesTest
require "#{app_path}/config/environment"
assert $ran_block
end
-
+
test "we can change our environment if we want to" do
begin
original_env = Rails.env
diff --git a/railties/test/script_rails_loader_test.rb b/railties/test/script_rails_loader_test.rb
index 2a87e5cb58..3ccc147749 100644
--- a/railties/test/script_rails_loader_test.rb
+++ b/railties/test/script_rails_loader_test.rb
@@ -2,21 +2,21 @@ require 'abstract_unit'
require 'rails/script_rails_loader'
class ScriptRailsLoaderTest < ActiveSupport::TestCase
-
+
test "is in a rails application if script/rails exists" do
File.stubs(:exists?).returns(true)
assert Rails::ScriptRailsLoader.in_rails_application?
end
-
+
test "is in a rails application if parent directory has script/rails" do
File.stubs(:exists?).with("/foo/bar/script/rails").returns(false)
File.stubs(:exists?).with("/foo/script/rails").returns(true)
assert Rails::ScriptRailsLoader.in_rails_application_subdirectory?(Pathname.new("/foo/bar"))
end
-
+
test "is not in a rails application if at the root directory and doesn't have script/rails" do
Pathname.any_instance.stubs(:root?).returns true
assert !Rails::ScriptRailsLoader.in_rails_application?
end
-
+
end
\ No newline at end of file
--
cgit v1.2.3
From 0a2257697019f5eca65d46416ea1fa405ad41021 Mon Sep 17 00:00:00 2001
From: Santiago Pastorino
Date: Sat, 14 Aug 2010 05:58:34 -0300
Subject: Fixes some ActionMailer tests
---
actionmailer/test/old_base/mail_render_test.rb | 2 +-
actionmailer/test/old_base/mail_service_test.rb | 4 ++--
actionmailer/test/old_base/url_test.rb | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/actionmailer/test/old_base/mail_render_test.rb b/actionmailer/test/old_base/mail_render_test.rb
index 08951833a5..bf489e77d4 100644
--- a/actionmailer/test/old_base/mail_render_test.rb
+++ b/actionmailer/test/old_base/mail_render_test.rb
@@ -112,7 +112,7 @@ class RenderHelperTest < Test::Unit::TestCase
def test_file_template
mail = RenderMailer.file_template
- assert_equal "Hello there, \n\nMr. test@localhost", mail.body.to_s.strip
+ assert_equal "Hello there,\n\nMr. test@localhost", mail.body.to_s.strip
end
def test_rxml_template
diff --git a/actionmailer/test/old_base/mail_service_test.rb b/actionmailer/test/old_base/mail_service_test.rb
index 4c93eb63e2..a216b94a55 100644
--- a/actionmailer/test/old_base/mail_service_test.rb
+++ b/actionmailer/test/old_base/mail_service_test.rb
@@ -392,7 +392,7 @@ class ActionMailerTest < Test::Unit::TestCase
expected = new_mail
expected.to = @recipient
expected.subject = "[Signed up] Welcome #{@recipient}"
- expected.body = "Hello there, \n\nMr. #{@recipient}"
+ expected.body = "Hello there,\n\nMr. #{@recipient}"
expected.from = "system@loudthinking.com"
expected.date = Time.now
@@ -420,7 +420,7 @@ class ActionMailerTest < Test::Unit::TestCase
expected = new_mail
expected.to = @recipient
expected.subject = "[Signed up] Welcome #{@recipient}"
- expected.body = "Hello there, \n\nMr. #{@recipient}"
+ expected.body = "Hello there,\n\nMr. #{@recipient}"
expected.from = "system@loudthinking.com"
expected.date = Time.local(2004, 12, 12)
diff --git a/actionmailer/test/old_base/url_test.rb b/actionmailer/test/old_base/url_test.rb
index b4be7dfe32..573186dbee 100644
--- a/actionmailer/test/old_base/url_test.rb
+++ b/actionmailer/test/old_base/url_test.rb
@@ -68,7 +68,7 @@ class ActionMailerUrlTest < ActionMailer::TestCase
expected = new_mail
expected.to = @recipient
expected.subject = "[Signed up] Welcome #{@recipient}"
- expected.body = "Hello there, \n\nMr. #{@recipient}. Please see our greeting at http://example.com/welcome/greeting http://www.basecamphq.com/welcome\n\n"
+ expected.body = "Hello there,\n\nMr. #{@recipient}. Please see our greeting at http://example.com/welcome/greeting http://www.basecamphq.com/welcome\n\n"
expected.from = "system@loudthinking.com"
expected.date = Time.local(2004, 12, 12)
--
cgit v1.2.3
From b7fdc937fafb96134a484ee68669899f66f02637 Mon Sep 17 00:00:00 2001
From: Subba Rao Pasupuleti
Date: Sat, 14 Aug 2010 06:23:18 -0300
Subject: Adding missing required statement
[#5056 state:resolved]
Signed-off-by: Santiago Pastorino
---
activemodel/test/cases/serializeration/json_serialization_test.rb | 1 +
1 file changed, 1 insertion(+)
diff --git a/activemodel/test/cases/serializeration/json_serialization_test.rb b/activemodel/test/cases/serializeration/json_serialization_test.rb
index 91e123e655..3bc39bb06d 100644
--- a/activemodel/test/cases/serializeration/json_serialization_test.rb
+++ b/activemodel/test/cases/serializeration/json_serialization_test.rb
@@ -1,5 +1,6 @@
require 'cases/helper'
require 'models/contact'
+require 'models/automobile'
require 'active_support/core_ext/object/instance_variables'
class Contact
--
cgit v1.2.3
From ad4272922d6a42ac1fed2282bcc7bd937c85bb30 Mon Sep 17 00:00:00 2001
From: Santiago Pastorino
Date: Sat, 14 Aug 2010 18:33:38 -0300
Subject: object/try should be required after abstract_unit to have AS in the
load path
---
actionpack/test/controller/resources_test.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb
index 6c8f470fba..4505cdabae 100644
--- a/actionpack/test/controller/resources_test.rb
+++ b/actionpack/test/controller/resources_test.rb
@@ -1,5 +1,5 @@
-require 'active_support/core_ext/object/try'
require 'abstract_unit'
+require 'active_support/core_ext/object/try'
class ResourcesController < ActionController::Base
def index() render :nothing => true end
--
cgit v1.2.3
From 59a0700b56cb6dc895d5f371b08ba7a339bc2d98 Mon Sep 17 00:00:00 2001
From: Santiago Pastorino
Date: Sat, 14 Aug 2010 18:48:06 -0300
Subject: Both tests are using the same model, move the model to another file
and add the missing require
---
activerecord/test/cases/attribute_methods_test.rb | 3 ++-
activerecord/test/cases/base_test.rb | 27 ++++++++++++-----------
activerecord/test/schema/schema.rb | 2 +-
3 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb
index d9e5efa8da..a698f23fb6 100644
--- a/activerecord/test/cases/attribute_methods_test.rb
+++ b/activerecord/test/cases/attribute_methods_test.rb
@@ -2,6 +2,7 @@ require "cases/helper"
require 'models/minimalistic'
require 'models/developer'
require 'models/auto_id'
+require 'models/boolean'
require 'models/computer'
require 'models/topic'
require 'models/company'
@@ -101,7 +102,7 @@ class AttributeMethodsTest < ActiveRecord::TestCase
if current_adapter?(:MysqlAdapter)
def test_read_attributes_before_type_cast_on_boolean
- bool = Booleantest.create({ "value" => false })
+ bool = Boolean.create({ "value" => false })
assert_equal "0", bool.reload.attributes_before_type_cast["value"]
end
end
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb
index ca397d3847..b2799f649a 100644
--- a/activerecord/test/cases/base_test.rb
+++ b/activerecord/test/cases/base_test.rb
@@ -10,6 +10,7 @@ require 'models/developer'
require 'models/project'
require 'models/default'
require 'models/auto_id'
+require 'models/boolean'
require 'models/column_name'
require 'models/subscriber'
require 'models/keyboard'
@@ -42,7 +43,7 @@ class ReadonlyTitlePost < Post
attr_readonly :title
end
-class Booleantest < ActiveRecord::Base; end
+class Boolean < ActiveRecord::Base; end
class BasicsTest < ActiveRecord::TestCase
fixtures :topics, :companies, :developers, :projects, :computers, :accounts, :minimalistics, 'warehouse-things', :authors, :categorizations, :categories, :posts
@@ -596,34 +597,34 @@ class BasicsTest < ActiveRecord::TestCase
end
def test_boolean
- b_nil = Booleantest.create({ "value" => nil })
+ b_nil = Boolean.create({ "value" => nil })
nil_id = b_nil.id
- b_false = Booleantest.create({ "value" => false })
+ b_false = Boolean.create({ "value" => false })
false_id = b_false.id
- b_true = Booleantest.create({ "value" => true })
+ b_true = Boolean.create({ "value" => true })
true_id = b_true.id
- b_nil = Booleantest.find(nil_id)
+ b_nil = Boolean.find(nil_id)
assert_nil b_nil.value
- b_false = Booleantest.find(false_id)
+ b_false = Boolean.find(false_id)
assert !b_false.value?
- b_true = Booleantest.find(true_id)
+ b_true = Boolean.find(true_id)
assert b_true.value?
end
def test_boolean_cast_from_string
- b_blank = Booleantest.create({ "value" => "" })
+ b_blank = Boolean.create({ "value" => "" })
blank_id = b_blank.id
- b_false = Booleantest.create({ "value" => "0" })
+ b_false = Boolean.create({ "value" => "0" })
false_id = b_false.id
- b_true = Booleantest.create({ "value" => "1" })
+ b_true = Boolean.create({ "value" => "1" })
true_id = b_true.id
- b_blank = Booleantest.find(blank_id)
+ b_blank = Boolean.find(blank_id)
assert_nil b_blank.value
- b_false = Booleantest.find(false_id)
+ b_false = Boolean.find(false_id)
assert !b_false.value?
- b_true = Booleantest.find(true_id)
+ b_true = Boolean.find(true_id)
assert b_true.value?
end
diff --git a/activerecord/test/schema/schema.rb b/activerecord/test/schema/schema.rb
index ce7ee78aea..8017e13920 100644
--- a/activerecord/test/schema/schema.rb
+++ b/activerecord/test/schema/schema.rb
@@ -74,7 +74,7 @@ ActiveRecord::Schema.define do
t.column :name, :string
end
- create_table :booleantests, :force => true do |t|
+ create_table :booleans, :force => true do |t|
t.boolean :value
end
--
cgit v1.2.3
From 9a7e7e5fdb56dd1a805bce291acf122c7b6e3b83 Mon Sep 17 00:00:00 2001
From: Santiago Pastorino
Date: Sat, 14 Aug 2010 18:49:04 -0300
Subject: Add missing model
---
activerecord/test/models/boolean.rb | 2 ++
1 file changed, 2 insertions(+)
create mode 100644 activerecord/test/models/boolean.rb
diff --git a/activerecord/test/models/boolean.rb b/activerecord/test/models/boolean.rb
new file mode 100644
index 0000000000..7bae22e5f9
--- /dev/null
+++ b/activerecord/test/models/boolean.rb
@@ -0,0 +1,2 @@
+class Boolean < ActiveRecord::Base
+end
--
cgit v1.2.3
From 98818f92b8a61ad70f99dc18f148b3d2f34f2cbe Mon Sep 17 00:00:00 2001
From: "Josep M. Bach"
Date: Sat, 14 Aug 2010 16:28:30 +0200
Subject: Documented active_support/concern dependency handling
---
activesupport/lib/active_support/concern.rb | 82 ++++++++++++++++++++++++++++-
1 file changed, 81 insertions(+), 1 deletion(-)
diff --git a/activesupport/lib/active_support/concern.rb b/activesupport/lib/active_support/concern.rb
index 2d87e8d0e5..6781082786 100644
--- a/activesupport/lib/active_support/concern.rb
+++ b/activesupport/lib/active_support/concern.rb
@@ -1,4 +1,4 @@
-# A typical module looks like this
+# A typical module looks like this:
#
# module M
# def self.included(base)
@@ -17,6 +17,8 @@
# end
#
# By using ActiveSupport::Concern the above module could instead be written as:
+#
+# require 'active_support/concern'
#
# module M
# extend ActiveSupport::Concern
@@ -33,6 +35,84 @@
# def im; puts 'I am an instance method'; end
# end
# end
+#
+# Moreover, it gracefully handles module dependencies. Given a Foo module and a Bar module which depends on the former, we would typically write the following:
+#
+# module Foo
+# def self.included(base)
+# # Define some :enhanced_method for Host class
+# base.class_eval do
+# def self.enhanced_method
+# # Do enhanced stuff
+# end
+# end
+# end
+# end
+#
+# module Bar
+# def self.included(base)
+# base.send(:enhanced_method)
+# end
+# end
+#
+# class Host
+# include Foo # We need to include this dependency for Bar
+# include Bar # Bar is the module that Host really needs
+# end
+#
+# But why should Host care about Bar's dependencies, namely Foo? We could try to hide these from Host directly including Foo in Bar:
+#
+# module Foo
+# def self.included(base)
+# # Define some :enhanced_method for Host class
+# base.class_eval do
+# def self.enhanced_method
+# # Do enhanced stuff
+# end
+# end
+# end
+# end
+#
+# module Bar
+# include Foo
+# def self.included(base)
+# base.send(:enhanced_method)
+# end
+# end
+#
+# class Host
+# include Bar
+# end
+#
+# Unfortunately this won't work, since when Foo is included, its base is Bar module, not Host class.
+# With ActiveSupport::Concern, module dependencies are properly resolved:
+#
+# require 'active_support/concern'
+#
+# module Foo
+# extend ActiveSupport::Concern
+# included do
+# class_eval do
+# def self.enhanced_method
+# # Do enhanced stuff
+# end
+# end
+# end
+# end
+#
+# module Bar
+# extend ActiveSupport::Concern
+# include Foo
+#
+# included do
+# self.send(:enhanced_method)
+# end
+# end
+#
+# class Host
+# include Bar # Host only needs to care about Bar without needing to know about its dependencies
+# end
+#
module ActiveSupport
module Concern
def self.extended(base)
--
cgit v1.2.3
From ca87d0a395c43eb95f0f744dd71b85cfb76e9545 Mon Sep 17 00:00:00 2001
From: "Josep M. Bach"
Date: Sat, 14 Aug 2010 16:52:05 +0200
Subject: Documentation just before Concern module
---
activesupport/lib/active_support/concern.rb | 230 ++++++++++++++--------------
1 file changed, 115 insertions(+), 115 deletions(-)
diff --git a/activesupport/lib/active_support/concern.rb b/activesupport/lib/active_support/concern.rb
index 6781082786..d1e03e596c 100644
--- a/activesupport/lib/active_support/concern.rb
+++ b/activesupport/lib/active_support/concern.rb
@@ -1,119 +1,119 @@
-# A typical module looks like this:
-#
-# module M
-# def self.included(base)
-# base.send(:extend, ClassMethods)
-# base.send(:include, InstanceMethods)
-# scope :foo, :conditions => { :created_at => nil }
-# end
-#
-# module ClassMethods
-# def cm; puts 'I am a class method'; end
-# end
-#
-# module InstanceMethods
-# def im; puts 'I am an instance method'; end
-# end
-# end
-#
-# By using ActiveSupport::Concern the above module could instead be written as:
-#
-# require 'active_support/concern'
-#
-# module M
-# extend ActiveSupport::Concern
-#
-# included do
-# scope :foo, :conditions => { :created_at => nil }
-# end
-#
-# module ClassMethods
-# def cm; puts 'I am a class method'; end
-# end
-#
-# module InstanceMethods
-# def im; puts 'I am an instance method'; end
-# end
-# end
-#
-# Moreover, it gracefully handles module dependencies. Given a Foo module and a Bar module which depends on the former, we would typically write the following:
-#
-# module Foo
-# def self.included(base)
-# # Define some :enhanced_method for Host class
-# base.class_eval do
-# def self.enhanced_method
-# # Do enhanced stuff
-# end
-# end
-# end
-# end
-#
-# module Bar
-# def self.included(base)
-# base.send(:enhanced_method)
-# end
-# end
-#
-# class Host
-# include Foo # We need to include this dependency for Bar
-# include Bar # Bar is the module that Host really needs
-# end
-#
-# But why should Host care about Bar's dependencies, namely Foo? We could try to hide these from Host directly including Foo in Bar:
-#
-# module Foo
-# def self.included(base)
-# # Define some :enhanced_method for Host class
-# base.class_eval do
-# def self.enhanced_method
-# # Do enhanced stuff
-# end
-# end
-# end
-# end
-#
-# module Bar
-# include Foo
-# def self.included(base)
-# base.send(:enhanced_method)
-# end
-# end
-#
-# class Host
-# include Bar
-# end
-#
-# Unfortunately this won't work, since when Foo is included, its base is Bar module, not Host class.
-# With ActiveSupport::Concern, module dependencies are properly resolved:
-#
-# require 'active_support/concern'
-#
-# module Foo
-# extend ActiveSupport::Concern
-# included do
-# class_eval do
-# def self.enhanced_method
-# # Do enhanced stuff
-# end
-# end
-# end
-# end
-#
-# module Bar
-# extend ActiveSupport::Concern
-# include Foo
-#
-# included do
-# self.send(:enhanced_method)
-# end
-# end
-#
-# class Host
-# include Bar # Host only needs to care about Bar without needing to know about its dependencies
-# end
-#
module ActiveSupport
+ # A typical module looks like this:
+ #
+ # module M
+ # def self.included(base)
+ # base.send(:extend, ClassMethods)
+ # base.send(:include, InstanceMethods)
+ # scope :foo, :conditions => { :created_at => nil }
+ # end
+ #
+ # module ClassMethods
+ # def cm; puts 'I am a class method'; end
+ # end
+ #
+ # module InstanceMethods
+ # def im; puts 'I am an instance method'; end
+ # end
+ # end
+ #
+ # By using ActiveSupport::Concern the above module could instead be written as:
+ #
+ # require 'active_support/concern'
+ #
+ # module M
+ # extend ActiveSupport::Concern
+ #
+ # included do
+ # scope :foo, :conditions => { :created_at => nil }
+ # end
+ #
+ # module ClassMethods
+ # def cm; puts 'I am a class method'; end
+ # end
+ #
+ # module InstanceMethods
+ # def im; puts 'I am an instance method'; end
+ # end
+ # end
+ #
+ # Moreover, it gracefully handles module dependencies. Given a Foo module and a Bar module which depends on the former, we would typically write the following:
+ #
+ # module Foo
+ # def self.included(base)
+ # # Define some :enhanced_method for Host class
+ # base.class_eval do
+ # def self.enhanced_method
+ # # Do enhanced stuff
+ # end
+ # end
+ # end
+ # end
+ #
+ # module Bar
+ # def self.included(base)
+ # base.send(:enhanced_method)
+ # end
+ # end
+ #
+ # class Host
+ # include Foo # We need to include this dependency for Bar
+ # include Bar # Bar is the module that Host really needs
+ # end
+ #
+ # But why should Host care about Bar's dependencies, namely Foo? We could try to hide these from Host directly including Foo in Bar:
+ #
+ # module Foo
+ # def self.included(base)
+ # # Define some :enhanced_method for Host class
+ # base.class_eval do
+ # def self.enhanced_method
+ # # Do enhanced stuff
+ # end
+ # end
+ # end
+ # end
+ #
+ # module Bar
+ # include Foo
+ # def self.included(base)
+ # base.send(:enhanced_method)
+ # end
+ # end
+ #
+ # class Host
+ # include Bar
+ # end
+ #
+ # Unfortunately this won't work, since when Foo is included, its base is Bar module, not Host class.
+ # With ActiveSupport::Concern, module dependencies are properly resolved:
+ #
+ # require 'active_support/concern'
+ #
+ # module Foo
+ # extend ActiveSupport::Concern
+ # included do
+ # class_eval do
+ # def self.enhanced_method
+ # # Do enhanced stuff
+ # end
+ # end
+ # end
+ # end
+ #
+ # module Bar
+ # extend ActiveSupport::Concern
+ # include Foo
+ #
+ # included do
+ # self.send(:enhanced_method)
+ # end
+ # end
+ #
+ # class Host
+ # include Bar # Host only needs to care about Bar without needing to know about its dependencies
+ # end
+ #
module Concern
def self.extended(base)
base.instance_variable_set("@_dependencies", [])
--
cgit v1.2.3
From c7adc961868a8a0b83e70fc2be8c60013a20fa1b Mon Sep 17 00:00:00 2001
From: "Josep M. Bach"
Date: Sat, 14 Aug 2010 17:01:11 +0200
Subject: Documented active_support/configurable
---
activesupport/lib/active_support/configurable.rb | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/activesupport/lib/active_support/configurable.rb b/activesupport/lib/active_support/configurable.rb
index a0c9c9e33a..5b85f9394a 100644
--- a/activesupport/lib/active_support/configurable.rb
+++ b/activesupport/lib/active_support/configurable.rb
@@ -4,6 +4,8 @@ require 'active_support/core_ext/kernel/singleton_class'
require 'active_support/core_ext/module/delegation'
module ActiveSupport
+ # Configurable provides a config method to store and retrieve
+ # configuration options as an OrderedHash.
module Configurable
extend ActiveSupport::Concern
@@ -29,8 +31,25 @@ module ActiveSupport
end
end
+ # Reads and writes attributes from a configuration OrderedHash.
+ #
+ # require 'active_support/configurable'
+ #
+ # class User
+ # include ActiveSupport::Configurable
+ # 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 ||= ActiveSupport::InheritableOptions.new(self.class.config)
end
end
-end
\ No newline at end of file
+end
+
--
cgit v1.2.3
From 21bbcfe42cf163f532beff1f7a8ceb5e12f2907b Mon Sep 17 00:00:00 2001
From: Xavier Noria
Date: Sat, 14 Aug 2010 17:04:17 +0200
Subject: reviews commit dcc9d38
---
activesupport/lib/active_support/concern.rb | 54 ++++++++++++-----------------
1 file changed, 22 insertions(+), 32 deletions(-)
diff --git a/activesupport/lib/active_support/concern.rb b/activesupport/lib/active_support/concern.rb
index d1e03e596c..ac94d12e5e 100644
--- a/activesupport/lib/active_support/concern.rb
+++ b/activesupport/lib/active_support/concern.rb
@@ -3,48 +3,48 @@ module ActiveSupport
#
# module M
# def self.included(base)
- # base.send(:extend, ClassMethods)
+ # base.extend, ClassMethods
# base.send(:include, InstanceMethods)
- # scope :foo, :conditions => { :created_at => nil }
+ # scope :disabled, where(:disabled => true)
# end
#
# module ClassMethods
- # def cm; puts 'I am a class method'; end
+ # ...
# end
#
# module InstanceMethods
- # def im; puts 'I am an instance method'; end
+ # ...
# end
# end
#
# By using ActiveSupport::Concern the above module could instead be written as:
- #
+ #
# require 'active_support/concern'
#
# module M
# extend ActiveSupport::Concern
#
# included do
- # scope :foo, :conditions => { :created_at => nil }
+ # scope :disabled, where(:disabled => true)
# end
#
# module ClassMethods
- # def cm; puts 'I am a class method'; end
+ # ...
# end
#
# module InstanceMethods
- # def im; puts 'I am an instance method'; end
+ # ...
# end
# end
#
- # Moreover, it gracefully handles module dependencies. Given a Foo module and a Bar module which depends on the former, we would typically write the following:
+ # Moreover, it gracefully handles module dependencies. Given a +Foo+ module and a +Bar+
+ # module which depends on the former, we would typically write the following:
#
# module Foo
# def self.included(base)
- # # Define some :enhanced_method for Host class
# base.class_eval do
- # def self.enhanced_method
- # # Do enhanced stuff
+ # def self.method_injected_by_foo
+ # ...
# end
# end
# end
@@ -52,7 +52,7 @@ module ActiveSupport
#
# module Bar
# def self.included(base)
- # base.send(:enhanced_method)
+ # base.method_injected_by_foo
# end
# end
#
@@ -61,23 +61,13 @@ module ActiveSupport
# include Bar # Bar is the module that Host really needs
# end
#
- # But why should Host care about Bar's dependencies, namely Foo? We could try to hide these from Host directly including Foo in Bar:
- #
- # module Foo
- # def self.included(base)
- # # Define some :enhanced_method for Host class
- # base.class_eval do
- # def self.enhanced_method
- # # Do enhanced stuff
- # end
- # end
- # end
- # end
+ # But why should +Host+ care about +Bar+'s dependencies, namely +Foo+? We could try to hide
+ # these from +Host+ directly including +Foo+ in +Bar+:
#
# module Bar
# include Foo
# def self.included(base)
- # base.send(:enhanced_method)
+ # base.method_injected_by_foo
# end
# end
#
@@ -85,8 +75,8 @@ module ActiveSupport
# include Bar
# end
#
- # Unfortunately this won't work, since when Foo is included, its base is Bar module, not Host class.
- # With ActiveSupport::Concern, module dependencies are properly resolved:
+ # Unfortunately this won't work, since when +Foo+ is included, its base is the +Bar+ module,
+ # not the +Host+ class. With ActiveSupport::Concern, module dependencies are properly resolved:
#
# require 'active_support/concern'
#
@@ -94,8 +84,8 @@ module ActiveSupport
# extend ActiveSupport::Concern
# included do
# class_eval do
- # def self.enhanced_method
- # # Do enhanced stuff
+ # def self.method_injected_by_foo
+ # ...
# end
# end
# end
@@ -106,12 +96,12 @@ module ActiveSupport
# include Foo
#
# included do
- # self.send(:enhanced_method)
+ # self.method_injected_by_foo
# end
# end
#
# class Host
- # include Bar # Host only needs to care about Bar without needing to know about its dependencies
+ # include Bar # works, Bar takes care now of its dependencies
# end
#
module Concern
--
cgit v1.2.3
From 664afe37dd254199346b837286395325cf046188 Mon Sep 17 00:00:00 2001
From: "Josep M. Bach"
Date: Sat, 14 Aug 2010 17:15:03 +0200
Subject: Add example label to activesupport/configurable
---
activesupport/lib/active_support/configurable.rb | 2 ++
1 file changed, 2 insertions(+)
diff --git a/activesupport/lib/active_support/configurable.rb b/activesupport/lib/active_support/configurable.rb
index 5b85f9394a..3bfbd7f7d6 100644
--- a/activesupport/lib/active_support/configurable.rb
+++ b/activesupport/lib/active_support/configurable.rb
@@ -33,6 +33,8 @@ module ActiveSupport
# Reads and writes attributes from a configuration OrderedHash.
#
+ # Example:
+ #
# require 'active_support/configurable'
#
# class User
--
cgit v1.2.3
From e8ef58a697c4af99a7db44267cf6d975fb5d6091 Mon Sep 17 00:00:00 2001
From: "Josep M. Bach"
Date: Sat, 14 Aug 2010 17:19:04 +0200
Subject: Add example label to active_support/configurable
---
activesupport/lib/active_support/configurable.rb | 1 -
1 file changed, 1 deletion(-)
diff --git a/activesupport/lib/active_support/configurable.rb b/activesupport/lib/active_support/configurable.rb
index 3bfbd7f7d6..61c4b1be02 100644
--- a/activesupport/lib/active_support/configurable.rb
+++ b/activesupport/lib/active_support/configurable.rb
@@ -32,7 +32,6 @@ module ActiveSupport
end
# Reads and writes attributes from a configuration OrderedHash.
- #
# Example:
#
# require 'active_support/configurable'
--
cgit v1.2.3
From 9f9a02af86dee5372aae2bd84a5220245bee8706 Mon Sep 17 00:00:00 2001
From: "Josep M. Bach"
Date: Sat, 14 Aug 2010 17:52:52 +0200
Subject: Whitespace and example identation
---
activesupport/lib/active_support/lazy_load_hooks.rb | 14 +++++++-------
activesupport/lib/active_support/log_subscriber.rb | 4 ++--
activesupport/lib/active_support/rescuable.rb | 1 +
activesupport/lib/active_support/secure_random.rb | 14 ++++++++++----
activesupport/lib/active_support/time_with_zone.rb | 2 ++
5 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/activesupport/lib/active_support/lazy_load_hooks.rb b/activesupport/lib/active_support/lazy_load_hooks.rb
index 3b8696b5c7..82507c1e03 100644
--- a/activesupport/lib/active_support/lazy_load_hooks.rb
+++ b/activesupport/lib/active_support/lazy_load_hooks.rb
@@ -5,17 +5,17 @@
#
# Here is an example where +on_load+ method is called to register a hook.
#
-# initializer "active_record.initialize_timezone" do
-# ActiveSupport.on_load(:active_record) do
-# self.time_zone_aware_attributes = true
-# self.default_timezone = :utc
-# end
-# end
+# initializer "active_record.initialize_timezone" do
+# ActiveSupport.on_load(:active_record) do
+# self.time_zone_aware_attributes = true
+# self.default_timezone = :utc
+# end
+# end
#
# When the entirety of +activerecord/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)
+# ActiveSupport.run_load_hooks(:active_record, ActiveRecord::Base)
#
module ActiveSupport
@load_hooks = Hash.new {|h,k| h[k] = [] }
diff --git a/activesupport/lib/active_support/log_subscriber.rb b/activesupport/lib/active_support/log_subscriber.rb
index 63c0470d3f..49f7513193 100644
--- a/activesupport/lib/active_support/log_subscriber.rb
+++ b/activesupport/lib/active_support/log_subscriber.rb
@@ -4,7 +4,7 @@ require 'active_support/core_ext/class/attribute'
module ActiveSupport
# ActiveSupport::LogSubscriber is an object set to consume ActiveSupport::Notifications
# with solely purpose of logging. The log subscriber dispatches notifications to a
- # regirested object based on its given namespace.
+ # registered object based on its given namespace.
#
# An example would be Active Record log subscriber responsible for logging queries:
#
@@ -16,7 +16,7 @@ module ActiveSupport
# end
# end
#
- # And it's finally registed as:
+ # And it's finally registered as:
#
# ActiveRecord::LogSubscriber.attach_to :active_record
#
diff --git a/activesupport/lib/active_support/rescuable.rb b/activesupport/lib/active_support/rescuable.rb
index cd6f92cdfe..0f4a06468a 100644
--- a/activesupport/lib/active_support/rescuable.rb
+++ b/activesupport/lib/active_support/rescuable.rb
@@ -47,6 +47,7 @@ module ActiveSupport
# exception.record.new_record? ? ...
# end
# end
+ #
def rescue_from(*klasses, &block)
options = klasses.extract_options!
diff --git a/activesupport/lib/active_support/secure_random.rb b/activesupport/lib/active_support/secure_random.rb
index 73344498cb..488a7e14a7 100644
--- a/activesupport/lib/active_support/secure_random.rb
+++ b/activesupport/lib/active_support/secure_random.rb
@@ -46,8 +46,10 @@ module ActiveSupport
# p SecureRandom.random_bytes(10) # => "\016\t{\370g\310pbr\301"
# p SecureRandom.random_bytes(10) # => "\323U\030TO\234\357\020\a\337"
# ...
+ #
module SecureRandom
- # SecureRandom.random_bytes generates a random binary string.
+
+ # Generates a random binary string.
#
# The argument n specifies the length of the result string.
#
@@ -56,6 +58,7 @@ module ActiveSupport
#
# If secure random number generator is not available,
# NotImplementedError is raised.
+ #
def self.random_bytes(n=nil)
n ||= 16
@@ -124,7 +127,7 @@ module ActiveSupport
raise NotImplementedError, "No random device"
end
- # SecureRandom.hex generates a random hex string.
+ # Generates a random hex string.
#
# The argument n specifies the length of the random length.
# The length of the result string is twice of n.
@@ -134,11 +137,12 @@ module ActiveSupport
#
# If secure random number generator is not available,
# NotImplementedError is raised.
+ #
def self.hex(n=nil)
random_bytes(n).unpack("H*")[0]
end
- # SecureRandom.base64 generates a random base64 string.
+ # Generates a random base64 string.
#
# The argument n specifies the length of the random length.
# The length of the result string is about 4/3 of n.
@@ -148,11 +152,12 @@ module ActiveSupport
#
# If secure random number generator is not available,
# NotImplementedError is raised.
+ #
def self.base64(n=nil)
[random_bytes(n)].pack("m*").delete("\n")
end
- # SecureRandom.random_number generates a random number.
+ # Generates a random number.
#
# If an positive integer is given as n,
# SecureRandom.random_number returns an integer:
@@ -161,6 +166,7 @@ module ActiveSupport
# If 0 is given or an argument is not given,
# SecureRandom.random_number returns an float:
# 0.0 <= SecureRandom.random_number() < 1.0.
+ #
def self.random_number(n=0)
if 0 < n
hex = n.to_s(16)
diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb
index 48c7990b1e..93f5d5a0cc 100644
--- a/activesupport/lib/active_support/time_with_zone.rb
+++ b/activesupport/lib/active_support/time_with_zone.rb
@@ -32,6 +32,7 @@ module ActiveSupport
# t > Time.utc(1999) # => true
# t.is_a?(Time) # => true
# t.is_a?(ActiveSupport::TimeWithZone) # => true
+ #
class TimeWithZone
def self.name
'Time' # Report class name as 'Time' to thwart type checking
@@ -127,6 +128,7 @@ module ActiveSupport
# # With ActiveSupport::JSON::Encoding.use_standard_json_time_format = false
# Time.utc(2005,2,1,15,15,10).in_time_zone.to_json
# # => "2005/02/01 15:15:10 +0000"
+ #
def as_json(options = nil)
if ActiveSupport::JSON::Encoding.use_standard_json_time_format
xmlschema
--
cgit v1.2.3
From dd18840b7960cf337e316d9d3afadfa00a3725f1 Mon Sep 17 00:00:00 2001
From: Xavier Noria
Date: Sat, 14 Aug 2010 18:34:32 +0200
Subject: Revert "Add example label to active_support/configurable"
This reverts commit 693f770afe0e14fc1b4658ef51910d993e67dd07.
Reason: to be able to revert f480b2cea69247239f6fc2ad171b231595cc08c6
---
activesupport/lib/active_support/configurable.rb | 1 +
1 file changed, 1 insertion(+)
diff --git a/activesupport/lib/active_support/configurable.rb b/activesupport/lib/active_support/configurable.rb
index 61c4b1be02..3bfbd7f7d6 100644
--- a/activesupport/lib/active_support/configurable.rb
+++ b/activesupport/lib/active_support/configurable.rb
@@ -32,6 +32,7 @@ module ActiveSupport
end
# Reads and writes attributes from a configuration OrderedHash.
+ #
# Example:
#
# require 'active_support/configurable'
--
cgit v1.2.3
From 3ba61ecb7f71ec37d6f6adc0c4806ab9e65b2c58 Mon Sep 17 00:00:00 2001
From: Xavier Noria
Date: Sat, 14 Aug 2010 18:35:01 +0200
Subject: Revert "Add example label to activesupport/configurable"
This reverts commit f480b2cea69247239f6fc2ad171b231595cc08c6.
Reason: API guidelines discourage this, see http://edgeguides.rubyonrails.org/api_documentation_guidelines.html#example-code
---
activesupport/lib/active_support/configurable.rb | 2 --
1 file changed, 2 deletions(-)
diff --git a/activesupport/lib/active_support/configurable.rb b/activesupport/lib/active_support/configurable.rb
index 3bfbd7f7d6..5b85f9394a 100644
--- a/activesupport/lib/active_support/configurable.rb
+++ b/activesupport/lib/active_support/configurable.rb
@@ -33,8 +33,6 @@ module ActiveSupport
# Reads and writes attributes from a configuration OrderedHash.
#
- # Example:
- #
# require 'active_support/configurable'
#
# class User
--
cgit v1.2.3