batali 0.2.0 → 0.2.2
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 +6 -0
- data/batali.gemspec +1 -1
- data/lib/batali/command/resolve.rb +15 -2
- data/lib/batali/git.rb +1 -1
- data/lib/batali/manifest.rb +1 -0
- data/lib/batali/origin/remote_site.rb +8 -4
- data/lib/batali/score_keeper.rb +16 -1
- data/lib/batali/source/site.rb +22 -3
- data/lib/batali/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b932231673eb1265232f82a6a4e5e201e0324058
|
4
|
+
data.tar.gz: 64b947c6f2c44899a0e220800981a2eec1ff6954
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 815ced6e99320cc992db4a985dddebe8f426ee2dafce37ca6d542105b52e41e000d1ba19993c0005b88c1d606b422a33e6b93452599a1f248bc284efbc59a201
|
7
|
+
data.tar.gz: 7b40082eb73d94ff5216d83fd5089ec9fd29c376e966b37d6de770049f10b163ce813c0b07efc76bd56d435f49ef06f2eda25deed772dfeb8fe0e23c40d84ca4
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# v0.2.2
|
2
|
+
* Add guard when switching resolution types (#14)
|
3
|
+
* Cache HTTP requests (#20)
|
4
|
+
* Prune cookbook results for infrastructure resolution (#21)
|
5
|
+
* Provide least impact behavior when resolving infrastructure (#19)
|
6
|
+
|
1
7
|
# v0.2.0
|
2
8
|
* Add proxy support (#18)
|
3
9
|
* Transition to "beta" state
|
data/batali.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.require_path = 'lib'
|
12
12
|
s.license = 'Apache 2.0'
|
13
13
|
s.add_runtime_dependency 'attribute_struct', '~> 0.2.14'
|
14
|
-
s.add_runtime_dependency 'grimoire', '~> 0.2.
|
14
|
+
s.add_runtime_dependency 'grimoire', '~> 0.2.1'
|
15
15
|
s.add_runtime_dependency 'bogo', '~> 0.1.18'
|
16
16
|
s.add_runtime_dependency 'bogo-cli', '~> 0.1.12'
|
17
17
|
s.add_runtime_dependency 'bogo-config', '~> 0.1.10'
|
@@ -61,6 +61,9 @@ module Batali
|
|
61
61
|
end
|
62
62
|
]
|
63
63
|
ui.info 'Performing single path resolution.'
|
64
|
+
if(manifest.infrastructure)
|
65
|
+
ui.ask 'Current manifest is resolved for infrastucture. Convert to single path?'
|
66
|
+
end
|
64
67
|
results = []
|
65
68
|
run_action 'Resolving dependency constraints' do
|
66
69
|
results = solv.generate!
|
@@ -72,7 +75,10 @@ module Batali
|
|
72
75
|
ideal_solution = results.pop
|
73
76
|
dry_run('manifest file write') do
|
74
77
|
run_action 'Writing manifest' do
|
75
|
-
manifest = Manifest.new(
|
78
|
+
manifest = Manifest.new(
|
79
|
+
:cookbook => ideal_solution.units,
|
80
|
+
:infrastructure => false
|
81
|
+
)
|
76
82
|
File.open('batali.manifest', 'w') do |file|
|
77
83
|
file.write MultiJson.dump(manifest, :pretty => true)
|
78
84
|
end
|
@@ -106,13 +112,20 @@ module Batali
|
|
106
112
|
# @return [TrueClass]
|
107
113
|
def infrastructure_resolution(solv)
|
108
114
|
ui.info 'Performing infrastructure path resolution.'
|
115
|
+
if(manifest.infrastructure == false)
|
116
|
+
ui.ask 'Current manifest is resolved single path. Convert to infrastructure?'
|
117
|
+
end
|
109
118
|
run_action 'Writing infrastructure manifest file' do
|
110
119
|
File.open(manifest.path, 'w') do |file|
|
111
|
-
manifest = Manifest.new(
|
120
|
+
manifest = Manifest.new(
|
121
|
+
:cookbook => solv.world.units.values.flatten,
|
122
|
+
:infrastructure => true
|
123
|
+
)
|
112
124
|
file.write MultiJson.dump(manifest, :pretty => true)
|
113
125
|
nil
|
114
126
|
end
|
115
127
|
end
|
128
|
+
solv.prune_world!
|
116
129
|
ui.info 'Infrastructure manifest solution:'
|
117
130
|
solv.world.units.sort_by(&:first).each do |name, units|
|
118
131
|
ui.puts "#{name} <#{units.map(&:version).sort.map(&:to_s).join(', ')}>"
|
data/lib/batali/git.rb
CHANGED
@@ -47,7 +47,7 @@ module Batali
|
|
47
47
|
klass.class_eval do
|
48
48
|
attribute :url, String, :required => true
|
49
49
|
attribute :ref, String, :required => true
|
50
|
-
attribute :cache, String
|
50
|
+
attribute :cache, String, :default => File.expand_path('~/.batali/cache/remote_site')
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
data/lib/batali/manifest.rb
CHANGED
@@ -7,6 +7,7 @@ module Batali
|
|
7
7
|
include Bogo::Memoization
|
8
8
|
|
9
9
|
attribute :path, String
|
10
|
+
attribute :infrastructure, [TrueClass, FalseClass]
|
10
11
|
attribute :cookbook, Batali::Unit, :multiple => true, :coerce => lambda{|v| Batali::Unit.new(v)}, :default => []
|
11
12
|
|
12
13
|
# Build manifest from given path. If no file exists, empty
|
@@ -33,9 +33,10 @@ module Batali
|
|
33
33
|
# @return [String] cache directory path
|
34
34
|
def cache_directory
|
35
35
|
memoize(:cache_directory) do
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
['entitystore', 'metastore', identifier].each do |leaf|
|
37
|
+
FileUtils.mkdir_p(File.join(cache, leaf))
|
38
|
+
end
|
39
|
+
File.join(cache, leaf)
|
39
40
|
end
|
40
41
|
end
|
41
42
|
|
@@ -83,7 +84,10 @@ module Batali
|
|
83
84
|
if(do_fetch)
|
84
85
|
t_uni = "#{universe_path}.#{SecureRandom.urlsafe_base64}"
|
85
86
|
File.open(t_uni, 'w') do |file|
|
86
|
-
file.write HTTP.
|
87
|
+
file.write HTTP.with_cache(
|
88
|
+
:metastore => File.join(cache, 'metastore'),
|
89
|
+
:entitystore => File.join(cache, 'entitystore')
|
90
|
+
).get(URI.join(endpoint, 'universe')).body.to_s
|
87
91
|
end
|
88
92
|
FileUtils.mv(t_uni, universe_path)
|
89
93
|
end
|
data/lib/batali/score_keeper.rb
CHANGED
@@ -18,7 +18,8 @@ module Batali
|
|
18
18
|
# @param unit [Unit] unit to score
|
19
19
|
# @param idx [Integer] current index location
|
20
20
|
# @return [Numeric, NilClass]
|
21
|
-
def score_for(unit,
|
21
|
+
def score_for(unit, *args)
|
22
|
+
opts = args.detect{|a| a.is_a?(Hash)} || {}
|
22
23
|
multiplier = 1
|
23
24
|
manifest_unit = manifest.cookbook.detect do |m_unit|
|
24
25
|
m_unit.name == unit.name
|
@@ -28,6 +29,12 @@ module Batali
|
|
28
29
|
# should be _the_ preferred version
|
29
30
|
if(manifest_unit.version == unit.version)
|
30
31
|
multiplier = 10000000
|
32
|
+
elsif(opts[:solver].new_world)
|
33
|
+
new_world_unit = opts[:solver].new_world.units.detect do |n_unit|
|
34
|
+
n_unit.name == unit.name &&
|
35
|
+
n_unit.version == unit.version
|
36
|
+
end
|
37
|
+
multiplier = 10000000 if new_world_unit
|
31
38
|
else
|
32
39
|
# If the unit version satisfies within the patch segment of
|
33
40
|
# the manifest version score those versions highest for upgrade
|
@@ -49,6 +56,14 @@ module Batali
|
|
49
56
|
multiplier = multi_val + (multi_val * distance)
|
50
57
|
end
|
51
58
|
end
|
59
|
+
else
|
60
|
+
if(opts[:solver].new_world)
|
61
|
+
new_world_unit = opts[:solver].new_world.units.detect do |n_unit|
|
62
|
+
n_unit.name == unit.name &&
|
63
|
+
n_unit.version == unit.version
|
64
|
+
end
|
65
|
+
multiplier = 10000000 if new_world_unit
|
66
|
+
end
|
52
67
|
end
|
53
68
|
score = []
|
54
69
|
# Generate a "value" for each segment of the version with
|
data/lib/batali/source/site.rb
CHANGED
@@ -38,14 +38,33 @@ module Batali
|
|
38
38
|
deps.to_a
|
39
39
|
end
|
40
40
|
|
41
|
+
# @return [String] path to cache
|
42
|
+
def cache_directory
|
43
|
+
memoize(:cache_directory) do
|
44
|
+
unless(@cache)
|
45
|
+
@cache = File.expand_path('~/.batali/cache/remote_site')
|
46
|
+
end
|
47
|
+
['entitystore', 'metastore'].each do |leaf|
|
48
|
+
FileUtils.mkdir_p(File.join(cache, leaf))
|
49
|
+
end
|
50
|
+
cache
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
41
54
|
# @return [String] directory
|
42
55
|
def asset
|
43
|
-
path = File.join(
|
56
|
+
path = File.join(cache_directory, Base64.urlsafe_encode64(url))
|
44
57
|
unless(File.directory?(path))
|
45
58
|
FileUtils.mkdir_p(path)
|
46
|
-
result = HTTP.
|
59
|
+
result = HTTP.with_cache(
|
60
|
+
:metastore => File.join(cache_directory, 'metastore'),
|
61
|
+
:entitystore => File.join(cache_directory, 'entitystore')
|
62
|
+
).get(url)
|
47
63
|
while(result.code == 302)
|
48
|
-
result = HTTP.
|
64
|
+
result = HTTP.with_cache(
|
65
|
+
:metastore => File.join(cache_directory, 'metastore'),
|
66
|
+
:entitystore => File.join(cache_directory, 'entitystore')
|
67
|
+
).get(result.headers['Location'])
|
49
68
|
end
|
50
69
|
File.open(a_path = File.join(path, 'asset'), 'w') do |file|
|
51
70
|
while(content = result.body.readpartial(2048))
|
data/lib/batali/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: batali
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
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-04-
|
11
|
+
date: 2015-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: attribute_struct
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.2.
|
33
|
+
version: 0.2.1
|
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.2.
|
40
|
+
version: 0.2.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bogo
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|