trees 0.3.4 → 0.3.5
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/line.rb +1 -1
- data/lib/trees.rb +16 -13
- data/lib/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6ed26c969afc761461ea690075a2c838156cb3309fef5fbac31f219b716c71a8
|
|
4
|
+
data.tar.gz: 47fed5e9edb8a0b5a930ef505beb53381c121dd84cb4d50c89d1b84f6c2875ce
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3142f22906faf7f82aed9b56586c4007bbcda629b7d0c98b4099223854e0469317d39f49b44bd55f8fbf378d167a27e5d850a5210bfb0a7177d0547d1e662fa4
|
|
7
|
+
data.tar.gz: 425cf3ce7982b240e8527a34cb2928c071b588896112f2f02b23b428eb887fd017d26ade1f9502a130e9fcd6ea0ef5f6cca8cdd1493ef9c335ddef7aca98f55d
|
data/lib/line.rb
CHANGED
data/lib/trees.rb
CHANGED
|
@@ -4,20 +4,18 @@ require_relative 'line'
|
|
|
4
4
|
require_relative 'trie'
|
|
5
5
|
|
|
6
6
|
module Trees
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
TOKEN_SEPARATOR = ' '.freeze
|
|
7
|
+
TOKEN_SEPARATOR = ' '
|
|
10
8
|
|
|
11
9
|
def line(path, &block)
|
|
12
10
|
current_path << path
|
|
13
11
|
current_path_joined = current_path.join(TOKEN_SEPARATOR)
|
|
14
12
|
|
|
15
|
-
@current_line = Line.new(path: current_path_joined, params: block.parameters.
|
|
13
|
+
@current_line = Line.new(path: current_path_joined, params: block.parameters.map(&:last))
|
|
16
14
|
|
|
17
15
|
lines[current_path_joined] = @current_line
|
|
18
16
|
trie.merge(line: @current_line)
|
|
19
17
|
|
|
20
|
-
block.call if block_given?
|
|
18
|
+
block.call(**stub_required_keywords(block:)) if block_given?
|
|
21
19
|
|
|
22
20
|
current_path.pop
|
|
23
21
|
end
|
|
@@ -48,19 +46,24 @@ module Trees
|
|
|
48
46
|
while results.count > 0
|
|
49
47
|
result = results.pop
|
|
50
48
|
|
|
51
|
-
|
|
52
|
-
result.line.params.values.each do |param|
|
|
53
|
-
result.line.execute.binding.local_variable_set(param, result.params[param])
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
result.line.execute.call
|
|
49
|
+
next unless result.line.execute
|
|
57
50
|
|
|
58
|
-
|
|
51
|
+
result.line.params.each do |param|
|
|
52
|
+
result.line.execute.binding.local_variable_set(param, result.params[param]) if result.params.key?(param)
|
|
59
53
|
end
|
|
54
|
+
|
|
55
|
+
result.line.execute.call
|
|
56
|
+
|
|
57
|
+
return true
|
|
60
58
|
end
|
|
61
59
|
|
|
62
60
|
false
|
|
63
|
-
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# The "line" block defines the params that the "execute" child block will use later but doesn't itself execute user input.
|
|
64
|
+
def stub_required_keywords(block:)
|
|
65
|
+
block.parameters.filter_map { |type, name| [name, nil] if type == :keyreq }.to_h
|
|
66
|
+
end
|
|
64
67
|
|
|
65
68
|
def current_path
|
|
66
69
|
@current_path ||= []
|
data/lib/version.rb
CHANGED