ruby2ruby 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +1 -0
- data/History.txt +9 -0
- data/Rakefile +8 -24
- data/lib/ruby2ruby.rb +2 -18
- data/test/test_ruby2ruby.rb +46 -90
- metadata +54 -8
- metadata.gz.sig +0 -0
data.tar.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
zm)�e��BQ��ʸc�I����f�o�I�}�e�,�<1����(L���70�R�U��_�*l`�?�:���΅�ț|T,8��5��h�34��)�������۶4�s̕��Υ�B�{'1˥aL�7du��w׆Xzð� x�巒b��Df�9�QuoJ��"���Wh��ȥ��a\��:�n�����$L��W��i���gCxP���7�<�>�dI}��p�E��r���C�4RW��0�O�h�
|
data/History.txt
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
=== 1.2.3 / 2009-06-23
|
2
|
+
|
3
|
+
* 4 minor enhancements:
|
4
|
+
|
5
|
+
* Overhauled 4-generation tests to use RubyParser. Much cleaner
|
6
|
+
* Removed last of ParseTree. Fully switched to RubyParser.
|
7
|
+
* Switched to minitest
|
8
|
+
* Updated Rakefile to new hoe capabilities
|
9
|
+
|
1
10
|
=== 1.2.2 / 2009-01-20
|
2
11
|
|
3
12
|
* 3 minor enhancements:
|
data/Rakefile
CHANGED
@@ -4,36 +4,20 @@ require 'rubygems'
|
|
4
4
|
require 'hoe'
|
5
5
|
|
6
6
|
Hoe.add_include_dirs("lib",
|
7
|
-
"../../ZenTest/dev/lib",
|
8
7
|
"../../ParseTree/dev/test",
|
9
|
-
"../../ParseTree/dev/lib",
|
10
|
-
"../../RubyInline/dev/lib",
|
11
8
|
"../../ruby_parser/dev/lib",
|
12
9
|
"../../sexp_processor/dev/lib")
|
13
10
|
|
14
|
-
|
11
|
+
Hoe.plugin :seattlerb
|
15
12
|
|
16
|
-
Hoe.
|
17
|
-
|
18
|
-
r2r.developer('Ryan Davis', 'ryand-ruby@zenspider.com')
|
13
|
+
Hoe.spec 'ruby2ruby' do
|
14
|
+
developer 'Ryan Davis', 'ryand-ruby@zenspider.com'
|
19
15
|
|
20
|
-
|
21
|
-
r2r.extra_deps << ["ParseTree", "~> 3.0"]
|
22
|
-
end
|
23
|
-
|
24
|
-
task :test => :clean
|
25
|
-
|
26
|
-
task :rcov_info do
|
27
|
-
pat = ENV['PATTERN'] || "test/test_*.rb"
|
28
|
-
ruby "#{Hoe::RUBY_FLAGS} -S rcov --text-report --save coverage.info #{pat}"
|
29
|
-
end
|
16
|
+
self.rubyforge_name = 'seattlerb'
|
30
17
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
bol, eol = eol, eol + line.length
|
35
|
-
[bol, eol, "#ffcccc"] unless coverage
|
36
|
-
}.compact.inspect
|
18
|
+
extra_deps << ["sexp_processor", "~> 3.0"]
|
19
|
+
extra_deps << ["ruby_parser", "~> 2.0"]
|
20
|
+
extra_dev_deps << ["ParseTree", "~> 3.0"]
|
37
21
|
end
|
38
22
|
|
39
|
-
# vim: syntax=
|
23
|
+
# vim: syntax=ruby
|
data/lib/ruby2ruby.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby -w
|
2
2
|
|
3
|
-
|
3
|
+
require 'rubygems'
|
4
4
|
require 'sexp_processor'
|
5
|
-
require 'unified_ruby'
|
6
5
|
|
7
6
|
class Ruby2Ruby < SexpProcessor
|
8
|
-
VERSION = '1.2.
|
7
|
+
VERSION = '1.2.3'
|
9
8
|
LINE_LENGTH = 78
|
10
9
|
|
11
10
|
##
|
@@ -25,21 +24,6 @@ class Ruby2Ruby < SexpProcessor
|
|
25
24
|
:return,
|
26
25
|
]
|
27
26
|
|
28
|
-
def self.translate(klass_or_str, method = nil)
|
29
|
-
require 'parse_tree'
|
30
|
-
sexp = ParseTree.translate(klass_or_str, method)
|
31
|
-
|
32
|
-
unifier = Unifier.new
|
33
|
-
|
34
|
-
unifier.processors.each do |p|
|
35
|
-
p.unsupported.delete :cfunc # HACK
|
36
|
-
end
|
37
|
-
|
38
|
-
sexp = unifier.process(sexp)
|
39
|
-
|
40
|
-
self.new.process(sexp)
|
41
|
-
end
|
42
|
-
|
43
27
|
def initialize
|
44
28
|
super
|
45
29
|
@indent = " "
|
data/test/test_ruby2ruby.rb
CHANGED
@@ -4,16 +4,12 @@ $TESTING = true
|
|
4
4
|
|
5
5
|
$: << 'lib'
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
require 'test/unit'
|
7
|
+
require 'minitest/autorun'
|
10
8
|
require 'ruby2ruby'
|
11
9
|
require 'pt_testcase'
|
12
10
|
require 'fileutils'
|
13
11
|
require 'tmpdir'
|
14
12
|
|
15
|
-
FileUtils.rm_rf File.expand_path("~/.ruby_inline") # for self-translation
|
16
|
-
|
17
13
|
class R2RTestCase < ParseTreeTestCase
|
18
14
|
def self.previous key
|
19
15
|
"ParseTree"
|
@@ -36,21 +32,14 @@ class R2RTestCase < ParseTreeTestCase
|
|
36
32
|
end
|
37
33
|
end
|
38
34
|
|
39
|
-
|
40
|
-
alias :refute_nil :assert_not_nil unless defined? Mini
|
35
|
+
start = __LINE__
|
41
36
|
|
37
|
+
class TestRuby2Ruby < R2RTestCase
|
42
38
|
def setup
|
43
39
|
super
|
44
40
|
@processor = Ruby2Ruby.new
|
45
41
|
end
|
46
42
|
|
47
|
-
def teardown
|
48
|
-
unless $DEBUG then
|
49
|
-
FileUtils.rm_rf @rootdir
|
50
|
-
ENV.delete 'INLINEDIR'
|
51
|
-
end if defined?(@rootdir) && @rootdir
|
52
|
-
end
|
53
|
-
|
54
43
|
def test_dregx_slash
|
55
44
|
inn = util_thingy(:dregx)
|
56
45
|
out = "/blah\\\"blah#\{(1 + 1)}blah\\\"blah\\/blah/"
|
@@ -124,9 +113,9 @@ class TestRuby2Ruby < R2RTestCase
|
|
124
113
|
s(:call,
|
125
114
|
s(:call, nil, :line, s(:arglist)),
|
126
115
|
:split,
|
127
|
-
s(:arglist, s(:lit,
|
116
|
+
s(:arglist, s(:lit, /\=/), s(:lit, 2))))))
|
128
117
|
|
129
|
-
out = 'x(*line.split(
|
118
|
+
out = 'x(*line.split(/\=/, 2))'
|
130
119
|
util_compare inn, out
|
131
120
|
end
|
132
121
|
|
@@ -135,12 +124,6 @@ class TestRuby2Ruby < R2RTestCase
|
|
135
124
|
assert_equal expected_eval, eval(expected_ruby) if expected_eval
|
136
125
|
end
|
137
126
|
|
138
|
-
def util_setup_inline
|
139
|
-
@rootdir = File.join(Dir.tmpdir, "test_ruby_to_ruby.#{$$}")
|
140
|
-
Dir.mkdir @rootdir, 0700 unless test ?d, @rootdir
|
141
|
-
ENV['INLINEDIR'] = @rootdir
|
142
|
-
end
|
143
|
-
|
144
127
|
def util_thingy(type)
|
145
128
|
s(type,
|
146
129
|
'blah"blah',
|
@@ -149,44 +132,6 @@ class TestRuby2Ruby < R2RTestCase
|
|
149
132
|
end
|
150
133
|
end
|
151
134
|
|
152
|
-
##
|
153
|
-
# Converts a +target+ using a +processor+ and converts +target+ name
|
154
|
-
# in the source adding +gen+ to allow easy renaming.
|
155
|
-
|
156
|
-
$broken = false
|
157
|
-
def morph_and_eval(processor, target, gen, n)
|
158
|
-
return if $broken
|
159
|
-
begin
|
160
|
-
processor = Object.const_get processor if Symbol === processor
|
161
|
-
target = Object.const_get target if Symbol === target
|
162
|
-
old_name = target.name
|
163
|
-
new_name = target.name.sub(/\d*$/, gen.to_s)
|
164
|
-
ruby = processor.translate(target).sub(old_name, new_name)
|
165
|
-
|
166
|
-
old, $-w = $-w, nil
|
167
|
-
eval ruby
|
168
|
-
$-w = old
|
169
|
-
|
170
|
-
target.constants.each do |constant|
|
171
|
-
eval "#{new_name}::#{constant} = #{old_name}::#{constant}"
|
172
|
-
end
|
173
|
-
rescue Exception => e
|
174
|
-
warn "Self-Translation Generation #{n} failed:"
|
175
|
-
warn "#{e.class}: #{e.message}"
|
176
|
-
warn e.backtrace.join("\n ")
|
177
|
-
warn ""
|
178
|
-
warn ruby
|
179
|
-
warn ""
|
180
|
-
$broken = true
|
181
|
-
else
|
182
|
-
begin
|
183
|
-
yield if block_given?
|
184
|
-
rescue
|
185
|
-
# probably already handled
|
186
|
-
end
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
135
|
####################
|
191
136
|
# impl
|
192
137
|
# old new
|
@@ -196,33 +141,44 @@ end
|
|
196
141
|
# s
|
197
142
|
# t new 2 3
|
198
143
|
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
morph_and_eval
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
144
|
+
tr2r = File.read(__FILE__).split(/\n/)[start+1..__LINE__-2].join("\n")
|
145
|
+
ir2r = File.read("lib/ruby2ruby.rb")
|
146
|
+
|
147
|
+
require 'ruby_parser'
|
148
|
+
|
149
|
+
def silent_eval ruby
|
150
|
+
old, $-w = $-w, nil
|
151
|
+
eval ruby
|
152
|
+
$-w = old
|
153
|
+
end
|
154
|
+
|
155
|
+
def morph_and_eval src, from, to, processor
|
156
|
+
new_src = processor.new.process(RubyParser.new.process(src.sub(from, to)))
|
157
|
+
silent_eval new_src
|
158
|
+
new_src
|
159
|
+
end
|
160
|
+
|
161
|
+
____ = morph_and_eval tr2r, /TestRuby2Ruby/, 'TestRuby2Ruby2', Ruby2Ruby
|
162
|
+
ruby = morph_and_eval ir2r, /Ruby2Ruby/, 'Ruby2Ruby2', Ruby2Ruby
|
163
|
+
____ = morph_and_eval ruby, /Ruby2Ruby2/, 'Ruby2Ruby3', Ruby2Ruby2
|
164
|
+
|
165
|
+
class TestRuby2Ruby1 < TestRuby2Ruby
|
166
|
+
def setup
|
167
|
+
super
|
168
|
+
@processor = Ruby2Ruby2.new
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
class TestRuby2Ruby3 < TestRuby2Ruby2
|
173
|
+
def setup
|
174
|
+
super
|
175
|
+
@processor = Ruby2Ruby2.new
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
class TestRuby2Ruby4 < TestRuby2Ruby2
|
180
|
+
def setup
|
181
|
+
super
|
182
|
+
@processor = Ruby2Ruby3.new
|
183
|
+
end
|
184
|
+
end
|
metadata
CHANGED
@@ -1,21 +1,62 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby2ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Davis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
|
-
cert_chain:
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDPjCCAiagAwIBAgIBADANBgkqhkiG9w0BAQUFADBFMRMwEQYDVQQDDApyeWFu
|
14
|
+
ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
|
15
|
+
GRYDY29tMB4XDTA5MDMwNjE4NTMxNVoXDTEwMDMwNjE4NTMxNVowRTETMBEGA1UE
|
16
|
+
AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
|
17
|
+
JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
|
18
|
+
b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
|
19
|
+
taCPaLmfYIaFcHHCSY4hYDJijRQkLxPeB3xbOfzfLoBDbjvx5JxgJxUjmGa7xhcT
|
20
|
+
oOvjtt5P8+GSK9zLzxQP0gVLS/D0FmoE44XuDr3iQkVS2ujU5zZL84mMNqNB1znh
|
21
|
+
GiadM9GHRaDiaxuX0cIUBj19T01mVE2iymf9I6bEsiayK/n6QujtyCbTWsAS9Rqt
|
22
|
+
qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
|
23
|
+
gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
|
24
|
+
HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBBQUAA4IB
|
25
|
+
AQAY59gYvDxqSqgC92nAP9P8dnGgfZgLxP237xS6XxFGJSghdz/nI6pusfCWKM8m
|
26
|
+
vzjjH2wUMSSf3tNudQ3rCGLf2epkcU13/rguI88wO6MrE0wi4ZqLQX+eZQFskJb/
|
27
|
+
w6x9W1ur8eR01s397LSMexySDBrJOh34cm2AlfKr/jokKCTwcM0OvVZnAutaovC0
|
28
|
+
l1SVZ0ecg88bsWHA0Yhh7NFxK1utWoIhtB6AFC/+trM0FQEB/jZkIS8SaNzn96Rl
|
29
|
+
n0sZEf77FLf5peR8TP/PtmIg7Cyqz23sLM4mCOoTGIy5OcZ8TdyiyINUHtb5ej/T
|
30
|
+
FBHgymkyj/AOSqKRIpXPhjC6
|
31
|
+
-----END CERTIFICATE-----
|
11
32
|
|
12
|
-
date: 2009-
|
33
|
+
date: 2009-06-23 00:00:00 -07:00
|
13
34
|
default_executable:
|
14
35
|
dependencies:
|
15
36
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
37
|
+
name: sexp_processor
|
38
|
+
type: :runtime
|
39
|
+
version_requirement:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: "3.0"
|
45
|
+
version:
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: ruby_parser
|
17
48
|
type: :runtime
|
18
49
|
version_requirement:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: "2.0"
|
55
|
+
version:
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: ParseTree
|
58
|
+
type: :development
|
59
|
+
version_requirement:
|
19
60
|
version_requirements: !ruby/object:Gem::Requirement
|
20
61
|
requirements:
|
21
62
|
- - ~>
|
@@ -30,9 +71,12 @@ dependencies:
|
|
30
71
|
requirements:
|
31
72
|
- - ">="
|
32
73
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
74
|
+
version: 2.3.0
|
34
75
|
version:
|
35
|
-
description:
|
76
|
+
description: |-
|
77
|
+
ruby2ruby provides a means of generating pure ruby code easily from
|
78
|
+
ParseTree's Sexps. This makes making dynamic language processors much
|
79
|
+
easier in ruby than ever before.
|
36
80
|
email:
|
37
81
|
- ryand-ruby@zenspider.com
|
38
82
|
executables:
|
@@ -54,6 +98,8 @@ files:
|
|
54
98
|
- test/test_ruby2ruby.rb
|
55
99
|
has_rdoc: true
|
56
100
|
homepage: http://seattlerb.rubyforge.org/
|
101
|
+
licenses: []
|
102
|
+
|
57
103
|
post_install_message:
|
58
104
|
rdoc_options:
|
59
105
|
- --main
|
@@ -75,9 +121,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
121
|
requirements: []
|
76
122
|
|
77
123
|
rubyforge_project: seattlerb
|
78
|
-
rubygems_version: 1.3.
|
124
|
+
rubygems_version: 1.3.4
|
79
125
|
signing_key:
|
80
|
-
specification_version:
|
126
|
+
specification_version: 3
|
81
127
|
summary: ruby2ruby provides a means of generating pure ruby code easily from ParseTree's Sexps
|
82
128
|
test_files:
|
83
129
|
- test/test_ruby2ruby.rb
|
metadata.gz.sig
ADDED
Binary file
|