hydrochlorb 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/lib/hydrochlorb/builder.rb +8 -1
- data/lib/hydrochlorb/version.rb +1 -1
- data/spec/hydrochlorb_spec.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc11b7344bae61a9fee4c68f790c72dc2b8d8093772ede2cb7688e881c7dc5a2
|
4
|
+
data.tar.gz: dd32838c65549e87f5ab54731c7e23ba0c435af8aabd6da43207b3d912d0a51a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b506bd97ef9c5587db39bf4632ea97a56eebb7f668600198e7d1cc0ec093c4147625672249b7ecf49de4a461241036c11b2f6d51efd8aeaae60300cad191741
|
7
|
+
data.tar.gz: 5a99632255d034f3b6291a38b72b4891dbb31bd1e165006c28bd96af80dcba9a121b8f540ce527954349b9106e35ceaf6fa941f1dff54df8d335a5235409e971
|
data/lib/hydrochlorb/builder.rb
CHANGED
@@ -4,6 +4,7 @@ class Hydrochlorb::Builder
|
|
4
4
|
def initialize(options = {}, &block)
|
5
5
|
@attributes = {}
|
6
6
|
@current = @attributes
|
7
|
+
@context = nil
|
7
8
|
|
8
9
|
build(&block) if block_given?
|
9
10
|
end
|
@@ -11,13 +12,19 @@ class Hydrochlorb::Builder
|
|
11
12
|
def build(&block)
|
12
13
|
return unless block_given?
|
13
14
|
|
15
|
+
@context = eval('self', block.binding)
|
16
|
+
|
14
17
|
instance_eval(&block)
|
15
18
|
|
16
19
|
self
|
17
20
|
end
|
18
21
|
|
19
22
|
def method_missing(method, *args, &block)
|
20
|
-
|
23
|
+
if @context and @context.respond_to?(method)
|
24
|
+
@context.send(method, *args, &block)
|
25
|
+
else
|
26
|
+
add(method, *args, &block)
|
27
|
+
end
|
21
28
|
end
|
22
29
|
|
23
30
|
def add(*args, &block)
|
data/lib/hydrochlorb/version.rb
CHANGED
data/spec/hydrochlorb_spec.rb
CHANGED
@@ -180,4 +180,18 @@ describe Hydrochlorb do
|
|
180
180
|
}
|
181
181
|
EOF
|
182
182
|
end
|
183
|
+
|
184
|
+
it 'can handle method in different context' do
|
185
|
+
def bar
|
186
|
+
'barbar'
|
187
|
+
end
|
188
|
+
|
189
|
+
hcl = Hydrochlorb.build do
|
190
|
+
foo bar
|
191
|
+
end.to_hcl
|
192
|
+
|
193
|
+
expect(hcl).to eq <<~EOF.chomp
|
194
|
+
foo = "barbar"
|
195
|
+
EOF
|
196
|
+
end
|
183
197
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hydrochlorb
|
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
|
- Rianol Jou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|