unparser 0.0.3 → 0.0.4
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.
- checksums.yaml +4 -4
- data/README.md +0 -2
- data/config/flay.yml +2 -2
- data/lib/unparser/emitter/begin.rb +5 -7
- data/lib/unparser/emitter/repetition.rb +37 -0
- data/spec/integration/unparser/spike_spec.rb +15 -0
- data/unparser.gemspec +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 699cb6f7b7346130d08e26971bb7415989814195
|
4
|
+
data.tar.gz: 67f7d1d663508c344d141a74dfebf0a375457f49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93fc7a2d83ccb9a72d3b9eca238f70d6d87c1f6c7cd919faf2f0f418cf2ae82faf00c4dd912100748c78f66dbcf82b124e9cdb7e2ba7e08135dee82024d46ee8
|
7
|
+
data.tar.gz: a15743cd3c9596c3fcf9ab6d1813964a97287a3c6fb9b7ccb666d53c70185234799aed1585fcf85fb901a11d2462bf35c949bc95981816c0d4c5782c17e62831
|
data/README.md
CHANGED
data/config/flay.yml
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
---
|
2
|
-
threshold:
|
3
|
-
total_score:
|
2
|
+
threshold: 13
|
3
|
+
total_score: 353
|
@@ -122,7 +122,7 @@ module Unparser
|
|
122
122
|
# Emitter for begin nodes
|
123
123
|
class Begin < self
|
124
124
|
|
125
|
-
handle :begin
|
125
|
+
handle :begin, :kwbegin
|
126
126
|
|
127
127
|
private
|
128
128
|
|
@@ -133,9 +133,7 @@ module Unparser
|
|
133
133
|
# @api private
|
134
134
|
#
|
135
135
|
def dispatch
|
136
|
-
|
137
|
-
when 0
|
138
|
-
when 1
|
136
|
+
if children.length == 1 and !parent.needs_begin?
|
139
137
|
visit(first_child)
|
140
138
|
else
|
141
139
|
emit_normal
|
@@ -149,12 +147,12 @@ module Unparser
|
|
149
147
|
# @api private
|
150
148
|
#
|
151
149
|
def emit_normal
|
152
|
-
|
153
|
-
emit_inner
|
154
|
-
else
|
150
|
+
if parent.needs_begin?
|
155
151
|
k_begin
|
156
152
|
indented { emit_inner }
|
157
153
|
k_end
|
154
|
+
else
|
155
|
+
emit_inner
|
158
156
|
end
|
159
157
|
end
|
160
158
|
|
@@ -1,6 +1,43 @@
|
|
1
1
|
module Unparser
|
2
2
|
class Emitter
|
3
3
|
|
4
|
+
# Emitter for postconditions
|
5
|
+
class Post < self
|
6
|
+
|
7
|
+
handle :while_post, :until_post
|
8
|
+
|
9
|
+
children :condition, :body
|
10
|
+
|
11
|
+
MAP = {
|
12
|
+
:while_post => K_WHILE,
|
13
|
+
:until_until => K_UNTIL
|
14
|
+
}.freeze
|
15
|
+
|
16
|
+
handle *MAP.keys
|
17
|
+
|
18
|
+
# Test if child should be emitted with explicit begin nodes
|
19
|
+
#
|
20
|
+
# @return [true]
|
21
|
+
#
|
22
|
+
# @api private
|
23
|
+
#
|
24
|
+
def needs_begin?
|
25
|
+
true
|
26
|
+
end
|
27
|
+
|
28
|
+
# Perform dispatch
|
29
|
+
#
|
30
|
+
# @return [undefined]
|
31
|
+
#
|
32
|
+
# @api private
|
33
|
+
#
|
34
|
+
def dispatch
|
35
|
+
visit(body)
|
36
|
+
write(WS, MAP.fetch(node.type), WS)
|
37
|
+
visit(condition)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
4
41
|
# Base class for while and until emitters
|
5
42
|
class Repetition < self
|
6
43
|
|
@@ -956,6 +956,21 @@ describe Unparser, 'spike' do
|
|
956
956
|
RUBY
|
957
957
|
end
|
958
958
|
|
959
|
+
context 'post conditions' do
|
960
|
+
assert_source <<-RUBY
|
961
|
+
begin
|
962
|
+
foo
|
963
|
+
end while baz
|
964
|
+
RUBY
|
965
|
+
|
966
|
+
assert_source <<-RUBY
|
967
|
+
begin
|
968
|
+
foo
|
969
|
+
bar
|
970
|
+
end while baz
|
971
|
+
RUBY
|
972
|
+
end
|
973
|
+
|
959
974
|
context 'while' do
|
960
975
|
assert_source <<-RUBY
|
961
976
|
while false
|
data/unparser.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'unparser'
|
5
|
-
s.version = '0.0.
|
5
|
+
s.version = '0.0.4'
|
6
6
|
|
7
7
|
s.authors = ['Markus Schirp']
|
8
8
|
s.email = 'mbj@schir-dso.com'
|
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.require_paths = %w(lib)
|
17
17
|
s.extra_rdoc_files = %w(README.md)
|
18
18
|
|
19
|
-
s.add_dependency('parser', '~> 2.0.0.
|
19
|
+
s.add_dependency('parser', '~> 2.0.0.beta7')
|
20
20
|
s.add_dependency('concord', '~> 0.1.0')
|
21
21
|
s.add_dependency('adamantium', '~> 0.0.7')
|
22
22
|
s.add_dependency('equalizer', '~> 0.0.5')
|
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.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Markus Schirp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.0.0.
|
19
|
+
version: 2.0.0.beta7
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.0.0.
|
26
|
+
version: 2.0.0.beta7
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: concord
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|