Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix stack trace lines on class_eval

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
commit 958b0e977a263100e3767d749afc08986acc4e7e 1 parent f87a518
@spastorino spastorino authored josevalim committed
Showing with 33 additions and 33 deletions.
  1. +1 −1  actionpack/lib/action_controller/polymorphic_routes.rb
  2. +2 −2 actionpack/lib/action_view/helpers/form_helper.rb
  3. +2 −2 actionpack/test/template/form_helper_test.rb
  4. +1 −1  activerecord/lib/active_record/attribute_methods.rb
  5. +8 −8 activerecord/lib/active_record/base.rb
  6. +1 −1  activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
  7. +1 −1  activerecord/lib/active_record/dirty.rb
  8. +2 −2 activerecord/lib/active_record/nested_attributes.rb
  9. +2 −2 activeresource/lib/active_resource/base.rb
  10. +2 −2 activeresource/lib/active_resource/http_mock.rb
  11. +1 −1  activesupport/lib/active_support/buffered_logger.rb
  12. +1 −1  activesupport/lib/active_support/cache/strategy/local_cache.rb
  13. +1 −1  activesupport/lib/active_support/core_ext/module/aliasing.rb
  14. +1 −1  activesupport/lib/active_support/core_ext/module/attr_accessor_with_default.rb
  15. +1 −1  activesupport/lib/active_support/core_ext/module/synchronization.rb
  16. +1 −1  activesupport/lib/active_support/deprecation.rb
  17. +1 −1  activesupport/lib/active_support/memoizable.rb
  18. +2 −2 activesupport/lib/active_support/multibyte/unicode_database.rb
  19. +2 −2 activesupport/lib/active_support/vendor/i18n-0.3.3/lib/i18n/backend/interpolation_compiler.rb
View
2  actionpack/lib/action_controller/polymorphic_routes.rb
@@ -115,7 +115,7 @@ def polymorphic_path(record_or_hash_or_array, options = {})
end
%w(edit new).each do |action|
- module_eval <<-EOT, __FILE__, __LINE__
+ module_eval <<-EOT, __FILE__, __LINE__ + 1
def #{action}_polymorphic_url(record_or_hash, options = {}) # def edit_polymorphic_url(record_or_hash, options = {})
polymorphic_url( # polymorphic_url(
record_or_hash, # record_or_hash,
View
4 actionpack/lib/action_view/helpers/form_helper.rb
@@ -977,7 +977,7 @@ def initialize(object_name, object, template, options, proc)
end
(field_helpers - %w(label check_box radio_button fields_for hidden_field)).each do |selector|
- src = <<-end_src
+ src, line = <<-end_src, __FILE__ + 1
def #{selector}(method, options = {}) # def text_field(method, options = {})
@template.send( # @template.send(
#{selector.inspect}, # "text_field",
@@ -986,7 +986,7 @@ def #{selector}(method, options = {}) # def text_field(method, options = {})
objectify_options(options)) # objectify_options(options))
end # end
end_src
- class_eval src, __FILE__, __LINE__
+ class_eval src, __FILE__, line
end
def fields_for(record_or_name_or_array, *args, &block)
View
4 actionpack/test/template/form_helper_test.rb
@@ -1140,12 +1140,12 @@ def test_form_for_and_fields_for_with_object
class LabelledFormBuilder < ActionView::Helpers::FormBuilder
(field_helpers - %w(hidden_field)).each do |selector|
- src = <<-END_SRC
+ src, line = <<-END_SRC, __LINE__ + 1
def #{selector}(field, *args, &proc)
("<label for='\#{field}'>\#{field.to_s.humanize}:</label> " + super + "<br/>").html_safe
end
END_SRC
- class_eval src, __FILE__, __LINE__
+ class_eval src, __FILE__, line
end
end
View
2  activerecord/lib/active_record/attribute_methods.rb
@@ -208,7 +208,7 @@ def evaluate_attribute_method(attr_name, method_definition, method_name=attr_nam
end
begin
- class_eval(method_definition, __FILE__, __LINE__)
+ class_eval(method_definition, __FILE__)
rescue SyntaxError => err
generated_methods.delete(attr_name)
if logger
View
16 activerecord/lib/active_record/base.rb
@@ -1891,7 +1891,7 @@ def method_missing(method_id, *arguments, &block)
# find(:first, options.merge(finder_options))
# end
# end
- self.class_eval %{
+ self.class_eval <<-EOS, __FILE__, __LINE__ + 1
def self.#{method_id}(*args)
options = args.extract_options!
attributes = construct_attributes_from_arguments(
@@ -1911,7 +1911,7 @@ def self.#{method_id}(*args)
end
#{'result || raise(RecordNotFound, "Couldn\'t find #{name} with #{attributes.to_a.collect {|pair| "#{pair.first} = #{pair.second}"}.join(\', \')}")' if bang}
end
- }, __FILE__, __LINE__
+ EOS
send(method_id, *arguments)
elsif match.instantiator?
instantiator = match.instantiator
@@ -1940,7 +1940,7 @@ def self.#{method_id}(*args)
# record
# end
# end
- self.class_eval %{
+ self.class_eval <<-EOS, __FILE__, __LINE__ + 1
def self.#{method_id}(*args)
guard_protected_attributes = false
@@ -1966,14 +1966,14 @@ def self.#{method_id}(*args)
record
end
end
- }, __FILE__, __LINE__
+ EOS
send(method_id, *arguments, &block)
end
elsif match = DynamicScopeMatch.match(method_id)
attribute_names = match.attribute_names
super unless all_attributes_exists?(attribute_names)
if match.scope?
- self.class_eval %{
+ self.class_eval <<-EOS, __FILE__, __LINE__ + 1
def self.#{method_id}(*args) # def self.scoped_by_user_name_and_password(*args)
options = args.extract_options! # options = args.extract_options!
attributes = construct_attributes_from_arguments( # attributes = construct_attributes_from_arguments(
@@ -1982,7 +1982,7 @@ def self.#{method_id}(*args) # def self.scoped_by_user_na
#
scoped(:conditions => attributes) # scoped(:conditions => attributes)
end # end
- }, __FILE__, __LINE__
+ EOS
send(method_id, *arguments)
end
else
@@ -2224,9 +2224,9 @@ def compute_type(type_name)
modularized_name = type_name_with_module(type_name)
silence_warnings do
begin
- class_eval(modularized_name, __FILE__, __LINE__)
+ class_eval(modularized_name, __FILE__)
rescue NameError
- class_eval(type_name, __FILE__, __LINE__)
+ class_eval(type_name, __FILE__)
end
end
end
View
2  activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
@@ -13,7 +13,7 @@ def included(base)
def dirties_query_cache(base, *method_names)
method_names.each do |method_name|
- base.class_eval <<-end_code, __FILE__, __LINE__
+ base.class_eval <<-end_code, __FILE__, __LINE__ + 1
def #{method_name}_with_query_dirty(*args) # def update_with_query_dirty(*args)
clear_query_cache if @query_cache_enabled # clear_query_cache if @query_cache_enabled
#{method_name}_without_query_dirty(*args) # update_without_query_dirty(*args)
View
2  activerecord/lib/active_record/dirty.rb
@@ -173,7 +173,7 @@ def self.extended(base)
def alias_attribute_with_dirty(new_name, old_name)
alias_attribute_without_dirty(new_name, old_name)
DIRTY_SUFFIXES.each do |suffix|
- module_eval <<-STR, __FILE__, __LINE__+1
+ module_eval <<-STR, __FILE__, __LINE__ + 1
def #{new_name}#{suffix}; self.#{old_name}#{suffix}; end # def subject_changed?; self.title_changed?; end
STR
end
View
4 activerecord/lib/active_record/nested_attributes.rb
@@ -239,11 +239,11 @@ def accepts_nested_attributes_for(*attr_names)
# def pirate_attributes=(attributes)
# assign_nested_attributes_for_one_to_one_association(:pirate, attributes)
# end
- class_eval %{
+ class_eval <<-EOS, __FILE__, __LINE__ + 1
def #{association_name}_attributes=(attributes)
assign_nested_attributes_for_#{type}_association(:#{association_name}, attributes)
end
- }, __FILE__, __LINE__
+ EOS
else
raise ArgumentError, "No association found for name `#{association_name}'. Has it been defined yet?"
end
View
4 activeresource/lib/active_resource/base.rb
@@ -431,11 +431,11 @@ def prefix=(value = '/')
@prefix_parameters = nil
# Redefine the new methods.
- code = <<-end_code
+ code, line = <<-end_code, __LINE__ + 1
def prefix_source() "#{value}" end
def prefix(options={}) "#{prefix_call}" end
end_code
- silence_warnings { instance_eval code, __FILE__, __LINE__ }
+ silence_warnings { instance_eval code, __FILE__, line }
rescue
logger.error "Couldn't set prefix: #{$!}\n #{code}"
raise
View
4 activeresource/lib/active_resource/http_mock.rb
@@ -57,7 +57,7 @@ def initialize(responses)
# def post(path, request_headers = {}, body = nil, status = 200, response_headers = {})
# @responses[Request.new(:post, path, nil, request_headers)] = Response.new(body || "", status, response_headers)
# end
- module_eval <<-EOE, __FILE__, __LINE__
+ module_eval <<-EOE, __FILE__, __LINE__ + 1
def #{method}(path, request_headers = {}, body = nil, status = 200, response_headers = {})
@responses << [Request.new(:#{method}, path, nil, request_headers), Response.new(body || "", status, response_headers)]
end
@@ -125,7 +125,7 @@ def reset!
# self.class.requests << request
# self.class.responses.assoc(request).try(:second) || raise(InvalidRequestError.new("No response recorded for #{request}"))
# end
- module_eval <<-EOE, __FILE__, __LINE__
+ module_eval <<-EOE, __FILE__, __LINE__ + 1
def #{method}(path, #{'body, ' if has_body}headers)
request = ActiveResource::Request.new(:#{method}, path, #{has_body ? 'body, ' : 'nil, '}headers)
self.class.requests << request
View
2  activesupport/lib/active_support/buffered_logger.rb
@@ -67,7 +67,7 @@ def add(severity, message = nil, progname = nil, &block)
end
for severity in Severity.constants
- class_eval <<-EOT, __FILE__, __LINE__
+ class_eval <<-EOT, __FILE__, __LINE__ + 1
def #{severity.downcase}(message = nil, progname = nil, &block) # def debug(message = nil, progname = nil, &block)
add(#{severity}, message, progname, &block) # add(DEBUG, message, progname, &block)
end # end
View
2  activesupport/lib/active_support/cache/strategy/local_cache.rb
@@ -15,7 +15,7 @@ def with_local_cache
def middleware
@middleware ||= begin
klass = Class.new
- klass.class_eval(<<-EOS, __FILE__, __LINE__)
+ klass.class_eval(<<-EOS, __FILE__, __LINE__ + 1)
def initialize(app)
@app = app
end
View
2  activesupport/lib/active_support/core_ext/module/aliasing.rb
@@ -63,7 +63,7 @@ def alias_method_chain(target, feature)
# e.subject = "Megastars"
# e.title # => "Megastars"
def alias_attribute(new_name, old_name)
- module_eval <<-STR, __FILE__, __LINE__+1
+ module_eval <<-STR, __FILE__, __LINE__ + 1
def #{new_name}; self.#{old_name}; end # def subject; self.title; end
def #{new_name}?; self.#{old_name}?; end # def subject?; self.title?; end
def #{new_name}=(v); self.#{old_name} = v; end # def subject=(v); self.title = v; end
View
2  activesupport/lib/active_support/core_ext/module/attr_accessor_with_default.rb
@@ -21,7 +21,7 @@ class Module
def attr_accessor_with_default(sym, default = nil, &block)
raise 'Default value or block required' unless !default.nil? || block
define_method(sym, block_given? ? block : Proc.new { default })
- module_eval(<<-EVAL, __FILE__, __LINE__)
+ module_eval(<<-EVAL, __FILE__, __LINE__ + 1)
def #{sym}=(value) # def age=(value)
class << self; attr_reader :#{sym} end # class << self; attr_reader :age end
@#{sym} = value # @age = value
View
2  activesupport/lib/active_support/core_ext/module/synchronization.rb
@@ -25,7 +25,7 @@ def synchronize(*methods)
raise ArgumentError, "#{method} is already synchronized. Double synchronization is not currently supported."
end
- module_eval(<<-EOS, __FILE__, __LINE__)
+ module_eval(<<-EOS, __FILE__, __LINE__ + 1)
def #{aliased_method}_with_synchronization#{punctuation}(*args, &block) # def expire_with_synchronization(*args, &block)
#{with}.synchronize do # @@lock.synchronize do
#{aliased_method}_without_synchronization#{punctuation}(*args, &block) # expire_without_synchronization(*args, &block)
View
2  activesupport/lib/active_support/deprecation.rb
@@ -90,7 +90,7 @@ def deprecate(*method_names)
method_names = method_names + options.keys
method_names.each do |method_name|
alias_method_chain(method_name, :deprecation) do |target, punctuation|
- class_eval(<<-EOS, __FILE__, __LINE__)
+ class_eval(<<-EOS, __FILE__, __LINE__ + 1)
def #{target}_with_deprecation#{punctuation}(*args, &block) # def generate_secret_with_deprecation(*args, &block)
::ActiveSupport::Deprecation.warn( # ::ActiveSupport::Deprecation.warn(
self.class.deprecated_method_warning( # self.class.deprecated_method_warning(
View
2  activesupport/lib/active_support/memoizable.rb
@@ -58,7 +58,7 @@ def memoize(*symbols)
original_method = :"_unmemoized_#{symbol}"
memoized_ivar = ActiveSupport::Memoizable.memoized_ivar_for(symbol)
- class_eval <<-EOS, __FILE__, __LINE__
+ class_eval <<-EOS, __FILE__, __LINE__ + 1
include InstanceMethods # include InstanceMethods
#
if method_defined?(:#{original_method}) # if method_defined?(:_unmemoized_mime_type)
View
4 activesupport/lib/active_support/multibyte/unicode_database.rb
@@ -23,7 +23,7 @@ def initialize
# Lazy load the Unicode database so it's only loaded when it's actually used
ATTRIBUTES.each do |attr_name|
- class_eval(<<-EOS, __FILE__, __LINE__)
+ class_eval(<<-EOS, __FILE__, __LINE__ + 1)
def #{attr_name} # def codepoints
load # load
@#{attr_name} # @codepoints
@@ -68,4 +68,4 @@ def self.filename
# UniCode Database
UCD = UnicodeDatabase.new
end
-end
+end
View
4 ...vesupport/lib/active_support/vendor/i18n-0.3.3/lib/i18n/backend/interpolation_compiler.rb
@@ -22,7 +22,7 @@ module Compiler
def compile_if_an_interpolation(string)
if interpolated_str?(string)
- string.instance_eval <<-RUBY_EVAL, __FILE__, __LINE__
+ string.instance_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
def i18n_interpolate(v = {})
"#{compiled_interpolation_body(string)}"
end
@@ -116,4 +116,4 @@ def compile_all_strings_in(data)
end
end
end
-end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.