sourcify 0.2.1 → 0.2.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.2.2 (Sep 15, 2010)
2
+
3
+ * fixed failure to run on MRI-1.8.6 [#ngty]
4
+
1
5
  === 0.2.1 (Sep 14, 2010)
2
6
 
3
7
  * introduced hack to ensure procs generated by Symbol#to_proc & Method#to_proc
data/README.rdoc CHANGED
@@ -157,15 +157,26 @@ following bug[http://redmine.ruby-lang.org/issues/show/574] under 1.8.* may trip
157
157
  This is another reason to install ParseTree when u are on 1.8.*. On JRuby, where u don't
158
158
  have the choice, just avoid multiple procs per line.
159
159
 
160
+ === 3. Occasional Racc::ParseError
161
+
162
+ Under the hood, sourcify relies on RubyParser to yield s-expression, and since RubyParser
163
+ does not yet fully handle 1.8.7/1.9.* syntax, you will get a nasty Racc::ParseError when
164
+ you have any code that is not compatible with 1.8.6.
165
+
160
166
  == Is it working ??
161
167
 
162
- Besides its own spec suite, sourcify has been tested to handle:
168
+ Sourcify spec suite currently passes in the following rubies:
169
+ * MRI-1.8.6 (ParseTree mode ONLY)
170
+ * MRI-1.8.7, REE-1.8.7 (ParseTree & static scanner modes)
171
+ * JRuby-1.5.1+, MRI-1.9.1 (static scanner ONLY)
172
+
173
+ Besides its own spec suite, sourcify has also been tested to handle:
163
174
 
164
175
  ObjectSpace.each_object(Proc) {|o| puts o.to_source }
165
176
 
166
177
  For projects:
167
- * Spree[http://github.com/railsdog/spree] (ruby-1.8.7-p299, ruby-1.9.1-p376 & jruby-1.5.2)
168
- * Redmine[http://github.com/edavis10/redmine] (ruby-1.8.7-p299, ruby-1.9.1-p376 & jruby-1.5.2)
178
+ * Spree[http://github.com/railsdog/spree]
179
+ * Redmine[http://github.com/edavis10/redmine]
169
180
 
170
181
  (TODO: the more the merrier)
171
182
 
data/Rakefile CHANGED
@@ -11,16 +11,16 @@ begin
11
11
  gem.email = "ngty77@gmail.com"
12
12
  gem.homepage = "http://github.com/ngty/sourcify"
13
13
  gem.authors = ["NgTzeYang"]
14
- gem.add_dependency 'ruby2ruby', '>= 1.2.4'
14
+ gem.add_dependency 'ruby2ruby', '>= 1.2.5'
15
15
  gem.add_development_dependency "bacon", ">= 0"
16
16
  # Plus one of the following groups:
17
17
  #
18
18
  # 1). ParseTree (better performance + dynamic goodness, but not supported on java & 1.9.*)
19
- # >> gem.add_dependency "ParseTree", ">= 3.0.5"
19
+ # >> gem.add_dependency "ParseTree", ">= 3.0.6"
20
20
  #
21
21
  # 2). RubyParser (supported for all)
22
- # >> gem.add_dependency "ruby_parser", ">= 2.0.4"
23
- # >> gem.add_dependency "sexp_processor", ">= 3.0.4"
22
+ # >> gem.add_dependency "ruby_parser", ">= 2.0.5"
23
+ # >> gem.add_dependency "sexp_processor", ">= 3.0.5"
24
24
  # >> gem.add_dependency "file-tail", ">= 1.0.5"
25
25
  end
26
26
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2.1
data/lib/sourcify/proc.rb CHANGED
@@ -11,7 +11,8 @@ module Sourcify
11
11
  def self.included(base)
12
12
  base.class_eval do
13
13
 
14
- meths = instance_methods.map(&:to_s)
14
+ # Rubies of 1.8.6 & earlier doesn't support something.map(&:blah)
15
+ meths = instance_methods.map{|m| m.to_s }
15
16
 
16
17
  unless meths.include?('source_location')
17
18
 
@@ -34,12 +35,15 @@ module Sourcify
34
35
  end
35
36
 
36
37
  [::Method, ::Symbol].each do |klass|
37
- klass.class_eval do
38
- alias_method :__pre_sourcified_to_proc, :to_proc
39
- def to_proc
40
- (_proc = __pre_sourcified_to_proc).created_on_the_fly = true
41
- _proc
38
+ begin
39
+ klass.class_eval do
40
+ alias_method :__pre_sourcified_to_proc, :to_proc
41
+ def to_proc
42
+ (_proc = __pre_sourcified_to_proc).created_on_the_fly = true
43
+ _proc
44
+ end
42
45
  end
46
+ rescue NameError
43
47
  end
44
48
  end
45
49
 
data/sourcify.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sourcify}
8
- s.version = "0.2.1"
8
+ s.version = "0.2.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["NgTzeYang"]
12
- s.date = %q{2010-09-14}
12
+ s.date = %q{2010-09-15}
13
13
  s.description = %q{}
14
14
  s.email = %q{ngty77@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -126,14 +126,14 @@ Gem::Specification.new do |s|
126
126
  s.specification_version = 3
127
127
 
128
128
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
129
- s.add_runtime_dependency(%q<ruby2ruby>, [">= 1.2.4"])
129
+ s.add_runtime_dependency(%q<ruby2ruby>, [">= 1.2.5"])
130
130
  s.add_development_dependency(%q<bacon>, [">= 0"])
131
131
  else
132
- s.add_dependency(%q<ruby2ruby>, [">= 1.2.4"])
132
+ s.add_dependency(%q<ruby2ruby>, [">= 1.2.5"])
133
133
  s.add_dependency(%q<bacon>, [">= 0"])
134
134
  end
135
135
  else
136
- s.add_dependency(%q<ruby2ruby>, [">= 1.2.4"])
136
+ s.add_dependency(%q<ruby2ruby>, [">= 1.2.5"])
137
137
  s.add_dependency(%q<bacon>, [">= 0"])
138
138
  end
139
139
  end
@@ -1,7 +1,7 @@
1
1
  require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
2
 
3
3
  describe "Created on the fly proc" do
4
- unless Object.const_defined?(:ParseTree)
4
+ unless has_parsetree?
5
5
 
6
6
  klass = Class.new do
7
7
  def test(&block); block ; end
@@ -2,7 +2,7 @@ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
2
 
3
3
  describe 'Proc#to_source from multi blocks w many matches' do
4
4
 
5
- if Object.const_defined?(:ParseTree)
5
+ if has_parsetree?
6
6
 
7
7
  expected = 'proc { @x%s }'
8
8
 
@@ -1,5 +1,6 @@
1
1
  require File.join(File.dirname(__FILE__), 'spec_helper')
2
2
 
3
+ unless has_parsetree?
3
4
  describe "Block comment (=begin ... =end)" do
4
5
 
5
6
  should 'handle =begin\n ... =end\n' do
@@ -57,3 +58,4 @@ EOL
57
58
  end
58
59
 
59
60
  end
61
+ end
@@ -1,5 +1,6 @@
1
1
  require File.join(File.dirname(__FILE__), 'spec_helper')
2
2
 
3
+ unless has_parsetree?
3
4
  describe "Double colons" do
4
5
 
5
6
  should "handle A::B as :const" do
@@ -11,4 +12,4 @@ describe "Double colons" do
11
12
  end
12
13
 
13
14
  end
14
-
15
+ end
@@ -1,5 +1,6 @@
1
1
  require File.join(File.dirname(__FILE__), 'spec_helper')
2
2
 
3
+ unless has_parsetree?
3
4
  describe 'Double quote strings (w interpolation)' do
4
5
 
5
6
  # NOTE: we skip %Q#...# cos %Q#..#{..}..# is invalid syntax.
@@ -60,3 +61,4 @@ describe 'Double quote strings (w interpolation)' do
60
61
  end
61
62
 
62
63
  end
64
+ end
@@ -1,5 +1,6 @@
1
1
  require File.join(File.dirname(__FILE__), 'spec_helper')
2
2
 
3
+ unless has_parsetree?
3
4
  describe 'Double quote strings (wo interpolation)' do
4
5
 
5
6
  %w{~ ` ! @ # $ % ^ & * _ - + = | \\ ; : ' " , . ? /}.map{|w| [w,w] }.concat(
@@ -86,3 +87,4 @@ describe 'Double quote strings (wo interpolation)' do
86
87
  end
87
88
 
88
89
  end
90
+ end
@@ -1,5 +1,6 @@
1
1
  require File.join(File.dirname(__FILE__), 'spec_helper')
2
2
 
3
+ unless has_parsetree?
3
4
  describe "Heredoc (wo indent)" do
4
5
  %w{X "X" 'X'}.each do |tag|
5
6
 
@@ -140,3 +141,4 @@ X
140
141
 
141
142
  end
142
143
  end
144
+ end
@@ -1,5 +1,6 @@
1
1
  require File.join(File.dirname(__FILE__), 'spec_helper')
2
2
 
3
+ unless has_parsetree?
3
4
  describe "Keyword do alias #1 (incrementing do...end counter by 1)" do
4
5
 
5
6
  behaves_like 'has started do...end counter'
@@ -85,3 +86,4 @@ EOL
85
86
  end
86
87
 
87
88
  end
89
+ end
@@ -1,5 +1,6 @@
1
1
  require File.join(File.dirname(__FILE__), 'spec_helper')
2
2
 
3
+ unless has_parsetree?
3
4
  describe "Keyword do alias #2 (increment do..end block counter by 0..1)" do
4
5
 
5
6
  behaves_like 'has started do...end counter'
@@ -84,3 +85,4 @@ EOL
84
85
 
85
86
  end
86
87
  end
88
+ end
@@ -1,5 +1,6 @@
1
1
  require File.join(File.dirname(__FILE__), 'spec_helper')
2
2
 
3
+ unless has_parsetree?
3
4
  describe "Per line comment (# ...)" do
4
5
 
5
6
  should 'handle start of line' do
@@ -32,3 +33,4 @@ EOL
32
33
  end
33
34
 
34
35
  end
36
+ end
@@ -1,5 +1,6 @@
1
1
  require File.join(File.dirname(__FILE__), 'spec_helper')
2
2
 
3
+ unless has_parsetree?
3
4
  describe 'Single quote strings (\', %q & %w)' do
4
5
 
5
6
  %w{~ ` ! @ # $ % ^ & * _ - + = \\ | ; : ' " , . ? /}.map{|w| [w,w] }.concat(
@@ -79,3 +80,4 @@ describe 'Single quote strings (\', %q & %w)' do
79
80
  end
80
81
 
81
82
  end
83
+ end
data/spec/spec_helper.rb CHANGED
@@ -20,12 +20,16 @@ end
20
20
 
21
21
  Bacon.summary_on_exit
22
22
 
23
+ def has_parsetree?
24
+ Object.const_defined?(:ParseTree)
25
+ end
26
+
23
27
  def watever(*args, &block)
24
28
  Proc.new(&block)
25
29
  end
26
30
 
27
31
  def code_to_sexp(code)
28
- if Object.const_defined?(:ParseTree)
32
+ if has_parsetree?
29
33
  require 'parse_tree'
30
34
  Unifier.new.process(ParseTree.translate(code))
31
35
  else
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sourcify
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 85
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
+ - 2
9
10
  - 1
10
- version: 0.2.1
11
+ version: 0.2.2.1
11
12
  platform: ruby
12
13
  authors:
13
14
  - NgTzeYang
@@ -15,7 +16,7 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-09-14 00:00:00 +08:00
19
+ date: 2010-09-15 00:00:00 +08:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
@@ -26,12 +27,12 @@ dependencies:
26
27
  requirements:
27
28
  - - ">="
28
29
  - !ruby/object:Gem::Version
29
- hash: 23
30
+ hash: 21
30
31
  segments:
31
32
  - 1
32
33
  - 2
33
- - 4
34
- version: 1.2.4
34
+ - 5
35
+ version: 1.2.5
35
36
  type: :runtime
36
37
  version_requirements: *id001
37
38
  - !ruby/object:Gem::Dependency