dslh 0.1.9 → 0.2.0
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/README.md +1 -1
- data/dslh.gemspec +1 -1
- data/lib/dslh.rb +14 -11
- data/lib/dslh/version.rb +1 -1
- 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: bf9e9e4937fa96b3e6896e280e24d44b63622287
|
|
4
|
+
data.tar.gz: ac2fe663b7d7c66d0a7530d6a77f57019586a525
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a58ffa0d678c4831fd55c47c27a24dea2b8f28e59aa2b5cb0a0653fe7f7ed1c76b26065f418024dc676e59ef8f3d7a6a3e2e07836b4d2a3514a9e8b5ba07422f
|
|
7
|
+
data.tar.gz: 29ab30743682fd4820dc144e5e7b7629dcd2a7bf3586f0b785302b6f8c927933a2b6830cbacb2413fc4f2df78748781d680f438201f38e2f7acd2dbe258b441b
|
data/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
It define Hash as a DSL.
|
|
4
4
|
|
|
5
5
|
[](http://badge.fury.io/rb/dslh)
|
|
6
|
-
[](https://drone.io/github.com/winebarrel/dslh/latest)
|
|
7
7
|
|
|
8
8
|
## Installation
|
|
9
9
|
|
data/dslh.gemspec
CHANGED
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
|
10
10
|
spec.email = ['sugawara@cookpad.com']
|
|
11
11
|
spec.summary = %q{It define Hash as a DSL.}
|
|
12
12
|
spec.description = %q{It define Hash as a DSL.}
|
|
13
|
-
spec.homepage = 'https://
|
|
13
|
+
spec.homepage = 'https://github.com/winebarrel/dslh'
|
|
14
14
|
spec.license = 'MIT'
|
|
15
15
|
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
data/lib/dslh.rb
CHANGED
|
@@ -39,6 +39,8 @@ class Dslh
|
|
|
39
39
|
|
|
40
40
|
def initialize(options = {})
|
|
41
41
|
@options = options.dup
|
|
42
|
+
@options[:key_conv] ||= @options[:conv]
|
|
43
|
+
@options[:value_conv] ||= @options[:conv]
|
|
42
44
|
end
|
|
43
45
|
|
|
44
46
|
def eval(expr = nil, &block)
|
|
@@ -74,11 +76,11 @@ class Dslh
|
|
|
74
76
|
def deval0(hash, depth, buf)
|
|
75
77
|
indent = (INDENT_SPACES * depth)
|
|
76
78
|
next_indent = (INDENT_SPACES * (depth + 1))
|
|
77
|
-
key_conv = @options[:key_conv]
|
|
78
|
-
value_conv = @options[:value_conv]
|
|
79
|
+
key_conv = @options[:key_conv]
|
|
80
|
+
value_conv = @options[:value_conv]
|
|
79
81
|
nested = false
|
|
80
82
|
|
|
81
|
-
if exclude_key?(
|
|
83
|
+
if exclude_key?(hash.keys)
|
|
82
84
|
buf.puts('(' + ("\n" + hash.pretty_inspect.strip).gsub("\n", "\n" + indent) + ')')
|
|
83
85
|
return
|
|
84
86
|
end
|
|
@@ -87,7 +89,7 @@ class Dslh
|
|
|
87
89
|
value_proc = proc do |value_buf|
|
|
88
90
|
case value
|
|
89
91
|
when Hash
|
|
90
|
-
if exclude_key?(
|
|
92
|
+
if exclude_key?(value.keys)
|
|
91
93
|
value_buf.puts('(' + ("\n" + value.pretty_inspect.strip).gsub("\n", "\n" + next_indent) + ')')
|
|
92
94
|
else
|
|
93
95
|
nested = true
|
|
@@ -155,12 +157,13 @@ class Dslh
|
|
|
155
157
|
end
|
|
156
158
|
end
|
|
157
159
|
|
|
158
|
-
def exclude_key?(
|
|
159
|
-
|
|
160
|
+
def exclude_key?(keys)
|
|
161
|
+
key_conv = @options[:key_conv]
|
|
160
162
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
163
|
+
exclude_key = @options[:exclude_key] || proc {|k|
|
|
164
|
+
k = key_conv.call(k) if key_conv
|
|
165
|
+
k.to_s !~ /\A[_a-z]\w+\Z/i
|
|
166
|
+
}
|
|
164
167
|
|
|
165
168
|
keys.any? {|k| exclude_key.call(k) }
|
|
166
169
|
end
|
|
@@ -171,8 +174,8 @@ class Dslh
|
|
|
171
174
|
end
|
|
172
175
|
|
|
173
176
|
def method_missing(method_name, *args, &block)
|
|
174
|
-
key_conv = @__options__[:key_conv]
|
|
175
|
-
value_conv = @__options__[:value_conv]
|
|
177
|
+
key_conv = @__options__[:key_conv]
|
|
178
|
+
value_conv = @__options__[:value_conv]
|
|
176
179
|
nested_hash = ScopeBlock.nest(binding, 'block')
|
|
177
180
|
method_name = key_conv.call(method_name) if key_conv
|
|
178
181
|
|
data/lib/dslh/version.rb
CHANGED
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.
|
|
4
|
+
version: 0.2.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-02
|
|
11
|
+
date: 2014-03-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -71,7 +71,7 @@ files:
|
|
|
71
71
|
- spec/Drupal_Multi_AZ.template
|
|
72
72
|
- spec/dslh_spec.rb
|
|
73
73
|
- spec/spec_helper.rb
|
|
74
|
-
homepage: https://
|
|
74
|
+
homepage: https://github.com/winebarrel/dslh
|
|
75
75
|
licenses:
|
|
76
76
|
- MIT
|
|
77
77
|
metadata: {}
|