dslh 0.2.3 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f54e329df51e56943cdc60617113f7ef8a8ea225
4
- data.tar.gz: 913c752ede8898f9a1b0af78f7e76046fabfa17f
3
+ metadata.gz: bce00164dbac9519528c2fe51039b347f62cddce
4
+ data.tar.gz: d6623f383890d4e1942901e146dbf75de5ad26b2
5
5
  SHA512:
6
- metadata.gz: 431c84f8b8fc1c5508e0c98bbe6482d8148c803f35f0de60e257f2d4e4c09dc1ed0124794d46576954e5968134d921a672a4bfb4eebb71b567368ba012cfac6a
7
- data.tar.gz: e9cb7c46c181de6934a4fd717fdff6d24986221f7ea18d39d5e6c0df4b7a70307ef4d958795b7a0932fc62aadcf84160264e853becb26dcc2881a8a385d5263f
6
+ metadata.gz: a3589a330df396ef06d25a1dd50934ec30372b9f6f694b1e372ada3f528a6fdbb247eba1fcd0128766e4d93c3d1401cd0960d6f43bbcdc4949efce8a87c3425a
7
+ data.tar.gz: 8549ccdfb535a1065eaff69f155eae51f37577dd6a703ae687800db5f586a8198b636c0de94b2813c24bbe8389a266b89929d6aa7071b1b553c8ed74e24ce01e
data/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  It define Hash as a DSL.
4
4
 
5
- [![Gem Version](https://badge.fury.io/rb/dslh.png?201403041920)](http://badge.fury.io/rb/dslh)
6
- [![Build Status](https://drone.io/github.com/winebarrel/dslh/status.png?201403041920)](https://drone.io/github.com/winebarrel/dslh/latest)
5
+ [![Gem Version](https://badge.fury.io/rb/dslh.png?201403062101)](http://badge.fury.io/rb/dslh)
6
+ [![Build Status](https://drone.io/github.com/winebarrel/dslh/status.png?201403062101)](https://drone.io/github.com/winebarrel/dslh/latest)
7
7
 
8
8
  ## Installation
9
9
 
data/lib/dslh.rb CHANGED
@@ -182,8 +182,16 @@ class Dslh
182
182
  end
183
183
 
184
184
  class Scope
185
- def _(&block)
186
- ScopeBlock.nest(binding, 'block')
185
+ def _(key = nil, &block)
186
+ nested_hash = ScopeBlock.nest(binding, 'block')
187
+
188
+ if key
189
+ key_conv = @__options__[:key_conv]
190
+ key = key_conv.call(key) if key_conv
191
+ @__hash__[key] = nested_hash
192
+ else
193
+ return nested_hash
194
+ end
187
195
  end
188
196
 
189
197
  def method_missing(method_name, *args, &block)
data/lib/dslh/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Dslh
2
- VERSION = '0.2.3'
2
+ VERSION = '0.2.4'
3
3
  end
data/spec/dslh_spec.rb CHANGED
@@ -55,6 +55,37 @@ describe Dslh do
55
55
  )
56
56
  end
57
57
 
58
+ it 'should be nested hash with _()' do
59
+ h = Dslh.eval do
60
+ key1 'value'
61
+ key2 100
62
+
63
+ _(:key3) do
64
+ _(:key31) do
65
+ key311 100
66
+ key312 '200'
67
+ end
68
+
69
+ _('key32') do
70
+ key321 do
71
+ key3211 'XXX'
72
+ key3212 :XXX
73
+ end
74
+ key322 300
75
+ end
76
+ end
77
+ end
78
+
79
+ expect(h).to eq(
80
+ {:key1=>"value",
81
+ :key2=>100,
82
+ :key3=>
83
+ {:key31=>{:key311=>100, :key312=>"200"},
84
+ 'key32'=>
85
+ {:key321=>{:key3211=>"XXX", :key3212=>:XXX}, :key322=>300}}}
86
+ )
87
+ end
88
+
58
89
  it 'should be nested hash with block args' do
59
90
  h = Dslh.eval do
60
91
  key1 'value'
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.2.3
4
+ version: 0.2.4
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-03-04 00:00:00.000000000 Z
11
+ date: 2014-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler