librarian-puppet-maestrodev 0.9.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. data/.gitignore +3 -0
  2. data/LICENSE +20 -0
  3. data/README.md +187 -0
  4. data/bin/librarian-puppet +9 -0
  5. data/lib/librarian/puppet.rb +13 -0
  6. data/lib/librarian/puppet/cli.rb +85 -0
  7. data/lib/librarian/puppet/dsl.rb +16 -0
  8. data/lib/librarian/puppet/environment.rb +54 -0
  9. data/lib/librarian/puppet/extension.rb +41 -0
  10. data/lib/librarian/puppet/lockfile/parser.rb +53 -0
  11. data/lib/librarian/puppet/source.rb +4 -0
  12. data/lib/librarian/puppet/source/forge.rb +279 -0
  13. data/lib/librarian/puppet/source/git.rb +114 -0
  14. data/lib/librarian/puppet/source/githubtarball.rb +234 -0
  15. data/lib/librarian/puppet/source/local.rb +57 -0
  16. data/lib/librarian/puppet/source/path.rb +12 -0
  17. data/lib/librarian/puppet/templates/Puppetfile +10 -0
  18. data/lib/librarian/puppet/version.rb +5 -0
  19. data/vendor/librarian/CHANGELOG.md +185 -0
  20. data/vendor/librarian/Gemfile +6 -0
  21. data/vendor/librarian/MIT-LICENSE +20 -0
  22. data/vendor/librarian/README.md +403 -0
  23. data/vendor/librarian/Rakefile +34 -0
  24. data/vendor/librarian/bin/librarian-chef +7 -0
  25. data/vendor/librarian/bin/librarian-mock +7 -0
  26. data/vendor/librarian/config/cucumber.yaml +1 -0
  27. data/vendor/librarian/features/chef/cli/init.feature +11 -0
  28. data/vendor/librarian/features/chef/cli/install.feature +64 -0
  29. data/vendor/librarian/features/chef/cli/show.feature +77 -0
  30. data/vendor/librarian/features/chef/cli/version.feature +11 -0
  31. data/vendor/librarian/features/support/env.rb +9 -0
  32. data/vendor/librarian/lib/librarian.rb +19 -0
  33. data/vendor/librarian/lib/librarian/action.rb +5 -0
  34. data/vendor/librarian/lib/librarian/action/base.rb +24 -0
  35. data/vendor/librarian/lib/librarian/action/clean.rb +44 -0
  36. data/vendor/librarian/lib/librarian/action/ensure.rb +24 -0
  37. data/vendor/librarian/lib/librarian/action/install.rb +99 -0
  38. data/vendor/librarian/lib/librarian/action/resolve.rb +81 -0
  39. data/vendor/librarian/lib/librarian/action/update.rb +78 -0
  40. data/vendor/librarian/lib/librarian/chef.rb +1 -0
  41. data/vendor/librarian/lib/librarian/chef/cli.rb +48 -0
  42. data/vendor/librarian/lib/librarian/chef/dsl.rb +15 -0
  43. data/vendor/librarian/lib/librarian/chef/environment.rb +27 -0
  44. data/vendor/librarian/lib/librarian/chef/extension.rb +9 -0
  45. data/vendor/librarian/lib/librarian/chef/integration/knife.rb +42 -0
  46. data/vendor/librarian/lib/librarian/chef/manifest_reader.rb +59 -0
  47. data/vendor/librarian/lib/librarian/chef/source.rb +3 -0
  48. data/vendor/librarian/lib/librarian/chef/source/git.rb +25 -0
  49. data/vendor/librarian/lib/librarian/chef/source/local.rb +69 -0
  50. data/vendor/librarian/lib/librarian/chef/source/path.rb +12 -0
  51. data/vendor/librarian/lib/librarian/chef/source/site.rb +446 -0
  52. data/vendor/librarian/lib/librarian/chef/templates/Cheffile +15 -0
  53. data/vendor/librarian/lib/librarian/cli.rb +205 -0
  54. data/vendor/librarian/lib/librarian/cli/manifest_presenter.rb +79 -0
  55. data/vendor/librarian/lib/librarian/config.rb +7 -0
  56. data/vendor/librarian/lib/librarian/config/database.rb +205 -0
  57. data/vendor/librarian/lib/librarian/config/file_source.rb +47 -0
  58. data/vendor/librarian/lib/librarian/config/hash_source.rb +33 -0
  59. data/vendor/librarian/lib/librarian/config/source.rb +149 -0
  60. data/vendor/librarian/lib/librarian/dependency.rb +91 -0
  61. data/vendor/librarian/lib/librarian/dsl.rb +108 -0
  62. data/vendor/librarian/lib/librarian/dsl/receiver.rb +48 -0
  63. data/vendor/librarian/lib/librarian/dsl/target.rb +172 -0
  64. data/vendor/librarian/lib/librarian/environment.rb +134 -0
  65. data/vendor/librarian/lib/librarian/error.rb +4 -0
  66. data/vendor/librarian/lib/librarian/helpers.rb +13 -0
  67. data/vendor/librarian/lib/librarian/lockfile.rb +29 -0
  68. data/vendor/librarian/lib/librarian/lockfile/compiler.rb +66 -0
  69. data/vendor/librarian/lib/librarian/lockfile/parser.rb +100 -0
  70. data/vendor/librarian/lib/librarian/logger.rb +46 -0
  71. data/vendor/librarian/lib/librarian/manifest.rb +132 -0
  72. data/vendor/librarian/lib/librarian/manifest_set.rb +153 -0
  73. data/vendor/librarian/lib/librarian/mock.rb +1 -0
  74. data/vendor/librarian/lib/librarian/mock/cli.rb +19 -0
  75. data/vendor/librarian/lib/librarian/mock/dsl.rb +15 -0
  76. data/vendor/librarian/lib/librarian/mock/environment.rb +24 -0
  77. data/vendor/librarian/lib/librarian/mock/extension.rb +9 -0
  78. data/vendor/librarian/lib/librarian/mock/source.rb +1 -0
  79. data/vendor/librarian/lib/librarian/mock/source/mock.rb +97 -0
  80. data/vendor/librarian/lib/librarian/mock/source/mock/registry.rb +83 -0
  81. data/vendor/librarian/lib/librarian/resolution.rb +44 -0
  82. data/vendor/librarian/lib/librarian/resolver.rb +78 -0
  83. data/vendor/librarian/lib/librarian/resolver/implementation.rb +118 -0
  84. data/vendor/librarian/lib/librarian/source.rb +2 -0
  85. data/vendor/librarian/lib/librarian/source/git.rb +150 -0
  86. data/vendor/librarian/lib/librarian/source/git/repository.rb +217 -0
  87. data/vendor/librarian/lib/librarian/source/local.rb +61 -0
  88. data/vendor/librarian/lib/librarian/source/path.rb +74 -0
  89. data/vendor/librarian/lib/librarian/spec.rb +13 -0
  90. data/vendor/librarian/lib/librarian/spec_change_set.rb +173 -0
  91. data/vendor/librarian/lib/librarian/specfile.rb +18 -0
  92. data/vendor/librarian/lib/librarian/support/abstract_method.rb +21 -0
  93. data/vendor/librarian/lib/librarian/ui.rb +64 -0
  94. data/vendor/librarian/lib/librarian/version.rb +3 -0
  95. data/vendor/librarian/librarian.gemspec +34 -0
  96. data/vendor/librarian/spec/functional/chef/source/git_spec.rb +432 -0
  97. data/vendor/librarian/spec/functional/chef/source/site_spec.rb +215 -0
  98. data/vendor/librarian/spec/functional/source/git/repository_spec.rb +149 -0
  99. data/vendor/librarian/spec/unit/action/base_spec.rb +18 -0
  100. data/vendor/librarian/spec/unit/action/clean_spec.rb +102 -0
  101. data/vendor/librarian/spec/unit/action/ensure_spec.rb +37 -0
  102. data/vendor/librarian/spec/unit/action/install_spec.rb +111 -0
  103. data/vendor/librarian/spec/unit/config/database_spec.rb +319 -0
  104. data/vendor/librarian/spec/unit/dependency_spec.rb +36 -0
  105. data/vendor/librarian/spec/unit/dsl_spec.rb +194 -0
  106. data/vendor/librarian/spec/unit/environment_spec.rb +9 -0
  107. data/vendor/librarian/spec/unit/lockfile/parser_spec.rb +162 -0
  108. data/vendor/librarian/spec/unit/lockfile_spec.rb +65 -0
  109. data/vendor/librarian/spec/unit/manifest_set_spec.rb +202 -0
  110. data/vendor/librarian/spec/unit/manifest_spec.rb +36 -0
  111. data/vendor/librarian/spec/unit/mock/source/mock_spec.rb +22 -0
  112. data/vendor/librarian/spec/unit/resolver_spec.rb +192 -0
  113. data/vendor/librarian/spec/unit/source/git_spec.rb +29 -0
  114. data/vendor/librarian/spec/unit/spec_change_set_spec.rb +169 -0
  115. metadata +227 -0
@@ -0,0 +1,46 @@
1
+ module Librarian
2
+ class Logger
3
+
4
+ librarian_path = Pathname(__FILE__)
5
+ librarian_path = librarian_path.dirname until librarian_path.join("lib").directory?
6
+ LIBRARIAN_PATH = librarian_path
7
+
8
+ attr_accessor :environment
9
+ private :environment=
10
+
11
+ def initialize(environment)
12
+ self.environment = environment
13
+ end
14
+
15
+ def info(string = nil, &block)
16
+ return unless ui
17
+
18
+ ui.info(string || yield)
19
+ end
20
+
21
+ def debug(string = nil, &block)
22
+ return unless ui
23
+
24
+ if ui.respond_to?(:debug_line_numbers) && ui.debug_line_numbers
25
+ loc = caller.find{|l| !(l =~ /in `debug'$/)}
26
+ if loc =~ /^(.+):(\d+):in `(.+)'$/
27
+ loc = "#{Pathname.new($1).relative_path_from(LIBRARIAN_PATH)}:#{$2}:in `#{$3}'"
28
+ end
29
+ ui.debug { "[Librarian] #{string || yield} [#{loc}]" }
30
+ else
31
+ ui.debug { "[Librarian] #{string || yield}" }
32
+ end
33
+ end
34
+
35
+ def relative_path_to(path)
36
+ environment.project_relative_path_to(path)
37
+ end
38
+
39
+ private
40
+
41
+ def ui
42
+ environment.ui
43
+ end
44
+
45
+ end
46
+ end
@@ -0,0 +1,132 @@
1
+ require 'rubygems'
2
+
3
+ module Librarian
4
+ class Manifest
5
+
6
+ class Version
7
+ include Comparable
8
+
9
+ def initialize(*args)
10
+ args = initialize_normalize_args(args)
11
+
12
+ self.backing = Gem::Version.new(*args)
13
+ end
14
+
15
+ def to_gem_version
16
+ backing
17
+ end
18
+
19
+ def <=>(other)
20
+ to_gem_version <=> other.to_gem_version
21
+ end
22
+
23
+ def to_s
24
+ to_gem_version.to_s
25
+ end
26
+
27
+ private
28
+
29
+ def initialize_normalize_args(args)
30
+ args.map do |arg|
31
+ arg = [arg] if self.class === arg
32
+ arg
33
+ end
34
+ end
35
+
36
+ attr_accessor :backing
37
+ end
38
+
39
+ attr_accessor :source, :name, :extra
40
+ private :source=, :name=, :extra=
41
+
42
+ def initialize(source, name, extra = nil)
43
+ assert_name_valid! name
44
+
45
+ self.source = source
46
+ self.name = name
47
+ self.extra = extra
48
+ end
49
+
50
+ def to_s
51
+ "#{name}/#{version} <#{source}>"
52
+ end
53
+
54
+ def version
55
+ defined_version || fetched_version
56
+ end
57
+
58
+ def version=(version)
59
+ self.defined_version = _normalize_version(version)
60
+ end
61
+
62
+ def version?
63
+ return unless defined_version
64
+
65
+ defined_version == fetched_version
66
+ end
67
+
68
+ def dependencies
69
+ defined_dependencies || fetched_dependencies
70
+ end
71
+
72
+ def dependencies=(dependencies)
73
+ self.defined_dependencies = _normalize_dependencies(dependencies)
74
+ end
75
+
76
+ def dependencies?
77
+ return unless defined_dependencies
78
+
79
+ defined_dependencies.zip(fetched_dependencies).all? do |(a, b)|
80
+ a.name == b.name && a.requirement == b.requirement
81
+ end
82
+ end
83
+
84
+ def satisfies?(dependency)
85
+ dependency.requirement.satisfied_by?(version)
86
+ end
87
+
88
+ def install!
89
+ source.install!(self)
90
+ end
91
+
92
+ private
93
+
94
+ attr_accessor :defined_version, :defined_dependencies
95
+
96
+ def environment
97
+ source.environment
98
+ end
99
+
100
+ def fetched_version
101
+ @fetched_version ||= _normalize_version(fetch_version!)
102
+ end
103
+
104
+ def fetched_dependencies
105
+ @fetched_dependencies ||= _normalize_dependencies(fetch_dependencies!)
106
+ end
107
+
108
+ def fetch_version!
109
+ source.fetch_version(name, extra)
110
+ end
111
+
112
+ def fetch_dependencies!
113
+ source.fetch_dependencies(name, version, extra)
114
+ end
115
+
116
+ def _normalize_version(version)
117
+ Version.new(version)
118
+ end
119
+
120
+ def _normalize_dependencies(dependencies)
121
+ if Hash === dependencies
122
+ dependencies = dependencies.map{|k, v| Dependency.new(k, v, nil)}
123
+ end
124
+ dependencies.sort_by(&:name)
125
+ end
126
+
127
+ def assert_name_valid!(name)
128
+ raise ArgumentError, "name (#{name.inspect}) must be sensible" unless name =~ /\A\S(?:.*\S)?\z/
129
+ end
130
+
131
+ end
132
+ end
@@ -0,0 +1,153 @@
1
+ require 'set'
2
+ require 'tsort'
3
+
4
+ module Librarian
5
+ class ManifestSet
6
+
7
+ class GraphHash < Hash
8
+ include TSort
9
+ alias tsort_each_node each_key
10
+ def tsort_each_child(node, &block)
11
+ self[node].each(&block)
12
+ end
13
+ end
14
+
15
+ class << self
16
+ def shallow_strip(manifests, names)
17
+ new(manifests).shallow_strip!(names).send(method_for(manifests))
18
+ end
19
+ def deep_strip(manifests, names)
20
+ new(manifests).deep_strip!(names).send(method_for(manifests))
21
+ end
22
+ def shallow_keep(manifests, names)
23
+ new(manifests).shallow_keep!(names).send(method_for(manifests))
24
+ end
25
+ def deep_keep(manifests, names)
26
+ new(manifests).deep_keep!(names).send(method_for(manifests))
27
+ end
28
+ def sort(manifests)
29
+ manifests = Hash[manifests.map{|m| [m.name, m]}] if Array === manifests
30
+ manifest_pairs = GraphHash[manifests.map{|k, m| [k, m.dependencies.map{|d| d.name}]}]
31
+ manifest_names = manifest_pairs.tsort
32
+ manifest_names.map{|n| manifests[n]}
33
+ end
34
+ private
35
+ def method_for(manifests)
36
+ case manifests
37
+ when Hash
38
+ :to_hash
39
+ when Array
40
+ :to_a
41
+ end
42
+ end
43
+ end
44
+
45
+ def initialize(manifests)
46
+ self.index = Hash === manifests ? manifests.dup : Hash[manifests.map{|m| [m.name, m]}]
47
+ end
48
+
49
+ def to_a
50
+ index.values
51
+ end
52
+
53
+ def to_hash
54
+ index.dup
55
+ end
56
+
57
+ def dup
58
+ self.class.new(index)
59
+ end
60
+
61
+ def shallow_strip(names)
62
+ dup.shallow_strip!(names)
63
+ end
64
+
65
+ def shallow_strip!(names)
66
+ assert_strings!(names)
67
+
68
+ names.each do |name|
69
+ index.delete(name)
70
+ end
71
+ self
72
+ end
73
+
74
+ def deep_strip(names)
75
+ dup.deep_strip!(names)
76
+ end
77
+
78
+ def deep_strip!(names)
79
+ names = Array === names ? names.dup : names.to_a
80
+ assert_strings!(names)
81
+
82
+ strippables = dependencies_of(names)
83
+ shallow_strip!(strippables)
84
+
85
+ self
86
+ end
87
+
88
+ def shallow_keep(names)
89
+ dup.shallow_keep!(names)
90
+ end
91
+
92
+ def shallow_keep!(names)
93
+ assert_strings!(names)
94
+
95
+ names = Set.new(names) unless Set === names
96
+ index.reject! { |k, v| !names.include?(k) }
97
+ self
98
+ end
99
+
100
+ def deep_keep(names)
101
+ dup.conservative_strip!(names)
102
+ end
103
+
104
+ def deep_keep!(names)
105
+ names = Array === names ? names.dup : names.to_a
106
+ assert_strings!(names)
107
+
108
+ keepables = dependencies_of(names)
109
+ shallow_keep!(keepables)
110
+
111
+ self
112
+ end
113
+
114
+ def consistent?
115
+ index.values.all? do |manifest|
116
+ in_compliance_with?(manifest.dependencies)
117
+ end
118
+ end
119
+
120
+ def in_compliance_with?(dependencies)
121
+ dependencies.all? do |dependency|
122
+ manifest = index[dependency.name]
123
+ manifest && manifest.satisfies?(dependency)
124
+ end
125
+ end
126
+
127
+ private
128
+
129
+ attr_accessor :index
130
+
131
+ def assert_strings!(names)
132
+ non_strings = names.reject{|name| String === name}
133
+ non_strings.empty? or raise TypeError, "names must all be strings"
134
+ end
135
+
136
+ # Straightforward breadth-first graph traversal algorithm.
137
+ def dependencies_of(names)
138
+ names = Array === names ? names.dup : names.to_a
139
+ assert_strings!(names)
140
+
141
+ deps = Set.new
142
+ until names.empty?
143
+ name = names.shift
144
+ next if deps.include?(name)
145
+
146
+ deps << name
147
+ names.concat index[name].dependencies.map(&:name)
148
+ end
149
+ deps.to_a
150
+ end
151
+
152
+ end
153
+ end
@@ -0,0 +1 @@
1
+ require 'librarian/mock/extension'
@@ -0,0 +1,19 @@
1
+ require 'librarian/cli'
2
+ require 'librarian/mock'
3
+
4
+ module Librarian
5
+ module Mock
6
+ class Cli < Librarian::Cli
7
+
8
+ module Particularity
9
+ def root_module
10
+ Mock
11
+ end
12
+ end
13
+
14
+ include Particularity
15
+ extend Particularity
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ require 'librarian/dsl'
2
+ require 'librarian/mock/source'
3
+
4
+ module Librarian
5
+ module Mock
6
+ class Dsl < Librarian::Dsl
7
+
8
+ dependency :dep
9
+
10
+ source :src => Source::Mock
11
+
12
+ shortcut :a, :src => 'source-a'
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,24 @@
1
+ require "librarian/environment"
2
+ require "librarian/mock/dsl"
3
+
4
+ module Librarian
5
+ module Mock
6
+ class Environment < Environment
7
+
8
+ def adapter_name
9
+ "mock"
10
+ end
11
+
12
+ def install_path
13
+ nil
14
+ end
15
+
16
+ def registry(options = nil, &block)
17
+ @registry ||= Source::Mock::Registry.new
18
+ @registry.merge!(options, &block)
19
+ @registry
20
+ end
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,9 @@
1
+ require 'librarian/mock/environment'
2
+
3
+ module Librarian
4
+ module Mock
5
+ extend self
6
+ extend Librarian
7
+
8
+ end
9
+ end
@@ -0,0 +1 @@
1
+ require 'librarian/mock/source/mock'
@@ -0,0 +1,97 @@
1
+ require 'librarian/manifest'
2
+ require 'librarian/mock/source/mock/registry'
3
+
4
+ module Librarian
5
+ module Mock
6
+ module Source
7
+ class Mock
8
+
9
+ class << self
10
+
11
+ LOCK_NAME = 'MOCK'
12
+
13
+ def lock_name
14
+ LOCK_NAME
15
+ end
16
+
17
+ def from_lock_options(environment, options)
18
+ new(environment, options[:remote], options.reject{|k, v| k == :remote})
19
+ end
20
+
21
+ def from_spec_args(environment, name, options)
22
+ recognized_options = []
23
+ unrecognized_options = options.keys - recognized_options
24
+ unrecognized_options.empty? or raise Error, "unrecognized options: #{unrecognized_options.join(", ")}"
25
+
26
+ new(environment, name, options)
27
+ end
28
+
29
+ end
30
+
31
+ attr_accessor :environment
32
+ private :environment=
33
+ attr_reader :name
34
+
35
+ def initialize(environment, name, options)
36
+ self.environment = environment
37
+ @name = name
38
+ end
39
+
40
+ def to_s
41
+ name
42
+ end
43
+
44
+ def ==(other)
45
+ other &&
46
+ self.class == other.class &&
47
+ self.name == other.name
48
+ end
49
+
50
+ def to_spec_args
51
+ [name, {}]
52
+ end
53
+
54
+ def to_lock_options
55
+ {:remote => name}
56
+ end
57
+
58
+ def registry
59
+ environment.registry[name]
60
+ end
61
+
62
+ def manifest(name, version, dependencies)
63
+ manifest = Manifest.new(self, name)
64
+ manifest.version = version
65
+ manifest.dependencies = dependencies
66
+ manifest
67
+ end
68
+
69
+ def manifests(name)
70
+ if d = registry[name]
71
+ d.map{|v| manifest(name, v[:version], v[:dependencies])}
72
+ else
73
+ nil
74
+ end
75
+ end
76
+
77
+ def install!(manifest)
78
+ end
79
+
80
+ def to_s
81
+ name
82
+ end
83
+
84
+ def fetch_version(name, extra)
85
+ extra
86
+ end
87
+
88
+ def fetch_dependencies(name, version, extra)
89
+ d = registry[name]
90
+ m = d.find{|v| v[:version] == version.to_s}
91
+ m[:dependencies]
92
+ end
93
+
94
+ end
95
+ end
96
+ end
97
+ end