1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix Rubocop violations and fix documentation visibility

Some methods were added to public API in
5b14129d8d and they should be not part of
the public API.
This commit is contained in:
Rafael Mendonça França 2016-12-28 21:53:51 -05:00
parent 09cdf425d7
commit 010e246756
No known key found for this signature in database
GPG key ID: FC23B6D0F1EEE948
33 changed files with 246 additions and 247 deletions

View file

@ -1,4 +1,4 @@
require 'active_support/core_ext/string/filters'
require "active_support/core_ext/string/filters"
module ActionDispatch
# The routing module provides URL rewriting in native Ruby. It's a way to

View file

@ -50,7 +50,7 @@ class ParamsWrapperTest < ActionController::TestCase
with_default_wrapper_options do
@request.env["CONTENT_TYPE"] = "application/json"
post :parse, params: { "username" => "sikachu" }
assert_equal({"controller" => "params_wrapper_test/users", "action" => "parse", "username" => "sikachu", "user" => { "username" => "sikachu" }}, @request.filtered_parameters)
assert_equal({ "controller" => "params_wrapper_test/users", "action" => "parse", "username" => "sikachu", "user" => { "username" => "sikachu" } }, @request.filtered_parameters)
end
end

View file

@ -111,7 +111,7 @@ class ResponseTest < ActiveSupport::TestCase
end
def test_empty_content_type_returns_nil
@response.headers['Content-Type'] = ""
@response.headers["Content-Type"] = ""
assert_nil @response.content_type
end

View file

@ -49,7 +49,7 @@ end
namespace :ujs do
desc "Starts the test server"
task :server do
system 'bundle exec rackup test/ujs/config.ru -p 4567 -s puma'
system "bundle exec rackup test/ujs/config.ru -p 4567 -s puma"
end
end

View file

@ -123,14 +123,14 @@ module ActionView
end
private
def _routes_context
controller
end
def _routes_context
controller
end
def optimize_routes_generation?
controller.respond_to?(:optimize_routes_generation?, true) ?
controller.optimize_routes_generation? : super
end
def optimize_routes_generation?
controller.respond_to?(:optimize_routes_generation?, true) ?
controller.optimize_routes_generation? : super
end
def _generate_paths_by_default
true

View file

@ -339,7 +339,7 @@ class FormWithActsLikeFormForTest < FormWithTest
def test_form_with_only_url_on_update
form_with(url: "/posts/123") do |f|
concat f.label :title, 'Label me'
concat f.label :title, "Label me"
concat f.text_field :title
end
@ -965,7 +965,6 @@ class FormWithActsLikeFormForTest < FormWithTest
assert_dom_equal expected, output_buffer
end
def test_nested_fields
@comment.body = "Hello World"
form_with(model: @post) do |f|

View file

@ -1829,9 +1829,9 @@ class FormHelperTest < ActionView::TestCase
obj = Class.new do
private
def private_property
raise "This method should not be called."
end
def private_property
raise "This method should not be called."
end
end.new
form_for(obj, as: "other_name", url: "/", html: { id: "edit-other-name" }) do |f|

View file

@ -694,31 +694,31 @@ class FormTagHelperTest < ActionView::TestCase
def test_text_area_tag_options_symbolize_keys_side_effects
options = { option: "random_option" }
text_area_tag "body", "hello world", options
assert_equal({option: "random_option"}, options)
assert_equal({ option: "random_option" }, options)
end
def test_submit_tag_options_symbolize_keys_side_effects
options = { option: "random_option" }
submit_tag "submit value", options
assert_equal({option: "random_option"}, options)
assert_equal({ option: "random_option" }, options)
end
def test_button_tag_options_symbolize_keys_side_effects
options = { option: "random_option" }
button_tag "button value", options
assert_equal({option: "random_option"}, options)
assert_equal({ option: "random_option" }, options)
end
def test_image_submit_tag_options_symbolize_keys_side_effects
options = { option: "random_option" }
image_submit_tag "submit source", options
assert_equal({option: "random_option"}, options)
assert_equal({ option: "random_option" }, options)
end
def test_image_label_tag_options_symbolize_keys_side_effects
options = { option: "random_option" }
label_tag "submit source", "title", options
assert_equal({option: "random_option"}, options)
assert_equal({ option: "random_option" }, options)
end
def protect_against_forgery?

View file

@ -1,3 +1,3 @@
$LOAD_PATH.unshift File.expand_path('..', __FILE__)
require 'server'
$LOAD_PATH.unshift File.expand_path("..", __FILE__)
require "server"
run UJS::Server

View file

@ -12,7 +12,7 @@ module UJS
get "/rails-ujs.js" => Blade::Assets.environment
get "/" => "tests#index"
match "/echo" => "tests#echo", via: :all
get "/error" => proc {|env| [403, {}, []] }
get "/error" => proc { |env| [403, {}, []] }
end
config.cache_classes = false
@ -26,7 +26,7 @@ module UJS
end
module TestsHelper
def jquery_link version
def jquery_link(version)
if params[:version] == version
"[#{version}]"
else
@ -34,7 +34,7 @@ module TestsHelper
end
end
def cdn_link cdn
def cdn_link(cdn)
if params[:cdn] == cdn
"[#{cdn}]"
else
@ -43,22 +43,22 @@ module TestsHelper
end
def jquery_src
if params[:version] == 'edge'
if params[:version] == "edge"
"/vendor/jquery.js"
elsif params[:cdn] && params[:cdn] == 'googleapis'
elsif params[:cdn] && params[:cdn] == "googleapis"
"https://ajax.googleapis.com/ajax/libs/jquery/#{params[:version]}/jquery.min.js"
else
"http://code.jquery.com/jquery-#{params[:version]}.js"
end
end
def test_to *names
def test_to(*names)
names = ["/vendor/qunit.js", "settings"] + names
names.map { |name| script_tag name }.join("\n").html_safe
end
def script_tag src
src = "/test/#{src}.js" unless src.index('/')
def script_tag(src)
src = "/test/#{src}.js" unless src.index("/")
%(<script src="#{src}" type="text/javascript"></script>).html_safe
end
@ -72,20 +72,20 @@ class TestsController < ActionController::Base
layout "application"
def index
params[:version] ||= ENV['JQUERY_VERSION'] || '1.11.0'
params[:cdn] ||= 'jquery'
params[:version] ||= ENV["JQUERY_VERSION"] || "1.11.0"
params[:cdn] ||= "jquery"
render :index
end
def echo
data = { :params => params.to_unsafe_h }.update(request.env)
data = { params: params.to_unsafe_h }.update(request.env)
if params[:content_type] and params[:content]
if params[:content_type] && params[:content]
render inline: params[:content], content_type: params[:content_type]
elsif request.xhr?
render json: JSON.generate(data)
elsif params[:iframe]
payload = JSON.generate(data).gsub('<', '&lt;').gsub('>', '&gt;')
payload = JSON.generate(data).gsub("<", "&lt;").gsub(">", "&gt;")
html = <<-HTML
<script>
if (window.top && window.top !== window)

View file

@ -78,9 +78,9 @@ module ActiveRecord::Associations::Builder # :nodoc:
private
def self.suppress_composite_primary_key(pk)
pk unless pk.is_a?(Array)
end
def self.suppress_composite_primary_key(pk)
pk unless pk.is_a?(Array)
end
}
join_model.name = "HABTM_#{association_name.to_s.camelize}"

View file

@ -1128,12 +1128,12 @@ module ActiveRecord
private
def find_nth_with_limit(index, limit) # :doc:
def find_nth_with_limit(index, limit)
load_target if find_from_target?
super
end
def find_nth_from_last(index) # :doc:
def find_nth_from_last(index)
load_target if find_from_target?
super
end

View file

@ -52,7 +52,7 @@ module ActiveRecord
private
def attribute_method?(attr_name) # :doc:
def attribute_method?(attr_name)
attr_name == "id" || super
end

View file

@ -24,7 +24,7 @@ module ActiveRecord
# to allocate an object on each call to the attribute method.
# Making it frozen means that it doesn't get duped when used to
# key the @attributes in read_attribute.
def define_method_attribute(name) # :doc:
def define_method_attribute(name)
safe_name = name.unpack("h*".freeze).first
temp_method = "__temp__#{safe_name}"

View file

@ -10,7 +10,7 @@ module ActiveRecord
module ClassMethods
private
def define_method_attribute=(name) # :doc:
def define_method_attribute=(name)
safe_name = name.unpack("h*".freeze).first
ActiveRecord::AttributeMethods::AttrNames.set_name_cache safe_name, name

View file

@ -363,31 +363,31 @@ module ActiveRecord
private
# Returns a subquery for the given key using the join information.
def subquery_for(key, select) # :doc:
def subquery_for(key, select)
subselect = select.clone
subselect.projections = [key]
subselect
end
# Returns an ActiveRecord::Result instance.
def select(sql, name = nil, binds = []) # :doc:
def select(sql, name = nil, binds = [])
exec_query(sql, name, binds, prepare: false)
end
def select_prepared(sql, name = nil, binds = []) # :doc:
def select_prepared(sql, name = nil, binds = [])
exec_query(sql, name, binds, prepare: true)
end
def sql_for_insert(sql, pk, id_value, sequence_name, binds) # :doc:
def sql_for_insert(sql, pk, id_value, sequence_name, binds)
[sql, binds]
end
def last_inserted_id(result) # :doc:
def last_inserted_id(result)
row = result.rows.first
row && row.first
end
def binds_from_relation(relation, binds) # :doc:
def binds_from_relation(relation, binds)
if relation.is_a?(Relation) && binds.empty?
relation, binds = relation.arel, relation.bound_attributes
end

View file

@ -1171,7 +1171,7 @@ module ActiveRecord
private
def add_index_sort_order(quoted_columns, **options) # :doc:
def add_index_sort_order(quoted_columns, **options)
if order = options[:order]
case order
when Hash
@ -1186,7 +1186,7 @@ module ActiveRecord
end
# Overridden by the MySQL adapter for supporting index lengths
def add_options_for_index_columns(quoted_columns, **options) # :doc:
def add_options_for_index_columns(quoted_columns, **options)
if supports_index_sort_order?
quoted_columns = add_index_sort_order(quoted_columns, options)
end
@ -1194,14 +1194,14 @@ module ActiveRecord
quoted_columns
end
def quoted_columns_for_index(column_names, **options) # :doc:
def quoted_columns_for_index(column_names, **options)
return [column_names] if column_names.is_a?(String)
quoted_columns = Hash[column_names.map { |name| [name.to_sym, quote_column_name(name).dup] }]
add_options_for_index_columns(quoted_columns, options).values
end
def index_name_for_remove(table_name, options = {}) # :doc:
def index_name_for_remove(table_name, options = {})
return options[:name] if can_remove_index_by_name?(options)
checks = []
@ -1231,7 +1231,7 @@ module ActiveRecord
end
end
def rename_table_indexes(table_name, new_name) # :doc:
def rename_table_indexes(table_name, new_name)
indexes(new_name).each do |index|
generated_index_name = index_name(table_name, column: index.columns)
if generated_index_name == index.name
@ -1240,7 +1240,7 @@ module ActiveRecord
end
end
def rename_column_indexes(table_name, column_name, new_column_name) # :doc:
def rename_column_indexes(table_name, column_name, new_column_name)
column_name, new_column_name = column_name.to_s, new_column_name.to_s
indexes(table_name).each do |index|
next unless index.columns.include?(new_column_name)

View file

@ -571,7 +571,7 @@ module ActiveRecord
end
end
def translate_exception_class(e, sql) # :doc:
def translate_exception_class(e, sql)
begin
message = "#{e.class.name}: #{e.message}: #{sql}"
rescue Encoding::CompatibilityError
@ -596,7 +596,7 @@ module ActiveRecord
raise translate_exception_class(e, sql)
end
def translate_exception(exception, message) # :doc:
def translate_exception(exception, message)
# override in derived class
case exception
when RuntimeError
@ -606,7 +606,7 @@ module ActiveRecord
end
end
def without_prepared_statement?(binds) # :doc:
def without_prepared_statement?(binds)
!prepared_statements || binds.empty?
end

View file

@ -701,7 +701,7 @@ module ActiveRecord
end
end
def extract_precision(sql_type) # :doc:
def extract_precision(sql_type)
if /time/.match?(sql_type)
super || 0
else
@ -709,11 +709,11 @@ module ActiveRecord
end
end
def fetch_type_metadata(sql_type, extra = "") # :doc:
def fetch_type_metadata(sql_type, extra = "")
MySQL::TypeMetadata.new(super(sql_type), extra: extra)
end
def add_index_length(quoted_columns, **options) # :doc:
def add_index_length(quoted_columns, **options)
if length = options[:length]
case length
when Hash
@ -727,7 +727,7 @@ module ActiveRecord
quoted_columns
end
def add_options_for_index_columns(quoted_columns, **options) # :doc:
def add_options_for_index_columns(quoted_columns, **options)
quoted_columns = add_index_length(quoted_columns, options)
super
end
@ -743,7 +743,7 @@ module ActiveRecord
ER_CANNOT_ADD_FOREIGN = 1215
ER_CANNOT_CREATE_TABLE = 1005
def translate_exception(exception, message) # :doc:
def translate_exception(exception, message)
case error_number(exception)
when ER_DUP_ENTRY
RecordNotUnique.new(message)
@ -770,13 +770,13 @@ module ActiveRecord
end
end
def add_column_sql(table_name, column_name, type, options = {}) # :doc:
def add_column_sql(table_name, column_name, type, options = {})
td = create_table_definition(table_name)
cd = td.new_column_definition(column_name, type, options)
schema_creation.accept(AddColumnDefinition.new(cd))
end
def change_column_sql(table_name, column_name, type, options = {}) # :doc:
def change_column_sql(table_name, column_name, type, options = {})
column = column_for(table_name, column_name)
unless options_include_default?(options)
@ -796,7 +796,7 @@ module ActiveRecord
schema_creation.accept(ChangeColumnDefinition.new(cd, column.name))
end
def rename_column_sql(table_name, column_name, new_column_name) # :doc:
def rename_column_sql(table_name, column_name, new_column_name)
column = column_for(table_name, column_name)
options = {
default: column.default,
@ -810,30 +810,30 @@ module ActiveRecord
schema_creation.accept(ChangeColumnDefinition.new(cd, column.name))
end
def remove_column_sql(table_name, column_name, type = nil, options = {}) # :doc:
def remove_column_sql(table_name, column_name, type = nil, options = {})
"DROP #{quote_column_name(column_name)}"
end
def remove_columns_sql(table_name, *column_names) # :doc:
def remove_columns_sql(table_name, *column_names)
column_names.map { |column_name| remove_column_sql(table_name, column_name) }
end
def add_index_sql(table_name, column_name, options = {}) # :doc:
def add_index_sql(table_name, column_name, options = {})
index_name, index_type, index_columns, _, index_algorithm, index_using = add_index_options(table_name, column_name, options)
index_algorithm[0, 0] = ", " if index_algorithm.present?
"ADD #{index_type} INDEX #{quote_column_name(index_name)} #{index_using} (#{index_columns})#{index_algorithm}"
end
def remove_index_sql(table_name, options = {}) # :doc:
def remove_index_sql(table_name, options = {})
index_name = index_name_for_remove(table_name, options)
"DROP INDEX #{index_name}"
end
def add_timestamps_sql(table_name, options = {}) # :doc:
def add_timestamps_sql(table_name, options = {})
[add_column_sql(table_name, :created_at, :datetime, options), add_column_sql(table_name, :updated_at, :datetime, options)]
end
def remove_timestamps_sql(table_name, options = {}) # :doc:
def remove_timestamps_sql(table_name, options = {})
[remove_column_sql(table_name, :updated_at), remove_column_sql(table_name, :created_at)]
end

View file

@ -54,7 +54,7 @@ module ActiveRecord
private
def last_inserted_id(result) # :doc:
def last_inserted_id(result)
@connection.last_id
end

View file

@ -415,7 +415,7 @@ module ActiveRecord
SERIALIZATION_FAILURE = "40001"
DEADLOCK_DETECTED = "40P01"
def translate_exception(exception, message) # :doc:
def translate_exception(exception, message)
return exception unless exception.respond_to?(:result)
case exception.result.try(:error_field, PGresult::PG_DIAG_SQLSTATE)

View file

@ -518,11 +518,11 @@ module ActiveRecord
SELECT #{quoted_from_columns} FROM #{quote_table_name(from)}")
end
def sqlite_version # :doc:
def sqlite_version
@sqlite_version ||= SQLite3Adapter::Version.new(select_value("select sqlite_version(*)"))
end
def translate_exception(exception, message) # :doc:
def translate_exception(exception, message)
case exception.message
# SQLite 3.8.2 returns a newly formatted error message:
# UNIQUE constraint failed: *table_name*.*column_name*

View file

@ -441,139 +441,139 @@ module ActiveRecord
private
def find_with_ids(*ids) # :doc:
raise UnknownPrimaryKey.new(@klass) if primary_key.nil?
def find_with_ids(*ids)
raise UnknownPrimaryKey.new(@klass) if primary_key.nil?
expects_array = ids.first.kind_of?(Array)
return ids.first if expects_array && ids.first.empty?
expects_array = ids.first.kind_of?(Array)
return ids.first if expects_array && ids.first.empty?
ids = ids.flatten.compact.uniq
ids = ids.flatten.compact.uniq
case ids.size
when 0
raise RecordNotFound, "Couldn't find #{@klass.name} without an ID"
when 1
result = find_one(ids.first)
expects_array ? [ result ] : result
else
find_some(ids)
case ids.size
when 0
raise RecordNotFound, "Couldn't find #{@klass.name} without an ID"
when 1
result = find_one(ids.first)
expects_array ? [ result ] : result
else
find_some(ids)
end
rescue ::RangeError
raise RecordNotFound, "Couldn't find #{@klass.name} with an out of range ID"
end
rescue ::RangeError
raise RecordNotFound, "Couldn't find #{@klass.name} with an out of range ID"
end
def find_one(id) # :doc:
if ActiveRecord::Base === id
id = id.id
ActiveSupport::Deprecation.warn(<<-MSG.squish)
def find_one(id)
if ActiveRecord::Base === id
id = id.id
ActiveSupport::Deprecation.warn(<<-MSG.squish)
You are passing an instance of ActiveRecord::Base to `find`.
Please pass the id of the object by calling `.id`.
MSG
end
relation = where(primary_key => id)
record = relation.take
raise_record_not_found_exception!(id, 0, 1) unless record
record
end
def find_some(ids) # :doc:
return find_some_ordered(ids) unless order_values.present?
result = where(primary_key => ids).to_a
expected_size =
if limit_value && ids.size > limit_value
limit_value
else
ids.size
end
# 11 ids with limit 3, offset 9 should give 2 results.
if offset_value && (ids.size - offset_value < expected_size)
expected_size = ids.size - offset_value
relation = where(primary_key => id)
record = relation.take
raise_record_not_found_exception!(id, 0, 1) unless record
record
end
if result.size == expected_size
result
else
raise_record_not_found_exception!(ids, result.size, expected_size)
end
end
def find_some(ids)
return find_some_ordered(ids) unless order_values.present?
def find_some_ordered(ids) # :doc:
ids = ids.slice(offset_value || 0, limit_value || ids.size) || []
result = where(primary_key => ids).to_a
result = except(:limit, :offset).where(primary_key => ids).records
expected_size =
if limit_value && ids.size > limit_value
limit_value
else
ids.size
end
if result.size == ids.size
pk_type = @klass.type_for_attribute(primary_key)
records_by_id = result.index_by(&:id)
ids.map { |id| records_by_id.fetch(pk_type.cast(id)) }
else
raise_record_not_found_exception!(ids, result.size, ids.size)
end
end
def find_take # :doc:
if loaded?
records.first
else
@take ||= limit(1).records.first
end
end
def find_take_with_limit(limit) # :doc:
if loaded?
records.take(limit)
else
limit(limit).to_a
end
end
def find_nth(index) # :doc:
@offsets[offset_index + index] ||= find_nth_with_limit(index, 1).first
end
def find_nth_with_limit(index, limit) # :doc:
if loaded?
records[index, limit] || []
else
relation = if order_values.empty? && primary_key
order(arel_attribute(primary_key).asc)
else
self
# 11 ids with limit 3, offset 9 should give 2 results.
if offset_value && (ids.size - offset_value < expected_size)
expected_size = ids.size - offset_value
end
relation = relation.offset(offset_index + index) unless index.zero?
relation.limit(limit).to_a
end
end
def find_nth_from_last(index) # :doc:
if loaded?
records[-index]
else
relation = if order_values.empty? && primary_key
order(arel_attribute(primary_key).asc)
if result.size == expected_size
result
else
self
raise_record_not_found_exception!(ids, result.size, expected_size)
end
relation.to_a[-index]
# TODO: can be made more performant on large result sets by
# for instance, last(index)[-index] (which would require
# refactoring the last(n) finder method to make test suite pass),
# or by using a combination of reverse_order, limit, and offset,
# e.g., reverse_order.offset(index-1).first
end
end
def find_last(limit)
limit ? records.last(limit) : records.last
end
def find_some_ordered(ids)
ids = ids.slice(offset_value || 0, limit_value || ids.size) || []
result = except(:limit, :offset).where(primary_key => ids).records
if result.size == ids.size
pk_type = @klass.type_for_attribute(primary_key)
records_by_id = result.index_by(&:id)
ids.map { |id| records_by_id.fetch(pk_type.cast(id)) }
else
raise_record_not_found_exception!(ids, result.size, ids.size)
end
end
def find_take
if loaded?
records.first
else
@take ||= limit(1).records.first
end
end
def find_take_with_limit(limit)
if loaded?
records.take(limit)
else
limit(limit).to_a
end
end
def find_nth(index)
@offsets[offset_index + index] ||= find_nth_with_limit(index, 1).first
end
def find_nth_with_limit(index, limit)
if loaded?
records[index, limit] || []
else
relation = if order_values.empty? && primary_key
order(arel_attribute(primary_key).asc)
else
self
end
relation = relation.offset(offset_index + index) unless index.zero?
relation.limit(limit).to_a
end
end
def find_nth_from_last(index)
if loaded?
records[-index]
else
relation = if order_values.empty? && primary_key
order(arel_attribute(primary_key).asc)
else
self
end
relation.to_a[-index]
# TODO: can be made more performant on large result sets by
# for instance, last(index)[-index] (which would require
# refactoring the last(n) finder method to make test suite pass),
# or by using a combination of reverse_order, limit, and offset,
# e.g., reverse_order.offset(index-1).first
end
end
def find_last(limit)
limit ? records.last(limit) : records.last
end
end
end

View file

@ -171,14 +171,14 @@ module ActiveRecord
end
end
private
private
def valid_scope_name?(name) # :doc:
if respond_to?(name, true) && logger
logger.warn "Creating scope :#{name}. " \
"Overwriting existing method #{self.name}.#{name}."
def valid_scope_name?(name)
if respond_to?(name, true) && logger
logger.warn "Creating scope :#{name}. " \
"Overwriting existing method #{self.name}.#{name}."
end
end
end
end
end
end

View file

@ -70,11 +70,11 @@ module ActiveRecord
private
def default_validation_context # :doc:
def default_validation_context
new_record? ? :create : :update
end
def raise_validation_error # :doc:
def raise_validation_error
raise(RecordInvalid.new(self))
end

View file

@ -36,11 +36,11 @@ class TestAutosaveAssociationsInGeneral < ActiveRecord::TestCase
private
def should_be_cool
unless self.first_name == "cool"
errors.add :first_name, "not cool"
def should_be_cool
unless self.first_name == "cool"
errors.add :first_name, "not cool"
end
end
end
}
reference = Class.new(ActiveRecord::Base) {
self.table_name = "references"

View file

@ -501,11 +501,11 @@ module ActiveRecord
first_thread.join(2)
second_thread.join(2)
puts '---'
puts "---"
p [first_thread, second_thread]
p pool.stat
p pool.connections.map(&:owner)
puts '<<<'
puts "<<<"
puts
end

View file

@ -73,7 +73,7 @@ module ActiveSupport
begin
BigDecimal(number)
rescue ArgumentError
BigDecimal('0')
BigDecimal("0")
end
else
BigDecimal(number)

View file

@ -1040,7 +1040,7 @@ module CallbacksTest
set_callback :foo, :before, :foo, if: callback
def run; run_callbacks :foo; end
private
def foo; end
def foo; end
}
object = klass.new
object.run

View file

@ -127,7 +127,7 @@ class HashExtTest < ActiveSupport::TestCase
transformed_hash = @nested_mixed.deep_dup
transformed_hash.deep_transform_keys! { |key| key.to_s.upcase }
assert_equal @nested_upcase_strings, transformed_hash
assert_equal({"a" => { b: { "c" => 3 } } }, @nested_mixed)
assert_equal({ "a" => { b: { "c" => 3 } } }, @nested_mixed)
end
def test_symbolize_keys

View file

@ -13,7 +13,7 @@ namespace :guides do
desc "Generate .mobi file. The kindlegen executable must be in your PATH. You can get it for free from http://www.amazon.com/gp/feature.html?docId=1000765211"
task :kindle do
require 'kindlerb'
require "kindlerb"
unless Kindlerb.kindlegen_available?
abort "Please run `setupkindlerb` to install kindlegen"
end

View file

@ -1,6 +1,6 @@
#!/usr/bin/env ruby
require 'kindlerb'
require "kindlerb"
require "nokogiri"
require "fileutils"
require "yaml"

View file

@ -29,50 +29,50 @@ module Rails
private
def call_app(request, env) # :doc:
instrumenter = ActiveSupport::Notifications.instrumenter
instrumenter.start "request.action_dispatch", request: request
logger.info { started_request_message(request) }
resp = @app.call(env)
resp[2] = ::Rack::BodyProxy.new(resp[2]) { finish(request) }
resp
rescue Exception
finish(request)
raise
ensure
ActiveSupport::LogSubscriber.flush_all!
end
def call_app(request, env) # :doc:
instrumenter = ActiveSupport::Notifications.instrumenter
instrumenter.start "request.action_dispatch", request: request
logger.info { started_request_message(request) }
resp = @app.call(env)
resp[2] = ::Rack::BodyProxy.new(resp[2]) { finish(request) }
resp
rescue Exception
finish(request)
raise
ensure
ActiveSupport::LogSubscriber.flush_all!
end
# Started GET "/session/new" for 127.0.0.1 at 2012-09-26 14:51:42 -0700
def started_request_message(request) # :doc:
'Started %s "%s" for %s at %s' % [
request.request_method,
request.filtered_path,
request.ip,
Time.now.to_default_s ]
end
# Started GET "/session/new" for 127.0.0.1 at 2012-09-26 14:51:42 -0700
def started_request_message(request) # :doc:
'Started %s "%s" for %s at %s' % [
request.request_method,
request.filtered_path,
request.ip,
Time.now.to_default_s ]
end
def compute_tags(request) # :doc:
@taggers.collect do |tag|
case tag
when Proc
tag.call(request)
when Symbol
request.send(tag)
else
tag
def compute_tags(request) # :doc:
@taggers.collect do |tag|
case tag
when Proc
tag.call(request)
when Symbol
request.send(tag)
else
tag
end
end
end
end
def finish(request)
instrumenter = ActiveSupport::Notifications.instrumenter
instrumenter.finish "request.action_dispatch", request: request
end
def finish(request)
instrumenter = ActiveSupport::Notifications.instrumenter
instrumenter.finish "request.action_dispatch", request: request
end
def logger
Rails.logger
end
def logger
Rails.logger
end
end
end
end