batali 0.1.14 → 0.1.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 27264f54883b15e90cf86e0c44a18c861ee33e05
4
- data.tar.gz: 3db117858379470704b67ad9e0acef863a471d3a
3
+ metadata.gz: c69ca3a698a94a1797c499c491e9a50f69bc8d3b
4
+ data.tar.gz: 781d13d797963bdb886c0a22f219bee3e161bd2b
5
5
  SHA512:
6
- metadata.gz: 4fad68431b1362dafb49f2c2821ce8907a06c1af70c8591512e1ad4094148f681d85a335cf281e903887eb1ca76fbccb1e74c2590a99de79c942c9e8b60a92d7
7
- data.tar.gz: 136eaed0d5bf501e5fe0f66b03f697beb532230f33600031794d29e06a92c2b3cc76e021adb7c66fd48b01095c7040f80fbdb953c1cf6cf583aff1773f5bbb23
6
+ metadata.gz: 2c56fcd91bb80bcafdc94f5a5b13ff3db00f32066e754ec92a249f7d488b4da23a97bb0d2662fee2feab71408493d88289e7f06209545d68baac704c43f3ad69
7
+ data.tar.gz: 1c171c5155f4ce221809273e899a6daa8a551aabc7fdfb25a14ae48617bc5e114fa5dabedc5e6f87431c00dab6a5e8093d2e27cac25fc0a9e57bd84076c928b1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # v0.1.16
2
+ * Include cookbook removals on resolve output
3
+ * Add initial infrastructure resolve output to show cookbooks + versions
4
+ * Update restrictions to use `:source` instead of `:to` for source reference
5
+
1
6
  # v0.1.14
2
7
  * Start adding debug and verbose output (#9)
3
8
  * Update exception messages to provide more clarity
data/lib/batali/b_file.rb CHANGED
@@ -81,7 +81,7 @@ module Batali
81
81
  end
82
82
 
83
83
  attribute :restrict, Restriction, :multiple => true, :coerce => lambda{|v|
84
- Restriction.new(:cookbook => v.first, :source => v.last.to_smash[:to])
84
+ Restriction.new(:cookbook => v.first, :source => v.last.to_smash[:source])
85
85
  }
86
86
  attribute :source, Origin::RemoteSite, :multiple => true, :coerce => lambda{|v|
87
87
  args = Smash.new(:endpoint => v.first)
@@ -30,56 +30,9 @@ module Batali
30
30
  :score_keeper => score_keeper
31
31
  )
32
32
  if(opts[:infrastructure])
33
- ui.info 'Performing infrastructure path resolution.'
34
- run_action 'Writing infrastructure manifest file' do
35
- File.open('batali.manifest', 'w') do |file|
36
- manifest = Manifest.new(:cookbook => solv.world.units.values.flatten)
37
- file.write MultiJson.dump(manifest, :pretty => true)
38
- nil
39
- end
40
- end
33
+ infrastructure_resolution(solv)
41
34
  else
42
- original_units = Smash[
43
- [manifest.cookbook].flatten.compact.map do |unit|
44
- [unit.name, unit.version]
45
- end
46
- ]
47
- ui.info 'Performing single path resolution.'
48
- results = []
49
- run_action 'Resolving dependency constraints' do
50
- results = solv.generate!
51
- nil
52
- end
53
- if(results.empty?)
54
- ui.error 'No solutions found defined requirements!'
55
- else
56
- ideal_solution = results.pop
57
- dry_run('manifest file write') do
58
- run_action 'Writing manifest' do
59
- manifest = Manifest.new(:cookbook => ideal_solution.units)
60
- File.open('batali.manifest', 'w') do |file|
61
- file.write MultiJson.dump(manifest, :pretty => true)
62
- end
63
- nil
64
- end
65
- end
66
- # ui.info "Number of solutions collected for defined requirements: #{results.size + 1}"
67
- ui.info 'Ideal solution:'
68
- ideal_solution.units.sort_by(&:name).map do |unit|
69
- output_args = ["#{unit.name} <#{unit.version}>"]
70
- unless(original_units.empty?)
71
- if(original_units[unit.name])
72
- unless(original_units[unit.name] == unit.version)
73
- output_args.first.replace "#{unit.name} <#{original_units[unit.name]} -> #{unit.version}>"
74
- output_args.push(:yellow)
75
- end
76
- else
77
- output_args.push(:green)
78
- end
79
- end
80
- ui.puts ui.color(*output_args)
81
- end
82
- end
35
+ single_path_resolution(solv)
83
36
  end
84
37
  end
85
38
 
@@ -97,6 +50,75 @@ module Batali
97
50
  end
98
51
  end
99
52
 
53
+ # Generate manifest comprised of units for single path resolution
54
+ #
55
+ # @param solv [Grimoire::Solver]
56
+ # @return [TrueClass]
57
+ def single_path_resolution(solv)
58
+ original_units = Smash[
59
+ [manifest.cookbook].flatten.compact.map do |unit|
60
+ [unit.name, unit.version]
61
+ end
62
+ ]
63
+ ui.info 'Performing single path resolution.'
64
+ results = []
65
+ run_action 'Resolving dependency constraints' do
66
+ results = solv.generate!
67
+ nil
68
+ end
69
+ if(results.empty?)
70
+ ui.error 'No solutions found defined requirements!'
71
+ else
72
+ ideal_solution = results.pop
73
+ dry_run('manifest file write') do
74
+ run_action 'Writing manifest' do
75
+ manifest = Manifest.new(:cookbook => ideal_solution.units)
76
+ File.open('batali.manifest', 'w') do |file|
77
+ file.write MultiJson.dump(manifest, :pretty => true)
78
+ end
79
+ nil
80
+ end
81
+ end
82
+ # ui.info "Number of solutions collected for defined requirements: #{results.size + 1}"
83
+ ui.info 'Ideal solution:'
84
+ solution = Smash[ideal_solution.units.map{|unit| [unit.name, unit.version]}]
85
+ (original_units.keys + solution.keys).compact.uniq.sort.each do |unit_name|
86
+ if(original_units[unit_name])
87
+ if(solution[unit_name])
88
+ if(solution[unit_name] == original_units[unit_name])
89
+ ui.puts "#{unit_name} <#{solution[unit_name]}>"
90
+ else
91
+ ui.puts ui.color("#{unit_name} <#{original_units[unit_name]} -> #{solution[unit_name]}>", :yellow)
92
+ end
93
+ else
94
+ ui.puts ui.color("#{unit_name} <#{original_units[unit_name]}>", :red)
95
+ end
96
+ else
97
+ ui.puts ui.color("#{unit_name} <#{solution[unit_name]}>", :green)
98
+ end
99
+ end
100
+ end
101
+ end
102
+
103
+ # Generate manifest comprised of units for entire infrastructure
104
+ #
105
+ # @param solv [Grimoire::Solver]
106
+ # @return [TrueClass]
107
+ def infrastructure_resolution(solv)
108
+ ui.info 'Performing infrastructure path resolution.'
109
+ run_action 'Writing infrastructure manifest file' do
110
+ File.open(manifest.path, 'w') do |file|
111
+ manifest = Manifest.new(:cookbook => solv.world.units.values.flatten)
112
+ file.write MultiJson.dump(manifest, :pretty => true)
113
+ nil
114
+ end
115
+ end
116
+ ui.info 'Infrastructure manifest solution:'
117
+ solv.world.units.sort_by(&:first).each do |name, units|
118
+ ui.puts "#{name} <#{units.map(&:version).sort.map(&:to_s).join(', ')}>"
119
+ end
120
+ end
121
+
100
122
  end
101
123
 
102
124
  end
@@ -6,6 +6,7 @@ module Batali
6
6
 
7
7
  include Bogo::Memoization
8
8
 
9
+ attribute :path, String
9
10
  attribute :cookbook, Batali::Unit, :multiple => true, :coerce => lambda{|v| Batali::Unit.new(v)}, :default => []
10
11
 
11
12
  # Build manifest from given path. If no file exists, empty
@@ -15,9 +16,9 @@ module Batali
15
16
  # @return [Manifest]
16
17
  def self.build(path)
17
18
  if(File.exists?(path))
18
- self.new(Bogo::Config.new(path).data)
19
+ self.new(Bogo::Config.new(path).data.merge(:path => path))
19
20
  else
20
- self.new
21
+ self.new(:path => path)
21
22
  end
22
23
  end
23
24
 
@@ -1,4 +1,4 @@
1
1
  module Batali
2
2
  # Current version
3
- VERSION = Gem::Version.new('0.1.14')
3
+ VERSION = Gem::Version.new('0.1.16')
4
4
  end
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.1.14
4
+ version: 0.1.16
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-19 00:00:00.000000000 Z
11
+ date: 2015-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: attribute_struct