Permalink
Browse files

remove reverse_merge

Conflicts:
	padrino-helpers/lib/padrino-helpers/asset_tag_helpers.rb
	padrino-helpers/lib/padrino-helpers/form_builder/standard_form_builder.rb
  • Loading branch information...
ujifgc committed Oct 27, 2015
1 parent af177cc commit a335e0d8328d841e5481a9bc567ed3ad928e8eba
@@ -507,7 +507,7 @@ def route(verb, path, *args, &block)
path, *route_options[:with] = path if path.is_a?(Array)
action = path
path, name, route_parents, options, route_options = *parse_route(path, route_options, verb)
options.reverse_merge!(@_conditions) if @_conditions
options = @_conditions.merge(options) if @_conditions
method_name = "#{verb} #{path}"
unbound_method = generate_method(method_name, &block)
@@ -656,8 +656,7 @@ def parse_route(path, options, verb)
name = "#{controller_name} #{name}".to_sym unless controller_name.blank?
end
# Merge in option defaults.
options.reverse_merge!(:default_values => @_defaults)
options[:default_values] = @_defaults unless options.has_key?(:default_values)
[path, name, parent_params, options, route_options]
end
@@ -144,7 +144,7 @@ def remove_migration(name)
# => inject_into_file("test/test_config.rb", TEST.gsub(/CLASS_NAME/, @app_name), :after => "set :environment, :test")
#
def insert_test_suite_setup(suite_text, options={})
options.reverse_merge!(:path => "test/test_config.rb")
options = { :path => "test/test_config.rb" }.update(options)
create_file(options[:path], suite_text.gsub(/CLASS_NAME/, "#{@project_name}::#{@app_name}"))
end
@@ -161,7 +161,7 @@ def insert_test_suite_setup(suite_text, options={})
# => inject_into_file("test/test_config.rb", " include Mocha::API\n", :after => /class.*?\n/)
#
def insert_mocking_include(library_name, options={})
options.reverse_merge!(:indent => 2, :after => /class.*?\n/, :path => "test/test_config.rb")
options = { :indent => 2, :after => /class.*?\n/, :path => "test/test_config.rb" }.update(options)
return unless File.exist?(destination_root(options[:path]))
include_text = indent_spaces(2) + "include #{library_name}\n"
inject_into_file(options[:path], include_text, :after => options[:after])
@@ -85,7 +85,7 @@ def link_to(*args, &block)
options = args.extract_options!
name = block_given? ? '' : args.shift
href = args.first
options.reverse_merge!(:href => href || '#')
options = { :href => href || '#' }.update(options)
return name unless parse_conditions(href, options)
block_given? ? content_tag(:a, options, &block) : content_tag(:a, name, options)
end
@@ -116,7 +116,7 @@ def link_to(*args, &block)
#
def feed_tag(mime, url, options={})
full_mime = (mime == :atom) ? 'application/atom+xml' : 'application/rss+xml'
tag(:link, options.reverse_merge(:rel => 'alternate', :type => full_mime, :title => mime, :href => url))
tag(:link, { :rel => 'alternate', :type => full_mime, :title => mime, :href => url }.update(options))
end
##
@@ -167,7 +167,7 @@ def mail_to(email, caption=nil, mail_options={})
# # Generates: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
#
def meta_tag(content, options={})
options.reverse_merge!("content" => content)
options = { "content" => content }.update(options)
tag(:meta, options)
end
@@ -189,7 +189,7 @@ def meta_tag(content, options={})
#
def favicon_tag(source, options={})
type = File.extname(source).sub('.','')
options = options.dup.reverse_merge!(:href => image_path(source), :rel => 'icon', :type => "image/#{type}")
options = { :href => image_path(source), :rel => 'icon', :type => "image/#{type}" }.update(options)
tag(:link, options)
end
@@ -207,8 +207,8 @@ def favicon_tag(source, options={})
# image_tag('icons/avatar.png')
#
def image_tag(url, options={})
options.reverse_merge!(:src => image_path(url))
options[:alt] ||= image_alt(url) unless url =~ /\A(?:cid|data):/ || url.blank?
options = { :src => image_path(url) }.update(options)
options[:alt] ||= image_alt(url) unless url.to_s =~ /\A(?:cid|data):|\A\Z/
tag(:img, options)
end
@@ -17,7 +17,10 @@ class StandardFormBuilder < AbstractFormBuilder
(self.field_types - [ :hidden_field, :radio_button ]).each do |field_type|
class_eval <<-EOF
def #{field_type}_block(field, options={}, label_options={})
label_options = { :caption => options[:caption] }.update(label_options) if options[:caption]
if options[:caption]
options = options.dup
label_options = { :caption => options.delete(:caption) }.update(label_options)
end
field_html = label(field, label_options)
field_html << #{field_type}(field, options)
@template.content_tag(:p, field_html)
@@ -125,7 +125,7 @@ def pluralize(count, singular, plural = nil)
# truncate("Once upon a time in a world far far away", :length => 8) => "Once upon..."
#
def truncate(text, options={})
options.reverse_merge!(:length => 30, :omission => "...")
options = { :length => 30, :omission => "..." }.update(options)
if text
len = options[:length] - options[:omission].length
chars = text
@@ -152,7 +152,7 @@ def truncate(text, options={})
# truncate_words("Once upon a time in a world far far away", :length => 8) => "Once upon a time in a world far..."
#
def truncate_words(text, options={})
options.reverse_merge!(:length => 30, :omission => "...")
options = { :length => 30, :omission => "..." }.update(options)
if text
words = text.split()
words[0..(options[:length]-1)].join(' ') + (words.length > options[:length] ? options[:omission] : '')
@@ -181,7 +181,7 @@ def word_wrap(text, *args)
unless args.blank?
options[:line_width] = args[0] || 80
end
options.reverse_merge!(:line_width => 80)
options = { :line_width => 80 }.update(options)
text.split("\n").map do |line|
line.length > options[:line_width] ? line.gsub(/(.{1,#{options[:line_width]}})(\s+|$)/, "\\1\n").strip : line
@@ -214,8 +214,7 @@ def word_wrap(text, *args)
# # => Lorem ipsum <strong class="custom">dolor</strong> sit amet
#
def highlight(text, words, *args)
options = args.extract_options!
options.reverse_merge!(:highlighter => '<strong class="highlight">\1</strong>')
options = { :highlighter => '<strong class="highlight">\1</strong>' }.update(args.extract_options!)
if text.blank? || words.blank?
text
@@ -33,7 +33,7 @@ def stop_time_for_test
# mock_model("Business", :new_record? => true) => <Business>
def mock_model(klazz, options={})
options.reverse_merge!(:class => klazz, :new_record? => false, :id => 20, :errors => {})
options = { :class => klazz, :new_record? => false, :id => 20, :errors => {}}.update(options)
record = stub(options)
record.stubs(:to_ary => [record])
record
@@ -137,7 +137,7 @@ def email(mail_attributes={}, &block)
message = _padrino_mailer::Message.new(self)
message.delivery_method(*delivery_settings)
message.instance_eval(&block) if block_given?
mail_attributes.reverse_merge(mailer_defaults) if respond_to?(:mailer_defaults)
mail_attributes = mailer_defaults.merge(mail_attributes) if respond_to?(:mailer_defaults)
mail_attributes.each_pair { |k, v| message.method(k).call(v) }
message.deliver
end
@@ -2,14 +2,16 @@
# This file loads certain extensions required by Padrino from ActiveSupport.
#
require 'active_support/core_ext/module/aliasing' # alias_method_chain
require 'active_support/core_ext/hash/reverse_merge' # reverse_merge
require 'active_support/core_ext/hash/keys' # symbolize_keys
require 'active_support/core_ext/hash/indifferent_access' # params[:foo]
require 'active_support/core_ext/hash/slice' # slice
require 'active_support/core_ext/array/extract_options' # Array#extract_options!
require 'active_support/core_ext/object/blank' # present?
require 'active_support/core_ext/string/output_safety' # SafeBuffer and html_safe
# Remove these on 0.14:
require 'active_support/core_ext/hash/reverse_merge' # reverse_merge
require 'padrino-support/core_ext/string/inflections'
require 'padrino-support/core_ext/string/colorize'
require 'padrino-support/core_ext/object_space'

0 comments on commit a335e0d

Please sign in to comment.