ruby-dagger 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e030dad6d87f620512b7a158700c1f8cea254b52a22c07a7553830fe30091235
4
+ data.tar.gz: 72f5cb1df8b73511966b807265429afca3afd3a60160c82ff2431cd3564e8754
5
+ SHA512:
6
+ metadata.gz: c608c41c1390c0a39a4bfb3be347bc7c423f4594b06c5c041ebbd544620379afceb9cf9f40b257e3323b0d1e9f869da53dbe311b444f75c74ad872099a8966cf
7
+ data.tar.gz: a45e9fecd2fb5eb124632e01279857e5edfe8f6f619a8f5d061d8f57c67db894699bade0c7e9977eff65f9447161839c23ec284259169016921f613dfe263601
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ /vendor
13
+ /Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,12 @@
1
+ Metrics/BlockLength:
2
+ Exclude:
3
+ - 'spec/*_spec.rb'
4
+
5
+ Style/BlockDelimiters:
6
+ Exclude:
7
+ - 'spec/*_spec.rb'
8
+
9
+ # Rubocop 0.56 causes false positives
10
+ # https://github.com/bbatsov/rubocop/issues/5887
11
+ Lint/SplatKeywordArguments:
12
+ Enabled: false
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.0
5
+ before_install: gem install bundler -v 1.16.0
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at calle@discord.bofh.se. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ gem 'key_tree', github: 'notCalle/ruby-keytree'
6
+ gem 'tangle', github: 'notCalle/ruby-tangle'
7
+
8
+ # Specify your gem's dependencies in ruby_dagger.gemspec
9
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Calle Englund
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,70 @@
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)
2
+
3
+ # Dagger
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).
7
+
8
+ 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
+
11
+ Edge direction (default top->down & target->source) is selectable,
12
+ but key tree inheritence is always top->down & target->source.
13
+
14
+ ```
15
+ spec/fixture/graph
16
+ ├── vertex1
17
+ │   ├── a.yaml # a.b = 2
18
+ │   └── c.yaml # c = 3
19
+ └── vertex2
20
+ ├── b.yaml # b = 2
21
+ └── parent -> ../vertex1 # a.b = 2, c = 3
22
+ ```
23
+
24
+ ## Installation
25
+
26
+ Add this line to your application's Gemfile:
27
+
28
+ ```ruby
29
+ gem 'ruby-dagger'
30
+ ```
31
+
32
+ And then execute:
33
+
34
+ $ bundle
35
+
36
+ Or install it yourself as:
37
+
38
+ $ gem install ruby-dagger
39
+
40
+ ## Usage
41
+
42
+ $ bin/console
43
+ ```ruby
44
+ g=Dagger.load('spec/fixture/graph')
45
+ => #<Dagger::Graph: 3 vertices, 3 edges>
46
+ g['/vertex1']['a.b']
47
+ => 2
48
+ g['/vertex2']['a.b']
49
+ => 2
50
+ g['/vertex2'].local['a.b']
51
+ => nil
52
+ ```
53
+
54
+ ## Development
55
+
56
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
57
+
58
+ To install this gem onto your local machine, run `bundle exec rake install`.
59
+
60
+ ## Contributing
61
+
62
+ Bug reports and pull requests are welcome on GitHub at https://github.com/notCalle/ruby_dagger. Pull requests should be rebased to HEAD of `master` before submitting, and all commits must be signed with valid GPG key. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
63
+
64
+ ## License
65
+
66
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
67
+
68
+ ## Code of Conduct
69
+
70
+ Everyone interacting in the RubyDagger project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/notCalle/ruby_dagger/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,14 @@
1
+ require 'bundler/setup'
2
+ require 'bundler/gem_tasks'
3
+
4
+ desc 'Run RuboCop'
5
+ require 'rubocop/rake_task'
6
+ RuboCop::RakeTask.new(:rubocop) do |task|
7
+ task.options << '--display-cop-names'
8
+ end
9
+
10
+ desc 'Run RSpec'
11
+ require 'rspec/core/rake_task'
12
+ RSpec::Core::RakeTask.new(:spec)
13
+
14
+ task default: %i[rubocop spec]
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'dagger'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require 'pry'
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,13 @@
1
+ require 'json'
2
+ require 'yaml'
3
+ require 'dagger/graph'
4
+
5
+ # Manage a DAG, stored in a posix file structure
6
+ #
7
+ module Dagger
8
+ def self.load(dir)
9
+ Graph.load(dir)
10
+ end
11
+ end
12
+
13
+ KeyTree::Loader.fallback(KeyTree::Loader::Nil)
@@ -0,0 +1,6 @@
1
+ require 'ostruct'
2
+
3
+ module Dagger
4
+ # Context keeper for default value generation
5
+ class Context < OpenStruct; end
6
+ end
@@ -0,0 +1,97 @@
1
+ require 'set'
2
+ require_relative 'context'
3
+ require_relative 'generator'
4
+
5
+ module Dagger
6
+ # Default value generator for a dictionary
7
+ class Default
8
+ # Initialize a default value generator for a +dictionary+
9
+ #
10
+ # :call-seq:
11
+ # new(dictionary) => Dagger::Default
12
+ # new(*, cached: false)
13
+ # new(*, rule_prefix: '_default')
14
+ def initialize(dictionary, cached: false, rule_prefix: '_default')
15
+ @dictionary = dictionary
16
+ @cached = cached
17
+ @rule_prefix = KeyTree::Path[rule_prefix]
18
+ @default_proc = ->(tree, key) { generate(tree, key) }
19
+ @locks = Set[]
20
+ end
21
+
22
+ attr_reader :default_proc
23
+
24
+ # Verify state of caching of future values
25
+ #
26
+ # :call-seq:
27
+ # cached? => bool
28
+ def cached?
29
+ !(!@cached)
30
+ end
31
+ attr_writer :cached
32
+
33
+ # Generate a default value for a +key+, possibly caching the
34
+ # result in the +tree+.
35
+ # Raises a +KeyError+ f the default value cannot be generated.
36
+ #
37
+ # :call-seq:
38
+ # generate(tree, key) => value || KeyError
39
+ def generate(tree, key)
40
+ key = KeyTree::Path[key] unless key.is_a? KeyTree::Path
41
+ raise %(deadlock detected: "#{key}") unless @locks.add?(key)
42
+
43
+ return result = process(key) unless cached?
44
+ tree[key] = result unless result.nil?
45
+ ensure
46
+ @locks.delete(key)
47
+ end
48
+
49
+ private
50
+
51
+ # Process value generation rules for +context+, raising a +KeyError+
52
+ # if a value could not be generated. Catches :result thows from rule
53
+ # processing.
54
+ #
55
+ # :call-seq:
56
+ # yield => value || KeyError
57
+ def process(key)
58
+ catch do |ball|
59
+ default_rules(key).each do |rule|
60
+ context = Context.new(result: ball,
61
+ dictionary: @dictionary,
62
+ rule_chain: rule.clone)
63
+
64
+ process_rule(context) until context.rule_chain.empty?
65
+ end
66
+ raise KeyError, %(no rule succeeded for "#{key}")
67
+ end
68
+ end
69
+
70
+ # Return the default value generation rules for a +key+.
71
+ #
72
+ # :call-seq:
73
+ # default_rules(key) => Array of Hash || KeyError
74
+ def default_rules(key)
75
+ @dictionary.fetch(@rule_prefix + key)
76
+ end
77
+
78
+ # Call the processing method for the first clause of a rule
79
+ #
80
+ # :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 }]
87
+ end
88
+
89
+ # Convert snake_case to CamelCase
90
+ #
91
+ # :call-seq:
92
+ # camelize(string)
93
+ def camelize(string)
94
+ string.split('_').map!(&:capitalize).join
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,60 @@
1
+ require 'forwardable'
2
+
3
+ module Dagger
4
+ # Abstract super class for default value generators.
5
+ # Stores the +Context+ on initialization, and provides private
6
+ # helper methods to concrete subclasses.
7
+ #
8
+ # +Context+ key access:
9
+ # :call-seq:
10
+ # dictionary => Hash-like with current key lookup dictionary.
11
+ # rule_chain => Hash of remaining rules in the current chain.
12
+ #
13
+ # +Context+ value update:
14
+ # :call-seq:
15
+ # update(key: value, ...)
16
+ #
17
+ # Wrap non-enumerable objects in an +Array+
18
+ # :call-seq:
19
+ # enumerable(value) => value || [value]
20
+ #
21
+ # Concrete subclasses must implement:
22
+ # :call-seq:
23
+ # process(arg, &->(value))
24
+ #
25
+ # [+arg+] Value for current method in the +rule_chain+
26
+ # [+value+] If a value was found it should be +yield+:ed
27
+ class Generator
28
+ extend Forwardable
29
+
30
+ def self.[](context, arg, &result_yielder)
31
+ new(context).process(arg, &result_yielder)
32
+ end
33
+
34
+ def initialize(context)
35
+ @context = context
36
+ end
37
+
38
+ private
39
+
40
+ delegate %i[dictionary rule_chain] => :@context
41
+
42
+ # Update context attributes with new values
43
+ #
44
+ # :call-seq:
45
+ # update(key: value, ...)
46
+ def update(**kwargs)
47
+ kwargs.each { |key, value| @context[key] = value }
48
+ end
49
+
50
+ # Make an array of a value unless it is already enumerable
51
+ #
52
+ # :call-seq:
53
+ # enumerable(value) => value || [value]
54
+ def enumerable(value)
55
+ value.respond_to?(:each) ? value : [value]
56
+ end
57
+ end
58
+ end
59
+
60
+ Dir[__dir__ + '/generator/*.rb'].each { |file| load(file) }
@@ -0,0 +1,44 @@
1
+ require_relative '../generator'
2
+
3
+ module Dagger
4
+ module Generate
5
+ # Generate a value by collecting regexp matches for keys,
6
+ # and filling format strings.
7
+ #
8
+ # _default.key:
9
+ # - regexp:
10
+ # srckey:
11
+ # - regexp
12
+ # - ...
13
+ # ...
14
+ # string:
15
+ # - format string
16
+ # - ...
17
+ class Regexp < Dagger::Generator
18
+ def process(sources)
19
+ matches = {}
20
+ sources.each do |key, regexps|
21
+ matches.merge!(match_regexps(key, regexps))
22
+ end
23
+ update(dictionary: matches)
24
+ end
25
+
26
+ private
27
+
28
+ # Match the value of a key agains regexps, returning the named
29
+ # captured data.
30
+ #
31
+ # :call-seq:
32
+ # match_regexps(key, regexps) => Hash
33
+ def match_regexps(key, regexps)
34
+ string = dictionary[key]
35
+
36
+ enumerable(regexps).each_with_object({}) do |regexp, matches|
37
+ matchdata = ::Regexp.new(regexp).match(string)
38
+ next if matchdata.nil?
39
+ matches.merge!(matchdata.named_captures.transform_keys(&:to_sym))
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,22 @@
1
+ require_relative '../generator'
2
+
3
+ module Dagger
4
+ module Generate
5
+ # Set requirement for further processing.
6
+ #
7
+ # _default.key:
8
+ # - require:
9
+ # key: regexp
10
+ # - ...
11
+ class Require < Dagger::Generator
12
+ def process(keys)
13
+ return unless keys.all? do |key, regexps|
14
+ string = dictionary[key]
15
+ enumerable(regexps).any? do |regexp|
16
+ ::Regexp.new(regexp).match?(string)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,19 @@
1
+ require_relative '../generator'
2
+
3
+ module Dagger
4
+ module Generate
5
+ # Set requirement for further processing.
6
+ #
7
+ # _default.key:
8
+ # - require_name: regexp
9
+ # - ...
10
+ class RequireName < Dagger::Generator
11
+ def process(regexps)
12
+ string = dictionary['_meta.name']
13
+ enumerable(regexps).any? do |regexp|
14
+ ::Regexp.new(regexp).match?(string)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,33 @@
1
+ require_relative '../generator'
2
+
3
+ module Dagger
4
+ module Generate
5
+ # Generate a value for a +string+ rule.
6
+ #
7
+ # _default.key:
8
+ # - string: "format string"
9
+ # - string:
10
+ # - "format string"
11
+ # - ...
12
+ class String < Dagger::Generator
13
+ def process(strings)
14
+ enumerable(strings).each do |fmtstr|
15
+ result = format_string(fmtstr, dictionary)
16
+ yield result unless result.nil?
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ # Format a +string+ with values from a +dictionary+
23
+ #
24
+ # :call-seq:
25
+ # format_string(string, dictionary)
26
+ def format_string(string, dictionary)
27
+ Kernel.format(string, Hash.new { |_, key| dictionary[key] })
28
+ rescue KeyError
29
+ nil
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,72 @@
1
+ require 'tangle'
2
+ require 'tangle/mixin/directory'
3
+ require_relative 'vertex'
4
+
5
+ module Dagger
6
+ # Specialization of Tangle::DAG
7
+ class Graph < Tangle::DAG
8
+ DEFAULT_MIXINS = [Tangle::Mixin::Directory].freeze
9
+
10
+ def self.load(dir)
11
+ dir_options = {
12
+ root: File.realpath(dir),
13
+ loaders: %i[symlink_loader directory_loader keytree_loader]
14
+ }
15
+ new(directory: dir_options)
16
+ end
17
+
18
+ def initialize(*)
19
+ @deferred_edges = []
20
+ super
21
+ @deferred_edges.each do |args|
22
+ tail, head, *kwargs = args
23
+ add_edge(*[tail, head].map { |name| fetch(name) }, *kwargs)
24
+ end
25
+ end
26
+
27
+ def select(&_filter)
28
+ vertices.select { |vertex| yield(self, vertex) }
29
+ end
30
+
31
+ protected
32
+
33
+ def symlink_loader(path:, parent:, lstat:, **)
34
+ return unless lstat.symlink?
35
+
36
+ target = local_path(File.realpath(path))
37
+ parent = local_path(parent)
38
+ defer_edge(target, parent, name: File.basename(path))
39
+ end
40
+
41
+ def directory_loader(path:, parent:, lstat:, **)
42
+ return unless lstat.directory?
43
+
44
+ path = local_path(path)
45
+ vertex = Vertex.new(path)
46
+ add_vertex(vertex)
47
+ return true if parent.nil?
48
+ parent = local_path(parent)
49
+ defer_edge(parent, path)
50
+ end
51
+
52
+ def keytree_loader(path:, parent:, lstat:, **)
53
+ return unless lstat.file?
54
+
55
+ fetch(local_path(parent)) << KeyTree.open(path)
56
+ end
57
+
58
+ private
59
+
60
+ def local_path(path)
61
+ raise "#{path} outside root" unless path.start_with?(root_directory)
62
+
63
+ result = path.delete_prefix(root_directory)
64
+ return '/' if result.empty?
65
+ result
66
+ end
67
+
68
+ def defer_edge(*args)
69
+ @deferred_edges << args
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,59 @@
1
+ require 'key_tree'
2
+ require_relative 'default'
3
+
4
+ module Dagger
5
+ # Vertex class for Dagger, representing a filesystem directory
6
+ class Vertex
7
+ def initialize(name)
8
+ initialize_forest
9
+
10
+ meta['_meta.name'] = name
11
+ meta['_meta.basename'] = File.basename(name)
12
+ meta['_meta.dirname'] = File.dirname(name)
13
+ end
14
+
15
+ attr_reader :inherited, :keys, :local, :meta
16
+
17
+ def name
18
+ meta['_meta.name']
19
+ end
20
+
21
+ def [](key)
22
+ key = KeyTree::Path[key] unless key.is_a? KeyTree::Path
23
+ return inherited[key[1..-1]] if key.prefix?(KeyTree::Path['^'])
24
+ keys[key]
25
+ end
26
+
27
+ def fetch(key)
28
+ keys.fetch(key)
29
+ end
30
+
31
+ def <<(keytree)
32
+ local << keytree
33
+ end
34
+
35
+ def edge_added(edge)
36
+ return unless edge.head?(self)
37
+ inherited << edge.tail.keys
38
+ end
39
+
40
+ def edge_removed(edge)
41
+ return unless edge.head?(self)
42
+ inherited.reject! { |tree| tree.equal?(edge.tail.keys) }
43
+ end
44
+
45
+ alias to_s name
46
+
47
+ private
48
+
49
+ def initialize_forest
50
+ @keys = KeyTree::Forest.new
51
+ @keys << @meta = KeyTree::Tree.new
52
+ @keys << @local = KeyTree::Forest.new
53
+ @keys << @default = KeyTree::Forest.new
54
+ @keys << @inherited = KeyTree::Forest.new
55
+ default_proc = Default.new(self).default_proc
56
+ @default << KeyTree::Tree.new(&default_proc)
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,40 @@
1
+
2
+ lib = File.expand_path('lib', __dir__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ begin
6
+ require 'git-version-bump'
7
+ GIT_VERSION = GVB.version.freeze
8
+ rescue LoadError
9
+ GIT_VERSION = '0.0.0.UNDEF'.freeze
10
+ end
11
+
12
+ Gem::Specification.new do |spec|
13
+ spec.name = 'ruby-dagger'
14
+ spec.version = GIT_VERSION
15
+ spec.authors = ['Calle Englund']
16
+ spec.email = ['calle@discord.bofh.se']
17
+
18
+ spec.summary = 'Manage a DAG, stored in posix file structures'
19
+ spec.homepage = 'https://github.com/notcalle/ruby-dagger'
20
+ spec.license = 'MIT'
21
+
22
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
23
+ f.match(%r{^(test|spec|features)/})
24
+ end
25
+ spec.bindir = 'exe'
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ['lib']
28
+
29
+ spec.platform = Gem::Platform::RUBY
30
+ spec.required_ruby_version = '~> 2.1'
31
+
32
+ spec.add_dependency 'key_tree', '~> 0.5'
33
+ spec.add_dependency 'tangle', '~> 0.9'
34
+
35
+ spec.add_development_dependency 'bundler', '~> 1.16'
36
+ spec.add_development_dependency 'git-version-bump', '~> 0.15'
37
+ spec.add_development_dependency 'rake', '~> 10.0'
38
+ spec.add_development_dependency 'rspec', '~> 3.0'
39
+ spec.add_development_dependency 'rubocop', '~> 0.52'
40
+ end
metadata ADDED
@@ -0,0 +1,164 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby-dagger
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Calle Englund
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-05-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: key_tree
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: tangle
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.9'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.9'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.16'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.16'
55
+ - !ruby/object:Gem::Dependency
56
+ name: git-version-bump
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.15'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.15'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.52'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.52'
111
+ description:
112
+ email:
113
+ - calle@discord.bofh.se
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - ".rubocop.yml"
121
+ - ".travis.yml"
122
+ - CODE_OF_CONDUCT.md
123
+ - Gemfile
124
+ - LICENSE.txt
125
+ - README.md
126
+ - Rakefile
127
+ - bin/console
128
+ - bin/setup
129
+ - lib/dagger.rb
130
+ - lib/dagger/context.rb
131
+ - lib/dagger/default.rb
132
+ - lib/dagger/generator.rb
133
+ - lib/dagger/generator/regexp.rb
134
+ - lib/dagger/generator/require.rb
135
+ - lib/dagger/generator/require_name.rb
136
+ - lib/dagger/generator/string.rb
137
+ - lib/dagger/graph.rb
138
+ - lib/dagger/vertex.rb
139
+ - ruby-dagger.gemspec
140
+ homepage: https://github.com/notcalle/ruby-dagger
141
+ licenses:
142
+ - MIT
143
+ metadata: {}
144
+ post_install_message:
145
+ rdoc_options: []
146
+ require_paths:
147
+ - lib
148
+ required_ruby_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '2.1'
153
+ required_rubygems_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ requirements: []
159
+ rubyforge_project:
160
+ rubygems_version: 2.7.6
161
+ signing_key:
162
+ specification_version: 4
163
+ summary: Manage a DAG, stored in posix file structures
164
+ test_files: []