batali 0.2.8 → 0.2.10

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: e09935acfcbc04835f428e88c65c46d5effbc164
4
- data.tar.gz: 5d9b81aacd71727b823947a744a050962908e197
3
+ metadata.gz: 26d1612a3534961100e76d695b09186fdfd8fa31
4
+ data.tar.gz: 4e7804e3d98b4cfe9f9fde3be6a78357945cffd6
5
5
  SHA512:
6
- metadata.gz: cfa3f9193ac35a32b7d467d4f46dbc687c67e944f8ae0ffc95d5ca952d8613a93dde468af54a7310004677ed177cb78f44f581f6135c53899b64ad4e60af60c6
7
- data.tar.gz: 05a5d1eff7e95a0b584a52f1a3e2ca38a17511a17dd5641f8256a8627027368e9db748df7be50b9078f6f43f2819ab0abcbc96a472b8fbe76915c095fe2b2565
6
+ metadata.gz: dd028fa13dd2eb38f133d309f6c402add91bd70665dd9c55dec1db2da13312765e43bbd499eac4550e4aba292169d94a80c03fe4965eca5244c07892dffbe9c5
7
+ data.tar.gz: e2c1f1f064380fabc81c4366477af941fc60172cbf00840e649a2c7aa5d9501b0b84ea05c71ad013a9dd540fbfcaee6e7e6c54cf5523f53f1eca5a9fbffd239d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # v0.2.10
2
+ * Parse full metadata file on path sources to properly discover all deps (#26)
3
+ * Allow source to be optionally defined for Units
4
+ * Provide better handling when encountering Units with no possible solution
5
+ * Include `no_proxy` environment variable support
6
+
1
7
  # v0.2.8
2
8
  * Include missing infrastructure configuration flag on install command
3
9
  * Default the cache directory to home directory to isolate users
data/batali.gemspec CHANGED
@@ -11,8 +11,8 @@ 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.1'
15
- s.add_runtime_dependency 'bogo', '~> 0.1.18'
14
+ s.add_runtime_dependency 'grimoire', '~> 0.2.3'
15
+ s.add_runtime_dependency 'bogo', '~> 0.1.20'
16
16
  s.add_runtime_dependency 'bogo-cli', '~> 0.1.18'
17
17
  s.add_runtime_dependency 'bogo-config', '~> 0.1.10'
18
18
  s.add_runtime_dependency 'bogo-ui', '~> 0.1.6'
@@ -87,20 +87,27 @@ module Batali
87
87
  end
88
88
  # ui.info "Number of solutions collected for defined requirements: #{results.size + 1}"
89
89
  ui.info 'Ideal solution:'
90
- solution = Smash[ideal_solution.units.map{|unit| [unit.name, unit.version]}]
91
- (original_units.keys + solution.keys).compact.uniq.sort.each do |unit_name|
92
- if(original_units[unit_name])
93
- if(solution[unit_name])
94
- if(solution[unit_name] == original_units[unit_name])
95
- ui.puts "#{unit_name} <#{solution[unit_name]}>"
90
+ solution_units = Smash[ideal_solution.units.map{|unit| [unit.name, unit]}]
91
+ manifest_units = Smash[manifest.cookbook.map{|unit| [unit.name, unit]}]
92
+ (solution_units.keys + manifest_units.keys).compact.uniq.sort.each do |unit_name|
93
+ if(manifest_units[unit_name])
94
+ if(solution_units[unit_name])
95
+ if(solution_units[unit_name].same?(manifest_units[unit_name]))
96
+ ui.puts "#{unit_name} <#{solution_units[unit_name].version}>"
96
97
  else
97
- ui.puts ui.color("#{unit_name} <#{original_units[unit_name]} -> #{solution[unit_name]}>", :yellow)
98
+ u_diff = manifest_units[unit_name].diff(solution_units[unit_name])
99
+ version_output = u_diff[:version] ? u_diff[:version].join(' -> ') : solution_units[unit_name].version
100
+ u_diff.delete(:version)
101
+ unless(u_diff.empty?)
102
+ diff_output = "[#{u_diff.values.map{|v| v.join(' -> ')}.join(' | ')}]"
103
+ end
104
+ ui.puts ui.color("#{unit_name} <#{version_output}> #{diff_output}" , :yellow)
98
105
  end
99
106
  else
100
- ui.puts ui.color("#{unit_name} <#{original_units[unit_name]}>", :red)
107
+ ui.puts ui.color("#{unit_name} <#{manifest_units[unit_name].version}>", :red)
101
108
  end
102
109
  else
103
- ui.puts ui.color("#{unit_name} <#{solution[unit_name]}>", :green)
110
+ ui.puts ui.color("#{unit_name} <#{solution_units[unit_name].version}>", :green)
104
111
  end
105
112
  end
106
113
  end
data/lib/batali/git.rb CHANGED
@@ -45,9 +45,9 @@ module Batali
45
45
  # Load attributes into class
46
46
  def self.included(klass)
47
47
  klass.class_eval do
48
- attribute :url, String, :required => true
49
- attribute :ref, String, :required => true
50
- attribute :cache, String, :default => File.expand_path('~/.batali/cache/remote_site')
48
+ attribute :url, String, :required => true, :equivalent => true
49
+ attribute :ref, String, :required => true, :equivalent => true
50
+ attribute :cache, String, :default => File.expand_path('~/.batali/cache/git')
51
51
  end
52
52
  end
53
53
 
data/lib/batali/monkey.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'batali'
2
+ require 'bogo/http_proxy'
2
3
 
3
4
  module Batali
4
5
  # Simple stubs mostly for naming
@@ -16,25 +17,3 @@ module Batali
16
17
  end
17
18
  end
18
19
  end
19
-
20
- require 'resolv'
21
- require 'http'
22
- require 'http/request'
23
-
24
- class HTTP::Request
25
-
26
- def proxy
27
- if(_proxy_point = ENV["#{uri.scheme}_proxy"])
28
- _proxy = URI.parse(_proxy_point)
29
- Hash.new.tap do |opts|
30
- opts[:proxy_address] = _proxy.host
31
- opts[:proxy_port] = _proxy.port
32
- opts[:proxy_username] = _proxy.user if _proxy.user
33
- opts[:proxy_password] = _proxy.password if _proxy.password
34
- end
35
- else
36
- @proxy
37
- end
38
- end
39
-
40
- end
@@ -7,6 +7,17 @@ module Batali
7
7
 
8
8
  class Metadata < AttributeStruct
9
9
 
10
+ # Perform constant lookup if required
11
+ #
12
+ # @return [Constant]
13
+ def self.const_missing(const)
14
+ [::Object, ::ObjectSpace].map do |root|
15
+ if(root.const_defined?(const))
16
+ root.const_get(const)
17
+ end
18
+ end.compact.first || super
19
+ end
20
+
10
21
  def depends(*args)
11
22
  set!(:depends, args)
12
23
  self
@@ -67,13 +78,7 @@ module Batali
67
78
  elsif(File.exists?(rb = File.join(path, 'metadata.rb')))
68
79
  struct = Metadata.new
69
80
  struct.set_state!(:value_collapse => true)
70
- File.readlines(rb).find_all do |line|
71
- line.start_with?('name') ||
72
- line.start_with?('version') ||
73
- line.start_with?('depends')
74
- end.each do |line|
75
- struct.instance_eval(line)
76
- end
81
+ struct.instance_eval(File.read(rb), rb, 1)
77
82
  struct._dump.to_smash
78
83
  else
79
84
  raise Errno::ENOENT.new("Failed to locate metadata file in cookbook directory! (path: #{path})")
@@ -10,7 +10,7 @@ module Batali
10
10
 
11
11
  include Bogo::Memoization
12
12
 
13
- attribute :path, String, :required => true
13
+ attribute :path, String, :required => true, :equivalent => true
14
14
 
15
15
  # @return [String] directory containing contents
16
16
  def asset
@@ -18,8 +18,8 @@ module Batali
18
18
  # @return [String] local cache path
19
19
  attr_accessor :cache
20
20
 
21
- attribute :url, String, :required => true
22
- attribute :version, String, :required => true
21
+ attribute :url, String, :required => true, :equivalent => true
22
+ attribute :version, String, :required => true, :equivalent => true
23
23
 
24
24
  # Extract extra info before allowing super to load data
25
25
  #
data/lib/batali/source.rb CHANGED
@@ -39,6 +39,32 @@ module Batali
39
39
  end
40
40
  end
41
41
 
42
+ # @return [TrueClass, FalseClass]
43
+ def ==(s)
44
+ s.is_a?(Source) && attributes.map do |key, attr|
45
+ key if attr[:equivalent]
46
+ end.compact.all? do |key|
47
+ attributes[key] == s.attributes[key]
48
+ end
49
+ end
50
+
51
+ # Detect differences in equivalency
52
+ #
53
+ # @param s [Source]
54
+ # @return [Smash]
55
+ def diff(s)
56
+ Smash.new.tap do |_diff|
57
+ self.class.attributes.each do |k,v|
58
+ if(v[:equivalent])
59
+ s_attrs = s.respond_to?(:attributes) ? s.attributes : {}
60
+ unless(attributes[k] == s_attrs[k])
61
+ _diff[k] = [attributes[k], s_attrs[k]]
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+
42
68
  # Build a source
43
69
  #
44
70
  # @param args [Hash]
data/lib/batali/unit.rb CHANGED
@@ -3,8 +3,33 @@ require 'batali'
3
3
  module Batali
4
4
  # Customized Unit
5
5
  class Unit < Grimoire::Unit
6
- attribute :source, Source, :required => true, :coerce => lambda{|v| Batali::Source.build(v)}
6
+ attribute :source, Source, :coerce => lambda{|v| Batali::Source.build(v)}
7
7
  attribute :dependencies, [Batali::UnitDependency, Grimoire::DEPENDENCY_CLASS], :multiple => true, :default => [], :coerce => lambda{|val| Batali::UnitDependency.new(val.first, *val.last)}
8
8
  attribute :version, [Batali::UnitVersion, Grimoire::VERSION_CLASS], :required => true, :coerce => lambda{|val| Batali::UnitVersion.new(val)}
9
+
10
+ # @return [TrueClass, FalseClass]
11
+ def diff?(u)
12
+ !same?(u)
13
+ end
14
+
15
+ # @return [TrueClass, FalseClass]
16
+ def same?(u)
17
+ diff(u).empty?
18
+ end
19
+
20
+ # @return [String] difference output
21
+ def diff(u)
22
+ Smash.new.tap do |_diff|
23
+ [:name, :version].each do |k|
24
+ unless(self.send(k) == u.send(k))
25
+ _diff[k] = [self.send(k), u.send(k)]
26
+ end
27
+ end
28
+ if(source)
29
+ _diff.merge!(source.diff(u.source))
30
+ end
31
+ end
32
+ end
33
+
9
34
  end
10
35
  end
@@ -1,4 +1,4 @@
1
1
  module Batali
2
2
  # Current version
3
- VERSION = Gem::Version.new('0.2.8')
3
+ VERSION = Gem::Version.new('0.2.10')
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.2.8
4
+ version: 0.2.10
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-16 00:00:00.000000000 Z
11
+ date: 2015-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: attribute_struct
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.2.1
33
+ version: 0.2.3
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.1
40
+ version: 0.2.3
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.18
47
+ version: 0.1.20
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.18
54
+ version: 0.1.20
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bogo-cli
57
57
  requirement: !ruby/object:Gem::Requirement