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,15 @@
1
+ #!/usr/bin/env ruby
2
+ #^syntax detection
3
+
4
+ site 'http://community.opscode.com/api/v1'
5
+
6
+ # cookbook 'chef-client'
7
+
8
+ # cookbook 'apache2', '>= 1.0.0'
9
+
10
+ # cookbook 'rvm',
11
+ # :git => 'https://github.com/fnichol/chef-rvm'
12
+
13
+ # cookbook 'postgresql',
14
+ # :git => 'https://github.com/findsyou/cookbooks',
15
+ # :ref => 'postgresql-improvements'
@@ -0,0 +1,175 @@
1
+ require 'thor'
2
+ require 'thor/actions'
3
+
4
+ require 'librarian'
5
+ require 'librarian/error'
6
+ require 'librarian/action'
7
+ require "librarian/ui"
8
+
9
+ require "librarian/helpers/debug"
10
+
11
+ module Librarian
12
+ class Cli < Thor
13
+
14
+ autoload :ManifestPresenter, "librarian/cli/manifest_presenter"
15
+
16
+ include Thor::Actions
17
+
18
+ module Particularity
19
+ def root_module
20
+ nil
21
+ end
22
+ end
23
+
24
+ include Particularity
25
+ extend Particularity
26
+
27
+ include Helpers::Debug
28
+
29
+ class << self
30
+ def bin!
31
+ begin
32
+ environment = root_module.environment
33
+ start
34
+ rescue Librarian::Error => e
35
+ environment.ui.error e.message
36
+ environment.ui.debug e.backtrace.join("\n")
37
+ exit (e.respond_to?(:status_code) ? e.status_code : 1)
38
+ rescue Interrupt => e
39
+ environment.ui.error "\nQuitting..."
40
+ exit 1
41
+ end
42
+ end
43
+ end
44
+
45
+ def initialize(*)
46
+ super
47
+ the_shell = (options["no-color"] ? Thor::Shell::Basic.new : shell)
48
+ environment.ui = UI::Shell.new(the_shell)
49
+ environment.ui.debug! if options["verbose"]
50
+ environment.ui.debug_line_numbers! if options["verbose"] && options["line-numbers"]
51
+
52
+ write_debug_header
53
+ end
54
+
55
+ desc "version", "Displays the version."
56
+ def version
57
+ say "librarian-#{root_module.version}"
58
+ end
59
+
60
+ desc "clean", "Cleans out the cache and install paths."
61
+ option "verbose"
62
+ option "line-numbers"
63
+ def clean
64
+ ensure!
65
+ clean!
66
+ end
67
+
68
+ desc "install", "Resolves and installs all of the dependencies you specify."
69
+ option "verbose"
70
+ option "line-numbers"
71
+ option "clean"
72
+ def install
73
+ ensure!
74
+ clean! if options["clean"]
75
+ resolve!
76
+ install!
77
+ end
78
+
79
+ desc "update", "Updates and installs the dependencies you specify."
80
+ option "verbose"
81
+ option "line-numbers"
82
+ def update(*names)
83
+ ensure!
84
+ if names.empty?
85
+ resolve!(:force => true)
86
+ else
87
+ update!(:names => names)
88
+ end
89
+ install!
90
+ end
91
+
92
+ desc "outdated", "Lists outdated dependencies."
93
+ option "verbose"
94
+ option "line-numbers"
95
+ def outdated
96
+ ensure!
97
+ resolution = environment.lock
98
+ resolution.manifests.sort_by(&:name).each do |manifest|
99
+ source = manifest.source
100
+ source_manifest = source.manifests(manifest.name).first
101
+ next if manifest.version == source_manifest.version
102
+ say "#{manifest.name} (#{manifest.version} -> #{source_manifest.version})"
103
+ end
104
+ end
105
+
106
+ desc "show", "Shows dependencies"
107
+ option "verbose"
108
+ option "line-numbers"
109
+ option "detailed", :type => :boolean
110
+ def show(*names)
111
+ ensure!
112
+ manifest_presenter.present(names, :detailed => options["detailed"])
113
+ end
114
+
115
+ desc "init", "Initializes the current directory."
116
+ def init
117
+ puts "Nothing to do."
118
+ end
119
+
120
+ private
121
+
122
+ def environment
123
+ root_module.environment
124
+ end
125
+
126
+ def ensure!(options = { })
127
+ Action::Ensure.new(environment, options).run
128
+ end
129
+
130
+ def clean!(options = { })
131
+ Action::Clean.new(environment, options).run
132
+ end
133
+
134
+ def install!(options = { })
135
+ Action::Install.new(environment, options).run
136
+ end
137
+
138
+ def resolve!(options = { })
139
+ Action::Resolve.new(environment, options).run
140
+ end
141
+
142
+ def update!(options = { })
143
+ Action::Update.new(environment, options).run
144
+ end
145
+
146
+ def manifest_presenter
147
+ ManifestPresenter.new(self, environment.lock.manifests)
148
+ end
149
+
150
+ def write_debug_header
151
+ debug { "Ruby Version: #{RUBY_VERSION}" }
152
+ debug { "Ruby Platform: #{RUBY_PLATFORM}" }
153
+ debug { "Rubinius Version: #{Rubinius::VERSION}" } if defined?(Rubinius)
154
+ debug { "JRuby Version: #{JRUBY_VERSION}" } if defined?(JRUBY_VERSION)
155
+ debug { "Rubygems Version: #{Gem::VERSION}" }
156
+ debug { "Librarian Version: #{VERSION}" }
157
+ debug { "Librarian Adapter: #{environment.adapter_name}"}
158
+ debug { "Project: #{environment.project_path}" }
159
+ debug { "Specfile: #{relative_path_to(environment.specfile_path)}" }
160
+ debug { "Lockfile: #{relative_path_to(environment.lockfile_path)}" }
161
+ debug { "Git: #{Source::Git::Repository.bin}" }
162
+ debug { "Git Version: #{Source::Git::Repository.new(environment, environment.project_path).version(:silent => true)}" }
163
+ debug { "Git Environment Variables:" }
164
+ git_env = ENV.to_a.select{|(k, v)| k =~ /\AGIT/}.sort_by{|(k, v)| k}
165
+ if git_env.empty?
166
+ debug { " (empty)" }
167
+ else
168
+ git_env.each do |(k, v)|
169
+ debug { " #{k}=#{v}"}
170
+ end
171
+ end
172
+ end
173
+
174
+ end
175
+ end
@@ -0,0 +1,79 @@
1
+ module Librarian
2
+ class Cli
3
+ class ManifestPresenter
4
+
5
+ attr_accessor :cli, :manifests
6
+ private :cli=, :manifests=
7
+
8
+ def initialize(cli, manifests)
9
+ self.cli = cli or raise ArgumentError, "cli required"
10
+ self.manifests = manifests or raise ArgumentError, "manifests required"
11
+ self.manifests_index = Hash[manifests.map{|m| [m.name, m]}]
12
+
13
+ self.scope_level = 0
14
+ end
15
+
16
+ def present(names = [], options = { })
17
+ full = options[:detailed]
18
+ full = !names.empty? if full.nil?
19
+
20
+ if names.empty?
21
+ names = manifests.map(&:name).sort if names.empty?
22
+ else
23
+ missing_names = names.reject{|name| manifest(name)}
24
+ unless missing_names.empty?
25
+ raise Error, "not found: #{missing_names.map(&:inspect).join(', ')}"
26
+ end
27
+ end
28
+
29
+ names.each do |name|
30
+ manifest = manifest(name)
31
+ present_one(manifest, :detailed => full)
32
+ end
33
+ end
34
+
35
+ def present_one(manifest, options = { })
36
+ full = options[:detailed]
37
+
38
+ say "#{manifest.name} (#{manifest.version})" do
39
+ if full
40
+ say "source: #{manifest.source}"
41
+ unless manifest.dependencies.empty?
42
+ say "dependencies:" do
43
+ manifest.dependencies.sort_by(&:name).each do |dependency|
44
+ say "#{dependency.name} (#{dependency.requirement})"
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+
52
+ private
53
+
54
+ attr_accessor :scope_level, :manifests_index
55
+
56
+ def manifest(name)
57
+ manifests_index[name]
58
+ end
59
+
60
+ def say(string)
61
+ cli.say " " * scope_level << string
62
+ if block_given?
63
+ scope do
64
+ yield
65
+ end
66
+ end
67
+ end
68
+
69
+ def scope
70
+ original_scope_level = scope_level
71
+ self.scope_level = scope_level + 1
72
+ yield
73
+ ensure
74
+ self.scope_level = original_scope_level
75
+ end
76
+
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,95 @@
1
+ require 'rubygems'
2
+
3
+ require 'librarian/helpers/debug'
4
+
5
+ module Librarian
6
+ class Dependency
7
+
8
+ class Requirement
9
+ def initialize(*args)
10
+ args = initialize_normalize_args(args)
11
+
12
+ self.backing = Gem::Requirement.create(*args)
13
+ end
14
+
15
+ def to_gem_requirement
16
+ backing
17
+ end
18
+
19
+ def satisfied_by?(version)
20
+ to_gem_requirement.satisfied_by?(version.to_gem_version)
21
+ end
22
+
23
+ def ==(other)
24
+ to_gem_requirement == other.to_gem_requirement
25
+ end
26
+
27
+ def to_s
28
+ to_gem_requirement.to_s
29
+ end
30
+
31
+ protected
32
+
33
+ attr_accessor :backing
34
+
35
+ private
36
+
37
+ def initialize_normalize_args(args)
38
+ args.map do |arg|
39
+ arg = arg.backing if self.class === arg
40
+ arg
41
+ end
42
+ end
43
+ end
44
+
45
+ include Helpers::Debug
46
+
47
+ attr_accessor :name, :requirement, :source
48
+ private :name=, :requirement=, :source=
49
+
50
+ def initialize(name, requirement, source)
51
+ assert_name_valid! name
52
+
53
+ self.name = name
54
+ self.requirement = Requirement.new(requirement)
55
+ self.source = source
56
+
57
+ @manifests = nil
58
+ end
59
+
60
+ def manifests
61
+ @manifests ||= cache_manifests!
62
+ end
63
+
64
+ def cache_manifests!
65
+ source.manifests(name)
66
+ end
67
+
68
+ def satisfied_by?(manifest)
69
+ manifest.satisfies?(self)
70
+ end
71
+
72
+ def to_s
73
+ "#{name} (#{requirement}) <#{source}>"
74
+ end
75
+
76
+ def ==(other)
77
+ !other.nil? &&
78
+ self.class == other.class &&
79
+ self.name == other.name &&
80
+ self.requirement == other.requirement &&
81
+ self.source == other.source
82
+ end
83
+
84
+ private
85
+
86
+ def environment
87
+ source.environment
88
+ end
89
+
90
+ def assert_name_valid!(name)
91
+ raise ArgumentError, "name (#{name.inspect}) must be sensible" unless name =~ /^\S.*\S$/
92
+ end
93
+
94
+ end
95
+ end
@@ -0,0 +1,105 @@
1
+ require 'librarian/dependency'
2
+ require 'librarian/dsl/receiver'
3
+ require 'librarian/dsl/target'
4
+ require 'librarian/helpers/debug'
5
+
6
+ module Librarian
7
+ class Dsl
8
+
9
+ include Helpers::Debug
10
+
11
+ class Error < Exception
12
+ end
13
+
14
+ attr_accessor :environment
15
+ private :environment=
16
+
17
+ class << self
18
+
19
+ def run(environment, specfile = nil, precache_sources = [], &block)
20
+ new(environment).run(specfile, precache_sources, &block)
21
+ end
22
+
23
+ private
24
+
25
+ def dependency(name)
26
+ dependency_name = name
27
+ dependency_type = Dependency
28
+ singleton_class = class << self; self end
29
+ singleton_class.instance_eval do
30
+ define_method(:dependency_name) { dependency_name }
31
+ define_method(:dependency_type) { dependency_type }
32
+ end
33
+ end
34
+
35
+ define_method(:source_types) { [] }
36
+
37
+ def source(options)
38
+ name = options.keys.first
39
+ type = options[name]
40
+ types = source_types
41
+ types << [name, type]
42
+ singleton_class = class << self; self end
43
+ singleton_class.instance_eval do
44
+ define_method(:source_types) { types }
45
+ end
46
+ end
47
+
48
+ define_method(:source_shortcuts) { {} }
49
+
50
+ def shortcut(name, options)
51
+ instances = source_shortcuts
52
+ instances[name] = options
53
+ singleton_class = class << self; self end
54
+ singleton_class.instance_eval do
55
+ define_method(:source_shortcuts) { instances }
56
+ end
57
+ end
58
+
59
+ def delegate_to_class(*names)
60
+ names.each do |name|
61
+ define_method(name) { self.class.send(name) }
62
+ end
63
+ end
64
+
65
+ end
66
+
67
+ delegate_to_class :dependency_name, :dependency_type, :source_types, :source_shortcuts
68
+
69
+ def initialize(environment)
70
+ self.environment = environment
71
+ end
72
+
73
+ def run(specfile = nil, sources = [])
74
+ Target.new(self).tap do |target|
75
+ target.precache_sources(sources)
76
+ debug_named_source_cache("Pre-Cached Sources", target)
77
+
78
+ receiver = Receiver.new(target)
79
+ if block_given?
80
+ receiver.run(&Proc.new)
81
+ else
82
+ case specfile
83
+ when Specfile, String, Proc
84
+ receiver.run(specfile)
85
+ else
86
+ raise ArgumentError, "specfile must be a #{Specfile}, #{String}, or #{Proc} if no block is given (it was #{specfile.inspect})"
87
+ end
88
+ end
89
+
90
+ debug_named_source_cache("Post-Cached Sources", target)
91
+ end.to_spec
92
+ end
93
+
94
+ def debug_named_source_cache(name, target)
95
+ source_cache = target.source_cache
96
+ debug { "#{name}:" }
97
+ source_cache.each do |key, value|
98
+ type = key[0]
99
+ attributes = key[1...key.size]
100
+ debug { " #{key.inspect}" }
101
+ end
102
+ end
103
+
104
+ end
105
+ end