Hello community,
here is the log from the commit of package rubygem-method_source for
openSUSE:Factory checked in at 2017-09-26 21:16:48
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-method_source (Old)
and /work/SRC/openSUSE:Factory/.rubygem-method_source.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-method_source"
Tue Sep 26 21:16:48 2017 rev:10 rq:528823 version:0.9.0
Changes:
--------
---
/work/SRC/openSUSE:Factory/rubygem-method_source/rubygem-method_source.changes
2015-04-10 09:54:02.000000000 +0200
+++
/work/SRC/openSUSE:Factory/.rubygem-method_source.new/rubygem-method_source.changes
2017-09-26 21:17:44.530393441 +0200
@@ -1,0 +2,9 @@
+Tue Sep 26 13:22:44 UTC 2017 - [email protected]
+
+- update to version 0.9.0
+ Manually added the License (MIT), wasn't read by gem2rpm from
+ meta data of the gem
+
+ No changelog provided by the gem authors
+
+-------------------------------------------------------------------
Old:
----
method_source-0.8.2.gem
New:
----
method_source-0.9.0.gem
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ rubygem-method_source.spec ++++++
--- /var/tmp/diff_new_pack.1bbJPc/_old 2017-09-26 21:17:45.034322594 +0200
+++ /var/tmp/diff_new_pack.1bbJPc/_new 2017-09-26 21:17:45.038322031 +0200
@@ -1,7 +1,7 @@
#
# spec file for package rubygem-method_source
#
-# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -24,16 +24,16 @@
#
Name: rubygem-method_source
-Version: 0.8.2
+Version: 0.9.0
Release: 0
%define mod_name method_source
%define mod_full_name %{mod_name}-%{version}
BuildRoot: %{_tmppath}/%{name}-%{version}-build
-BuildRequires: ruby-macros >= 5
-BuildRequires: %{ruby}
BuildRequires: %{rubygem gem2rpm}
+BuildRequires: %{ruby}
+BuildRequires: ruby-macros >= 5
Url: http://banisterfiend.wordpress.com
-Source: http://rubygems.org/gems/%{mod_full_name}.gem
+Source: https://rubygems.org/gems/%{mod_full_name}.gem
Source1: gem2rpm.yml
Summary: retrieve the sourcecode for a method
License: MIT
++++++ gem2rpm.yml ++++++
--- /var/tmp/diff_new_pack.1bbJPc/_old 2017-09-26 21:17:45.098313597 +0200
+++ /var/tmp/diff_new_pack.1bbJPc/_new 2017-09-26 21:17:45.098313597 +0200
@@ -7,7 +7,7 @@
#
# it can be multiline
# ## used by gem2rpm
-# :license: MIT or Ruby
+:license: MIT
# ## used by gem2rpm and gem_packages
# :version_suffix: -x_y
# ## used by gem2rpm and gem_packages
++++++ method_source-0.8.2.gem -> method_source-0.9.0.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/.travis.yml new/.travis.yml
--- old/.travis.yml 1970-01-01 01:00:00.000000000 +0100
+++ new/.travis.yml 2017-09-26 13:43:00.000000000 +0200
@@ -1,12 +1,29 @@
+# To use rbx environment.
+dist: trusty
+bundler_args: "--verbose"
+before_install:
+ - gem update --system
+ - which bundle || gem install bundler
+ - gem update bundler
rvm:
- 1.8.7
- - 1.9.2
- 1.9.3
- ree
- - rbx-18mode
- - rbx-19mode
+ - rbx-3
- jruby
-
+ - jruby-head
+ - 2.0.0
+ - 2.1
+ - 2.2
+ - 2.3
+ - 2.4.1
+ - ruby-head
+matrix:
+ allow_failures:
+ - rvm: ruby-head
+ - rvm: jruby-head
+ - rvm: rbx-3
+ fast_finish: true
notifications:
irc: "irc.freenode.org#pry"
recipients:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Gemfile new/Gemfile
--- old/Gemfile 1970-01-01 01:00:00.000000000 +0100
+++ new/Gemfile 2017-09-26 13:43:00.000000000 +0200
@@ -1,2 +1,2 @@
-source :rubygems
+source 'https://rubygems.org'
gemspec
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/README.markdown new/README.markdown
--- old/README.markdown 1970-01-01 01:00:00.000000000 +0100
+++ new/README.markdown 2017-09-26 13:43:00.000000000 +0200
@@ -1,4 +1,4 @@
-method_source
+method_source [](https://travis-ci.org/banister/method_source)
=============
(C) John Mair (banisterfiend) 2011
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Rakefile new/Rakefile
--- old/Rakefile 1970-01-01 01:00:00.000000000 +0100
+++ new/Rakefile 2017-09-26 13:43:00.000000000 +0200
@@ -20,16 +20,17 @@
s.description = s.summary
s.require_path = 'lib'
- s.add_development_dependency("bacon","~>1.1.0")
+ s.add_development_dependency("rspec","~>3.6")
s.add_development_dependency("rake", "~>0.9")
s.homepage = "http://banisterfiend.wordpress.com"
s.has_rdoc = 'yard'
s.files = `git ls-files`.split("\n")
- s.test_files = `git ls-files -- test/*`.split("\n")
+ s.test_files = `git ls-files -- spec/*`.split("\n")
end
-task :test do
- sh "bacon -q #{direc}/test/test.rb #{direc}/test/test_code_helpers.rb"
+require "rspec/core/rake_task"
+RSpec::Core::RakeTask.new(:spec) do |t|
+ t.ruby_opts = %w[-w]
end
desc "reinstall gem"
@@ -39,7 +40,7 @@
end
desc "Set up and run tests"
-task :default => [:test]
+task :default => [:spec]
desc "Build the gemspec file"
task :gemspec => "ruby:gemspec"
Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/method_source/code_helpers.rb
new/lib/method_source/code_helpers.rb
--- old/lib/method_source/code_helpers.rb 1970-01-01 01:00:00.000000000
+0100
+++ new/lib/method_source/code_helpers.rb 2017-09-26 13:43:00.000000000
+0200
@@ -6,14 +6,14 @@
# This is useful to get module or method source code.
#
# @param [Array<String>, File, String] file The file to parse, either as
a File or as
- # @param [Fixnum] line_number The line number at which to look.
+ # @param [Integer] line_number The line number at which to look.
# NOTE: The first line in a file is
# line 1!
# @param [Hash] options The optional configuration parameters.
# @option options [Boolean] :strict If set to true, then only completely
# valid expressions are returned. Otherwise heuristics are used to
extract
# expressions that may have been valid inside an eval.
- # @option options [Fixnum] :consume A number of lines to automatically
+ # @option options [Integer] :consume A number of lines to automatically
# consume (add to the expression buffer) without checking for validity.
# @return [String] The first complete expression
# @raise [SyntaxError] If the first complete expression can't be
identified
@@ -46,7 +46,7 @@
#
# @param [Array<String>, File, String] file The file to parse, either as
a File or as
# a String or an Array of lines.
- # @param [Fixnum] line_number The line number at which to look.
+ # @param [Integer] line_number The line number at which to look.
# NOTE: The first line in a file is line 1!
# @return [String] The comment
def comment_describing(file, line_number)
@@ -84,7 +84,7 @@
# Get the first expression from the input.
#
# @param [Array<String>] lines
- # @param [Fixnum] consume A number of lines to automatically
+ # @param [Integer] consume A number of lines to automatically
# consume (add to the expression buffer) without checking for validity.
# @yield a clean-up function to run before checking for complete_expression
# @return [String] a valid ruby expression
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/method_source/source_location.rb
new/lib/method_source/source_location.rb
--- old/lib/method_source/source_location.rb 1970-01-01 01:00:00.000000000
+0100
+++ new/lib/method_source/source_location.rb 2017-09-26 13:43:00.000000000
+0200
@@ -111,7 +111,7 @@
case
when klass == Symbol
return :a.method(name).source_location
- when klass == Fixnum
+ when klass == Integer
return 0.method(name).source_location
when klass == TrueClass
return true.method(name).source_location
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/method_source/version.rb
new/lib/method_source/version.rb
--- old/lib/method_source/version.rb 1970-01-01 01:00:00.000000000 +0100
+++ new/lib/method_source/version.rb 2017-09-26 13:43:00.000000000 +0200
@@ -1,3 +1,3 @@
module MethodSource
- VERSION = "0.8.2"
+ VERSION = "0.9.0"
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata 1970-01-01 01:00:00.000000000 +0100
+++ new/metadata 2017-09-26 13:43:00.000000000 +0200
@@ -1,41 +1,41 @@
--- !ruby/object:Gem::Specification
name: method_source
version: !ruby/object:Gem::Version
- version: 0.8.2
+ version: 0.9.0
platform: ruby
authors:
- John Mair (banisterfiend)
autorequire:
bindir: bin
cert_chain: []
-date: 2013-07-27 00:00:00.000000000 Z
+date: 2017-09-26 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
- name: bacon
+ name: rspec
requirement: !ruby/object:Gem::Requirement
requirements:
- - - ~>
+ - - "~>"
- !ruby/object:Gem::Version
- version: 1.1.0
+ version: '3.6'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - - ~>
+ - - "~>"
- !ruby/object:Gem::Version
- version: 1.1.0
+ version: '3.6'
- !ruby/object:Gem::Dependency
name: rake
requirement: !ruby/object:Gem::Requirement
requirements:
- - - ~>
+ - - "~>"
- !ruby/object:Gem::Version
version: '0.9'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - - ~>
+ - - "~>"
- !ruby/object:Gem::Version
version: '0.9'
description: retrieve the sourcecode for a method
@@ -44,9 +44,9 @@
extensions: []
extra_rdoc_files: []
files:
-- .gemtest
-- .travis.yml
-- .yardopts
+- ".gemtest"
+- ".travis.yml"
+- ".yardopts"
- Gemfile
- LICENSE
- README.markdown
@@ -56,9 +56,9 @@
- lib/method_source/source_location.rb
- lib/method_source/version.rb
- method_source.gemspec
-- test/test.rb
-- test/test_code_helpers.rb
-- test/test_helper.rb
+- spec/method_source/code_helpers_spec.rb
+- spec/method_source_spec.rb
+- spec/spec_helper.rb
homepage: http://banisterfiend.wordpress.com
licenses: []
metadata: {}
@@ -68,21 +68,21 @@
- lib
required_ruby_version: !ruby/object:Gem::Requirement
requirements:
- - - '>='
+ - - ">="
- !ruby/object:Gem::Version
version: '0'
required_rubygems_version: !ruby/object:Gem::Requirement
requirements:
- - - '>='
+ - - ">="
- !ruby/object:Gem::Version
version: '0'
requirements: []
rubyforge_project:
-rubygems_version: 2.0.2
+rubygems_version: 2.6.12
signing_key:
specification_version: 4
summary: retrieve the sourcecode for a method
test_files:
-- test/test.rb
-- test/test_code_helpers.rb
-- test/test_helper.rb
+- spec/method_source/code_helpers_spec.rb
+- spec/method_source_spec.rb
+- spec/spec_helper.rb
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/method_source.gemspec new/method_source.gemspec
--- old/method_source.gemspec 1970-01-01 01:00:00.000000000 +0100
+++ new/method_source.gemspec 2017-09-26 13:43:00.000000000 +0200
@@ -6,28 +6,29 @@
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to?
:required_rubygems_version=
s.authors = ["John Mair (banisterfiend)"]
+ s.licenses = ['MIT']
s.date = "2012-10-17"
s.description = "retrieve the sourcecode for a method"
s.email = "[email protected]"
- s.files = [".gemtest", ".travis.yml", ".yardopts", "Gemfile", "LICENSE",
"README.markdown", "Rakefile", "lib/method_source.rb",
"lib/method_source/code_helpers.rb", "lib/method_source/source_location.rb",
"lib/method_source/version.rb", "method_source.gemspec", "test/test.rb",
"test/test_code_helpers.rb", "test/test_helper.rb"]
+ s.files = [".gemtest", ".travis.yml", ".yardopts", "Gemfile", "LICENSE",
"README.markdown", "Rakefile", "lib/method_source.rb",
"lib/method_source/code_helpers.rb", "lib/method_source/source_location.rb",
"lib/method_source/version.rb", "method_source.gemspec",
"spec/method_source/code_helpers_spec.rb", "spec/method_source_spec.rb",
"spec/spec_helper.rb"]
s.homepage = "http://banisterfiend.wordpress.com"
s.require_paths = ["lib"]
s.rubygems_version = "1.8.23"
s.summary = "retrieve the sourcecode for a method"
- s.test_files = ["test/test.rb", "test/test_code_helpers.rb",
"test/test_helper.rb"]
+ s.test_files = ["spec/method_source/code_helpers_spec.rb",
"spec/method_source_spec.rb", "spec/spec_helper.rb"]
if s.respond_to? :specification_version then
s.specification_version = 3
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
- s.add_development_dependency(%q<bacon>, ["~> 1.1.0"])
+ s.add_development_dependency(%q<rspec>, ["~> 3.6"])
s.add_development_dependency(%q<rake>, ["~> 0.9"])
else
- s.add_dependency(%q<bacon>, ["~> 1.1.0"])
+ s.add_dependency(%q<rspec>, ["~> 3.6"])
s.add_dependency(%q<rake>, ["~> 0.9"])
end
else
- s.add_dependency(%q<bacon>, ["~> 1.1.0"])
+ s.add_dependency(%q<rspec>, ["~> 3.6"])
s.add_dependency(%q<rake>, ["~> 0.9"])
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/method_source/code_helpers_spec.rb
new/spec/method_source/code_helpers_spec.rb
--- old/spec/method_source/code_helpers_spec.rb 1970-01-01 01:00:00.000000000
+0100
+++ new/spec/method_source/code_helpers_spec.rb 2017-09-26 13:43:00.000000000
+0200
@@ -0,0 +1,43 @@
+require 'spec_helper'
+
+describe MethodSource::CodeHelpers do
+ before do
+ @tester = Object.new.extend(MethodSource::CodeHelpers)
+ end
+
+ [
+ ["p = '", "'"],
+ ["def", "a", "(); end"],
+ ["p = <<FOO", "lots", "and", "lots of", "foo", "FOO"],
+ ["[", ":lets,", "'list',", "[/nested/", "], things ]"],
+ ["abc =~ /hello", "/"],
+ ["issue = %W/", "343/"],
+ ["pouts(<<HI, 'foo", "bar", "HI", "baz')"],
+ ["=begin", "no-one uses this syntax anymore...", "=end"],
+ ["puts 1, 2,", "3"],
+ ["puts 'hello'\\", "'world'"]
+ ].each do |lines|
+ it "should not raise an error on broken lines: #{lines.join("\\n")}" do
+ 1.upto(lines.size - 1) do |i|
+ expect(@tester.complete_expression?(lines[0...i].join("\n") +
"\n")).to be_falsy
+ end
+ expect(@tester.complete_expression?(lines.join("\n"))).to be_truthy
+ end
+ end
+
+ [
+ ["end"],
+ ["puts )("],
+ ["1 1"],
+ ["puts :"]
+ ] + (RbConfig::CONFIG['ruby_install_name'] == 'rbx' ? [] : [
+ ["def", "method(1"], # in this case the syntax error is "expecting ')'".
+ ["o = Object.new.tap{ def o.render;","'MEH'", "}"] # in this case the
syntax error is "expecting keyword_end".
+ ]).compact.each do |foo|
+ it "should raise an error on invalid syntax like #{foo.inspect}" do
+ expect {
+ @tester.complete_expression?(foo.join("\n"))
+ }.to raise_error(SyntaxError)
+ end
+ end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/method_source_spec.rb
new/spec/method_source_spec.rb
--- old/spec/method_source_spec.rb 1970-01-01 01:00:00.000000000 +0100
+++ new/spec/method_source_spec.rb 2017-09-26 13:43:00.000000000 +0200
@@ -0,0 +1,143 @@
+require 'spec_helper'
+
+describe MethodSource do
+
+ describe "source_location (testing 1.8 implementation)" do
+ it 'should return correct source_location for a method' do
+ expect(method(:hello).source_location.first).to match(/spec_helper/)
+ end
+
+ it 'should not raise for immediate instance methods' do
+ [Symbol, Integer, TrueClass, FalseClass, NilClass].each do
|immediate_class|
+ expect do
+ immediate_class.instance_method(:to_s).source_location
+ end.not_to raise_error
+ end
+ end
+
+ it 'should not raise for immediate methods' do
+ [:a, 1, true, false, nil].each do |immediate|
+ expect do
+ immediate.method(:to_s).source_location
+ end.not_to raise_error
+ end
+ end
+ end
+
+ before do
+ @hello_module_source = " def hello; :hello_module; end\n"
+ @hello_singleton_source = "def $o.hello; :hello_singleton; end\n"
+ @hello_source = "def hello; :hello; end\n"
+ @hello_comment = "# A comment for hello\n# It spans two lines and is
indented by 2 spaces\n"
+ @lambda_comment = "# This is a comment for MyLambda\n"
+ @lambda_source = "MyLambda = lambda { :lambda }\n"
+ @proc_source = "MyProc = Proc.new { :proc }\n"
+ @hello_instance_evaled_source = " def hello_\#{name}(*args)\n
send_mesg(:\#{name}, *args)\n end\n"
+ @hello_instance_evaled_source_2 = " def \#{name}_two()\n if 44\n
45\n end\n end\n"
+ @hello_class_evaled_source = " def hello_\#{name}(*args)\n
send_mesg(:\#{name}, *args)\n end\n"
+ @hi_module_evaled_source = " def hi_\#{name}\n @var = \#{name}\n
end\n"
+ end
+
+ it 'should define methods on Method and UnboundMethod and Proc' do
+ expect(Method.method_defined?(:source)).to be_truthy
+ expect(UnboundMethod.method_defined?(:source)).to be_truthy
+ expect(Proc.method_defined?(:source)).to be_truthy
+ end
+
+ describe "Methods" do
+ it 'should return source for method' do
+ expect(method(:hello).source).to eq(@hello_source)
+ end
+
+ it 'should return source for a method defined in a module' do
+ expect(M.instance_method(:hello).source).to eq(@hello_module_source)
+ end
+
+ it 'should return source for a singleton method as an instance method' do
+ expect(class << $o
+ self
+ end.instance_method(:hello).source).to eq(@hello_singleton_source)
+ end
+
+ it 'should return source for a singleton method' do
+ expect($o.method(:hello).source).to eq(@hello_singleton_source)
+ end
+
+ it 'should return a comment for method' do
+ expect(method(:hello).comment).to eq(@hello_comment)
+ end
+
+ # These tests fail because of http://jira.codehaus.org/browse/JRUBY-4576
+ unless defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
+ it 'should return source for an *_evaled method' do
+ expect(M.method(:hello_name).source).to
eq(@hello_instance_evaled_source)
+ expect(M.method(:name_two).source).to
eq(@hello_instance_evaled_source_2)
+ expect(M.instance_method(:hello_name).source).to
eq(@hello_class_evaled_source)
+ expect(M.instance_method(:hi_name).source).to
eq(@hi_module_evaled_source)
+ end
+ end
+
+ it "should raise error for evaled methods that do not pass __FILE__ and
__LINE__ + 1 as its arguments" do
+ expect do
+ M.instance_method(:name_three).source
+ end.to raise_error(MethodSource::SourceNotFoundError)
+ end
+
+ if !is_rbx?
+ it 'should raise for C methods' do
+ expect do
+ method(:puts).source
+ end.to raise_error(MethodSource::SourceNotFoundError)
+ end
+ end
+ end
+
+ # if RUBY_VERSION =~ /1.9/ || is_rbx?
+ describe "Lambdas and Procs" do
+ it 'should return source for proc' do
+ expect(MyProc.source).to eq(@proc_source)
+ end
+
+ it 'should return an empty string if there is no comment' do
+ expect(MyProc.comment).to eq('')
+ end
+
+ it 'should return source for lambda' do
+ expect(MyLambda.source).to eq(@lambda_source)
+ end
+
+ it 'should return comment for lambda' do
+ expect(MyLambda.comment).to eq(@lambda_comment)
+ end
+ end
+ # end
+ describe "Comment tests" do
+ before do
+ @comment1 = "# a\n# b\n"
+ @comment2 = "# a\n# b\n"
+ @comment3 = "# a\n#\n# b\n"
+ @comment4 = "# a\n# b\n"
+ @comment5 = "# a\n# b\n# c\n# d\n"
+ end
+
+ it "should correctly extract multi-line comments" do
+ expect(method(:comment_test1).comment).to eq(@comment1)
+ end
+
+ it "should correctly strip leading whitespace before comments" do
+ expect(method(:comment_test2).comment).to eq(@comment2)
+ end
+
+ it "should keep empty comment lines" do
+ expect(method(:comment_test3).comment).to eq(@comment3)
+ end
+
+ it "should ignore blank lines between comments" do
+ expect(method(:comment_test4).comment).to eq(@comment4)
+ end
+
+ it "should align all comments to same indent level" do
+ expect(method(:comment_test5).comment).to eq(@comment5)
+ end
+ end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/spec_helper.rb new/spec/spec_helper.rb
--- old/spec/spec_helper.rb 1970-01-01 01:00:00.000000000 +0100
+++ new/spec/spec_helper.rb 2017-09-26 13:43:00.000000000 +0200
@@ -0,0 +1,101 @@
+require 'method_source'
+require 'rspec'
+
+def is_rbx?
+ defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /rbx/
+end
+
+def jruby?
+ defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/
+end
+
+
+module M
+ def hello; :hello_module; end
+end
+
+$o = Object.new
+def $o.hello; :hello_singleton; end
+
+# A comment for hello
+
+ # It spans two lines and is indented by 2 spaces
+def hello; :hello; end
+
+# a
+# b
+def comment_test1; end
+
+ # a
+ # b
+def comment_test2; end
+
+# a
+#
+# b
+def comment_test3; end
+
+# a
+
+# b
+def comment_test4; end
+
+
+# a
+ # b
+ # c
+# d
+def comment_test5; end
+
+# This is a comment for MyLambda
+MyLambda = lambda { :lambda }
+MyProc = Proc.new { :proc }
+
+
+name = "name"
+
+M.instance_eval <<-METHOD, __FILE__, __LINE__ + 1
+ def hello_#{name}(*args)
+ send_mesg(:#{name}, *args)
+ end
+METHOD
+
+M.class_eval <<-METHOD, __FILE__, __LINE__ + 1
+ def hello_#{name}(*args)
+ send_mesg(:#{name}, *args)
+ end
+METHOD
+
+# module_eval to DRY code up
+#
+M.module_eval <<-METHOD, __FILE__, __LINE__ + 1
+
+ # module_eval is used here
+ #
+ def hi_#{name}
+ @var = #{name}
+ end
+METHOD
+
+# case where 2 methods are defined inside an _eval block
+#
+M.instance_eval <<EOF, __FILE__, __LINE__ + 1
+
+ def #{name}_one()
+ if 43
+ 44
+ end
+ end
+
+
+ def #{name}_two()
+ if 44
+ 45
+ end
+ end
+EOF
+
+# class_eval without filename and lineno + 1 parameter
+
+M.class_eval "def #{name}_three; @tempfile.#{name}; end"
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/test/test.rb new/test/test.rb
--- old/test/test.rb 1970-01-01 01:00:00.000000000 +0100
+++ new/test/test.rb 1970-01-01 01:00:00.000000000 +0100
@@ -1,138 +0,0 @@
-direc = File.expand_path(File.dirname(__FILE__))
-
-require 'rubygems'
-require 'bacon'
-require "#{direc}/../lib/method_source"
-require "#{direc}/test_helper"
-
-describe MethodSource do
-
- describe "source_location (testing 1.8 implementation)" do
- it 'should return correct source_location for a method' do
- method(:hello).source_location.first.should =~ /test_helper/
- end
-
- it 'should not raise for immediate instance methods' do
- [Symbol, Fixnum, TrueClass, FalseClass, NilClass].each do
|immediate_class|
- lambda { immediate_class.instance_method(:to_s).source_location
}.should.not.raise
- end
- end
-
- it 'should not raise for immediate methods' do
- [:a, 1, true, false, nil].each do |immediate|
- lambda { immediate.method(:to_s).source_location }.should.not.raise
- end
- end
- end
-
- before do
- @hello_module_source = " def hello; :hello_module; end\n"
- @hello_singleton_source = "def $o.hello; :hello_singleton; end\n"
- @hello_source = "def hello; :hello; end\n"
- @hello_comment = "# A comment for hello\n# It spans two lines and is
indented by 2 spaces\n"
- @lambda_comment = "# This is a comment for MyLambda\n"
- @lambda_source = "MyLambda = lambda { :lambda }\n"
- @proc_source = "MyProc = Proc.new { :proc }\n"
- @hello_instance_evaled_source = " def hello_\#{name}(*args)\n
send_mesg(:\#{name}, *args)\n end\n"
- @hello_instance_evaled_source_2 = " def \#{name}_two()\n if 44\n
45\n end\n end\n"
- @hello_class_evaled_source = " def hello_\#{name}(*args)\n
send_mesg(:\#{name}, *args)\n end\n"
- @hi_module_evaled_source = " def hi_\#{name}\n @var = \#{name}\n
end\n"
- end
-
- it 'should define methods on Method and UnboundMethod and Proc' do
- Method.method_defined?(:source).should == true
- UnboundMethod.method_defined?(:source).should == true
- Proc.method_defined?(:source).should == true
- end
-
- describe "Methods" do
- it 'should return source for method' do
- method(:hello).source.should == @hello_source
- end
-
- it 'should return source for a method defined in a module' do
- M.instance_method(:hello).source.should == @hello_module_source
- end
-
- it 'should return source for a singleton method as an instance method' do
- class << $o; self; end.instance_method(:hello).source.should ==
@hello_singleton_source
- end
-
- it 'should return source for a singleton method' do
- $o.method(:hello).source.should == @hello_singleton_source
- end
-
- it 'should return a comment for method' do
- method(:hello).comment.should == @hello_comment
- end
-
- # These tests fail because of http://jira.codehaus.org/browse/JRUBY-4576
- unless defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
- it 'should return source for an *_evaled method' do
- M.method(:hello_name).source.should == @hello_instance_evaled_source
- M.method(:name_two).source.should == @hello_instance_evaled_source_2
- M.instance_method(:hello_name).source.should ==
@hello_class_evaled_source
- M.instance_method(:hi_name).source.should == @hi_module_evaled_source
- end
- end
-
- it "should raise error for evaled methods that do not pass __FILE__ and
__LINE__ + 1 as its arguments" do
- lambda { M.instance_method(:name_three).source }.should.raise
MethodSource::SourceNotFoundError
- end
-
- if !is_rbx?
- it 'should raise for C methods' do
- lambda { method(:puts).source }.should.raise
MethodSource::SourceNotFoundError
- end
- end
- end
-
- # if RUBY_VERSION =~ /1.9/ || is_rbx?
- describe "Lambdas and Procs" do
- it 'should return source for proc' do
- MyProc.source.should == @proc_source
- end
-
- it 'should return an empty string if there is no comment' do
- MyProc.comment.should == ''
- end
-
- it 'should return source for lambda' do
- MyLambda.source.should == @lambda_source
- end
-
- it 'should return comment for lambda' do
- MyLambda.comment.should == @lambda_comment
- end
- end
- # end
- describe "Comment tests" do
- before do
- @comment1 = "# a\n# b\n"
- @comment2 = "# a\n# b\n"
- @comment3 = "# a\n#\n# b\n"
- @comment4 = "# a\n# b\n"
- @comment5 = "# a\n# b\n# c\n# d\n"
- end
-
- it "should correctly extract multi-line comments" do
- method(:comment_test1).comment.should == @comment1
- end
-
- it "should correctly strip leading whitespace before comments" do
- method(:comment_test2).comment.should == @comment2
- end
-
- it "should keep empty comment lines" do
- method(:comment_test3).comment.should == @comment3
- end
-
- it "should ignore blank lines between comments" do
- method(:comment_test4).comment.should == @comment4
- end
-
- it "should align all comments to same indent level" do
- method(:comment_test5).comment.should == @comment5
- end
- end
-end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/test/test_code_helpers.rb
new/test/test_code_helpers.rb
--- old/test/test_code_helpers.rb 1970-01-01 01:00:00.000000000 +0100
+++ new/test/test_code_helpers.rb 1970-01-01 01:00:00.000000000 +0100
@@ -1,41 +0,0 @@
-describe MethodSource::CodeHelpers do
- before do
- @tester = Object.new.extend(MethodSource::CodeHelpers)
- end
-
- [
- ["p = '", "'"],
- ["def", "a", "(); end"],
- ["p = <<FOO", "lots", "and", "lots of", "foo", "FOO"],
- ["[", ":lets,", "'list',", "[/nested/", "], things ]"],
- ["abc =~ /hello", "/"],
- ["issue = %W/", "343/"],
- ["pouts(<<HI, 'foo", "bar", "HI", "baz')"],
- ["=begin", "no-one uses this syntax anymore...", "=end"],
- ["puts 1, 2,", "3"],
- ["puts 'hello'\\", "'world'"]
- ].each do |lines|
- it "should not raise an error on broken lines: #{lines.join("\\n")}" do
- 1.upto(lines.size - 1) do |i|
- @tester.complete_expression?(lines[0...i].join("\n") + "\n").should ==
false
- end
- @tester.complete_expression?(lines.join("\n")).should == true
- end
- end
-
- [
- ["end"],
- ["puts )("],
- ["1 1"],
- ["puts :"]
- ] + (RbConfig::CONFIG['ruby_install_name'] == 'rbx' ? [] : [
- ["def", "method(1"], # in this case the syntax error is "expecting ')'".
- ["o = Object.new.tap{ def o.render;","'MEH'", "}"] # in this case the
syntax error is "expecting keyword_end".
- ]).compact.each do |foo|
- it "should raise an error on invalid syntax like #{foo.inspect}" do
- lambda{
- @tester.complete_expression?(foo.join("\n"))
- }.should.raise(SyntaxError)
- end
- end
-end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/test/test_helper.rb new/test/test_helper.rb
--- old/test/test_helper.rb 1970-01-01 01:00:00.000000000 +0100
+++ new/test/test_helper.rb 1970-01-01 01:00:00.000000000 +0100
@@ -1,98 +0,0 @@
-def is_rbx?
- defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /rbx/
-end
-
-def jruby?
- defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/
-end
-
-
-module M
- def hello; :hello_module; end
-end
-
-$o = Object.new
-def $o.hello; :hello_singleton; end
-
-# A comment for hello
-
- # It spans two lines and is indented by 2 spaces
-def hello; :hello; end
-
-# a
-# b
-def comment_test1; end
-
- # a
- # b
-def comment_test2; end
-
-# a
-#
-# b
-def comment_test3; end
-
-# a
-
-# b
-def comment_test4; end
-
-
-# a
- # b
- # c
-# d
-def comment_test5; end
-
-# This is a comment for MyLambda
-MyLambda = lambda { :lambda }
-MyProc = Proc.new { :proc }
-
-
-name = "name"
-
-M.instance_eval <<-METHOD, __FILE__, __LINE__ + 1
- def hello_#{name}(*args)
- send_mesg(:#{name}, *args)
- end
-METHOD
-
-M.class_eval <<-METHOD, __FILE__, __LINE__ + 1
- def hello_#{name}(*args)
- send_mesg(:#{name}, *args)
- end
-METHOD
-
-# module_eval to DRY code up
-#
-M.module_eval <<-METHOD, __FILE__, __LINE__ + 1
-
- # module_eval is used here
- #
- def hi_#{name}
- @var = #{name}
- end
-METHOD
-
-# case where 2 methods are defined inside an _eval block
-#
-M.instance_eval <<EOF, __FILE__, __LINE__ + 1
-
- def #{name}_one()
- if 43
- 44
- end
- end
-
-
- def #{name}_two()
- if 44
- 45
- end
- end
-EOF
-
-# class_eval without filename and lineno + 1 parameter
-
-M.class_eval "def #{name}_three; @tempfile.#{name}; end"
-