berks-monolith 0.1.1 → 0.1.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/lib/monolith/berksfile.rb +5 -6
- data/lib/monolith/commands.rb +11 -0
- data/lib/monolith/locations/base.rb +1 -1
- data/lib/monolith/version.rb +1 -1
- data/test/helpers.rb +15 -0
- data/test/test_command_install.rb +9 -0
- data/test/test_gitlocation.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2467dd678de12d92c13cd15cd01c8446a4287e93
|
4
|
+
data.tar.gz: 3598971b6b6efb4b22ba4dfc9814e3a4ec169182
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c0dda7234dc134eddbdb583af9e8be15d126245f9c44434e1fcc1801f70e0b6e7a7d5263ae94a1a54bfcb84ca4facfa7bd655bebb6f911880fafbeda94b3bdf
|
7
|
+
data.tar.gz: eca5fac133ef4ddf15d52bfb363647eb5d356eeccd4f5925d10f64630d20e449045c14580f8c303fe7e4c06b85865ef5d5281c4c9b4821fb61e1f6e2ce06413f
|
data/lib/monolith/berksfile.rb
CHANGED
@@ -4,6 +4,7 @@ require 'fileutils'
|
|
4
4
|
module Monolith
|
5
5
|
class Berksfile
|
6
6
|
attr_reader :berksfile
|
7
|
+
attr_reader :cached_cookbooks
|
7
8
|
|
8
9
|
def initialize(options)
|
9
10
|
Berkshelf.ui.mute! if Monolith.formatter.quiet
|
@@ -20,7 +21,7 @@ module Monolith
|
|
20
21
|
# copy. However, it's not needed for other commands, so it separated out
|
21
22
|
# here.
|
22
23
|
def install
|
23
|
-
@berksfile.install
|
24
|
+
@cached_cookbooks = @berksfile.install
|
24
25
|
end
|
25
26
|
|
26
27
|
# Retrieve all cookbooks listed in the berksfile.
|
@@ -28,15 +29,13 @@ module Monolith
|
|
28
29
|
# Can take a block to do something with each cookbook.
|
29
30
|
def cookbooks(path)
|
30
31
|
FileUtils.mkdir_p(path)
|
31
|
-
cached_cookbooks = @
|
32
|
+
cached_cookbooks = @cached_cookbooks
|
32
33
|
if block_given?
|
33
34
|
cached_cookbooks.each do |cookbook|
|
34
35
|
destination = File.join(File.expand_path(path),
|
35
36
|
cookbook.cookbook_name)
|
36
37
|
dep = berksfile.get_dependency(cookbook.cookbook_name)
|
37
|
-
|
38
|
-
yield cookbook, dep, destination
|
39
|
-
end
|
38
|
+
yield cookbook, dep, destination
|
40
39
|
end
|
41
40
|
end
|
42
41
|
cached_cookbooks
|
@@ -54,7 +53,7 @@ module Monolith
|
|
54
53
|
# Feteches the appropriate monolith location object for a given cookbook
|
55
54
|
# dependency. I.e. Monolith::FooLocation.
|
56
55
|
def monolith_obj(cookbook, dep, destination)
|
57
|
-
if dep.location.nil?
|
56
|
+
if dep.nil? or dep.location.nil?
|
58
57
|
Monolith::DefaultLocation.new(cookbook, dep, destination)
|
59
58
|
else
|
60
59
|
klass = dep.location.class.name.split('::')[-1]
|
data/lib/monolith/commands.rb
CHANGED
@@ -2,6 +2,7 @@ require 'thor'
|
|
2
2
|
require 'monolith/berksfile'
|
3
3
|
require 'monolith/formatter'
|
4
4
|
require 'monolith/gitexclude'
|
5
|
+
require 'monolith/version'
|
5
6
|
|
6
7
|
module Monolith
|
7
8
|
class Command < Thor
|
@@ -52,6 +53,7 @@ module Monolith
|
|
52
53
|
desc 'update [PATH]', 'Update all cloned cookbooks'
|
53
54
|
def update(path = File.join(Dir.pwd, "cookbooks"))
|
54
55
|
berksfile = Monolith::Berksfile.new(options.dup)
|
56
|
+
berksfile.install # We need to run berks install first
|
55
57
|
berksfile.cookbooks(path) do |cookbook, dep, destination|
|
56
58
|
berksfile.monolith_action(:update, cookbook, dep, destination)
|
57
59
|
end
|
@@ -60,6 +62,10 @@ module Monolith
|
|
60
62
|
desc 'clean [PATH]', 'Delete all cloned cookbooks'
|
61
63
|
def clean(path = File.join(Dir.pwd, "cookbooks"))
|
62
64
|
berksfile = Monolith::Berksfile.new(options.dup)
|
65
|
+
# This is counter-intuitive given we're actually getting rid of the
|
66
|
+
# cookbooks. This performs the dependency resolution needed to work out
|
67
|
+
# what we need to remove.
|
68
|
+
berksfile.install
|
63
69
|
gitpath = File.expand_path('../.git', berksfile.berksfile.filepath)
|
64
70
|
gitexclude = GitExclude.new(gitpath, options)
|
65
71
|
berksfile.cookbooks(path) do |cookbook, dep, destination|
|
@@ -68,5 +74,10 @@ module Monolith
|
|
68
74
|
end
|
69
75
|
gitexclude.update
|
70
76
|
end
|
77
|
+
|
78
|
+
desc 'version', 'Print the version of berks-monlith'
|
79
|
+
def version
|
80
|
+
puts Monolith::VERSION
|
81
|
+
end
|
71
82
|
end
|
72
83
|
end
|
data/lib/monolith/version.rb
CHANGED
data/test/helpers.rb
CHANGED
@@ -70,6 +70,13 @@ module Monolith
|
|
70
70
|
elsif type == :path
|
71
71
|
cb_path = make_path_cookbook('test_path')
|
72
72
|
berksfile.puts("cookbook 'test_path', :path => '#{cb_path}'")
|
73
|
+
elsif type == :nested_community
|
74
|
+
cb_path = make_path_cookbook('test_nested')
|
75
|
+
berksfile.puts("cookbook 'test_nested', :path => '#{cb_path}'")
|
76
|
+
# Note: testmh is an arbitrary cookbook that exists on
|
77
|
+
# supermarket, and could be replaced by any other cookbook as long
|
78
|
+
# as the tests are updated appropriately.
|
79
|
+
add_metadata_dependency(cb_path, 'testmh')
|
73
80
|
end
|
74
81
|
end
|
75
82
|
end
|
@@ -80,5 +87,13 @@ module Monolith
|
|
80
87
|
end
|
81
88
|
end
|
82
89
|
end
|
90
|
+
|
91
|
+
def add_metadata_dependency(cookbook_path, cookbook_name)
|
92
|
+
Dir.chdir(cookbook_path) do
|
93
|
+
File.open('metadata.rb', 'a') do |f|
|
94
|
+
f.puts "depends '#{cookbook_name}'"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
83
98
|
end
|
84
99
|
end
|
@@ -22,4 +22,13 @@ class TestCommandInstall < MiniTest::Test
|
|
22
22
|
assert File.exist?("cookbooks/test_git/.git")
|
23
23
|
end
|
24
24
|
end
|
25
|
+
|
26
|
+
def test_nested_dependencies
|
27
|
+
make_berksfile([:nested_community]) do
|
28
|
+
Monolith::Command.start(['install', '-q'])
|
29
|
+
assert File.exist?("cookbooks/test_nested")
|
30
|
+
assert File.exist?("cookbooks/test_nested/metadata.rb")
|
31
|
+
assert File.exist?("cookbooks/testmh")
|
32
|
+
end
|
33
|
+
end
|
25
34
|
end
|
data/test/test_gitlocation.rb
CHANGED
@@ -35,6 +35,7 @@ class TestGitLocation < MiniTest::Test
|
|
35
35
|
@mock_cookbook.expect :cookbook_name, @test_cookbook
|
36
36
|
@mock_dep = Minitest::Mock.new
|
37
37
|
@mock_dep.expect :location, nil
|
38
|
+
@mock_dep.expect :nil?, false
|
38
39
|
location = Monolith::GitLocation.new(@mock_cookbook, @mock_dep,
|
39
40
|
@mock_destination)
|
40
41
|
location.stub(:cache_path, @mock_cache) do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: berks-monolith
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Harrison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: berkshelf
|