to_source 0.2.1 → 0.2.2

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/Changelog.md CHANGED
@@ -1,8 +1,17 @@
1
+ # v0.2.2 2012-12-07
2
+
3
+ * [fixed] Emit of pattern arguments with no formal arguments present
4
+ * [fixed] Missed to require set
5
+
6
+ [Compare v0.2.1..v0.2.2](https://github.com/mbj/to_source/compare/v0.2.1...v0.2.2)
7
+
1
8
  # v0.2.1 2012-12-07
2
9
 
3
10
  * [fixed] Emit of def on splat with block
4
11
  * [fixed] Emit of pattern args
5
12
 
13
+ [Compare v0.2.0..v0.2.1](https://github.com/mbj/to_source/compare/v0.2.0...v0.2.1)
14
+
6
15
  # v0.2.0 2012-12-07
7
16
 
8
17
  * [BRAKING CHANGE] Remove core extension Rubinius::AST::Node#to_source (mbj)
@@ -13,4 +22,4 @@
13
22
  * [feature] Introduce metric tools via devtools
14
23
  * [fixed] Lots of transitvity edge cases
15
24
 
16
- [Compare v0.1.3..v0.2.0](https://github.com/solnic/virtus/compare/v0.1.3...v0.2.0)
25
+ [Compare v0.1.3..v0.2.0](https://github.com/mbj/to_source/ompare/v0.1.3...v0.2.0)
data/lib/to_source.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'set'
1
2
  require 'melbourne'
2
3
  require 'to_source/version'
3
4
  require 'to_source/visitor'
@@ -1324,7 +1324,7 @@ module ToSource
1324
1324
  emit(' do')
1325
1325
 
1326
1326
  arguments = node.arguments
1327
- unless arguments.names.empty?
1327
+ unless arguments.required.empty?
1328
1328
  emit(' ')
1329
1329
  formal_arguments_generic(node.arguments,'|','|')
1330
1330
  end
@@ -1575,9 +1575,9 @@ module ToSource
1575
1575
  #
1576
1576
  # @api private
1577
1577
  #
1578
- def formal_arguments_generic(node,open,close)
1579
- return if node.names.empty?
1580
- required, defaults, splat = node.required, node.defaults, node.splat
1578
+ def formal_arguments_generic(node, open, close)
1579
+ required, defaults, splat, block_arg = node.required, node.defaults, node.splat, node.block_arg
1580
+ return unless required.any? or defaults or splat or block_arg
1581
1581
 
1582
1582
  emit(open)
1583
1583
 
@@ -1606,10 +1606,10 @@ module ToSource
1606
1606
  end
1607
1607
  end
1608
1608
 
1609
- if node.block_arg
1609
+ if block_arg
1610
1610
  emit(', ') unless empty
1611
1611
 
1612
- dispatch(node.block_arg)
1612
+ dispatch(block_arg)
1613
1613
  end
1614
1614
 
1615
1615
  emit(close)
@@ -20,7 +20,7 @@ describe ToSource::Visitor,'.run' do
20
20
  end
21
21
 
22
22
  def self.assert_source(source)
23
- let(:node) { puts source; source.to_ast }
23
+ let(:node) { source.to_ast }
24
24
  let(:source) { source }
25
25
  let(:expected_source) { source }
26
26
 
@@ -398,7 +398,7 @@ describe ToSource::Visitor,'.run' do
398
398
  end
399
399
  end
400
400
 
401
- context 'with block that takes pattern arguments' do
401
+ context 'with block that takes pattern and formal arguments' do
402
402
  assert_source <<-RUBY
403
403
  foo.bar do |(a, b), c|
404
404
  d
@@ -406,6 +406,15 @@ describe ToSource::Visitor,'.run' do
406
406
  RUBY
407
407
  end
408
408
 
409
+
410
+ context 'with block that takes pattern and no formal arguments' do
411
+ assert_source <<-RUBY
412
+ foo.bar do |(a, b)|
413
+ d
414
+ end
415
+ RUBY
416
+ end
417
+
409
418
  context 'with block that takes arguments' do
410
419
  assert_source <<-RUBY
411
420
  foo.bar do |a|
data/to_source.gemspec CHANGED
@@ -1,11 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path('../lib', __FILE__)
3
-
4
- require 'to_source/version'
5
-
6
2
  Gem::Specification.new do |s|
7
3
  s.name = 'to_source'
8
- s.version = ToSource::VERSION
4
+ s.version = '0.2.2'
9
5
  s.authors = ['Josep M. Bach', 'Markus Schirp']
10
6
  s.email = ['josep.m.bach@gmail.com', 'mbj@seonic.net']
11
7
  s.homepage = 'http://github.com/txus/to_source'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: to_source
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-12-08 00:00:00.000000000 Z
13
+ date: 2012-12-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: adamantium
@@ -70,7 +70,6 @@ files:
70
70
  - config/site.reek
71
71
  - config/yardstick.yml
72
72
  - lib/to_source.rb
73
- - lib/to_source/version.rb
74
73
  - lib/to_source/visitor.rb
75
74
  - spec/spec_helper.rb
76
75
  - spec/unit/to_source/visitor/class_methods/run_spec.rb
@@ -1,3 +0,0 @@
1
- module ToSource
2
- VERSION = '0.2.1'
3
- end