to_source 0.2.17 → 0.2.18

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/.gitignore CHANGED
@@ -1,4 +1,3 @@
1
- /*.gem
2
1
  /.bundle
3
2
  /Gemfile.lock
4
3
  /pkg/*
@@ -1,3 +1,9 @@
1
+ # v0.2.18 2013-01-29
2
+
3
+ * [fixed] Emit ranges in parantheses to resolve ambiguity
4
+
5
+ [Compare v0.2.17..v0.2.18](https://github.com/mbj/to_source/compare/v0.2.17...v0.2.18)
6
+
1
7
  # v0.2.17 2013-01-26
2
8
 
3
9
  * [fixed] Fix op assign 1 operators with implicit index array[] ||= etc
@@ -21,7 +21,7 @@ group :guard do
21
21
  gem 'rb-inotify', '~> 0.9.0', :require => false
22
22
 
23
23
  # Remove this one https://github.com/guard/listen/pull/78 is released
24
- gem 'listen', '~> 0.7.2', :git => 'https://github.com/guard/listen'
24
+ gem 'listen', '~> 0.7.2', :git => 'https://github.com/guard/listen.git'
25
25
 
26
26
  # notification handling
27
27
  gem 'libnotify', '~> 0.8.0', :require => false
@@ -33,20 +33,16 @@ group :metrics do
33
33
  gem 'backports', '~> 2.7.0'
34
34
  gem 'flay', '~> 1.4.3'
35
35
  gem 'flog', '~> 2.5.3'
36
- gem 'mutant', '~> 0.2.15'
36
+ gem 'mutant', '~> 0.2.16'
37
37
  gem 'reek', '~> 1.2.13', :git => 'https://github.com/troessner/reek.git', :ref => 'ef77fcecaa21c9ebcbe4d9a79d41b0e70196bf18'
38
38
  gem 'roodi', '~> 2.1.0'
39
- gem 'yardstick', '~> 0.9.0'
39
+ gem 'yardstick', '~> 0.9.1'
40
40
 
41
41
  platforms :ruby_18, :ruby_19 do
42
42
  # this indirectly depends on ffi which does not build on ruby-head
43
43
  gem 'yard-spellcheck', '~> 0.1.5'
44
44
  end
45
45
 
46
- platforms :mri_18 do
47
- gem 'rcov', '~> 1.0.0'
48
- end
49
-
50
46
  platforms :mri_19 do
51
47
  gem 'simplecov', '~> 0.7.1'
52
48
  end
data/README.md CHANGED
@@ -6,9 +6,15 @@ to_source
6
6
  [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/mbj/to_source)
7
7
 
8
8
  Reverse parser to generate source code from the Rubinius AST. Also works well under MRI using the mutant-melbourne gem.
9
-
10
9
  Currently only support for 1.9 mode!
11
10
 
11
+ To source is the backend of [mutant](https://github.com/mbj/mutant) it is used to create the (mutated) source that is
12
+ evaled into the vm. Also for creating the diffs.
13
+
14
+ It should be able to create equivalent, but not identical, source. The current focus is to create *correct* but not
15
+ *beautiful* source. Once correctnes is at 100% I'll focus on beautifullnes, so pls do not complain about excess of
16
+ parantheses now ;).
17
+
12
18
  Installation
13
19
  ------------
14
20
 
@@ -11,6 +11,7 @@ require 'to_source/emitter/literal/dynamic'
11
11
  require 'to_source/emitter/literal/dynamic/regexp'
12
12
  require 'to_source/emitter/literal/regexp'
13
13
  require 'to_source/emitter/literal/regexp/options'
14
+ require 'to_source/emitter/literal/range'
14
15
  require 'to_source/emitter/access'
15
16
  require 'to_source/emitter/formal_arguments'
16
17
  require 'to_source/emitter/actual_arguments'
@@ -41,41 +41,6 @@ module ToSource
41
41
  end
42
42
  end
43
43
 
44
- # Base class for range emitters
45
- class Range < self
46
-
47
- private
48
-
49
- # Perform dispatch
50
- #
51
- # @return [undefined]
52
- #
53
- # @api private
54
- #
55
- def dispatch
56
- util = node
57
- visit(util.start)
58
- emit(self.class::TOKEN)
59
- visit(util.finish)
60
- end
61
-
62
- # Emitter for incluive range nodes
63
- class Inclusive < self
64
-
65
- handle(Rubinius::AST::Range)
66
- TOKEN = '..'.freeze
67
-
68
- end
69
-
70
- # Emitter for exclusive range nodes
71
- class Exclude < self
72
-
73
- handle(Rubinius::AST::RangeExclude)
74
- TOKEN = '...'.freeze
75
-
76
- end
77
-
78
- end
79
44
 
80
45
  # Emitter for hash nodes
81
46
  class Hash < self
@@ -0,0 +1,43 @@
1
+ module ToSource
2
+ class Emitter
3
+ class Literal
4
+ # Base class for range emitters
5
+ class Range < self
6
+
7
+ private
8
+
9
+ # Perform dispatch
10
+ #
11
+ # @return [undefined]
12
+ #
13
+ # @api private
14
+ #
15
+ def dispatch
16
+ util = node
17
+ parantheses do
18
+ visit(util.start)
19
+ emit(self.class::TOKEN)
20
+ visit(util.finish)
21
+ end
22
+ end
23
+
24
+ # Emitter for incluive range nodes
25
+ class Inclusive < self
26
+
27
+ handle(Rubinius::AST::Range)
28
+ TOKEN = '..'.freeze
29
+
30
+ end
31
+
32
+ # Emitter for exclusive range nodes
33
+ class Exclude < self
34
+
35
+ handle(Rubinius::AST::RangeExclude)
36
+ TOKEN = '...'.freeze
37
+
38
+ end
39
+
40
+ end
41
+ end
42
+ end
43
+ end
@@ -387,12 +387,18 @@ describe ToSource,'.to_source' do
387
387
  assert_source '{:answer => 42, :bar => :baz}'
388
388
  end
389
389
 
390
- context 'inclusive range' do
391
- assert_source '20..34'
392
- end
390
+ context 'range' do
391
+ context 'inclusive' do
392
+ assert_source '(20..34)'
393
+ end
393
394
 
394
- context 'exclusive range' do
395
- assert_source '20...34'
395
+ context 'expression in bounds' do
396
+ assert_source '(foo..bar)'
397
+ end
398
+
399
+ context 'exclusive range' do
400
+ assert_source '(20...34)'
401
+ end
396
402
  end
397
403
 
398
404
  context 'regexp' do
@@ -1,11 +1,11 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |s|
3
3
  s.name = 'to_source'
4
- s.version = '0.2.17'
4
+ s.version = '0.2.18'
5
5
  s.authors = ['Markus Schirp']
6
6
  s.email = ['mbj@seonic.net']
7
7
  s.homepage = 'http://github.com/mbj/to_source'
8
- s.summary = %q{Transform Rubinius 1.9 AST back to equvalent source code.}
8
+ s.summary = %q{Transform Rubinius 1.9 AST back to equivalent source code}
9
9
  s.description = s.summary
10
10
  s.files = `git ls-files`.split("\n")
11
11
  s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
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.17
4
+ version: 0.2.18
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-26 00:00:00.000000000 Z
12
+ date: 2013-01-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: adamantium
@@ -75,7 +75,7 @@ dependencies:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
77
  version: 2.0.3
78
- description: Transform Rubinius 1.9 AST back to equvalent source code.
78
+ description: Transform Rubinius 1.9 AST back to equivalent source code
79
79
  email:
80
80
  - mbj@seonic.net
81
81
  executables:
@@ -143,6 +143,7 @@ files:
143
143
  - lib/to_source/emitter/literal.rb
144
144
  - lib/to_source/emitter/literal/dynamic.rb
145
145
  - lib/to_source/emitter/literal/dynamic/regexp.rb
146
+ - lib/to_source/emitter/literal/range.rb
146
147
  - lib/to_source/emitter/literal/regexp.rb
147
148
  - lib/to_source/emitter/literal/regexp/options.rb
148
149
  - lib/to_source/emitter/loop.rb
@@ -205,7 +206,7 @@ rubyforge_project:
205
206
  rubygems_version: 1.8.23
206
207
  signing_key:
207
208
  specification_version: 3
208
- summary: Transform Rubinius 1.9 AST back to equvalent source code.
209
+ summary: Transform Rubinius 1.9 AST back to equivalent source code
209
210
  test_files:
210
211
  - spec/spec_helper.rb
211
212
  - spec/unit/to_source/class_methods/run_spec.rb