librarian-puppet 0.0.1.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. data/.gitignore +1 -0
  2. data/LICENSE +20 -0
  3. data/README.md +0 -0
  4. data/bin/librarian-puppet +9 -0
  5. data/lib/librarian/puppet.rb +7 -0
  6. data/lib/librarian/puppet/cli.rb +30 -0
  7. data/lib/librarian/puppet/dsl.rb +14 -0
  8. data/lib/librarian/puppet/environment.rb +18 -0
  9. data/lib/librarian/puppet/extension.rb +9 -0
  10. data/lib/librarian/puppet/source.rb +2 -0
  11. data/lib/librarian/puppet/source/git.rb +12 -0
  12. data/lib/librarian/puppet/source/local.rb +46 -0
  13. data/lib/librarian/puppet/source/path.rb +12 -0
  14. data/lib/librarian/puppet/templates/Puppetfile +6 -0
  15. data/librarian-puppet.gemspec +126 -0
  16. data/vendor/librarian/.rspec +1 -0
  17. data/vendor/librarian/.travis.yml +6 -0
  18. data/vendor/librarian/CHANGELOG.md +168 -0
  19. data/vendor/librarian/Gemfile +4 -0
  20. data/vendor/librarian/MIT-LICENSE +20 -0
  21. data/vendor/librarian/README.md +318 -0
  22. data/vendor/librarian/Rakefile +34 -0
  23. data/vendor/librarian/bin/librarian-chef +7 -0
  24. data/vendor/librarian/bin/librarian-mock +7 -0
  25. data/vendor/librarian/config/cucumber.yaml +1 -0
  26. data/vendor/librarian/features/chef/cli/init.feature +10 -0
  27. data/vendor/librarian/features/chef/cli/install.feature +64 -0
  28. data/vendor/librarian/features/chef/cli/show.feature +65 -0
  29. data/vendor/librarian/features/chef/cli/version.feature +11 -0
  30. data/vendor/librarian/features/support/env.rb +9 -0
  31. data/vendor/librarian/lib/librarian.rb +19 -0
  32. data/vendor/librarian/lib/librarian/action.rb +5 -0
  33. data/vendor/librarian/lib/librarian/action/base.rb +22 -0
  34. data/vendor/librarian/lib/librarian/action/clean.rb +44 -0
  35. data/vendor/librarian/lib/librarian/action/ensure.rb +24 -0
  36. data/vendor/librarian/lib/librarian/action/install.rb +95 -0
  37. data/vendor/librarian/lib/librarian/action/resolve.rb +81 -0
  38. data/vendor/librarian/lib/librarian/action/update.rb +78 -0
  39. data/vendor/librarian/lib/librarian/chef.rb +1 -0
  40. data/vendor/librarian/lib/librarian/chef/cli.rb +27 -0
  41. data/vendor/librarian/lib/librarian/chef/dsl.rb +15 -0
  42. data/vendor/librarian/lib/librarian/chef/environment.rb +19 -0
  43. data/vendor/librarian/lib/librarian/chef/extension.rb +9 -0
  44. data/vendor/librarian/lib/librarian/chef/integration/knife.rb +42 -0
  45. data/vendor/librarian/lib/librarian/chef/manifest_reader.rb +47 -0
  46. data/vendor/librarian/lib/librarian/chef/source.rb +3 -0
  47. data/vendor/librarian/lib/librarian/chef/source/git.rb +12 -0
  48. data/vendor/librarian/lib/librarian/chef/source/local.rb +63 -0
  49. data/vendor/librarian/lib/librarian/chef/source/path.rb +12 -0
  50. data/vendor/librarian/lib/librarian/chef/source/site.rb +434 -0
  51. data/vendor/librarian/lib/librarian/chef/templates/Cheffile +15 -0
  52. data/vendor/librarian/lib/librarian/cli.rb +175 -0
  53. data/vendor/librarian/lib/librarian/cli/manifest_presenter.rb +79 -0
  54. data/vendor/librarian/lib/librarian/dependency.rb +95 -0
  55. data/vendor/librarian/lib/librarian/dsl.rb +105 -0
  56. data/vendor/librarian/lib/librarian/dsl/receiver.rb +48 -0
  57. data/vendor/librarian/lib/librarian/dsl/target.rb +176 -0
  58. data/vendor/librarian/lib/librarian/environment.rb +129 -0
  59. data/vendor/librarian/lib/librarian/error.rb +4 -0
  60. data/vendor/librarian/lib/librarian/helpers.rb +13 -0
  61. data/vendor/librarian/lib/librarian/helpers/debug.rb +35 -0
  62. data/vendor/librarian/lib/librarian/lockfile.rb +33 -0
  63. data/vendor/librarian/lib/librarian/lockfile/compiler.rb +70 -0
  64. data/vendor/librarian/lib/librarian/lockfile/parser.rb +104 -0
  65. data/vendor/librarian/lib/librarian/manifest.rb +140 -0
  66. data/vendor/librarian/lib/librarian/manifest_set.rb +153 -0
  67. data/vendor/librarian/lib/librarian/mock.rb +1 -0
  68. data/vendor/librarian/lib/librarian/mock/cli.rb +19 -0
  69. data/vendor/librarian/lib/librarian/mock/dsl.rb +15 -0
  70. data/vendor/librarian/lib/librarian/mock/environment.rb +24 -0
  71. data/vendor/librarian/lib/librarian/mock/extension.rb +9 -0
  72. data/vendor/librarian/lib/librarian/mock/source.rb +1 -0
  73. data/vendor/librarian/lib/librarian/mock/source/mock.rb +97 -0
  74. data/vendor/librarian/lib/librarian/mock/source/mock/registry.rb +83 -0
  75. data/vendor/librarian/lib/librarian/resolution.rb +44 -0
  76. data/vendor/librarian/lib/librarian/resolver.rb +73 -0
  77. data/vendor/librarian/lib/librarian/resolver/implementation.rb +122 -0
  78. data/vendor/librarian/lib/librarian/source.rb +2 -0
  79. data/vendor/librarian/lib/librarian/source/git.rb +150 -0
  80. data/vendor/librarian/lib/librarian/source/git/repository.rb +213 -0
  81. data/vendor/librarian/lib/librarian/source/local.rb +51 -0
  82. data/vendor/librarian/lib/librarian/source/path.rb +74 -0
  83. data/vendor/librarian/lib/librarian/spec.rb +13 -0
  84. data/vendor/librarian/lib/librarian/spec_change_set.rb +170 -0
  85. data/vendor/librarian/lib/librarian/specfile.rb +22 -0
  86. data/vendor/librarian/lib/librarian/support/abstract_method.rb +21 -0
  87. data/vendor/librarian/lib/librarian/ui.rb +64 -0
  88. data/vendor/librarian/lib/librarian/version.rb +3 -0
  89. data/vendor/librarian/librarian.gemspec +33 -0
  90. data/vendor/librarian/spec/functional/chef/source/git_spec.rb +432 -0
  91. data/vendor/librarian/spec/functional/chef/source/site_spec.rb +215 -0
  92. data/vendor/librarian/spec/unit/action/base_spec.rb +18 -0
  93. data/vendor/librarian/spec/unit/action/clean_spec.rb +102 -0
  94. data/vendor/librarian/spec/unit/action/ensure_spec.rb +37 -0
  95. data/vendor/librarian/spec/unit/action/install_spec.rb +111 -0
  96. data/vendor/librarian/spec/unit/dependency_spec.rb +30 -0
  97. data/vendor/librarian/spec/unit/dsl_spec.rb +194 -0
  98. data/vendor/librarian/spec/unit/environment_spec.rb +9 -0
  99. data/vendor/librarian/spec/unit/lockfile/parser_spec.rb +162 -0
  100. data/vendor/librarian/spec/unit/lockfile_spec.rb +65 -0
  101. data/vendor/librarian/spec/unit/manifest_set_spec.rb +202 -0
  102. data/vendor/librarian/spec/unit/manifest_spec.rb +30 -0
  103. data/vendor/librarian/spec/unit/mock/source/mock_spec.rb +22 -0
  104. data/vendor/librarian/spec/unit/resolver_spec.rb +192 -0
  105. data/vendor/librarian/spec/unit/source/git_spec.rb +29 -0
  106. data/vendor/librarian/spec/unit/spec_change_set_spec.rb +169 -0
  107. metadata +163 -0
@@ -0,0 +1,65 @@
1
+ Feature: cli/show
2
+
3
+
4
+
5
+ Background: A simple Cheffile with one cookbook with one dependency
6
+ Given a file named "cookbook-sources/main/metadata.yaml" with:
7
+ """
8
+ name: main
9
+ version: 1.0.0
10
+ dependencies:
11
+ sub: 1.0.0
12
+ """
13
+ Given a file named "cookbook-sources/sub/metadata.yaml" with:
14
+ """
15
+ name: sub
16
+ version: 1.0.0
17
+ dependencies: {}
18
+ """
19
+ Given a file named "Cheffile" with:
20
+ """
21
+ path 'cookbook-sources'
22
+ cookbook 'main'
23
+ """
24
+ Given I run `librarian-chef install`
25
+
26
+
27
+
28
+ Scenario: Showing all
29
+ When I run `librarian-chef show`
30
+ Then the exit status should be 0
31
+ Then the output should contain exactly:
32
+ """
33
+ main (1.0.0)
34
+ sub (1.0.0)
35
+
36
+ """
37
+
38
+
39
+
40
+ Scenario: Showing one without dependencies
41
+ When I run `librarian-chef show sub`
42
+ Then the exit status should be 0
43
+ Then the output should contain exactly:
44
+ """
45
+ sub (1.0.0)
46
+ source: cookbook-sources
47
+
48
+ """
49
+
50
+
51
+
52
+ Scenario: Showing one with dependencies
53
+ When I run `librarian-chef show main`
54
+ Then the exit status should be 0
55
+ Then the output should contain exactly:
56
+ """
57
+ main (1.0.0)
58
+ source: cookbook-sources
59
+ dependencies:
60
+ sub (= 1.0.0)
61
+
62
+ """
63
+
64
+
65
+
@@ -0,0 +1,11 @@
1
+ Feature: cli/version
2
+
3
+
4
+
5
+ Scenario: Getting the version
6
+ When I run `librarian-chef version`
7
+ Then the exit status should be 0
8
+ And the output should contain "librarian-"
9
+
10
+
11
+
@@ -0,0 +1,9 @@
1
+ require 'aruba/cucumber'
2
+
3
+ Before do
4
+ slow_boot = false
5
+ slow_boot ||= RUBY_PLATFORM == "java"
6
+ slow_boot ||= defined?(::Rubinius)
7
+
8
+ @aruba_timeout_seconds = slow_boot ? 5 : 2
9
+ end
@@ -0,0 +1,19 @@
1
+ require 'librarian/version'
2
+ require 'librarian/environment'
3
+
4
+ module Librarian
5
+ extend self
6
+
7
+ def environment_class
8
+ self::Environment
9
+ end
10
+
11
+ def environment
12
+ @environment ||= environment_class.new
13
+ end
14
+
15
+ def version
16
+ VERSION
17
+ end
18
+
19
+ end
@@ -0,0 +1,5 @@
1
+ require "librarian/action/clean"
2
+ require "librarian/action/ensure"
3
+ require "librarian/action/install"
4
+ require "librarian/action/resolve"
5
+ require "librarian/action/update"
@@ -0,0 +1,22 @@
1
+ require "librarian/helpers/debug"
2
+
3
+ module Librarian
4
+ module Action
5
+ class Base
6
+
7
+ include Helpers::Debug
8
+
9
+ attr_accessor :environment
10
+ private :environment=
11
+
12
+ attr_accessor :options
13
+ private :options=
14
+
15
+ def initialize(environment, options = { })
16
+ self.environment = environment
17
+ self.options = options
18
+ end
19
+
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,44 @@
1
+ require "librarian/action/base"
2
+
3
+ module Librarian
4
+ module Action
5
+ class Clean < Base
6
+
7
+ def run
8
+ clean_cache_path
9
+ clean_install_path
10
+ end
11
+
12
+ private
13
+
14
+ def clean_cache_path
15
+ if cache_path.exist?
16
+ debug { "Deleting #{project_relative_path_to(cache_path)}" }
17
+ cache_path.rmtree
18
+ end
19
+ end
20
+
21
+ def clean_install_path
22
+ if install_path.exist?
23
+ install_path.children.each do |c|
24
+ debug { "Deleting #{project_relative_path_to(c)}" }
25
+ c.rmtree unless c.file?
26
+ end
27
+ end
28
+ end
29
+
30
+ def cache_path
31
+ environment.cache_path
32
+ end
33
+
34
+ def install_path
35
+ environment.install_path
36
+ end
37
+
38
+ def project_relative_path_to(path)
39
+ environment.project_relative_path_to(path)
40
+ end
41
+
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,24 @@
1
+ require "librarian/error"
2
+ require "librarian/action/base"
3
+
4
+ module Librarian
5
+ module Action
6
+ class Ensure < Base
7
+
8
+ def run
9
+ raise Error, "Cannot find #{specfile_name}!" unless project_path
10
+ end
11
+
12
+ private
13
+
14
+ def specfile_name
15
+ environment.specfile_name
16
+ end
17
+
18
+ def project_path
19
+ environment.project_path
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,95 @@
1
+ require "librarian/manifest_set"
2
+ require "librarian/spec_change_set"
3
+ require "librarian/action/base"
4
+
5
+ module Librarian
6
+ module Action
7
+ class Install < Base
8
+
9
+ def run
10
+ check_preconditions
11
+
12
+ perform_installation
13
+ end
14
+
15
+ private
16
+
17
+ def check_preconditions
18
+ check_specfile
19
+ check_lockfile
20
+ check_consistent
21
+ end
22
+
23
+ def check_specfile
24
+ raise Error, "#{specfile_name} missing!" unless specfile_path.exist?
25
+ end
26
+
27
+ def check_lockfile
28
+ raise Error, "#{lockfile_name} missing!" unless lockfile_path.exist?
29
+ end
30
+
31
+ def check_consistent
32
+ raise Error, "#{specfile_name} and #{lockfile_name} are out of sync!" unless spec_consistent_with_lock?
33
+ end
34
+
35
+ def perform_installation
36
+ manifests = sorted_manifests
37
+
38
+ create_install_path
39
+ install_manifests(manifests)
40
+ end
41
+
42
+ def create_install_path
43
+ install_path.rmtree if install_path.exist?
44
+ install_path.mkpath
45
+ end
46
+
47
+ def install_manifests(manifests)
48
+ manifests.each do |manifest|
49
+ manifest.install!
50
+ end
51
+ end
52
+
53
+ def sorted_manifests
54
+ ManifestSet.sort(lock.manifests)
55
+ end
56
+
57
+ def specfile_name
58
+ environment.specfile_name
59
+ end
60
+
61
+ def specfile_path
62
+ environment.specfile_path
63
+ end
64
+
65
+ def lockfile_name
66
+ environment.lockfile_name
67
+ end
68
+
69
+ def lockfile_path
70
+ environment.lockfile_path
71
+ end
72
+
73
+ def spec
74
+ environment.spec
75
+ end
76
+
77
+ def lock
78
+ environment.lock
79
+ end
80
+
81
+ def spec_change_set(spec, lock)
82
+ SpecChangeSet.new(environment, spec, lock)
83
+ end
84
+
85
+ def spec_consistent_with_lock?
86
+ spec_change_set(spec, lock).same?
87
+ end
88
+
89
+ def install_path
90
+ environment.install_path
91
+ end
92
+
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,81 @@
1
+ require "librarian/error"
2
+ require "librarian/resolver"
3
+ require "librarian/spec_change_set"
4
+ require "librarian/action/base"
5
+
6
+ module Librarian
7
+ module Action
8
+ class Resolve < Base
9
+
10
+ def run
11
+ if force? || !lockfile_path.exist?
12
+ spec = specfile.read
13
+ manifests = []
14
+ else
15
+ lock = lockfile.read
16
+ spec = specfile.read(lock.sources)
17
+ changes = spec_change_set(spec, lock)
18
+ if changes.same?
19
+ debug { "The specfile is unchanged: nothing to do." }
20
+ return
21
+ end
22
+ manifests = changes.analyze
23
+ end
24
+
25
+ resolution = resolver.resolve(spec, manifests)
26
+ unless resolution.correct?
27
+ raise Error, "Could not resolve the dependencies."
28
+ else
29
+ lockfile_text = lockfile.save(resolution)
30
+ debug { "Bouncing #{lockfile_name}" }
31
+ bounced_lockfile_text = lockfile.save(lockfile.load(lockfile_text))
32
+ unless bounced_lockfile_text == lockfile_text
33
+ debug { "lockfile_text: \n#{lockfile_text}"}
34
+ debug { "bounced_lockfile_text: \n#{bounced_lockfile_text}"}
35
+ raise Error, "Cannot bounce #{lockfile_name}!"
36
+ end
37
+ lockfile_path.open('wb') { |f| f.write(lockfile_text) }
38
+ end
39
+ end
40
+
41
+ private
42
+
43
+ def force?
44
+ options[:force]
45
+ end
46
+
47
+ def specfile_name
48
+ environment.specfile_name
49
+ end
50
+
51
+ def lockfile_name
52
+ environment.lockfile_name
53
+ end
54
+
55
+ def specfile_path
56
+ environment.specfile_path
57
+ end
58
+
59
+ def lockfile_path
60
+ environment.lockfile_path
61
+ end
62
+
63
+ def specfile
64
+ environment.specfile
65
+ end
66
+
67
+ def lockfile
68
+ environment.lockfile
69
+ end
70
+
71
+ def resolver
72
+ Resolver.new(environment)
73
+ end
74
+
75
+ def spec_change_set(spec, lock)
76
+ SpecChangeSet.new(environment, spec, lock)
77
+ end
78
+
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,78 @@
1
+ require "librarian/error"
2
+ require "librarian/manifest_set"
3
+ require "librarian/resolver"
4
+ require "librarian/spec_change_set"
5
+ require "librarian/action/base"
6
+
7
+ module Librarian
8
+ module Action
9
+ class Update < Base
10
+
11
+ def run
12
+ unless lockfile_path.exist?
13
+ raise Error, "Lockfile missing!"
14
+ end
15
+ previous_resolution = lockfile.load(lockfile_path.read)
16
+ spec = specfile.read(previous_resolution.sources)
17
+ changes = spec_change_set(spec, previous_resolution)
18
+ manifests = changes.same? ? previous_resolution.manifests : changes.analyze
19
+ partial_manifests = ManifestSet.deep_strip(manifests, dependency_names)
20
+ unpinnable_sources = previous_resolution.sources - partial_manifests.map(&:source)
21
+ unpinnable_sources.each(&:unpin!)
22
+ resolution = resolver.resolve(spec, partial_manifests)
23
+ unless resolution.correct?
24
+ raise Error, "Could not resolve the dependencies."
25
+ else
26
+ lockfile_text = lockfile.save(resolution)
27
+ debug { "Bouncing #{lockfile_name}" }
28
+ bounced_lockfile_text = lockfile.save(lockfile.load(lockfile_text))
29
+ unless bounced_lockfile_text == lockfile_text
30
+ debug { "lockfile_text: \n#{lockfile_text}"}
31
+ debug { "bounced_lockfile_text: \n#{bounced_lockfile_text}"}
32
+ raise Error, "Cannot bounce #{lockfile_name}!"
33
+ end
34
+ lockfile_path.open('wb') { |f| f.write(lockfile_text) }
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ def dependency_names
41
+ options[:names]
42
+ end
43
+
44
+ def specfile_name
45
+ environment.specfile_name
46
+ end
47
+
48
+ def lockfile_name
49
+ environment.lockfile_name
50
+ end
51
+
52
+ def specfile_path
53
+ environment.specfile_path
54
+ end
55
+
56
+ def lockfile_path
57
+ environment.lockfile_path
58
+ end
59
+
60
+ def specfile
61
+ environment.specfile
62
+ end
63
+
64
+ def lockfile
65
+ environment.lockfile
66
+ end
67
+
68
+ def resolver
69
+ Resolver.new(environment)
70
+ end
71
+
72
+ def spec_change_set(spec, lock)
73
+ SpecChangeSet.new(environment, spec, lock)
74
+ end
75
+
76
+ end
77
+ end
78
+ end