dslh 0.3.8 → 0.3.9
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/dslh.rb +4 -0
- data/lib/dslh/version.rb +1 -1
- data/spec/dslh_spec.rb +22 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bea460ff3013100d73e63f5ad28d76314ff27922
|
4
|
+
data.tar.gz: d786b97c2645b741c5dbd301f3a9826f663931a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44c114e62597267087a86d9676cea3df76ae42a5533d98d8eb45692469ae9d3da2a48dbf6aec8bff32e990927effda441bfd8e9a2cd3790a4f6238c8c10a566d
|
7
|
+
data.tar.gz: 249d851a76f7026e6c334583fa78f71e0aff4629bba2e049aee8ea2bbed83372864ac56008864a49bbbde4de0c977d3032c18a3cfc552f136e905ebee7f161f3
|
data/lib/dslh.rb
CHANGED
@@ -56,6 +56,10 @@ class Dslh
|
|
56
56
|
scope.instance_variable_set(:@__hash__, retval)
|
57
57
|
@options[:scope_hook].call(scope) if @options[:scope_hook]
|
58
58
|
|
59
|
+
(@options[:scope_vars] || {}).each do |name, value|
|
60
|
+
scope.instance_variable_set("@#{name}", value)
|
61
|
+
end
|
62
|
+
|
59
63
|
if @options[:ignore_methods]
|
60
64
|
ignore_methods = Array(@options[:ignore_methods])
|
61
65
|
|
data/lib/dslh/version.rb
CHANGED
data/spec/dslh_spec.rb
CHANGED
@@ -394,6 +394,28 @@ describe Dslh do
|
|
394
394
|
expect(h).to eq({"key1"=>123, "key2"=>{"key21"=>123, "key22"=>{"key221"=>123}}})
|
395
395
|
end
|
396
396
|
|
397
|
+
it 'should hook vars' do
|
398
|
+
scope_hook = proc do |scope|
|
399
|
+
scope.instance_eval(<<-EOS)
|
400
|
+
def func
|
401
|
+
@var
|
402
|
+
end
|
403
|
+
EOS
|
404
|
+
end
|
405
|
+
|
406
|
+
h = Dslh.eval :scope_hook => scope_hook, :scope_vars => {:var => 999} do
|
407
|
+
key1 func
|
408
|
+
key2 do
|
409
|
+
key21 func
|
410
|
+
key22 do
|
411
|
+
key221 func
|
412
|
+
end
|
413
|
+
end
|
414
|
+
end
|
415
|
+
|
416
|
+
expect(h).to eq({"key1"=>999, "key2"=>{"key21"=>999, "key22"=>{"key221"=>999}}})
|
417
|
+
end
|
418
|
+
|
397
419
|
it 'should convert hash to dsl' do
|
398
420
|
h = {"glossary"=>
|
399
421
|
{"title"=>"example glossary",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dslh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genki Sugawara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|