rhcl 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rhcl/parse.tab.rb +7 -3
- data/lib/rhcl/parse.y +6 -2
- data/lib/rhcl/version.rb +1 -1
- data/spec/rhcl_parse_spec.rb +20 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b695aaa4c97d9c10ca368decfca0dddc645cc25
|
4
|
+
data.tar.gz: 02656190023a22d863ff3b6fb55b17a487df3fe5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b033fbea3f185bb4e21802b28a7550374be604c18310de14e8f650526f415efe5253511cf36972a301b45b8e4f10ff5f35d60c14eb476eac35f4c881bfdbb27
|
7
|
+
data.tar.gz: ee88148096a6631951ef4a547c31e1fdf18536c755842fb51c0186a017335300a56f6b8afba2c8ca8883edd4945c920f1706bec29a969c28fb6f135b9c089fb4
|
data/lib/rhcl/parse.tab.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# DO NOT MODIFY!!!!
|
3
|
-
# This file is automatically generated by Racc 1.4.
|
3
|
+
# This file is automatically generated by Racc 1.4.12
|
4
4
|
# from Racc grammer file "".
|
5
5
|
#
|
6
6
|
|
@@ -14,6 +14,10 @@ module Rhcl
|
|
14
14
|
|
15
15
|
module_eval(<<'...end parse.y/module_eval...', 'parse.y', 107)
|
16
16
|
|
17
|
+
TRUE_VALUES = %w(true on yes)
|
18
|
+
FALSE_VALUES = %w(false off no )
|
19
|
+
BOOLEAN_VALUES = TRUE_VALUES + FALSE_VALUES
|
20
|
+
|
17
21
|
def initialize(obj)
|
18
22
|
src = obj.is_a?(IO) ? obj.read : obj.to_s
|
19
23
|
@ss = StringScanner.new(src)
|
@@ -70,8 +74,8 @@ def scan
|
|
70
74
|
identifier = (backup { @ss.scan_until /(\s|\z)/ } || '').sub(/\s\z/, '')
|
71
75
|
token_type = :IDENTIFIER
|
72
76
|
|
73
|
-
if
|
74
|
-
identifier =
|
77
|
+
if BOOLEAN_VALUES.include?(identifier)
|
78
|
+
identifier = TRUE_VALUES.include?(identifier)
|
75
79
|
token_type = :BOOL
|
76
80
|
end
|
77
81
|
|
data/lib/rhcl/parse.y
CHANGED
@@ -105,6 +105,10 @@ require 'strscan'
|
|
105
105
|
|
106
106
|
---- inner
|
107
107
|
|
108
|
+
TRUE_VALUES = %w(true on yes)
|
109
|
+
FALSE_VALUES = %w(false off no )
|
110
|
+
BOOLEAN_VALUES = TRUE_VALUES + FALSE_VALUES
|
111
|
+
|
108
112
|
def initialize(obj)
|
109
113
|
src = obj.is_a?(IO) ? obj.read : obj.to_s
|
110
114
|
@ss = StringScanner.new(src)
|
@@ -161,8 +165,8 @@ def scan
|
|
161
165
|
identifier = (backup { @ss.scan_until /(\s|\z)/ } || '').sub(/\s\z/, '')
|
162
166
|
token_type = :IDENTIFIER
|
163
167
|
|
164
|
-
if
|
165
|
-
identifier =
|
168
|
+
if BOOLEAN_VALUES.include?(identifier)
|
169
|
+
identifier = TRUE_VALUES.include?(identifier)
|
166
170
|
token_type = :BOOL
|
167
171
|
end
|
168
172
|
|
data/lib/rhcl/version.rb
CHANGED
data/spec/rhcl_parse_spec.rb
CHANGED
@@ -323,4 +323,24 @@ output "web_ip" {
|
|
323
323
|
"output"=>{"web_ip"=>{"value"=>"${aws_instance.web.private_ip}"}}}
|
324
324
|
)
|
325
325
|
end
|
326
|
+
|
327
|
+
it 'bool types' do
|
328
|
+
parsed = Rhcl.parse(<<-EOS)
|
329
|
+
foo = true
|
330
|
+
bar = false
|
331
|
+
zoo = on
|
332
|
+
foo2 = off
|
333
|
+
bar2 = yes
|
334
|
+
zoo2 = no
|
335
|
+
EOS
|
336
|
+
|
337
|
+
expect(parsed).to eq(
|
338
|
+
{"foo"=>true,
|
339
|
+
"bar"=>false,
|
340
|
+
"zoo"=>true,
|
341
|
+
"foo2"=>false,
|
342
|
+
"bar2"=>true,
|
343
|
+
"zoo2"=>false}
|
344
|
+
)
|
345
|
+
end
|
326
346
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rhcl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genki Sugawara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deep_merge
|
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
123
|
version: '0'
|
124
124
|
requirements: []
|
125
125
|
rubyforge_project:
|
126
|
-
rubygems_version: 2.
|
126
|
+
rubygems_version: 2.0.14
|
127
127
|
signing_key:
|
128
128
|
specification_version: 4
|
129
129
|
summary: Pure Ruby HCL parser
|