unparser 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +7 -0
- data/Gemfile +1 -7
- data/README.md +6 -1
- data/Rakefile +11 -2
- data/bin/unparser +0 -2
- data/config/devtools.yml +1 -1
- data/config/flay.yml +1 -1
- data/config/flog.yml +1 -1
- data/config/reek.yml +4 -1
- data/config/rubocop.yml +0 -4
- data/lib/unparser.rb +1 -2
- data/lib/unparser/ast.rb +0 -2
- data/lib/unparser/ast/local_variable_scope.rb +0 -2
- data/lib/unparser/buffer.rb +0 -2
- data/lib/unparser/cli.rb +3 -4
- data/lib/unparser/cli/color.rb +0 -2
- data/lib/unparser/cli/differ.rb +0 -2
- data/lib/unparser/cli/source.rb +1 -3
- data/lib/unparser/comments.rb +0 -2
- data/lib/unparser/constants.rb +0 -2
- data/lib/unparser/emitter.rb +4 -3
- data/lib/unparser/emitter/alias.rb +0 -2
- data/lib/unparser/emitter/argument.rb +0 -2
- data/lib/unparser/emitter/assignment.rb +0 -2
- data/lib/unparser/emitter/begin.rb +1 -3
- data/lib/unparser/emitter/binary.rb +0 -2
- data/lib/unparser/emitter/block.rb +0 -2
- data/lib/unparser/emitter/case.rb +0 -2
- data/lib/unparser/emitter/cbase.rb +0 -2
- data/lib/unparser/emitter/class.rb +1 -3
- data/lib/unparser/emitter/def.rb +0 -2
- data/lib/unparser/emitter/defined.rb +0 -2
- data/lib/unparser/emitter/empty.rb +0 -2
- data/lib/unparser/emitter/ensure.rb +0 -2
- data/lib/unparser/emitter/flipflop.rb +0 -2
- data/lib/unparser/emitter/flow_modifier.rb +0 -2
- data/lib/unparser/emitter/for.rb +0 -2
- data/lib/unparser/emitter/hookexe.rb +0 -2
- data/lib/unparser/emitter/if.rb +0 -2
- data/lib/unparser/emitter/literal.rb +0 -2
- data/lib/unparser/emitter/literal/array.rb +0 -2
- data/lib/unparser/emitter/literal/dynamic.rb +2 -43
- data/lib/unparser/emitter/literal/dynamic_body.rb +0 -6
- data/lib/unparser/emitter/literal/execute_string.rb +0 -2
- data/lib/unparser/emitter/literal/hash.rb +1 -3
- data/lib/unparser/emitter/literal/primitive.rb +0 -2
- data/lib/unparser/emitter/literal/range.rb +0 -2
- data/lib/unparser/emitter/literal/regexp.rb +0 -2
- data/lib/unparser/emitter/literal/singleton.rb +0 -2
- data/lib/unparser/emitter/match.rb +0 -2
- data/lib/unparser/emitter/module.rb +0 -2
- data/lib/unparser/emitter/op_assign.rb +0 -2
- data/lib/unparser/emitter/redo.rb +0 -2
- data/lib/unparser/emitter/repetition.rb +0 -2
- data/lib/unparser/emitter/resbody.rb +0 -2
- data/lib/unparser/emitter/rescue.rb +0 -2
- data/lib/unparser/emitter/retry.rb +0 -2
- data/lib/unparser/emitter/root.rb +0 -2
- data/lib/unparser/emitter/send.rb +0 -2
- data/lib/unparser/emitter/send/arguments.rb +0 -2
- data/lib/unparser/emitter/send/attribute_assignment.rb +0 -2
- data/lib/unparser/emitter/send/binary.rb +0 -2
- data/lib/unparser/emitter/send/conditional.rb +38 -0
- data/lib/unparser/emitter/send/index.rb +0 -2
- data/lib/unparser/emitter/send/regular.rb +0 -2
- data/lib/unparser/emitter/send/unary.rb +3 -2
- data/lib/unparser/emitter/splat.rb +0 -2
- data/lib/unparser/emitter/super.rb +0 -2
- data/lib/unparser/emitter/undef.rb +0 -2
- data/lib/unparser/emitter/variable.rb +0 -2
- data/lib/unparser/emitter/yield.rb +0 -2
- data/lib/unparser/finalize.rb +0 -2
- data/lib/unparser/node_helpers.rb +0 -2
- data/lib/unparser/preprocessor.rb +3 -80
- data/spec/integration/unparser/corpus_spec.rb +3 -16
- data/spec/integrations.yml +10 -11
- data/spec/spec_helper.rb +0 -2
- data/spec/unit/unparser/buffer/append_spec.rb +0 -2
- data/spec/unit/unparser/buffer/append_without_prefix_spec.rb +0 -2
- data/spec/unit/unparser/buffer/capture_content_spec.rb +0 -2
- data/spec/unit/unparser/buffer/content_spec.rb +0 -2
- data/spec/unit/unparser/buffer/fresh_line_spec.rb +0 -2
- data/spec/unit/unparser/buffer/indent_spec.rb +0 -2
- data/spec/unit/unparser/buffer/nl_spec.rb +0 -2
- data/spec/unit/unparser/buffer/unindent_spec.rb +0 -2
- data/spec/unit/unparser/comments/consume_spec.rb +0 -2
- data/spec/unit/unparser/comments/take_all_spec.rb +0 -2
- data/spec/unit/unparser/comments/take_before_spec.rb +0 -2
- data/spec/unit/unparser/comments/take_eol_comments_spec.rb +0 -2
- data/spec/unit/unparser/emitter/class_methods/handle_spec.rb +1 -3
- data/spec/unit/unparser_spec.rb +47 -71
- data/unparser.gemspec +20 -17
- metadata +69 -28
- data/.travis.yml +0 -20
- data/Guardfile +0 -20
- data/TODO +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd0aa87d79ce744a9716b80c4a33767b8cbcd662
|
4
|
+
data.tar.gz: 6209862711ac0f807c9a6f20bdfdc626236a1b86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cbac595a34a132926c4c09a703ec08f57b71980e2ba711534ea188d4512703d000ebbef2d2eb743aceb2fa2d10ef2230adad17518300bb1aaba0e65d7e1361f
|
7
|
+
data.tar.gz: 2536d2b1151da2b12d2efe9dc3d45fb5de4158adfa4698d70204d343b50cac2217ad142e9d7220a43069bb912839dc080925bb9c05ea30320e8451b0b8efdaea
|
data/Changelog.md
CHANGED
data/Gemfile
CHANGED
@@ -1,11 +1,5 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
source 'https://rubygems.org'
|
3
2
|
|
4
3
|
gemspec
|
5
4
|
|
6
|
-
|
7
|
-
gem 'anima', '~> 0.2.0'
|
8
|
-
gem 'morpher', '~> 0.2.2'
|
9
|
-
|
10
|
-
gem 'devtools', git: 'https://github.com/rom-rb/devtools.git'
|
11
|
-
gem 'mutant', git: 'https://github.com/mbj/mutant.git'
|
5
|
+
gem 'mutant', git: 'https://github.com/mbj/mutant.git', branch: 'feature/parser-2-3'
|
data/README.md
CHANGED
@@ -7,10 +7,15 @@ unparser
|
|
7
7
|
[![Gem Version](https://img.shields.io/gem/v/unparser.svg)](https://rubygems.org/gems/unparser)
|
8
8
|
|
9
9
|
Generate equivalent source for ASTs from whitequarks [parser](https://github.com/whitequark/parser).
|
10
|
+
Excluding the macruby extensions the parser gem implemnents on top of ruby syntax.
|
11
|
+
|
12
|
+
Excluding the MacRuby / RubyMotion extensions the parser gem implemenents on top of MRI ruby syntax starting with parser release 2.3.
|
13
|
+
If you feel the need to get them supported, contact me.
|
10
14
|
|
11
15
|
This library is able to reproduce 100% of ruby 1.9, 2.0 and 2.1 syntax. Including its own source code.
|
12
16
|
|
13
|
-
It serves well for [mutant](https://github.com/mbj/mutant) mutators and the in-memory vendoring for self hosting
|
17
|
+
It serves well for [mutant](https://github.com/mbj/mutant) mutators and the in-memory vendoring for self hosting,
|
18
|
+
and other tooling.
|
14
19
|
|
15
20
|
Usage
|
16
21
|
-----
|
data/Rakefile
CHANGED
@@ -5,7 +5,16 @@ Rake.application.load_imports
|
|
5
5
|
task('metrics:mutant').clear
|
6
6
|
|
7
7
|
namespace :metrics do
|
8
|
-
task :
|
9
|
-
|
8
|
+
task mutant: :coverage do
|
9
|
+
system(*%w[
|
10
|
+
bundle exec mutant
|
11
|
+
--include lib
|
12
|
+
--require unparser
|
13
|
+
--use rspec
|
14
|
+
--zombie
|
15
|
+
--since HEAD~1
|
16
|
+
--
|
17
|
+
Unparser*
|
18
|
+
]) or fail "Mutant task failed"
|
10
19
|
end
|
11
20
|
end
|
data/bin/unparser
CHANGED
data/config/devtools.yml
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
---
|
2
|
-
unit_test_timeout:
|
2
|
+
unit_test_timeout: 2.0
|
data/config/flay.yml
CHANGED
data/config/flog.yml
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
---
|
2
|
-
threshold:
|
2
|
+
threshold: 21.3
|
data/config/reek.yml
CHANGED
@@ -55,7 +55,7 @@ BooleanParameter:
|
|
55
55
|
enabled: true
|
56
56
|
IrresponsibleModule:
|
57
57
|
exclude: []
|
58
|
-
enabled:
|
58
|
+
enabled: false # buggy / broken
|
59
59
|
UncommunicativeModuleName:
|
60
60
|
accept: []
|
61
61
|
exclude: []
|
@@ -90,6 +90,9 @@ UtilityFunction:
|
|
90
90
|
exclude:
|
91
91
|
# Intent to be helper methods
|
92
92
|
- Unparser::CLI::Source#strip
|
93
|
+
- Unparser::CLI::Source#parse
|
94
|
+
- Unparser::NodeHelpers#n
|
95
|
+
- Unparser::NodeHelpers#s
|
93
96
|
- Unparser::CLI#sources
|
94
97
|
enabled: true
|
95
98
|
Attribute:
|
data/config/rubocop.yml
CHANGED
@@ -72,10 +72,6 @@ ConstantName:
|
|
72
72
|
TrivialAccessors:
|
73
73
|
Enabled: false
|
74
74
|
|
75
|
-
# Do not prefer do/end over {} for multiline blocks
|
76
|
-
Blocks:
|
77
|
-
Enabled: false
|
78
|
-
|
79
75
|
# I like to have an empty line before closing the currently opened body
|
80
76
|
EmptyLinesAroundBlockBody:
|
81
77
|
Enabled: false
|
data/lib/unparser.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
require 'set'
|
4
2
|
require 'abstract_type'
|
5
3
|
require 'procto'
|
@@ -58,6 +56,7 @@ require 'unparser/emitter/send/unary'
|
|
58
56
|
require 'unparser/emitter/send/binary'
|
59
57
|
require 'unparser/emitter/send/index'
|
60
58
|
require 'unparser/emitter/send/regular'
|
59
|
+
require 'unparser/emitter/send/conditional'
|
61
60
|
require 'unparser/emitter/send/arguments'
|
62
61
|
require 'unparser/emitter/send/attribute_assignment'
|
63
62
|
require 'unparser/emitter/block'
|
data/lib/unparser/ast.rb
CHANGED
data/lib/unparser/buffer.rb
CHANGED
data/lib/unparser/cli.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
require 'unparser'
|
4
2
|
require 'optparse'
|
5
3
|
require 'diff/lcs'
|
@@ -38,7 +36,8 @@ module Unparser
|
|
38
36
|
# @api private
|
39
37
|
#
|
40
38
|
def initialize(arguments)
|
41
|
-
@sources
|
39
|
+
@sources = []
|
40
|
+
@ignore = Set.new
|
42
41
|
|
43
42
|
@success = true
|
44
43
|
@fail_fast = false
|
@@ -91,7 +90,7 @@ module Unparser
|
|
91
90
|
effective_sources.each do |source|
|
92
91
|
next if @ignore.include?(source)
|
93
92
|
process_source(source)
|
94
|
-
break
|
93
|
+
break if @fail_fast && !@success
|
95
94
|
end
|
96
95
|
|
97
96
|
@success ? EXIT_SUCCESS : EXIT_FAILURE
|
data/lib/unparser/cli/color.rb
CHANGED
data/lib/unparser/cli/differ.rb
CHANGED
data/lib/unparser/cli/source.rb
CHANGED
data/lib/unparser/comments.rb
CHANGED
data/lib/unparser/constants.rb
CHANGED
data/lib/unparser/emitter.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Unparser
|
4
2
|
|
5
3
|
# Emitter base class
|
4
|
+
#
|
5
|
+
# buggy, argument values are sends to self
|
6
|
+
# rubocop:disable CircularArgumentReference
|
6
7
|
class Emitter
|
7
8
|
include Adamantium::Flat, AbstractType, Constants, NodeHelpers
|
8
9
|
include Concord.new(:node, :parent)
|
@@ -198,7 +199,7 @@ module Unparser
|
|
198
199
|
emitter.write_to_buffer
|
199
200
|
end
|
200
201
|
|
201
|
-
# Visit
|
202
|
+
# Visit ambiguous node
|
202
203
|
#
|
203
204
|
# @param [Parser::AST::Node] node
|
204
205
|
#
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Unparser
|
4
2
|
class Emitter
|
5
3
|
|
@@ -38,7 +36,7 @@ module Unparser
|
|
38
36
|
children.empty?
|
39
37
|
end
|
40
38
|
|
41
|
-
TERMINATING_PARENT =
|
39
|
+
TERMINATING_PARENT = %i(root interpolated dyn_str_body).to_set.freeze
|
42
40
|
|
43
41
|
private
|
44
42
|
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Unparser
|
4
2
|
class Emitter
|
5
3
|
# Emitter for class nodes
|
@@ -41,7 +39,7 @@ module Unparser
|
|
41
39
|
end # Class
|
42
40
|
|
43
41
|
# Emitter for sclass nodes
|
44
|
-
class SClass
|
42
|
+
class SClass < self
|
45
43
|
include Terminated
|
46
44
|
|
47
45
|
handle :sclass
|
data/lib/unparser/emitter/def.rb
CHANGED
data/lib/unparser/emitter/for.rb
CHANGED
data/lib/unparser/emitter/if.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Unparser
|
4
2
|
class Emitter
|
5
3
|
class Literal
|
@@ -17,21 +15,7 @@ module Unparser
|
|
17
15
|
#
|
18
16
|
def dispatch
|
19
17
|
util = self.class
|
20
|
-
|
21
|
-
visit_parentheses(dynamic_body, util::OPEN, util::CLOSE)
|
22
|
-
else
|
23
|
-
emit_non_interpolated
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
# Test for interpolation
|
28
|
-
#
|
29
|
-
# @return [Boolean]
|
30
|
-
#
|
31
|
-
# @api private
|
32
|
-
#
|
33
|
-
def interpolation?
|
34
|
-
children.any? { |child| !child.type.equal?(:str) }
|
18
|
+
visit_parentheses(dynamic_body, util::OPEN, util::CLOSE)
|
35
19
|
end
|
36
20
|
|
37
21
|
# Return dynamic body
|
@@ -50,18 +34,6 @@ module Unparser
|
|
50
34
|
OPEN = CLOSE = '"'.freeze
|
51
35
|
handle :dstr
|
52
36
|
|
53
|
-
private
|
54
|
-
|
55
|
-
# Emit non interpolated form
|
56
|
-
#
|
57
|
-
# @return [undefined]
|
58
|
-
#
|
59
|
-
# @api private
|
60
|
-
#
|
61
|
-
def emit_non_interpolated
|
62
|
-
delimited(children, WS)
|
63
|
-
end
|
64
|
-
|
65
37
|
end # String
|
66
38
|
|
67
39
|
# Dynamic symbol literal emitter
|
@@ -72,21 +44,8 @@ module Unparser
|
|
72
44
|
|
73
45
|
handle :dsym
|
74
46
|
|
75
|
-
private
|
76
|
-
|
77
|
-
# Emit non interpolated form
|
78
|
-
#
|
79
|
-
# @return [undefined]
|
80
|
-
#
|
81
|
-
# @api private
|
82
|
-
#
|
83
|
-
def emit_non_interpolated
|
84
|
-
visit_parentheses(dynamic_body, OPEN, CLOSE)
|
85
|
-
end
|
86
|
-
|
87
47
|
end # Symbol
|
88
|
-
|
89
|
-
end
|
48
|
+
end # Dynamic
|
90
49
|
end # Literal
|
91
50
|
end # Emitter
|
92
51
|
end # Unparser
|