librarian-puppet-lmco 0.9.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +5 -0
  3. data/LICENSE +20 -0
  4. data/README.md +187 -0
  5. data/bin/librarian-puppet +9 -0
  6. data/lib/librarian/puppet.rb +22 -0
  7. data/lib/librarian/puppet/cli.rb +85 -0
  8. data/lib/librarian/puppet/dsl.rb +16 -0
  9. data/lib/librarian/puppet/environment.rb +54 -0
  10. data/lib/librarian/puppet/extension.rb +47 -0
  11. data/lib/librarian/puppet/lockfile/parser.rb +53 -0
  12. data/lib/librarian/puppet/source.rb +4 -0
  13. data/lib/librarian/puppet/source/forge.rb +348 -0
  14. data/lib/librarian/puppet/source/git.rb +121 -0
  15. data/lib/librarian/puppet/source/githubtarball.rb +249 -0
  16. data/lib/librarian/puppet/source/local.rb +57 -0
  17. data/lib/librarian/puppet/source/path.rb +12 -0
  18. data/lib/librarian/puppet/templates/Puppetfile +10 -0
  19. data/lib/librarian/puppet/version.rb +5 -0
  20. data/vendor/librarian/CHANGELOG.md +224 -0
  21. data/vendor/librarian/Gemfile +6 -0
  22. data/vendor/librarian/MIT-LICENSE +20 -0
  23. data/vendor/librarian/README.md +401 -0
  24. data/vendor/librarian/Rakefile +34 -0
  25. data/vendor/librarian/bin/librarian-chef +7 -0
  26. data/vendor/librarian/bin/librarian-mock +7 -0
  27. data/vendor/librarian/config/cucumber.yaml +1 -0
  28. data/vendor/librarian/features/chef/cli/init.feature +11 -0
  29. data/vendor/librarian/features/chef/cli/install.feature +64 -0
  30. data/vendor/librarian/features/chef/cli/show.feature +77 -0
  31. data/vendor/librarian/features/chef/cli/version.feature +11 -0
  32. data/vendor/librarian/features/support/env.rb +9 -0
  33. data/vendor/librarian/lib/librarian.rb +11 -0
  34. data/vendor/librarian/lib/librarian/action.rb +5 -0
  35. data/vendor/librarian/lib/librarian/action/base.rb +24 -0
  36. data/vendor/librarian/lib/librarian/action/clean.rb +44 -0
  37. data/vendor/librarian/lib/librarian/action/ensure.rb +24 -0
  38. data/vendor/librarian/lib/librarian/action/install.rb +95 -0
  39. data/vendor/librarian/lib/librarian/action/persist_resolution_mixin.rb +51 -0
  40. data/vendor/librarian/lib/librarian/action/resolve.rb +46 -0
  41. data/vendor/librarian/lib/librarian/action/update.rb +44 -0
  42. data/vendor/librarian/lib/librarian/chef.rb +1 -0
  43. data/vendor/librarian/lib/librarian/chef/cli.rb +47 -0
  44. data/vendor/librarian/lib/librarian/chef/dsl.rb +16 -0
  45. data/vendor/librarian/lib/librarian/chef/environment.rb +27 -0
  46. data/vendor/librarian/lib/librarian/chef/extension.rb +9 -0
  47. data/vendor/librarian/lib/librarian/chef/integration/knife.rb +46 -0
  48. data/vendor/librarian/lib/librarian/chef/manifest_reader.rb +59 -0
  49. data/vendor/librarian/lib/librarian/chef/source.rb +4 -0
  50. data/vendor/librarian/lib/librarian/chef/source/git.rb +25 -0
  51. data/vendor/librarian/lib/librarian/chef/source/github.rb +27 -0
  52. data/vendor/librarian/lib/librarian/chef/source/local.rb +69 -0
  53. data/vendor/librarian/lib/librarian/chef/source/path.rb +12 -0
  54. data/vendor/librarian/lib/librarian/chef/source/site.rb +442 -0
  55. data/vendor/librarian/lib/librarian/chef/templates/Cheffile +15 -0
  56. data/vendor/librarian/lib/librarian/cli.rb +223 -0
  57. data/vendor/librarian/lib/librarian/cli/manifest_presenter.rb +93 -0
  58. data/vendor/librarian/lib/librarian/config.rb +7 -0
  59. data/vendor/librarian/lib/librarian/config/database.rb +205 -0
  60. data/vendor/librarian/lib/librarian/config/file_source.rb +47 -0
  61. data/vendor/librarian/lib/librarian/config/hash_source.rb +33 -0
  62. data/vendor/librarian/lib/librarian/config/source.rb +149 -0
  63. data/vendor/librarian/lib/librarian/dependency.rb +147 -0
  64. data/vendor/librarian/lib/librarian/dsl.rb +108 -0
  65. data/vendor/librarian/lib/librarian/dsl/receiver.rb +46 -0
  66. data/vendor/librarian/lib/librarian/dsl/target.rb +171 -0
  67. data/vendor/librarian/lib/librarian/environment.rb +182 -0
  68. data/vendor/librarian/lib/librarian/error.rb +4 -0
  69. data/vendor/librarian/lib/librarian/helpers.rb +13 -0
  70. data/vendor/librarian/lib/librarian/linter/source_linter.rb +55 -0
  71. data/vendor/librarian/lib/librarian/lockfile.rb +29 -0
  72. data/vendor/librarian/lib/librarian/lockfile/compiler.rb +66 -0
  73. data/vendor/librarian/lib/librarian/lockfile/parser.rb +123 -0
  74. data/vendor/librarian/lib/librarian/logger.rb +46 -0
  75. data/vendor/librarian/lib/librarian/manifest.rb +140 -0
  76. data/vendor/librarian/lib/librarian/manifest_set.rb +151 -0
  77. data/vendor/librarian/lib/librarian/mock.rb +1 -0
  78. data/vendor/librarian/lib/librarian/mock/cli.rb +19 -0
  79. data/vendor/librarian/lib/librarian/mock/dsl.rb +15 -0
  80. data/vendor/librarian/lib/librarian/mock/environment.rb +24 -0
  81. data/vendor/librarian/lib/librarian/mock/extension.rb +9 -0
  82. data/vendor/librarian/lib/librarian/mock/source.rb +1 -0
  83. data/vendor/librarian/lib/librarian/mock/source/mock.rb +80 -0
  84. data/vendor/librarian/lib/librarian/mock/source/mock/registry.rb +83 -0
  85. data/vendor/librarian/lib/librarian/resolution.rb +46 -0
  86. data/vendor/librarian/lib/librarian/resolver.rb +81 -0
  87. data/vendor/librarian/lib/librarian/resolver/implementation.rb +223 -0
  88. data/vendor/librarian/lib/librarian/source.rb +2 -0
  89. data/vendor/librarian/lib/librarian/source/basic_api.rb +45 -0
  90. data/vendor/librarian/lib/librarian/source/git.rb +134 -0
  91. data/vendor/librarian/lib/librarian/source/git/repository.rb +217 -0
  92. data/vendor/librarian/lib/librarian/source/local.rb +54 -0
  93. data/vendor/librarian/lib/librarian/source/path.rb +56 -0
  94. data/vendor/librarian/lib/librarian/spec.rb +13 -0
  95. data/vendor/librarian/lib/librarian/spec_change_set.rb +173 -0
  96. data/vendor/librarian/lib/librarian/specfile.rb +17 -0
  97. data/vendor/librarian/lib/librarian/support/abstract_method.rb +21 -0
  98. data/vendor/librarian/lib/librarian/ui.rb +64 -0
  99. data/vendor/librarian/lib/librarian/version.rb +3 -0
  100. data/vendor/librarian/librarian.gemspec +35 -0
  101. data/vendor/librarian/spec/functional/chef/cli_spec.rb +194 -0
  102. data/vendor/librarian/spec/functional/chef/source/git_spec.rb +432 -0
  103. data/vendor/librarian/spec/functional/chef/source/site_spec.rb +266 -0
  104. data/vendor/librarian/spec/functional/source/git/repository_spec.rb +150 -0
  105. data/vendor/librarian/spec/integration/chef/source/git_spec.rb +441 -0
  106. data/vendor/librarian/spec/integration/chef/source/site_spec.rb +217 -0
  107. data/vendor/librarian/spec/support/cli_macro.rb +114 -0
  108. data/vendor/librarian/spec/support/method_patch_macro.rb +30 -0
  109. data/vendor/librarian/spec/support/with_env_macro.rb +20 -0
  110. data/vendor/librarian/spec/unit/action/base_spec.rb +18 -0
  111. data/vendor/librarian/spec/unit/action/clean_spec.rb +102 -0
  112. data/vendor/librarian/spec/unit/action/ensure_spec.rb +37 -0
  113. data/vendor/librarian/spec/unit/action/install_spec.rb +111 -0
  114. data/vendor/librarian/spec/unit/config/database_spec.rb +327 -0
  115. data/vendor/librarian/spec/unit/dependency_spec.rb +212 -0
  116. data/vendor/librarian/spec/unit/dsl_spec.rb +173 -0
  117. data/vendor/librarian/spec/unit/environment_spec.rb +173 -0
  118. data/vendor/librarian/spec/unit/lockfile/parser_spec.rb +162 -0
  119. data/vendor/librarian/spec/unit/lockfile_spec.rb +65 -0
  120. data/vendor/librarian/spec/unit/manifest_set_spec.rb +202 -0
  121. data/vendor/librarian/spec/unit/manifest_spec.rb +36 -0
  122. data/vendor/librarian/spec/unit/mock/source/mock_spec.rb +22 -0
  123. data/vendor/librarian/spec/unit/resolver_spec.rb +233 -0
  124. data/vendor/librarian/spec/unit/source/git_spec.rb +29 -0
  125. data/vendor/librarian/spec/unit/spec_change_set_spec.rb +169 -0
  126. metadata +220 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA512:
3
+ data.tar.gz: c81cad7f3784f46bc6a38076bfb9b74e1417bfc6699c677594f2606c5366b6c989f28813cf5f0c7fc7753065cf1f4634902cfe0bbb905abb8714c02b55aad339
4
+ metadata.gz: 7a74fd71514161fad06fd3d3dc6c3a2e9496351f0cac8bd293b0c85d628113f1365e8c7a51c3422cb09794e9c60852714e963bed6562d2b874212f5bcfeb8c2b
5
+ SHA1:
6
+ data.tar.gz: 068388076dedc0a4a9817ff6a25b597691dfdf93
7
+ metadata.gz: 76711886aba02a437e5c2ae154672c479e17ff89
@@ -0,0 +1,5 @@
1
+ pkg/
2
+ Gemfile.lock
3
+ tmp/
4
+ .project
5
+ *.gem
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Tim Sharpe
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,187 @@
1
+ # Librarian-puppet
2
+
3
+ ## Introduction
4
+
5
+ Librarian-puppet is a bundler for your puppet infrastructure. You can use
6
+ librarian-puppet to manage the puppet modules your infrastructure depends on.
7
+ It is based on [Librarian](https://github.com/applicationsonline/librarian), a
8
+ framework for writing bundlers, which are tools that resolve, fetch, install,
9
+ and isolate a project's dependencies.
10
+
11
+ Librarian-puppet manages your `modules/` directory for you based on your
12
+ `Puppetfile`. Your `Puppetfile` becomes the authoritative source for what
13
+ modules you require and at what version, tag or branch.
14
+
15
+ Once using Librarian-puppet you should not modify the contents of your `modules`
16
+ directory. The individual modules' repos should be updated, tagged with a new
17
+ release and the version bumped in your Puppetfile.
18
+
19
+ ## The Puppetfile
20
+
21
+ Every Puppet repository that uses Librarian-puppet will have a file named
22
+ `Puppetfile` in the root directory of that repository. The full specification
23
+ for which modules your puppet infrastructure repository depends goes in here.
24
+
25
+ ### Example Puppetfile
26
+
27
+ forge "http://forge.puppetlabs.com"
28
+
29
+ mod "puppetlabs/razor"
30
+ mod "puppetlabs/ntp", "0.0.3"
31
+
32
+ mod "apt",
33
+ :git => "git://github.com/puppetlabs/puppetlabs-apt.git"
34
+
35
+ mod "stdlib",
36
+ :git => "git://github.com/puppetlabs/puppetlabs-stdlib.git"
37
+
38
+ *See [jenkins-appliance](https://github.com/aussielunix/jenkins-appliance) for
39
+ a puppet repo already setup to use librarian-puppet.*
40
+
41
+ ### Puppetfile Breakdown
42
+
43
+ forge "http://forge.puppetlabs.com"
44
+
45
+ This declares that we want to use the official Puppet Labs Forge as our default
46
+ source when pulling down modules. If you run your own local forge, you may
47
+ want to change this.
48
+
49
+ mod "puppetlabs/razor"
50
+
51
+ Pull in the latest version of the Puppet Labs Razor module from the default
52
+ source.
53
+
54
+ mod "puppetlabs/ntp", "0.0.3"
55
+
56
+ Pull in version 0.0.3 of the Puppet Labs NTP module from the default source.
57
+
58
+ mod "apt",
59
+ :git => "git://github.com/puppetlabs/puppetlabs-apt.git"
60
+
61
+ Our puppet infrastructure repository depends on the `apt` module from the
62
+ Puppet Labs GitHub repos and checks out the `master` branch.
63
+
64
+ mod "apt",
65
+ :git => "git://github.com/puppetlabs/puppetlabs-apt.git",
66
+ :ref => '0.0.3'
67
+
68
+ Our puppet infrastructure repository depends on the `apt` module from the
69
+ Puppet Labs GitHub repos and checks out a tag of `0.0.3`.
70
+
71
+ mod "apt",
72
+ :git => "git://github.com/puppetlabs/puppetlabs-apt.git",
73
+ :ref => 'feature/master/dans_refactor'
74
+
75
+ Our puppet infrastructure repository depends on the `apt` module from the
76
+ Puppet Labs GitHub repos and checks out the `dans_refactor` branch.
77
+
78
+ When using a Git source, we do not have to use a `:ref =>`.
79
+ If we do not, then librarian-puppet will assume we meant the `master` branch.
80
+
81
+ If we use a `:ref =>`, we can use anything that Git will recognize as a ref.
82
+ This includes any branch name, tag name, SHA, or SHA unique prefix. If we use a
83
+ branch, we can later ask Librarian-puppet to update the module by fetching the
84
+ most recent version of the module from that same branch.
85
+
86
+ The Git source also supports a `:path =>` option. If we use the path option,
87
+ Librarian-puppet will navigate down into the Git repository and only use the
88
+ specified subdirectory. Some people have the habit of having a single repository
89
+ with many modules in it. If we need a module from such a repository, we can
90
+ use the `:path =>` option here to help Librarian-puppet drill down and find the
91
+ module subdirectory.
92
+
93
+ mod "apt",
94
+ :git => "git://github.com/fake/puppet-modules.git",
95
+ :path => "modules/apt"
96
+
97
+ Our puppet infrastructure repository depends on the `apt` module, which we have
98
+ stored as a directory under our `puppet-modules` git repos.
99
+
100
+ ## How to Use
101
+
102
+ Install librarian-puppet:
103
+
104
+ $ gem install librarian-puppet
105
+
106
+ Prepare your puppet infrastructure repository:
107
+
108
+ $ cd ~/path/to/puppet-inf-repos
109
+ $ (git) rm -rf modules
110
+ $ librarian-puppet init
111
+
112
+ Librarian-puppet takes over your `modules/` directory, and will always
113
+ reinstall (if missing) the modules listed the `Puppetfile.lock` into your
114
+ `modules/` directory, therefore you do not need your `modules/` directory to be
115
+ tracked in Git.
116
+
117
+ Librarian-puppet uses a `.tmp/` directory for tempfiles and caches. You should
118
+ not track this directory in Git.
119
+
120
+ Running `librarian-puppet init` will create a skeleton Puppetfile for you as
121
+ well as adding `tmp/` and `modules/` to your `.gitignore`.
122
+
123
+ $ librarian-puppet install [--clean] [--verbose]
124
+
125
+ This command looks at each `mod` declaration and fetches the module from the
126
+ source specified. This command writes the complete resolution into
127
+ `Puppetfile.lock` and then copies all of the fetched modules into your
128
+ `modules/` directory, overwriting whatever was there before.
129
+
130
+ Get an overview of your `Puppetfile.lock` with:
131
+
132
+ $ librarian-puppet show
133
+
134
+ Inspect the details of specific resolved dependencies with:
135
+
136
+ $ librarian-puppet show NAME1 [NAME2, ...]
137
+
138
+ Find out which dependencies are outdated and may be updated:
139
+
140
+ $ librarian-puppet outdated [--verbose]
141
+
142
+ Update the version of a dependency:
143
+
144
+ $ librarian-puppet update apt [--verbose]
145
+ $ git diff Puppetfile.lock
146
+ $ git add Puppetfile.lock
147
+ $ git commit -m "bumped the version of apt up to 0.0.4."
148
+
149
+ ## How to Contribute
150
+
151
+ * Pull requests please.
152
+ * Bonus points for feature branches.
153
+
154
+ ## Reporting Issues
155
+
156
+ Bug reports to the github issue tracker please.
157
+ Please include:
158
+
159
+ * Relevant `Puppetfile` and `Puppetfile.lock` files
160
+ * Version of ruby, librarian-puppet
161
+ * What distro
162
+ * Please run the `librarian-puppet` commands in verbose mode by using the
163
+ `--verbose` flag, and include the verbose output in the bug report as well.
164
+
165
+ ## Changelog
166
+
167
+ ### 0.9.0
168
+
169
+ * Initial release
170
+
171
+ ### 0.9.1
172
+
173
+ * Proper error message when a module that is sourced from the forge does not
174
+ exist.
175
+ * Added support for annotated tags as git references.
176
+ * `librarian-puppet init` adds `.tmp/` to gitignore instead of `tmp/`.
177
+ * Fixed syntax error in the template Puppetfile created by `librarian-puppet
178
+ init`.
179
+ * Checks for `lib/puppet` as well as `manifests/` when checking if the git
180
+ repository is a valid module.
181
+ * When a user specifies `<foo>/<bar>` as the name of a module sources from a
182
+ git repository, assume the module name is actually `<bar>`.
183
+ * Fixed gem description and summary in gemspec.
184
+
185
+ ## License
186
+ Please see the [LICENSE](https://github.com/rodjek/librarian-puppet/blob/master/LICENSE)
187
+ file.
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib = File.expand_path('../../lib', __FILE__)
4
+ vendor = File.expand_path('../../vendor/librarian/lib', __FILE__)
5
+ $:.unshift(lib) unless $:.include?(lib)
6
+ $:.unshift(vendor) unless $:.include?(vendor)
7
+
8
+ require 'librarian/puppet/cli'
9
+ Librarian::Puppet::Cli.bin!
@@ -0,0 +1,22 @@
1
+ require 'librarian'
2
+ require 'fileutils'
3
+
4
+ begin
5
+ require 'puppet'
6
+ rescue LoadError
7
+ $stderr.puts <<-EOF
8
+ Unable to load puppet. Either install it using native packages for your
9
+ platform (eg .deb, .rpm, .dmg, etc) or as a gem (gem install puppet).
10
+ EOF
11
+ exit 1
12
+ end
13
+
14
+ require 'librarian/puppet/extension'
15
+ require 'librarian/puppet/version'
16
+
17
+ require 'librarian/action/install'
18
+
19
+ module Librarian
20
+ module Puppet
21
+ end
22
+ end
@@ -0,0 +1,85 @@
1
+ require 'librarian/helpers'
2
+
3
+ require 'librarian/cli'
4
+ require 'librarian/puppet'
5
+
6
+ module Librarian
7
+ module Puppet
8
+ class Cli < Librarian::Cli
9
+
10
+ module Particularity
11
+ def root_module
12
+ Puppet
13
+ end
14
+ end
15
+
16
+ include Particularity
17
+ extend Particularity
18
+
19
+ source_root Pathname.new(__FILE__).dirname.join("templates")
20
+
21
+ def init
22
+ copy_file environment.specfile_name
23
+
24
+ if File.exists? ".gitignore"
25
+ gitignore = File.read('.gitignore').split("\n")
26
+ else
27
+ gitignore = []
28
+ end
29
+
30
+ gitignore << ".tmp/" unless gitignore.include? ".tmp/"
31
+ gitignore << "modules/" unless gitignore.include? "modules/"
32
+
33
+ File.open(".gitignore", 'w') do |f|
34
+ f.puts gitignore.join("\n")
35
+ end
36
+ end
37
+
38
+ desc "install", "Resolves and installs all of the dependencies you specify."
39
+ option "quiet", :type => :boolean, :default => false
40
+ option "verbose", :type => :boolean, :default => false
41
+ option "line-numbers", :type => :boolean, :default => false
42
+ option "clean", :type => :boolean, :default => false
43
+ option "strip-dot-git", :type => :boolean
44
+ option "path", :type => :string
45
+ option "destructive", :type => :boolean, :default => false
46
+ option "local", :type => :boolean, :default => false
47
+ def install
48
+ ensure!
49
+ clean! if options["clean"]
50
+ unless options["destructive"].nil?
51
+ environment.config_db.local['destructive'] = options['destructive'].to_s
52
+ end
53
+ if options.include?("strip-dot-git")
54
+ strip_dot_git_val = options["strip-dot-git"] ? "1" : nil
55
+ environment.config_db.local["install.strip-dot-git"] = strip_dot_git_val
56
+ end
57
+ if options.include?("path")
58
+ environment.config_db.local["path"] = options["path"]
59
+ end
60
+
61
+ environment.config_db.local['mode'] = options['local'] ? 'local' : nil
62
+
63
+ resolve!
64
+ install!
65
+ end
66
+
67
+ desc "package", "Cache the puppet modules in vendor/puppet/cache."
68
+ option "quiet", :type => :boolean, :default => false
69
+ option "verbose", :type => :boolean, :default => false
70
+ option "line-numbers", :type => :boolean, :default => false
71
+ option "clean", :type => :boolean, :default => false
72
+ option "strip-dot-git", :type => :boolean
73
+ option "path", :type => :string
74
+ option "destructive", :type => :boolean, :default => false
75
+ def package
76
+ environment.vendor!
77
+ install
78
+ end
79
+
80
+ def version
81
+ say "librarian-puppet v#{Librarian::Puppet::VERSION}"
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,16 @@
1
+ require 'librarian/dsl'
2
+ require 'librarian/puppet/source'
3
+
4
+ module Librarian
5
+ module Puppet
6
+ class Dsl < Librarian::Dsl
7
+
8
+ dependency :mod
9
+
10
+ source :forge => Source::Forge
11
+ source :git => Source::Git
12
+ source :path => Source::Path
13
+ source :github_tarball => Source::GitHubTarball
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,54 @@
1
+ require "librarian/environment"
2
+ require "librarian/puppet/dsl"
3
+ require "librarian/puppet/source"
4
+ require "librarian/puppet/lockfile/parser"
5
+
6
+ module Librarian
7
+ module Puppet
8
+ class Environment < Librarian::Environment
9
+
10
+ def adapter_name
11
+ "puppet"
12
+ end
13
+
14
+ def install_path
15
+ part = config_db["path"] || "modules"
16
+ project_path.join(part)
17
+ end
18
+
19
+ def vendor_path
20
+ project_path.join('vendor/puppet')
21
+ end
22
+
23
+ def vendor_cache
24
+ vendor_path.join('cache')
25
+ end
26
+
27
+ def vendor_source
28
+ vendor_path.join('source')
29
+ end
30
+
31
+ def cache_path
32
+ project_path.join(".tmp/librarian/cache")
33
+ end
34
+
35
+ def scratch_path
36
+ project_path.join(".tmp/librarian/scratch")
37
+ end
38
+
39
+ def vendor!
40
+ vendor_cache.mkpath unless vendor_cache.exist?
41
+ vendor_source.mkpath unless vendor_source.exist?
42
+ end
43
+
44
+ def vendor?
45
+ vendor_path.exist?
46
+ end
47
+
48
+ def local?
49
+ config_db['mode'] == 'local'
50
+ end
51
+
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,47 @@
1
+ require 'librarian/puppet/environment'
2
+
3
+ module Librarian
4
+ module Puppet
5
+ extend self
6
+ extend Librarian
7
+
8
+ end
9
+ end
10
+
11
+ module Librarian
12
+ class Dependency
13
+ class Requirement
14
+ def initialize(*args)
15
+ args = initialize_normalize_args(args)
16
+ self.backing = Gem::Requirement.create(puppet_to_gem_versions(args))
17
+ end
18
+
19
+ def puppet_to_gem_versions(args)
20
+ args.map do |arg|
21
+ case arg
22
+ when Array
23
+ arg.map { |v| puppet_to_gem_version(v) }
24
+ when String
25
+ puppet_to_gem_version(arg)
26
+ else
27
+ # Gem::Requirement, convert to string (ie. =1.0) so we can concat later
28
+ # Gem::Requirements can not be concatenated
29
+ arg.requirements.map{|x,y| "#{x}#{y}"}
30
+ end
31
+ end.flatten
32
+ end
33
+
34
+ # convert Puppet versions to gem supported versions
35
+ # '1.x' to '~>1.0'
36
+ # '>=1.1.0 <2.0.0' to ['>=1.1.0', '<2.0.0']
37
+ # http://docs.puppetlabs.com/puppet/2.7/reference/modules_publishing.html
38
+ def puppet_to_gem_version(version)
39
+ constraints = version.scan(/([~<>=]*[ ]*[\d\.x]+)/).flatten # split the constraints
40
+ constraints.map do |constraint|
41
+ matched = /(.*)\.x/.match(constraint)
42
+ matched.nil? ? constraint : "~>#{matched[1]}.0"
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end