unparser 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -3
- data/Changelog.md +4 -0
- data/Gemfile +0 -1
- data/README.md +32 -0
- data/circle.yml +1 -1
- data/lib/unparser.rb +1 -1
- data/lib/unparser/emitter/literal/dynamic_body.rb +3 -3
- data/spec/unit/unparser_spec.rb +3 -2
- data/unparser.gemspec +2 -2
- metadata +10 -5
- data/Gemfile.devtools +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72b3825e97d60720db496c242e5357cfb754ce0e
|
4
|
+
data.tar.gz: e0323d215ba4c0acf5652ca4c0403ef2442f27ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f2fa16b0648154c56234c76ceaaabdcd4ca1e5d41d0472cc498a4539245e1a05da12d85629cfa42e8aa4bcd3f7f9ceb1fcaa23796edb0b0b359138a468d30df
|
7
|
+
data.tar.gz: 2861a96bb2e77e0d5f3c7eecdfbcf4a314680e1ddfa4bff2ce7e3c7ffde05ec6d0b691044206200dc22f39ea6c61e699ff8e3f0a34b0325826029bb986757d69
|
data/.travis.yml
CHANGED
data/Changelog.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -29,6 +29,38 @@ ast, comments = Parser::CurrentRuby.parse_with_comments(your_source)
|
|
29
29
|
Unparser.unparse(ast, comments) # => "the code # with comments"
|
30
30
|
```
|
31
31
|
|
32
|
+
Passing in manually constructed AST:
|
33
|
+
```ruby
|
34
|
+
require 'parser/current'
|
35
|
+
require 'unparser'
|
36
|
+
|
37
|
+
module YourHelper
|
38
|
+
def s(type, *children)
|
39
|
+
Parser::AST::Node.new(type, children)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
include YourHelper
|
44
|
+
|
45
|
+
node = s(:def,
|
46
|
+
:foo,
|
47
|
+
s(:args,
|
48
|
+
s(:arg, :x)
|
49
|
+
),
|
50
|
+
s(:send,
|
51
|
+
s(:lvar, :x),
|
52
|
+
:+,
|
53
|
+
s(:int, 3)
|
54
|
+
)
|
55
|
+
)
|
56
|
+
|
57
|
+
Unparser.unparse(node) # => "def foo(x)\n x + 3\nend"
|
58
|
+
```
|
59
|
+
|
60
|
+
Note: DO NOT attempt to pass in nodes generated via `AST::Sexp#s`, these ones return
|
61
|
+
API incompatible `AST::Node` instances, unparser needs `Parser::AST::Node` instances.
|
62
|
+
|
63
|
+
|
32
64
|
Equivalent vs identical:
|
33
65
|
|
34
66
|
```ruby
|
data/circle.yml
CHANGED
data/lib/unparser.rb
CHANGED
@@ -47,7 +47,7 @@ module Unparser
|
|
47
47
|
|
48
48
|
# Emit segment
|
49
49
|
#
|
50
|
-
# @param [Parser::Node] node
|
50
|
+
# @param [Parser::AST::Node] node
|
51
51
|
#
|
52
52
|
# @return [undefined]
|
53
53
|
#
|
@@ -73,7 +73,7 @@ module Unparser
|
|
73
73
|
|
74
74
|
# Emit str segment
|
75
75
|
#
|
76
|
-
# @param [Parser::Node] node
|
76
|
+
# @param [Parser::AST::Node] node
|
77
77
|
#
|
78
78
|
# @return [undefined]
|
79
79
|
#
|
@@ -90,7 +90,7 @@ module Unparser
|
|
90
90
|
|
91
91
|
# Emit interpolated segment
|
92
92
|
#
|
93
|
-
# @param [Parser::Node] node
|
93
|
+
# @param [Parser::AST::Node] node
|
94
94
|
#
|
95
95
|
# @return [undefined]
|
96
96
|
#
|
data/spec/unit/unparser_spec.rb
CHANGED
@@ -189,7 +189,8 @@ describe Unparser do
|
|
189
189
|
|
190
190
|
context 'regexp' do
|
191
191
|
assert_terminated '/foo/'
|
192
|
-
assert_terminated %q(/[
|
192
|
+
assert_terminated %q(/[\x80-\xff]+/), %w(1.9)
|
193
|
+
assert_terminated %q(/[^-+',.\/:@[:alnum:]\[\]]+/)
|
193
194
|
assert_terminated '/foo#{@bar}/'
|
194
195
|
assert_terminated '/foo#{@bar}/imx'
|
195
196
|
assert_terminated '/#{"\x00"}/', %w(1.9)
|
@@ -205,7 +206,7 @@ describe Unparser do
|
|
205
206
|
end
|
206
207
|
RUBY
|
207
208
|
assert_generates '%r(/)', '/\//'
|
208
|
-
assert_generates '%r(\))', '
|
209
|
+
assert_generates '%r(\))', '/\)/'
|
209
210
|
assert_generates '%r(#{@bar}baz)', '/#{@bar}baz/'
|
210
211
|
assert_terminated '/\/\//x'
|
211
212
|
end
|
data/unparser.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
4
|
gem.name = 'unparser'
|
5
|
-
gem.version = '0.2.
|
5
|
+
gem.version = '0.2.3'
|
6
6
|
|
7
7
|
gem.authors = ['Markus Schirp']
|
8
8
|
gem.email = 'mbj@schir-dso.com'
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
|
|
19
19
|
|
20
20
|
gem.required_ruby_version = '>= 1.9.3'
|
21
21
|
|
22
|
-
gem.add_dependency('parser', '~> 2.2.
|
22
|
+
gem.add_dependency('parser', '~> 2.2.2', '>= 2.2.2.2')
|
23
23
|
gem.add_dependency('procto', '~> 0.0.2')
|
24
24
|
gem.add_dependency('concord', '~> 0.1.5')
|
25
25
|
gem.add_dependency('adamantium', '~> 0.2.0')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unparser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Markus Schirp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -16,14 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.2.
|
19
|
+
version: 2.2.2
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.2.2.2
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - "~>"
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.2.
|
29
|
+
version: 2.2.2
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.2.2.2
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: procto
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,7 +128,6 @@ files:
|
|
122
128
|
- ".travis.yml"
|
123
129
|
- Changelog.md
|
124
130
|
- Gemfile
|
125
|
-
- Gemfile.devtools
|
126
131
|
- Guardfile
|
127
132
|
- LICENSE
|
128
133
|
- README.md
|
data/Gemfile.devtools
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
group :development do
|
2
|
-
platform :rbx do
|
3
|
-
gem 'rubysl-singleton', '~> 2.0.0'
|
4
|
-
end
|
5
|
-
end
|
6
|
-
|
7
|
-
group :guard do
|
8
|
-
gem 'guard', '~> 2.10.3'
|
9
|
-
gem 'guard-bundler', '~> 2.1.0'
|
10
|
-
gem 'guard-rspec', '~> 4.5.0'
|
11
|
-
gem 'guard-rubocop', '~> 1.2.0'
|
12
|
-
|
13
|
-
# file system change event handling
|
14
|
-
gem 'listen', '~> 2.8.4'
|
15
|
-
gem 'rb-fchange', '~> 0.0.6', require: false
|
16
|
-
gem 'rb-fsevent', '~> 0.9.4', require: false
|
17
|
-
gem 'rb-inotify', '~> 0.9.5', require: false
|
18
|
-
|
19
|
-
# notification handling
|
20
|
-
gem 'libnotify', '~> 0.9.0', require: false
|
21
|
-
gem 'rb-notifu', '~> 0.0.4', require: false
|
22
|
-
gem 'terminal-notifier-guard', '~> 1.6.4', require: false
|
23
|
-
end
|
24
|
-
|
25
|
-
group :metrics do
|
26
|
-
platform :rbx do
|
27
|
-
gem 'json', '~> 1.8.1'
|
28
|
-
gem 'racc', '~> 1.4.12'
|
29
|
-
gem 'rubysl-logger', '~> 2.1.0'
|
30
|
-
gem 'rubysl-open-uri', '~> 2.0.0'
|
31
|
-
gem 'rubysl-prettyprint', '~> 2.0.3'
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
platform :jruby do
|
36
|
-
group :jruby do
|
37
|
-
gem 'jruby-openssl', '~> 0.9.4'
|
38
|
-
end
|
39
|
-
end
|