dslh 0.3.8 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7267513e3fe1badab65d769c081bb53f2404de4d
4
- data.tar.gz: 63b83baed10b9303f5078ab2d6b63231d85dc602
3
+ metadata.gz: bea460ff3013100d73e63f5ad28d76314ff27922
4
+ data.tar.gz: d786b97c2645b741c5dbd301f3a9826f663931a0
5
5
  SHA512:
6
- metadata.gz: 47010ec35a9c6c7e963569a3ecd6605d44c803efcd0911a65a142fe4d58d33c10a308972830d840498d919fcfd6289e1dc375361f63b3060d0fb02518ed4bfc7
7
- data.tar.gz: c7dd1ad51654a185a51b2722e583ca261866d95c22d5a5048ebc16f7c8953275ade78eca8384e7f0c9ced5d27ce2bff7f57386b46abaa72a5338ed7b0c5e6539
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
@@ -1,3 +1,3 @@
1
1
  class Dslh
2
- VERSION = '0.3.8'
2
+ VERSION = '0.3.9'
3
3
  end
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.8
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-05-27 00:00:00.000000000 Z
11
+ date: 2016-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler