method_source 0.8.2 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e3ceddabc464d5453097a8c60ed8250ff7c0459
4
- data.tar.gz: c002c999c368493393f55670cc014fae332364a6
3
+ metadata.gz: e1118a4c5ca09e1fc6975b68f403928990625f5f
4
+ data.tar.gz: 300af8354d67837579d383bdc15459b1515421b1
5
5
  SHA512:
6
- metadata.gz: a29c92a32800423eddce9e4cb5ec13c9e50bdafacf634c08908e331baeb602be8655781bf464f9dbc87c74fb80e7ce4919dd63efcff67cdf1f57445259afb3bf
7
- data.tar.gz: def76a2656612ce913098502cea143eb8a56263904a87ae27fe95f9f4d43b93aa0444ac7ad2023c4b381a14a3614cf6b5400f6abbc25f8b03bcee1206c6a5e76
6
+ metadata.gz: eda821b401319fb84c65668d1e627e403315e67fa0932cf04cc6eda25ce032ed1fece20ccb4268568b1d56d1110373050281ae05f86894beeda2f47dd890e1a1
7
+ data.tar.gz: 26d6010ff8487756651bf30e449d59fe1cf2729c778db676ce398cce1a6299ddc74c38305fd0b0ced24bd7b7cb7ad4806a3e20f992d58af1861021f6a9943fd6
@@ -1,12 +1,29 @@
1
+ # To use rbx environment.
2
+ dist: trusty
3
+ bundler_args: "--verbose"
4
+ before_install:
5
+ - gem update --system
6
+ - which bundle || gem install bundler
7
+ - gem update bundler
1
8
  rvm:
2
9
  - 1.8.7
3
- - 1.9.2
4
10
  - 1.9.3
5
11
  - ree
6
- - rbx-18mode
7
- - rbx-19mode
12
+ - rbx-3
8
13
  - jruby
9
-
14
+ - jruby-head
15
+ - 2.0.0
16
+ - 2.1
17
+ - 2.2
18
+ - 2.3
19
+ - 2.4.1
20
+ - ruby-head
21
+ matrix:
22
+ allow_failures:
23
+ - rvm: ruby-head
24
+ - rvm: jruby-head
25
+ - rvm: rbx-3
26
+ fast_finish: true
10
27
  notifications:
11
28
  irc: "irc.freenode.org#pry"
12
29
  recipients:
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
  gemspec
@@ -1,4 +1,4 @@
1
- method_source
1
+ method_source [![Build Status](https://travis-ci.org/banister/method_source.svg?branch=master)](https://travis-ci.org/banister/method_source)
2
2
  =============
3
3
 
4
4
  (C) John Mair (banisterfiend) 2011
data/Rakefile CHANGED
@@ -20,16 +20,17 @@ def apply_spec_defaults(s)
20
20
  s.description = s.summary
21
21
  s.require_path = 'lib'
22
22
 
23
- s.add_development_dependency("bacon","~>1.1.0")
23
+ s.add_development_dependency("rspec","~>3.6")
24
24
  s.add_development_dependency("rake", "~>0.9")
25
25
  s.homepage = "http://banisterfiend.wordpress.com"
26
26
  s.has_rdoc = 'yard'
27
27
  s.files = `git ls-files`.split("\n")
28
- s.test_files = `git ls-files -- test/*`.split("\n")
28
+ s.test_files = `git ls-files -- spec/*`.split("\n")
29
29
  end
30
30
 
31
- task :test do
32
- sh "bacon -q #{direc}/test/test.rb #{direc}/test/test_code_helpers.rb"
31
+ require "rspec/core/rake_task"
32
+ RSpec::Core::RakeTask.new(:spec) do |t|
33
+ t.ruby_opts = %w[-w]
33
34
  end
34
35
 
35
36
  desc "reinstall gem"
@@ -39,7 +40,7 @@ task :reinstall => :gems do
39
40
  end
40
41
 
41
42
  desc "Set up and run tests"
42
- task :default => [:test]
43
+ task :default => [:spec]
43
44
 
44
45
  desc "Build the gemspec file"
45
46
  task :gemspec => "ruby:gemspec"
@@ -6,14 +6,14 @@ module MethodSource
6
6
  # This is useful to get module or method source code.
7
7
  #
8
8
  # @param [Array<String>, File, String] file The file to parse, either as a File or as
9
- # @param [Fixnum] line_number The line number at which to look.
9
+ # @param [Integer] line_number The line number at which to look.
10
10
  # NOTE: The first line in a file is
11
11
  # line 1!
12
12
  # @param [Hash] options The optional configuration parameters.
13
13
  # @option options [Boolean] :strict If set to true, then only completely
14
14
  # valid expressions are returned. Otherwise heuristics are used to extract
15
15
  # expressions that may have been valid inside an eval.
16
- # @option options [Fixnum] :consume A number of lines to automatically
16
+ # @option options [Integer] :consume A number of lines to automatically
17
17
  # consume (add to the expression buffer) without checking for validity.
18
18
  # @return [String] The first complete expression
19
19
  # @raise [SyntaxError] If the first complete expression can't be identified
@@ -46,7 +46,7 @@ module MethodSource
46
46
  #
47
47
  # @param [Array<String>, File, String] file The file to parse, either as a File or as
48
48
  # a String or an Array of lines.
49
- # @param [Fixnum] line_number The line number at which to look.
49
+ # @param [Integer] line_number The line number at which to look.
50
50
  # NOTE: The first line in a file is line 1!
51
51
  # @return [String] The comment
52
52
  def comment_describing(file, line_number)
@@ -84,7 +84,7 @@ module MethodSource
84
84
  # Get the first expression from the input.
85
85
  #
86
86
  # @param [Array<String>] lines
87
- # @param [Fixnum] consume A number of lines to automatically
87
+ # @param [Integer] consume A number of lines to automatically
88
88
  # consume (add to the expression buffer) without checking for validity.
89
89
  # @yield a clean-up function to run before checking for complete_expression
90
90
  # @return [String] a valid ruby expression
@@ -111,7 +111,7 @@ module MethodSource
111
111
  case
112
112
  when klass == Symbol
113
113
  return :a.method(name).source_location
114
- when klass == Fixnum
114
+ when klass == Integer
115
115
  return 0.method(name).source_location
116
116
  when klass == TrueClass
117
117
  return true.method(name).source_location
@@ -1,3 +1,3 @@
1
1
  module MethodSource
2
- VERSION = "0.8.2"
2
+ VERSION = "0.9.0"
3
3
  end
@@ -6,28 +6,29 @@ Gem::Specification.new do |s|
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["John Mair (banisterfiend)"]
9
+ s.licenses = ['MIT']
9
10
  s.date = "2012-10-17"
10
11
  s.description = "retrieve the sourcecode for a method"
11
12
  s.email = "jrmair@gmail.com"
12
- 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"]
13
+ 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"]
13
14
  s.homepage = "http://banisterfiend.wordpress.com"
14
15
  s.require_paths = ["lib"]
15
16
  s.rubygems_version = "1.8.23"
16
17
  s.summary = "retrieve the sourcecode for a method"
17
- s.test_files = ["test/test.rb", "test/test_code_helpers.rb", "test/test_helper.rb"]
18
+ s.test_files = ["spec/method_source/code_helpers_spec.rb", "spec/method_source_spec.rb", "spec/spec_helper.rb"]
18
19
 
19
20
  if s.respond_to? :specification_version then
20
21
  s.specification_version = 3
21
22
 
22
23
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
23
- s.add_development_dependency(%q<bacon>, ["~> 1.1.0"])
24
+ s.add_development_dependency(%q<rspec>, ["~> 3.6"])
24
25
  s.add_development_dependency(%q<rake>, ["~> 0.9"])
25
26
  else
26
- s.add_dependency(%q<bacon>, ["~> 1.1.0"])
27
+ s.add_dependency(%q<rspec>, ["~> 3.6"])
27
28
  s.add_dependency(%q<rake>, ["~> 0.9"])
28
29
  end
29
30
  else
30
- s.add_dependency(%q<bacon>, ["~> 1.1.0"])
31
+ s.add_dependency(%q<rspec>, ["~> 3.6"])
31
32
  s.add_dependency(%q<rake>, ["~> 0.9"])
32
33
  end
33
34
  end
@@ -1,3 +1,5 @@
1
+ require 'spec_helper'
2
+
1
3
  describe MethodSource::CodeHelpers do
2
4
  before do
3
5
  @tester = Object.new.extend(MethodSource::CodeHelpers)
@@ -17,9 +19,9 @@ describe MethodSource::CodeHelpers do
17
19
  ].each do |lines|
18
20
  it "should not raise an error on broken lines: #{lines.join("\\n")}" do
19
21
  1.upto(lines.size - 1) do |i|
20
- @tester.complete_expression?(lines[0...i].join("\n") + "\n").should == false
22
+ expect(@tester.complete_expression?(lines[0...i].join("\n") + "\n")).to be_falsy
21
23
  end
22
- @tester.complete_expression?(lines.join("\n")).should == true
24
+ expect(@tester.complete_expression?(lines.join("\n"))).to be_truthy
23
25
  end
24
26
  end
25
27
 
@@ -33,9 +35,9 @@ describe MethodSource::CodeHelpers do
33
35
  ["o = Object.new.tap{ def o.render;","'MEH'", "}"] # in this case the syntax error is "expecting keyword_end".
34
36
  ]).compact.each do |foo|
35
37
  it "should raise an error on invalid syntax like #{foo.inspect}" do
36
- lambda{
38
+ expect {
37
39
  @tester.complete_expression?(foo.join("\n"))
38
- }.should.raise(SyntaxError)
40
+ }.to raise_error(SyntaxError)
39
41
  end
40
42
  end
41
43
  end
@@ -1,26 +1,25 @@
1
- direc = File.expand_path(File.dirname(__FILE__))
2
-
3
- require 'rubygems'
4
- require 'bacon'
5
- require "#{direc}/../lib/method_source"
6
- require "#{direc}/test_helper"
1
+ require 'spec_helper'
7
2
 
8
3
  describe MethodSource do
9
4
 
10
5
  describe "source_location (testing 1.8 implementation)" do
11
6
  it 'should return correct source_location for a method' do
12
- method(:hello).source_location.first.should =~ /test_helper/
7
+ expect(method(:hello).source_location.first).to match(/spec_helper/)
13
8
  end
14
9
 
15
10
  it 'should not raise for immediate instance methods' do
16
- [Symbol, Fixnum, TrueClass, FalseClass, NilClass].each do |immediate_class|
17
- lambda { immediate_class.instance_method(:to_s).source_location }.should.not.raise
11
+ [Symbol, Integer, TrueClass, FalseClass, NilClass].each do |immediate_class|
12
+ expect do
13
+ immediate_class.instance_method(:to_s).source_location
14
+ end.not_to raise_error
18
15
  end
19
16
  end
20
17
 
21
18
  it 'should not raise for immediate methods' do
22
19
  [:a, 1, true, false, nil].each do |immediate|
23
- lambda { immediate.method(:to_s).source_location }.should.not.raise
20
+ expect do
21
+ immediate.method(:to_s).source_location
22
+ end.not_to raise_error
24
23
  end
25
24
  end
26
25
  end
@@ -40,49 +39,55 @@ describe MethodSource do
40
39
  end
41
40
 
42
41
  it 'should define methods on Method and UnboundMethod and Proc' do
43
- Method.method_defined?(:source).should == true
44
- UnboundMethod.method_defined?(:source).should == true
45
- Proc.method_defined?(:source).should == true
42
+ expect(Method.method_defined?(:source)).to be_truthy
43
+ expect(UnboundMethod.method_defined?(:source)).to be_truthy
44
+ expect(Proc.method_defined?(:source)).to be_truthy
46
45
  end
47
46
 
48
47
  describe "Methods" do
49
48
  it 'should return source for method' do
50
- method(:hello).source.should == @hello_source
49
+ expect(method(:hello).source).to eq(@hello_source)
51
50
  end
52
51
 
53
52
  it 'should return source for a method defined in a module' do
54
- M.instance_method(:hello).source.should == @hello_module_source
53
+ expect(M.instance_method(:hello).source).to eq(@hello_module_source)
55
54
  end
56
55
 
57
56
  it 'should return source for a singleton method as an instance method' do
58
- class << $o; self; end.instance_method(:hello).source.should == @hello_singleton_source
57
+ expect(class << $o
58
+ self
59
+ end.instance_method(:hello).source).to eq(@hello_singleton_source)
59
60
  end
60
61
 
61
62
  it 'should return source for a singleton method' do
62
- $o.method(:hello).source.should == @hello_singleton_source
63
+ expect($o.method(:hello).source).to eq(@hello_singleton_source)
63
64
  end
64
65
 
65
66
  it 'should return a comment for method' do
66
- method(:hello).comment.should == @hello_comment
67
+ expect(method(:hello).comment).to eq(@hello_comment)
67
68
  end
68
69
 
69
70
  # These tests fail because of http://jira.codehaus.org/browse/JRUBY-4576
70
71
  unless defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
71
72
  it 'should return source for an *_evaled method' do
72
- M.method(:hello_name).source.should == @hello_instance_evaled_source
73
- M.method(:name_two).source.should == @hello_instance_evaled_source_2
74
- M.instance_method(:hello_name).source.should == @hello_class_evaled_source
75
- M.instance_method(:hi_name).source.should == @hi_module_evaled_source
73
+ expect(M.method(:hello_name).source).to eq(@hello_instance_evaled_source)
74
+ expect(M.method(:name_two).source).to eq(@hello_instance_evaled_source_2)
75
+ expect(M.instance_method(:hello_name).source).to eq(@hello_class_evaled_source)
76
+ expect(M.instance_method(:hi_name).source).to eq(@hi_module_evaled_source)
76
77
  end
77
78
  end
78
79
 
79
80
  it "should raise error for evaled methods that do not pass __FILE__ and __LINE__ + 1 as its arguments" do
80
- lambda { M.instance_method(:name_three).source }.should.raise MethodSource::SourceNotFoundError
81
+ expect do
82
+ M.instance_method(:name_three).source
83
+ end.to raise_error(MethodSource::SourceNotFoundError)
81
84
  end
82
85
 
83
86
  if !is_rbx?
84
87
  it 'should raise for C methods' do
85
- lambda { method(:puts).source }.should.raise MethodSource::SourceNotFoundError
88
+ expect do
89
+ method(:puts).source
90
+ end.to raise_error(MethodSource::SourceNotFoundError)
86
91
  end
87
92
  end
88
93
  end
@@ -90,19 +95,19 @@ describe MethodSource do
90
95
  # if RUBY_VERSION =~ /1.9/ || is_rbx?
91
96
  describe "Lambdas and Procs" do
92
97
  it 'should return source for proc' do
93
- MyProc.source.should == @proc_source
98
+ expect(MyProc.source).to eq(@proc_source)
94
99
  end
95
100
 
96
101
  it 'should return an empty string if there is no comment' do
97
- MyProc.comment.should == ''
102
+ expect(MyProc.comment).to eq('')
98
103
  end
99
104
 
100
105
  it 'should return source for lambda' do
101
- MyLambda.source.should == @lambda_source
106
+ expect(MyLambda.source).to eq(@lambda_source)
102
107
  end
103
108
 
104
109
  it 'should return comment for lambda' do
105
- MyLambda.comment.should == @lambda_comment
110
+ expect(MyLambda.comment).to eq(@lambda_comment)
106
111
  end
107
112
  end
108
113
  # end
@@ -116,23 +121,23 @@ describe MethodSource do
116
121
  end
117
122
 
118
123
  it "should correctly extract multi-line comments" do
119
- method(:comment_test1).comment.should == @comment1
124
+ expect(method(:comment_test1).comment).to eq(@comment1)
120
125
  end
121
126
 
122
127
  it "should correctly strip leading whitespace before comments" do
123
- method(:comment_test2).comment.should == @comment2
128
+ expect(method(:comment_test2).comment).to eq(@comment2)
124
129
  end
125
130
 
126
131
  it "should keep empty comment lines" do
127
- method(:comment_test3).comment.should == @comment3
132
+ expect(method(:comment_test3).comment).to eq(@comment3)
128
133
  end
129
134
 
130
135
  it "should ignore blank lines between comments" do
131
- method(:comment_test4).comment.should == @comment4
136
+ expect(method(:comment_test4).comment).to eq(@comment4)
132
137
  end
133
138
 
134
139
  it "should align all comments to same indent level" do
135
- method(:comment_test5).comment.should == @comment5
140
+ expect(method(:comment_test5).comment).to eq(@comment5)
136
141
  end
137
142
  end
138
143
  end
@@ -1,3 +1,6 @@
1
+ require 'method_source'
2
+ require 'rspec'
3
+
1
4
  def is_rbx?
2
5
  defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /rbx/
3
6
  end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: method_source
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mair (banisterfiend)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-27 00:00:00.000000000 Z
11
+ date: 2017-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bacon
14
+ name: rspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.1.0
19
+ version: '3.6'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.1.0
26
+ version: '3.6'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0.9'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.9'
41
41
  description: retrieve the sourcecode for a method
@@ -44,9 +44,9 @@ executables: []
44
44
  extensions: []
45
45
  extra_rdoc_files: []
46
46
  files:
47
- - .gemtest
48
- - .travis.yml
49
- - .yardopts
47
+ - ".gemtest"
48
+ - ".travis.yml"
49
+ - ".yardopts"
50
50
  - Gemfile
51
51
  - LICENSE
52
52
  - README.markdown
@@ -56,9 +56,9 @@ files:
56
56
  - lib/method_source/source_location.rb
57
57
  - lib/method_source/version.rb
58
58
  - method_source.gemspec
59
- - test/test.rb
60
- - test/test_code_helpers.rb
61
- - test/test_helper.rb
59
+ - spec/method_source/code_helpers_spec.rb
60
+ - spec/method_source_spec.rb
61
+ - spec/spec_helper.rb
62
62
  homepage: http://banisterfiend.wordpress.com
63
63
  licenses: []
64
64
  metadata: {}
@@ -68,21 +68,21 @@ require_paths:
68
68
  - lib
69
69
  required_ruby_version: !ruby/object:Gem::Requirement
70
70
  requirements:
71
- - - '>='
71
+ - - ">="
72
72
  - !ruby/object:Gem::Version
73
73
  version: '0'
74
74
  required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  requirements:
76
- - - '>='
76
+ - - ">="
77
77
  - !ruby/object:Gem::Version
78
78
  version: '0'
79
79
  requirements: []
80
80
  rubyforge_project:
81
- rubygems_version: 2.0.2
81
+ rubygems_version: 2.6.12
82
82
  signing_key:
83
83
  specification_version: 4
84
84
  summary: retrieve the sourcecode for a method
85
85
  test_files:
86
- - test/test.rb
87
- - test/test_code_helpers.rb
88
- - test/test_helper.rb
86
+ - spec/method_source/code_helpers_spec.rb
87
+ - spec/method_source_spec.rb
88
+ - spec/spec_helper.rb