ruby-dagger 0.1.0 → 0.1.1
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 +6 -4
- data/lib/dagger/default.rb +11 -11
- data/lib/dagger/generator.rb +15 -2
- data/lib/dagger/generator/require.rb +1 -1
- data/lib/dagger/generator/require_name.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d74463b8145c28c660a15879bd8e3ce3ff2059aa7bd9fbf6ec58ed0d2412d7b2
|
4
|
+
data.tar.gz: ea0364d683460c925dddc028dbbb041e06774cba69c3725d738c9a850bffa5c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e0e6bde47b0aeed349122b293fcd4322febe07c9a6d85c1e469e479661d4152aa01ed62340dc26d4a901acba5951a0cd4ca53f012da6f06ff30e9d8fddf94a2
|
7
|
+
data.tar.gz: 20e4b90104dc47c3abe92b9fed52f3a7b4f3fdb101154f62b2bd2cd9a46fb7dc8c6cabb922dc4e0aa0df997c85524c8ea37979a75f1ba9abc74cd92311a0787c
|
data/README.md
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
-
[](https://badge.fury.io/rb/ruby-dagger) [](https://badge.fury.io/rb/ruby-dagger) [](https://codeclimate.com/github/notCalle/ruby-dagger/maintainability)
|
2
2
|
|
3
3
|
# Dagger
|
4
4
|
|
5
|
-
`Dagger` can manage a
|
6
|
-
[
|
5
|
+
`Dagger` can manage a
|
6
|
+
[directed acyclic graph](https://github.com/notcalle/tangle) of
|
7
|
+
[key trees](https://github.com/notcalle/keytree), inspired by the ideas behind [PalletJack](https://github.com/saab-simc-admin/palletjack).
|
7
8
|
|
8
9
|
The DAG is stored in a regular posix file system hierarchy, where
|
9
|
-
|
10
|
+
_directories_ are vertices with a forest of key trees from the contained
|
11
|
+
_files_. Edges are formed from the directory structure, and _symlinks_.
|
10
12
|
|
11
13
|
Edge direction (default top->down & target->source) is selectable,
|
12
14
|
but key tree inheritence is always top->down & target->source.
|
data/lib/dagger/default.rb
CHANGED
@@ -57,11 +57,9 @@ module Dagger
|
|
57
57
|
def process(key)
|
58
58
|
catch do |ball|
|
59
59
|
default_rules(key).each do |rule|
|
60
|
-
context = Context.new(result: ball,
|
61
|
-
dictionary: @dictionary,
|
62
|
-
rule_chain: rule.clone)
|
60
|
+
context = Context.new(result: ball, dictionary: @dictionary)
|
63
61
|
|
64
|
-
|
62
|
+
process_rule_chain(rule, context)
|
65
63
|
end
|
66
64
|
raise KeyError, %(no rule succeeded for "#{key}")
|
67
65
|
end
|
@@ -75,15 +73,17 @@ module Dagger
|
|
75
73
|
@dictionary.fetch(@rule_prefix + key)
|
76
74
|
end
|
77
75
|
|
78
|
-
#
|
76
|
+
# Process the methods in a rule chain
|
79
77
|
#
|
80
78
|
# :call-seq:
|
81
|
-
#
|
82
|
-
def
|
83
|
-
key, arg
|
84
|
-
|
85
|
-
|
86
|
-
|
79
|
+
# process_rule_chain(rule_chain, context)
|
80
|
+
def process_rule_chain(rule_chain, context)
|
81
|
+
rule_chain.each do |key, arg|
|
82
|
+
klass = Dagger::Generate.const_get(camelize(key))
|
83
|
+
klass[context, arg, &->(value) { throw context.result, value }]
|
84
|
+
end
|
85
|
+
rescue StopIteration
|
86
|
+
nil
|
87
87
|
end
|
88
88
|
|
89
89
|
# Convert snake_case to CamelCase
|
data/lib/dagger/generator.rb
CHANGED
@@ -8,12 +8,15 @@ module Dagger
|
|
8
8
|
# +Context+ key access:
|
9
9
|
# :call-seq:
|
10
10
|
# dictionary => Hash-like with current key lookup dictionary.
|
11
|
-
# rule_chain => Hash of remaining rules in the current chain.
|
12
11
|
#
|
13
12
|
# +Context+ value update:
|
14
13
|
# :call-seq:
|
15
14
|
# update(key: value, ...)
|
16
15
|
#
|
16
|
+
# Stop the processing of current rule chain:
|
17
|
+
# :call-seq:
|
18
|
+
# stop
|
19
|
+
#
|
17
20
|
# Wrap non-enumerable objects in an +Array+
|
18
21
|
# :call-seq:
|
19
22
|
# enumerable(value) => value || [value]
|
@@ -37,7 +40,17 @@ module Dagger
|
|
37
40
|
|
38
41
|
private
|
39
42
|
|
40
|
-
delegate %i[dictionary
|
43
|
+
delegate %i[dictionary] => :@context
|
44
|
+
|
45
|
+
# Stop processing the current rule chain
|
46
|
+
#
|
47
|
+
# :call-seq:
|
48
|
+
# stop
|
49
|
+
#
|
50
|
+
# Raises +StopIteration+
|
51
|
+
def stop
|
52
|
+
raise StopIteration
|
53
|
+
end
|
41
54
|
|
42
55
|
# Update context attributes with new values
|
43
56
|
#
|
@@ -10,7 +10,7 @@ module Dagger
|
|
10
10
|
# - ...
|
11
11
|
class Require < Dagger::Generator
|
12
12
|
def process(keys)
|
13
|
-
|
13
|
+
stop unless keys.any? do |key, regexps|
|
14
14
|
string = dictionary[key]
|
15
15
|
enumerable(regexps).any? do |regexp|
|
16
16
|
::Regexp.new(regexp).match?(string)
|
@@ -10,7 +10,7 @@ module Dagger
|
|
10
10
|
class RequireName < Dagger::Generator
|
11
11
|
def process(regexps)
|
12
12
|
string = dictionary['_meta.name']
|
13
|
-
enumerable(regexps).any? do |regexp|
|
13
|
+
stop unless enumerable(regexps).any? do |regexp|
|
14
14
|
::Regexp.new(regexp).match?(string)
|
15
15
|
end
|
16
16
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-dagger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Calle Englund
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: key_tree
|