diff --git a/CHANGELOG b/CHANGELOG index d1bf359..05136d8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +0.3.2 (unreleased) + - Fixed an issue with classes that define their own #send method (ex: Socket) + - Fixed compatibility issue with Liquid gem that defines Module#liquid_methods + - Fixed hash spec for Ruby < 1.9 where order of hash keys is not guaranteed + 0.3.1 RubyConf X edition - Fixed Ruby 1.8.6 compatibility issues (thanks, Tim!) - Fixed stack overflow issue with Rails 2.3.x console diff --git a/lib/ap/core_ext/array.rb b/lib/ap/core_ext/array.rb index 30c6555..60e126b 100644 --- a/lib/ap/core_ext/array.rb +++ b/lib/ap/core_ext/array.rb @@ -16,7 +16,7 @@ class Array #:nodoc: [ :-, :& ].each do |operator| alias :"original_#{operator.object_id}" :"#{operator}" define_method operator do |*args| - arr = self.send(:"original_#{operator.object_id}", *args) + arr = self.__send__(:"original_#{operator.object_id}", *args) if self.instance_variable_defined?('@__awesome_methods__') arr.instance_variable_set('@__awesome_methods__', self.instance_variable_get('@__awesome_methods__')) arr.sort! diff --git a/lib/ap/core_ext/class.rb b/lib/ap/core_ext/class.rb index 67573a1..07f28cf 100644 --- a/lib/ap/core_ext/class.rb +++ b/lib/ap/core_ext/class.rb @@ -4,10 +4,12 @@ # See LICENSE file or http://www.opensource.org/licenses/mit-license.php #------------------------------------------------------------------------------ class Class #:nodoc: - methods.grep(/instance_methods$/) do |name| + # Remaining public/private etc. '_methods' are handled in core_ext/object.rb. + %w(instance_methods private_instance_methods protected_instance_methods public_instance_methods).each do |name| alias :"original_#{name}" :"#{name}" + define_method name do |*args| - methods = self.send(:"original_#{name}", *args) + methods = self.__send__(:"original_#{name}", *args) methods.instance_variable_set('@__awesome_methods__', self) # Evil?! methods.sort! end diff --git a/lib/ap/core_ext/object.rb b/lib/ap/core_ext/object.rb index 5227887..2d7c0a6 100644 --- a/lib/ap/core_ext/object.rb +++ b/lib/ap/core_ext/object.rb @@ -4,14 +4,14 @@ # See LICENSE file or http://www.opensource.org/licenses/mit-license.php #------------------------------------------------------------------------------ class Object #:nodoc: - methods.grep(/methods$/) do |name| - next if name.to_s.include? 'instance' # Instance methods are trapped in Class. - + # Remaining instance '_methods' are handled in core_ext/class.rb. + %w(methods private_methods protected_methods public_methods singleton_methods).each do |name| alias :"original_#{name}" :"#{name}" + define_method name do |*args| - methods = self.send(:"original_#{name}", *args) + methods = self.__send__(:"original_#{name}", *args) methods.instance_variable_set('@__awesome_methods__', self) # Evil?! methods.sort! end end -end \ No newline at end of file +end diff --git a/lib/ap/core_ext/string.rb b/lib/ap/core_ext/string.rb old mode 100755 new mode 100644 diff --git a/spec/awesome_print_spec.rb b/spec/awesome_print_spec.rb index 1dc6a1c..1a265ec 100644 --- a/spec/awesome_print_spec.rb +++ b/spec/awesome_print_spec.rb @@ -514,5 +514,14 @@ EOS my = My.new('/tmp') my.ai(:plain => true).should == "#{my.inspect}\n" << `ls -alF #{my.path}`.chop end + + it "should handle a class that defines its own #send method" do + class My + def send(arg1, arg2, arg3); end + end + + my = My.new + my.methods.ai(:plain => true).should_not raise_error(ArgumentError) + end end end