build-dependency 1.0.0 → 1.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.
- checksums.yaml +4 -4
- data/.travis.yml +4 -4
- data/build-dependency.gemspec +1 -1
- data/lib/build/dependency.rb +3 -1
- data/lib/build/dependency/{unit.rb → provider.rb} +23 -3
- data/lib/build/dependency/version.rb +1 -1
- data/spec/build/dependency/chain_spec.rb +10 -4
- data/spec/build/dependency/partial_chain_spec.rb +4 -4
- data/spec/build/dependency/provider_spec.rb +89 -0
- data/spec/spec_helper.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6cb795ff1a6fb70f25f646a916bbdb307bc56646
|
|
4
|
+
data.tar.gz: 54665a26d16a62df4161e21d6a8ad32c31101a7a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a86ff842300e174fe0eb00696a0c8ffee6141e28b9777009901c088004fe92c668ba391c3f3166eb07451c108bc5090cbf8028beb12ea67d3a41aa8bf25b2090
|
|
7
|
+
data.tar.gz: 9c0e120c21cd393dd9f647e6e7b98206ec76ea43f573a5db6d6965ae3bd206988058321a061fdf7c93a0170c12da95d000ee956502180832354ddab1dc5b1aab
|
data/.travis.yml
CHANGED
data/build-dependency.gemspec
CHANGED
|
@@ -6,7 +6,7 @@ Gem::Specification.new do |spec|
|
|
|
6
6
|
spec.version = Build::Dependency::VERSION
|
|
7
7
|
spec.authors = ["Samuel Williams"]
|
|
8
8
|
spec.email = ["samuel.williams@oriontransfer.co.nz"]
|
|
9
|
-
spec.summary = %q{A
|
|
9
|
+
spec.summary = %q{A set of data structures and algorithms for dependency resolution.}
|
|
10
10
|
spec.homepage = ""
|
|
11
11
|
spec.license = "MIT"
|
|
12
12
|
|
data/lib/build/dependency.rb
CHANGED
|
@@ -20,7 +20,9 @@
|
|
|
20
20
|
|
|
21
21
|
require_relative 'dependency/version'
|
|
22
22
|
|
|
23
|
-
require_relative 'dependency/
|
|
23
|
+
require_relative 'dependency/provider'
|
|
24
|
+
|
|
24
25
|
require_relative 'dependency/chain'
|
|
25
26
|
require_relative 'dependency/partial_chain'
|
|
27
|
+
|
|
26
28
|
require_relative 'dependency/visualization'
|
|
@@ -23,7 +23,7 @@ require 'set'
|
|
|
23
23
|
module Build
|
|
24
24
|
module Dependency
|
|
25
25
|
def self.included(klass)
|
|
26
|
-
klass.include(
|
|
26
|
+
klass.include(Provider)
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
# A provision is a thing which satisfies a dependency.
|
|
@@ -31,18 +31,30 @@ module Build
|
|
|
31
31
|
def alias?
|
|
32
32
|
false
|
|
33
33
|
end
|
|
34
|
+
|
|
35
|
+
def to_s
|
|
36
|
+
"provides #{name.inspect}"
|
|
37
|
+
end
|
|
34
38
|
end
|
|
35
39
|
|
|
36
40
|
Alias = Struct.new(:name, :provider, :dependencies) do
|
|
37
41
|
def alias?
|
|
38
42
|
true
|
|
39
43
|
end
|
|
44
|
+
|
|
45
|
+
def to_s
|
|
46
|
+
"provides #{name.inspect} -> #{dependencies.collect(&:inspect).join(', ')}"
|
|
47
|
+
end
|
|
40
48
|
end
|
|
41
49
|
|
|
42
50
|
Resolution = Struct.new(:provider, :dependency) do
|
|
43
51
|
def name
|
|
44
52
|
dependency.name
|
|
45
53
|
end
|
|
54
|
+
|
|
55
|
+
def to_s
|
|
56
|
+
"resolution #{provider.name.inspect} -> #{dependency.name.inspect}"
|
|
57
|
+
end
|
|
46
58
|
end
|
|
47
59
|
|
|
48
60
|
Depends = Struct.new(:name) do
|
|
@@ -54,6 +66,14 @@ module Build
|
|
|
54
66
|
|
|
55
67
|
attr :options
|
|
56
68
|
|
|
69
|
+
def to_s
|
|
70
|
+
if @options.any?
|
|
71
|
+
"depends on #{name.inspect} #{@options.inspect}"
|
|
72
|
+
else
|
|
73
|
+
"depends on #{name.inspect}"
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
57
77
|
def private?
|
|
58
78
|
@options[:private]
|
|
59
79
|
end
|
|
@@ -62,12 +82,12 @@ module Build
|
|
|
62
82
|
name.is_a?(Symbol)
|
|
63
83
|
end
|
|
64
84
|
|
|
65
|
-
def self.[]
|
|
85
|
+
def self.[](name_or_dependency)
|
|
66
86
|
name_or_dependency.is_a?(self) ? name_or_dependency : self.new(name_or_dependency)
|
|
67
87
|
end
|
|
68
88
|
end
|
|
69
89
|
|
|
70
|
-
module
|
|
90
|
+
module Provider
|
|
71
91
|
def freeze
|
|
72
92
|
return unless frozen?
|
|
73
93
|
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
RSpec.describe Build::Dependency do
|
|
22
22
|
describe "valid dependency resolution" do
|
|
23
23
|
let(:a) do
|
|
24
|
-
Package.new.tap do |package|
|
|
24
|
+
Package.new('apple-tree').tap do |package|
|
|
25
25
|
package.provides 'apple' do
|
|
26
26
|
fruit ['apple']
|
|
27
27
|
end
|
|
@@ -29,7 +29,7 @@ RSpec.describe Build::Dependency do
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
let(:b) do
|
|
32
|
-
Package.new.tap do |package|
|
|
32
|
+
Package.new('orange-tree').tap do |package|
|
|
33
33
|
package.provides 'orange' do
|
|
34
34
|
fruit ['orange']
|
|
35
35
|
end
|
|
@@ -37,7 +37,7 @@ RSpec.describe Build::Dependency do
|
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
let(:c) do
|
|
40
|
-
Package.new.tap do |package|
|
|
40
|
+
Package.new('blender').tap do |package|
|
|
41
41
|
package.provides 'fruit-juice' do
|
|
42
42
|
juice ['ice', 'cold']
|
|
43
43
|
end
|
|
@@ -54,7 +54,7 @@ RSpec.describe Build::Dependency do
|
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
let(:d) do
|
|
57
|
-
Package.new.tap do |package|
|
|
57
|
+
Package.new('bakery').tap do |package|
|
|
58
58
|
package.provides 'pie'
|
|
59
59
|
package.depends 'apple'
|
|
60
60
|
end
|
|
@@ -66,6 +66,12 @@ RSpec.describe Build::Dependency do
|
|
|
66
66
|
expect(chain.unresolved).to be == []
|
|
67
67
|
expect(chain.ordered.collect(&:first)).to be == [a, d]
|
|
68
68
|
end
|
|
69
|
+
|
|
70
|
+
it "should format nicely" do
|
|
71
|
+
chain = Build::Dependency::Chain.expand(['fruit-juice'], [a, b, c])
|
|
72
|
+
resolution = chain.ordered.first
|
|
73
|
+
expect(resolution.to_s).to be == 'resolution "apple-tree" -> "apple"'
|
|
74
|
+
end
|
|
69
75
|
end
|
|
70
76
|
|
|
71
77
|
describe "incomplete dependency resolution" do
|
|
@@ -36,11 +36,11 @@ RSpec.describe Build::Dependency::PartialChain do
|
|
|
36
36
|
|
|
37
37
|
it "should generate a full list of provisions" do
|
|
38
38
|
expect(chain.provisions).to be == [
|
|
39
|
-
variant.provision_for(Build::Dependency::Depends
|
|
40
|
-
platform.provision_for(Build::Dependency::Depends
|
|
41
|
-
compiler.provision_for(Build::Dependency::Depends
|
|
39
|
+
variant.provision_for(Build::Dependency::Depends.new('Variant/debug')),
|
|
40
|
+
platform.provision_for(Build::Dependency::Depends.new('Platform/linux')),
|
|
41
|
+
compiler.provision_for(Build::Dependency::Depends.new('Language/C++17')),
|
|
42
42
|
lib.provision_for(Build::Dependency::Depends.new('lib')),
|
|
43
|
-
compiler.provision_for(Build::Dependency::Depends
|
|
43
|
+
compiler.provision_for(Build::Dependency::Depends.new('Language/C++14')),
|
|
44
44
|
app.provision_for(Build::Dependency::Depends.new('app')),
|
|
45
45
|
]
|
|
46
46
|
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
|
2
|
+
#
|
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
# furnished to do so, subject to the following conditions:
|
|
9
|
+
#
|
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
|
11
|
+
# all copies or substantial portions of the Software.
|
|
12
|
+
#
|
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
# THE SOFTWARE.
|
|
20
|
+
|
|
21
|
+
RSpec.describe Build::Dependency::Provider do
|
|
22
|
+
include_context "app packages"
|
|
23
|
+
|
|
24
|
+
let(:provider) do
|
|
25
|
+
Package.new("test").tap do |package|
|
|
26
|
+
package.depends "a", private: true
|
|
27
|
+
package.depends "b"
|
|
28
|
+
package.depends :variant
|
|
29
|
+
|
|
30
|
+
package.provides "c" do
|
|
31
|
+
puts "Hello World"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
package.provides platform: "linux"
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "should have specified dependencies" do
|
|
39
|
+
expect(provider.dependencies.count).to be == 3
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "should have specified provisions" do
|
|
43
|
+
expect(provider.provisions.count).to be == 2
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe Build::Dependency::Provision do
|
|
47
|
+
subject {provider.provisions["c"]}
|
|
48
|
+
|
|
49
|
+
it "should have name" do
|
|
50
|
+
expect(subject.name).to be == "c"
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "should not be an alias" do
|
|
54
|
+
is_expected.to_not be_alias
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "should format nicely" do
|
|
58
|
+
expect(subject.to_s).to be == 'provision "c"'
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
describe Build::Dependency::Depends do
|
|
63
|
+
subject {provider.dependencies.first}
|
|
64
|
+
|
|
65
|
+
it "should have a name" do
|
|
66
|
+
expect(subject.name).to be == "a"
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it "should not be an alias" do
|
|
70
|
+
is_expected.to_not be_alias
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it "should format nicely" do
|
|
74
|
+
expect(subject.to_s).to be == 'depends on "a" {:private=>true}'
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
describe Build::Dependency::Alias do
|
|
79
|
+
subject {provider.provisions[:platform]}
|
|
80
|
+
|
|
81
|
+
it "should be an alias" do
|
|
82
|
+
is_expected.to be_alias
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it "should format nicely" do
|
|
86
|
+
expect(subject.to_s).to be == 'alias :platform -> "linux"'
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: build-dependency
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-04-
|
|
11
|
+
date: 2017-04-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: graphviz
|
|
@@ -85,12 +85,13 @@ files:
|
|
|
85
85
|
- lib/build/dependency.rb
|
|
86
86
|
- lib/build/dependency/chain.rb
|
|
87
87
|
- lib/build/dependency/partial_chain.rb
|
|
88
|
-
- lib/build/dependency/
|
|
88
|
+
- lib/build/dependency/provider.rb
|
|
89
89
|
- lib/build/dependency/version.rb
|
|
90
90
|
- lib/build/dependency/visualization.rb
|
|
91
91
|
- partial.svg
|
|
92
92
|
- spec/build/dependency/chain_spec.rb
|
|
93
93
|
- spec/build/dependency/partial_chain_spec.rb
|
|
94
|
+
- spec/build/dependency/provider_spec.rb
|
|
94
95
|
- spec/build/dependency/visualization_spec.rb
|
|
95
96
|
- spec/spec_helper.rb
|
|
96
97
|
- visualization.svg
|
|
@@ -117,9 +118,10 @@ rubyforge_project:
|
|
|
117
118
|
rubygems_version: 2.6.10
|
|
118
119
|
signing_key:
|
|
119
120
|
specification_version: 4
|
|
120
|
-
summary: A
|
|
121
|
+
summary: A set of data structures and algorithms for dependency resolution.
|
|
121
122
|
test_files:
|
|
122
123
|
- spec/build/dependency/chain_spec.rb
|
|
123
124
|
- spec/build/dependency/partial_chain_spec.rb
|
|
125
|
+
- spec/build/dependency/provider_spec.rb
|
|
124
126
|
- spec/build/dependency/visualization_spec.rb
|
|
125
127
|
- spec/spec_helper.rb
|