batali 0.1.16 → 0.1.18
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/CHANGELOG.md +5 -0
- data/README.md +57 -1
- data/batali.gemspec +6 -6
- data/lib/batali/score_keeper.rb +58 -3
- data/lib/batali/version.rb +1 -1
- metadata +18 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af52638ac3a1721abd7bb9615d6807ed37d9eea4
|
4
|
+
data.tar.gz: 2dbcf019a32eb2c3da9def2faafdeb5157488811
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cc681411a0120068b946ee946763de6a0cbadad3bd8193242b86beab9c19f2c59e66ad006dfd87d3f1ef60d430c8e046d2e992c92f29608386d485b10a8a534
|
7
|
+
data.tar.gz: 553311a853ae125722fd8f78b97b745753a373e468992680c19bcf8f9a56027e8bf28ff7c1e615c15b6206aab7631c0694ba905049c61000557ca4514494e7cc
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# v0.1.18
|
2
|
+
* Update restriction key from :to -> :source (#7)
|
3
|
+
* Show unit removals on single path resolution output
|
4
|
+
* Complete unit scoring implementation (#11)
|
5
|
+
|
1
6
|
# v0.1.16
|
2
7
|
* Include cookbook removals on resolve output
|
3
8
|
* Add initial infrastructure resolve output to show cookbooks + versions
|
data/README.md
CHANGED
@@ -89,7 +89,63 @@ $ batali resolve example
|
|
89
89
|
```
|
90
90
|
|
91
91
|
This will only update the version of the example cookbook, and any dependency cookbooks
|
92
|
-
that _must_ be updated to provide resolution.
|
92
|
+
that _must_ be updated to provide resolution. Dependency cookbooks that require an upgrade
|
93
|
+
based on constraints will attempt to upgrade with the _least impact possible_ by attempting
|
94
|
+
to satisfy constraints within the minimum version segement possible. For example, if our
|
95
|
+
Batali file contains the following:
|
96
|
+
|
97
|
+
```ruby
|
98
|
+
Batali.define do
|
99
|
+
source 'https://example.com'
|
100
|
+
cookbook 'soup'
|
101
|
+
end
|
102
|
+
```
|
103
|
+
|
104
|
+
and after resolving we have two cookbooks in our manifest:
|
105
|
+
|
106
|
+
```
|
107
|
+
soup <1.0.0>
|
108
|
+
salad <0.1.4>
|
109
|
+
```
|
110
|
+
|
111
|
+
Some time passes and a new version of `soup` is released, version 1.0.2. In that time
|
112
|
+
multiple new versions of the `salad` cookbook have been released, with new features and
|
113
|
+
with some breaking changes. For this example, lets assume available versions of the `salad`
|
114
|
+
cookbook are:
|
115
|
+
|
116
|
+
```
|
117
|
+
<0.1.4>
|
118
|
+
<0.1.6>
|
119
|
+
<0.1.8>
|
120
|
+
<0.2.0>
|
121
|
+
<0.2.2>
|
122
|
+
<0.3.0>
|
123
|
+
<1.0.0>
|
124
|
+
```
|
125
|
+
|
126
|
+
and the `soup` cookbook has updated its `salad` dependency:
|
127
|
+
|
128
|
+
```ruby
|
129
|
+
# soup metadata.rb
|
130
|
+
depends 'salad', '> 0.2'
|
131
|
+
```
|
132
|
+
|
133
|
+
Due to the behavior of existing solvers, we may expect the resolved manifest to include
|
134
|
+
`salad` at the latest possible version: `1.0.0`. This is a valid solution, since the
|
135
|
+
dependency is simply stating the constraint requires `salad` be _greater_ than `0.2` and
|
136
|
+
nothing more. However, this is a very large jump from what we currently have defined
|
137
|
+
within our manifest, and jumps a major and minor version. The possibility of breaking
|
138
|
+
changes being introduced is extremely high.
|
139
|
+
|
140
|
+
Since Batali has the **least impact** feature enabled by default, it will only upgrade
|
141
|
+
`salad` to the `0.2.2` version. This is due to the fact that the **least impact** feature
|
142
|
+
prefers the _latest_ cookbook available within the _closest_ version segement of the cookbook
|
143
|
+
version currently defined within the manifest. Since thew new `soup` dependency contraint
|
144
|
+
requires versions `> 0.2`, no `> 0.1` versions are acceptable. Batali then looks to the
|
145
|
+
next available segment `0.2` and attempts to use the latest version: `0.2.2`. This solves the
|
146
|
+
constraint, and is used for the new solution.
|
147
|
+
|
148
|
+
Multiple cookbooks can be listed for upgrade:
|
93
149
|
|
94
150
|
```
|
95
151
|
$ batali resolve example ipsum lorem
|
data/batali.gemspec
CHANGED
@@ -10,12 +10,12 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.description = 'Magic'
|
11
11
|
s.require_path = 'lib'
|
12
12
|
s.license = 'Apache 2.0'
|
13
|
-
s.add_runtime_dependency 'attribute_struct', '
|
14
|
-
s.add_runtime_dependency 'grimoire', '
|
15
|
-
s.add_runtime_dependency 'bogo', '
|
16
|
-
s.add_runtime_dependency 'bogo-cli', '
|
17
|
-
s.add_runtime_dependency 'bogo-config', '
|
18
|
-
s.add_runtime_dependency 'bogo-ui', '
|
13
|
+
s.add_runtime_dependency 'attribute_struct', '~> 0.2.14'
|
14
|
+
s.add_runtime_dependency 'grimoire', '~> 0.2.0'
|
15
|
+
s.add_runtime_dependency 'bogo', '~> 0.1.18'
|
16
|
+
s.add_runtime_dependency 'bogo-cli', '~> 0.1.8'
|
17
|
+
s.add_runtime_dependency 'bogo-config', '~> 0.1.10'
|
18
|
+
s.add_runtime_dependency 'bogo-ui', '~> 0.1.6'
|
19
19
|
s.add_runtime_dependency 'git'
|
20
20
|
s.add_runtime_dependency 'http'
|
21
21
|
s.add_development_dependency 'minitest'
|
data/lib/batali/score_keeper.rb
CHANGED
@@ -6,12 +6,67 @@ module Batali
|
|
6
6
|
|
7
7
|
attribute :manifest, Manifest, :required => true
|
8
8
|
|
9
|
+
# Always prefer higher scoring units
|
10
|
+
#
|
11
|
+
# @return [Symbol] :highscore
|
12
|
+
def preferred_score
|
13
|
+
:highscore
|
14
|
+
end
|
15
|
+
|
9
16
|
# Provide score for given unit
|
10
17
|
#
|
11
|
-
# @param unit [Unit]
|
18
|
+
# @param unit [Unit] unit to score
|
19
|
+
# @param idx [Integer] current index location
|
12
20
|
# @return [Numeric, NilClass]
|
13
|
-
def score_for(unit)
|
14
|
-
|
21
|
+
def score_for(unit, idx)
|
22
|
+
multiplier = 1
|
23
|
+
manifest_unit = manifest.cookbook.detect do |m_unit|
|
24
|
+
m_unit.name == unit.name
|
25
|
+
end
|
26
|
+
if(manifest_unit)
|
27
|
+
# If the unit version matches the manifest version, this
|
28
|
+
# should be _the_ preferred version
|
29
|
+
if(manifest_unit.version == unit.version)
|
30
|
+
multiplier = 10000000
|
31
|
+
else
|
32
|
+
# If the unit version satisfies within the patch segment of
|
33
|
+
# the manifest version score those versions highest for upgrade
|
34
|
+
if(UnitRequirement.new("~> #{manifest_unit.version}").satisfied_by?(unit.version))
|
35
|
+
multiplier = 1000000
|
36
|
+
else
|
37
|
+
# If the unit version satisfies within the minor or major
|
38
|
+
# version segments of the manifest version, bump score
|
39
|
+
# value up (with satisfaction within minor segment being
|
40
|
+
# worth more than satisfaction within major segment)
|
41
|
+
pos = UnitRequirement.new("~> #{manifest_unit.version.segments.slice(0,2).join('.')}").satisfied_by?(unit.version) ? 1 : 0
|
42
|
+
multi_val = pos == 1 ? 1000 : 100
|
43
|
+
distance = (manifest_unit.version.segments[pos] - unit.version.segments[pos])
|
44
|
+
if(distance > 0)
|
45
|
+
distance = 1.0 / distance
|
46
|
+
else
|
47
|
+
distance = 0
|
48
|
+
end
|
49
|
+
multiplier = multi_val + (multi_val * distance)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
score = []
|
54
|
+
# Generate a "value" for each segment of the version with
|
55
|
+
# growing importance (major > minor > patch)
|
56
|
+
unit.version.segments.reverse.each_with_index.map do |val, pos|
|
57
|
+
if(val == 0)
|
58
|
+
score.push 0
|
59
|
+
else
|
60
|
+
score.push (2 - (1.0 / val)) * ((pos + 1)**10)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
# Sum the score for each segment to provide the score for the
|
64
|
+
# version and multiply by defined multiplier to force higher
|
65
|
+
# score when manifest drives desire for versions closer to
|
66
|
+
# version defined within manifest
|
67
|
+
score = score.inject(&:+) * multiplier
|
68
|
+
debug "Score <#{unit.name}:#{unit.version}>: #{score}"
|
69
|
+
score
|
15
70
|
end
|
16
71
|
|
17
72
|
end
|
data/lib/batali/version.rb
CHANGED
metadata
CHANGED
@@ -1,97 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: batali
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Roberts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: attribute_struct
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.2.14
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.2.14
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: grimoire
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.2.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.2.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bogo
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.1.
|
47
|
+
version: 0.1.18
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.1.
|
54
|
+
version: 0.1.18
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bogo-cli
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 0.1.8
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.1.8
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bogo-config
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: 0.1.10
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 0.1.10
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: bogo-ui
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: 0.1.6
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 0.1.6
|
97
97
|
- !ruby/object:Gem::Dependency
|