method_source 0.6.7 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -19,7 +19,6 @@ def apply_spec_defaults(s)
19
19
  s.email = 'jrmair@gmail.com'
20
20
  s.description = s.summary
21
21
  s.require_path = 'lib'
22
- s.add_dependency("ruby_parser",">= 2.3.1")
23
22
 
24
23
  s.add_development_dependency("bacon","~>1.1.0")
25
24
  s.add_development_dependency("rake", "~>0.9")
data/lib/method_source.rb CHANGED
@@ -7,38 +7,25 @@ require "#{direc}/method_source/version"
7
7
  require "#{direc}/method_source/source_location"
8
8
 
9
9
  module MethodSource
10
-
11
- if RUBY_VERSION =~ /1.9/ && RUBY_ENGINE == "ruby"
12
- require 'ripper'
13
-
14
- # Determine if a string of code is a valid Ruby expression.
15
- # Ruby 1.9 uses Ripper, Ruby 1.8 uses RubyParser.
16
- # @param [String] code The code to validate.
17
- # @return [Boolean] Whether or not the code is a valid Ruby expression.
18
- # @example
19
- # valid_expression?("class Hello") #=> false
20
- # valid_expression?("class Hello; end") #=> true
21
- def self.valid_expression?(code)
22
- !!Ripper::SexpBuilder.new(code).parse
23
- end
24
-
25
- else
26
- require 'ruby_parser'
27
-
28
- # Determine if a string of code is a valid Ruby expression.
29
- # Ruby 1.9 uses Ripper, Ruby 1.8 uses RubyParser.
30
- # @param [String] code The code to validate.
31
- # @return [Boolean] Whether or not the code is a valid Ruby expression.
32
- # @example
33
- # valid_expression?("class Hello") #=> false
34
- # valid_expression?("class Hello; end") #=> true
35
- def self.valid_expression?(code)
36
- RubyParser.new.parse(code)
37
- rescue Racc::ParseError, SyntaxError
38
- false
10
+ # Determine if a string of code is a valid Ruby expression.
11
+ # @param [String] code The code to validate.
12
+ # @return [Boolean] Whether or not the code is a valid Ruby expression.
13
+ # @example
14
+ # valid_expression?("class Hello") #=> false
15
+ # valid_expression?("class Hello; end") #=> true
16
+ def self.valid_expression?(str)
17
+ if defined?(Rubinius::Melbourne19) && RUBY_VERSION =~ /^1\.9/
18
+ Rubinius::Melbourne19.parse_string(str)
19
+ elsif defined?(Rubinius::Melbourne)
20
+ Rubinius::Melbourne.parse_string(str)
39
21
  else
40
- true
22
+ catch(:valid) {
23
+ eval("BEGIN{throw :valid}\n#{str}")
24
+ }
41
25
  end
26
+ true
27
+ rescue SyntaxError
28
+ false
42
29
  end
43
30
 
44
31
  # Helper method responsible for extracting method body.
@@ -1,3 +1,3 @@
1
1
  module MethodSource
2
- VERSION = "0.6.7"
2
+ VERSION = "0.7.0"
3
3
  end
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "method_source"
5
- s.version = "0.6.7"
5
+ s.version = "0.7.0"
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.date = "2011-10-26"
9
+ s.date = "2012-01-01"
10
10
  s.description = "retrieve the sourcecode for a method"
11
11
  s.email = "jrmair@gmail.com"
12
12
  s.files = [".gemtest", ".travis.yml", ".yardopts", "Gemfile", "LICENSE", "README.markdown", "Rakefile", "lib/method_source.rb", "lib/method_source/source_location.rb", "lib/method_source/version.rb", "method_source.gemspec", "test/test.rb", "test/test_helper.rb"]
@@ -20,16 +20,13 @@ Gem::Specification.new do |s|
20
20
  s.specification_version = 3
21
21
 
22
22
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
23
- s.add_runtime_dependency(%q<ruby_parser>, [">= 2.3.1"])
24
23
  s.add_development_dependency(%q<bacon>, ["~> 1.1.0"])
25
24
  s.add_development_dependency(%q<rake>, ["~> 0.9"])
26
25
  else
27
- s.add_dependency(%q<ruby_parser>, [">= 2.3.1"])
28
26
  s.add_dependency(%q<bacon>, ["~> 1.1.0"])
29
27
  s.add_dependency(%q<rake>, ["~> 0.9"])
30
28
  end
31
29
  else
32
- s.add_dependency(%q<ruby_parser>, [">= 2.3.1"])
33
30
  s.add_dependency(%q<bacon>, ["~> 1.1.0"])
34
31
  s.add_dependency(%q<rake>, ["~> 0.9"])
35
32
  end
metadata CHANGED
@@ -1,78 +1,44 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: method_source
3
- version: !ruby/object:Gem::Version
4
- hash: 9
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.7.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 6
9
- - 7
10
- version: 0.6.7
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - John Mair (banisterfiend)
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-10-26 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- name: ruby_parser
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 1
29
- segments:
30
- - 2
31
- - 3
32
- - 1
33
- version: 2.3.1
34
- type: :runtime
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
12
+ date: 2012-01-01 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
37
15
  name: bacon
38
- prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
16
+ requirement: &70179976064580 !ruby/object:Gem::Requirement
40
17
  none: false
41
- requirements:
18
+ requirements:
42
19
  - - ~>
43
- - !ruby/object:Gem::Version
44
- hash: 19
45
- segments:
46
- - 1
47
- - 1
48
- - 0
20
+ - !ruby/object:Gem::Version
49
21
  version: 1.1.0
50
22
  type: :development
51
- version_requirements: *id002
52
- - !ruby/object:Gem::Dependency
53
- name: rake
54
23
  prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
24
+ version_requirements: *70179976064580
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ requirement: &70179976063220 !ruby/object:Gem::Requirement
56
28
  none: false
57
- requirements:
29
+ requirements:
58
30
  - - ~>
59
- - !ruby/object:Gem::Version
60
- hash: 25
61
- segments:
62
- - 0
63
- - 9
64
- version: "0.9"
31
+ - !ruby/object:Gem::Version
32
+ version: '0.9'
65
33
  type: :development
66
- version_requirements: *id003
34
+ prerelease: false
35
+ version_requirements: *70179976063220
67
36
  description: retrieve the sourcecode for a method
68
37
  email: jrmair@gmail.com
69
38
  executables: []
70
-
71
39
  extensions: []
72
-
73
40
  extra_rdoc_files: []
74
-
75
- files:
41
+ files:
76
42
  - .gemtest
77
43
  - .travis.yml
78
44
  - .yardopts
@@ -88,37 +54,28 @@ files:
88
54
  - test/test_helper.rb
89
55
  homepage: http://banisterfiend.wordpress.com
90
56
  licenses: []
91
-
92
57
  post_install_message:
93
58
  rdoc_options: []
94
-
95
- require_paths:
59
+ require_paths:
96
60
  - lib
97
- required_ruby_version: !ruby/object:Gem::Requirement
61
+ required_ruby_version: !ruby/object:Gem::Requirement
98
62
  none: false
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- hash: 3
103
- segments:
104
- - 0
105
- version: "0"
106
- required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
68
  none: false
108
- requirements:
109
- - - ">="
110
- - !ruby/object:Gem::Version
111
- hash: 3
112
- segments:
113
- - 0
114
- version: "0"
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
115
73
  requirements: []
116
-
117
74
  rubyforge_project:
118
75
  rubygems_version: 1.8.10
119
76
  signing_key:
120
77
  specification_version: 3
121
78
  summary: retrieve the sourcecode for a method
122
- test_files:
79
+ test_files:
123
80
  - test/test.rb
124
81
  - test/test_helper.rb