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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e030dad6d87f620512b7a158700c1f8cea254b52a22c07a7553830fe30091235
4
- data.tar.gz: 72f5cb1df8b73511966b807265429afca3afd3a60160c82ff2431cd3564e8754
3
+ metadata.gz: d74463b8145c28c660a15879bd8e3ce3ff2059aa7bd9fbf6ec58ed0d2412d7b2
4
+ data.tar.gz: ea0364d683460c925dddc028dbbb041e06774cba69c3725d738c9a850bffa5c5
5
5
  SHA512:
6
- metadata.gz: c608c41c1390c0a39a4bfb3be347bc7c423f4594b06c5c041ebbd544620379afceb9cf9f40b257e3323b0d1e9f869da53dbe311b444f75c74ad872099a8966cf
7
- data.tar.gz: a45e9fecd2fb5eb124632e01279857e5edfe8f6f619a8f5d061d8f57c67db894699bade0c7e9977eff65f9447161839c23ec284259169016921f613dfe263601
6
+ metadata.gz: 9e0e6bde47b0aeed349122b293fcd4322febe07c9a6d85c1e469e479661d4152aa01ed62340dc26d4a901acba5951a0cd4ca53f012da6f06ff30e9d8fddf94a2
7
+ data.tar.gz: 20e4b90104dc47c3abe92b9fed52f3a7b4f3fdb101154f62b2bd2cd9a46fb7dc8c6cabb922dc4e0aa0df997c85524c8ea37979a75f1ba9abc74cd92311a0787c
data/README.md CHANGED
@@ -1,12 +1,14 @@
1
- [![Gem Version](https://badge.fury.io/rb/ruby-dagger.svg)](https://badge.fury.io/rb/ruby-dagger) [![Maintainability](https://api.codeclimate.com/v1/badges/0d92a4d05b6bb5c06dce/maintainability)](https://codeclimate.com/github/notCalle/ruby-dagger/maintainability)
1
+ [![Gem Version](https://badge.fury.io/rb/ruby-dagger.svg)](https://badge.fury.io/rb/ruby-dagger) [![Maintainability](https://api.codeclimate.com/v1/badges/4038215eb129292a826d/maintainability)](https://codeclimate.com/github/notCalle/ruby-dagger/maintainability)
2
2
 
3
3
  # Dagger
4
4
 
5
- `Dagger` can manage a [directed acyclic graph](/notcalle/tangle) of
6
- [key trees](/notcalle/keytree), inspired by the ideas behind [PalletJack](/saab-simc-admin/palletjack).
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
- /directories/ are vertices with a forest of key trees from the contained /files/. Edges are formed from the directory structure, and /symlinks/.
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.
@@ -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
- process_rule(context) until context.rule_chain.empty?
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
- # Call the processing method for the first clause of a rule
76
+ # Process the methods in a rule chain
79
77
  #
80
78
  # :call-seq:
81
- # call_rule
82
- def process_rule(context)
83
- key, arg = *context.rule_chain.first
84
- context.rule_chain.delete(key)
85
- klass = Dagger::Generate.const_get(camelize(key))
86
- klass[context, arg, &->(value) { throw context.result, value }]
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
@@ -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 rule_chain] => :@context
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
- return unless keys.all? do |key, regexps|
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.0
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-25 00:00:00.000000000 Z
11
+ date: 2018-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: key_tree