to_source 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog.md +7 -0
- data/lib/to_source/visitor.rb +21 -4
- data/spec/unit/to_source/visitor/class_methods/run_spec.rb +12 -8
- data/to_source.gemspec +1 -1
- metadata +1 -1
data/Changelog.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# v0.2.4 2012-12-07
|
2
|
+
|
3
|
+
* [feature] Allow to emit pattern variables as root node
|
4
|
+
* [fixed] Emit send with splat and block argument correctly
|
5
|
+
|
6
|
+
[Compare v0.2.3..v0.2.4](https://github.com/mbj/to_source/compare/v0.2.3...v0.2.4)
|
7
|
+
|
1
8
|
# v0.2.3 2012-12-07
|
2
9
|
|
3
10
|
* [fixed] Nuke dangling require (sorry for not running specs after gemspec change)
|
data/lib/to_source/visitor.rb
CHANGED
@@ -1047,7 +1047,7 @@ module ToSource
|
|
1047
1047
|
end
|
1048
1048
|
end
|
1049
1049
|
|
1050
|
-
# Emit send
|
1050
|
+
# Emit send node
|
1051
1051
|
#
|
1052
1052
|
# @param [Rubinius::AST::Node] node
|
1053
1053
|
#
|
@@ -1100,13 +1100,16 @@ module ToSource
|
|
1100
1100
|
array_body(array)
|
1101
1101
|
is_block_pass = block.kind_of?(Rubinius::AST::BlockPass)
|
1102
1102
|
|
1103
|
+
empty = array.empty?
|
1104
|
+
|
1103
1105
|
if arguments.splat
|
1104
|
-
emit(', ') unless
|
1106
|
+
emit(', ') unless empty
|
1105
1107
|
dispatch(arguments.splat)
|
1108
|
+
empty = false
|
1106
1109
|
end
|
1107
1110
|
|
1108
1111
|
if is_block_pass
|
1109
|
-
emit(', ') unless
|
1112
|
+
emit(', ') unless empty
|
1110
1113
|
block_pass(block)
|
1111
1114
|
end
|
1112
1115
|
|
@@ -1157,6 +1160,7 @@ module ToSource
|
|
1157
1160
|
if node.name == :[]
|
1158
1161
|
return element_reference(node)
|
1159
1162
|
end
|
1163
|
+
|
1160
1164
|
return if process_binary_operator(node)
|
1161
1165
|
|
1162
1166
|
if receiver(node)
|
@@ -1549,6 +1553,18 @@ module ToSource
|
|
1549
1553
|
kend
|
1550
1554
|
end
|
1551
1555
|
|
1556
|
+
# Emit pattern variable
|
1557
|
+
#
|
1558
|
+
# @param [Rubinius::AST::PatternVariable] node
|
1559
|
+
#
|
1560
|
+
# @return [undefined]
|
1561
|
+
#
|
1562
|
+
# @api private
|
1563
|
+
#
|
1564
|
+
def pattern_variable(node)
|
1565
|
+
emit(node.name)
|
1566
|
+
end
|
1567
|
+
|
1552
1568
|
# Emit pattern arguments
|
1553
1569
|
#
|
1554
1570
|
# @param [Rubinius::AST::PatternArguments] node
|
@@ -1561,7 +1577,7 @@ module ToSource
|
|
1561
1577
|
emit('(')
|
1562
1578
|
arguments = node.arguments.body
|
1563
1579
|
arguments.each_with_index do |argument, index|
|
1564
|
-
|
1580
|
+
dispatch(argument)
|
1565
1581
|
emit(', ') unless index == arguments.size - 1
|
1566
1582
|
end
|
1567
1583
|
emit(')')
|
@@ -1748,6 +1764,7 @@ module ToSource
|
|
1748
1764
|
emit('&')
|
1749
1765
|
dispatch(node.body)
|
1750
1766
|
end
|
1767
|
+
alias_method :block_pass19, :block_pass
|
1751
1768
|
|
1752
1769
|
# Emit return statement
|
1753
1770
|
#
|
@@ -438,17 +438,13 @@ describe ToSource::Visitor,'.run' do
|
|
438
438
|
|
439
439
|
context 'with formal splat and block' do
|
440
440
|
assert_source <<-RUBY
|
441
|
-
foo
|
442
|
-
some_stuff
|
443
|
-
end
|
441
|
+
foo(bar, *args)
|
444
442
|
RUBY
|
445
443
|
end
|
446
444
|
|
447
445
|
context 'with splat and block argument' do
|
448
446
|
assert_source <<-RUBY
|
449
|
-
|
450
|
-
some_stuff
|
451
|
-
end
|
447
|
+
foo(*args, &block)
|
452
448
|
RUBY
|
453
449
|
end
|
454
450
|
|
@@ -1008,7 +1004,7 @@ describe ToSource::Visitor,'.run' do
|
|
1008
1004
|
|
1009
1005
|
context 'with block argument' do
|
1010
1006
|
assert_source <<-RUBY
|
1011
|
-
def
|
1007
|
+
def foo(&block)
|
1012
1008
|
bar
|
1013
1009
|
end
|
1014
1010
|
RUBY
|
@@ -1016,7 +1012,15 @@ describe ToSource::Visitor,'.run' do
|
|
1016
1012
|
|
1017
1013
|
context 'with required and block arguments' do
|
1018
1014
|
assert_source <<-RUBY
|
1019
|
-
def
|
1015
|
+
def foo(bar, &block)
|
1016
|
+
bar
|
1017
|
+
end
|
1018
|
+
RUBY
|
1019
|
+
end
|
1020
|
+
|
1021
|
+
context 'with spat and block arguments' do
|
1022
|
+
assert_source <<-RUBY
|
1023
|
+
def foo(*bar, &block)
|
1020
1024
|
bar
|
1021
1025
|
end
|
1022
1026
|
RUBY
|
data/to_source.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
s.name = 'to_source'
|
4
|
-
s.version = '0.2.
|
4
|
+
s.version = '0.2.4'
|
5
5
|
s.authors = ['Josep M. Bach', 'Markus Schirp']
|
6
6
|
s.email = ['josep.m.bach@gmail.com', 'mbj@seonic.net']
|
7
7
|
s.homepage = 'http://github.com/txus/to_source'
|