vagrant-cookbook-fetcher 0.3.0 → 0.4.0

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.
@@ -1,8 +1,10 @@
1
+ require 'fileutils'
2
+
1
3
  module VagrantPlugins
2
4
  module CookbookFetcher
3
5
 
4
6
  # Utility method - reads the config, fetches the checkout list,
5
- # does the checkout, and does the crosslinks. Expects cwd to be the root_path.
7
+ # does the checkout, and does the copying-in. Expects cwd to be the root_path.
6
8
  def perform_fetch (args = {})
7
9
  url = args[:url]
8
10
  logger = args[:logger]
@@ -16,7 +18,7 @@ module VagrantPlugins
16
18
  Dir.chdir(path) do
17
19
  checkouts = CookbookFetcher.fetch_checkout_list(url,logger)
18
20
  CookbookFetcher.perform_checkouts(checkouts,logger)
19
- CookbookFetcher.update_links(checkouts,logger)
21
+ CookbookFetcher.update_copies(checkouts,logger)
20
22
  end
21
23
  end
22
24
  module_function :perform_fetch
@@ -165,84 +167,39 @@ module VagrantPlugins
165
167
 
166
168
  # Utility method - given a parsed checkout list, and assuming the checkout have
167
169
  # already been performed, creates the combined/ directory in the current directory,
168
- # and symlinks in the roles, nodes, etc.
169
- def update_links (checkouts,logger)
170
- things_to_link = {
171
- "roles" => {:vagrant_pov_link => true, :target_dir => "roles", :step_in => false },
172
- "nodes" => {:vagrant_pov_link => true, :target_dir => "nodes", :step_in => false },
173
- "handlers" => {:vagrant_pov_link => true, :target_dir => "handlers", :step_in => false },
174
- "data_bags" => {:vagrant_pov_link => true, :target_dir => "data_bags", :step_in => true },
175
- "spec_ext" => {:vagrant_pov_link => false, :target_dir => "spec", :step_in => false },
176
- "spec_int" => {:vagrant_pov_link => true, :target_dir => "spec", :step_in => false },
177
- }
178
- logger.info "Updating links to #{things_to_link.keys.sort.join(', ')}"
179
-
180
- if !Dir.exists?("combined") then Dir.mkdir("combined") end
170
+ # and copies in the roles, nodes, etc.
171
+ def update_copies (checkouts,logger)
172
+ things_to_link = [
173
+ "roles",
174
+ "nodes",
175
+ "handlers",
176
+ "data_bags",
177
+ ]
178
+ logger.info "Copying into combined/ #{things_to_link.sort.join(', ')}"
179
+
180
+ if Dir.exists?("combined") then FileUtils.rm_rf("combined") end
181
+ Dir.mkdir("combined")
181
182
  Dir.chdir("combined") do
182
-
183
183
  # Create/clear the subdirs
184
- things_to_link.keys.each do |thing|
185
- if !Dir.exists?(thing) then Dir.mkdir(thing) end
186
- if (things_to_link[thing][:step_in]) then
187
- Dir.foreach(thing) do |top_dir|
188
- Dir.foreach(thing + '/' + top_dir) do |file|
189
- if FileTest.symlink?(file) then File.delete(file) end
190
- end
191
- end
192
- else
193
- Dir.foreach(thing) do |file|
194
- if FileTest.symlink?(file) then File.delete(file) end
195
- end
196
- end
184
+ things_to_link.each do |thing|
185
+ Dir.mkdir(thing)
197
186
  end
198
187
  end
199
188
 
200
- # Being careful to go in cookbook order, symlink the files
189
+ # Being careful to go in cookbook order, copy the files
201
190
  checkouts[:cookbook_list].each do |cookbook_dir|
202
191
  checkout_dir = (cookbook_dir.split('/'))[1]
203
- things_to_link.each do |thing, opts|
204
- checkout_thing_dir = "checkouts/#{checkout_dir}/#{opts[:target_dir]}"
192
+ things_to_link.each do |thing|
193
+ checkout_thing_dir = "checkouts/#{checkout_dir}/#{thing}"
205
194
  combined_dir = "combined/#{thing}"
195
+
196
+ # If this checkout has anything to contribute
206
197
  if Dir.exists?(checkout_thing_dir) then
207
- if opts[:step_in] then
208
- Dir.foreach(checkout_thing_dir) do |checkout_top_dir|
209
- next unless File.directory?(checkout_thing_dir + '/' + checkout_top_dir)
210
- next if checkout_top_dir.start_with?('.')
211
- combined_top_dir = combined_dir + '/' + checkout_top_dir
212
- if !Dir.exists?(combined_top_dir) then Dir.mkdir(combined_top_dir) end
213
- Dir.entries(checkout_thing_dir + '/' + checkout_top_dir).grep(/\.(rb|json)$/).each do |file|
214
- if opts[:vagrant_pov_link] then
215
- # Under vagrant, we see this directory as /vagrant/checkouts/<checkout>/data_bags/<dbag>/<dbag_entry.json>
216
- # Use -f so later checkouts can override earlier ones
217
- cmd = "ln -sf /vagrant/#{checkout_thing_dir + '/' + checkout_top_dir}/#{file} combined/#{thing}/#{checkout_top_dir}/#{file}"
218
- unless system cmd then raise "Could not '#{cmd}'" end
219
- else
220
- # Link as visible to the host machine
221
- # Use -f so later checkouts can override earlier ones
222
- cmd = "ln -sf ../../#{checkout_thing_dir + '/' + checkout_top_dir}/#{file} combined/#{thing}/#{checkout_top_dir}/#{file}"
223
- unless system cmd then raise "Could not '#{cmd}'" end
224
- end
225
- end
226
- end
227
- else
228
- Dir.entries(checkout_thing_dir).grep(/\.(rb|json)$/).each do |file|
229
- if opts[:vagrant_pov_link] then
230
- # Under vagrant, we see this directory as /vagrant/checkouts/foo/role/bar.rb
231
- # Use -f so later checkouts can override earlier ones
232
- cmd = "ln -sf /vagrant/#{checkout_thing_dir}/#{file} combined/#{thing}/#{file}"
233
- unless system cmd then raise "Could not '#{cmd}'" end
234
- else
235
- # Link as visible to the host machine
236
- # Use -f so later checkouts can override earlier ones
237
- cmd = "ln -sf ../../#{checkout_thing_dir}/#{file} combined/#{thing}/#{file}"
238
- unless system cmd then raise "Could not '#{cmd}'" end
239
- end
240
- end
241
- end
198
+ FileUtils.cp_r("#{checkout_thing_dir}/.", combined_dir)
242
199
  end
243
200
  end
244
201
  end
245
202
  end
246
- module_function :update_links
203
+ module_function :update_copies
247
204
  end
248
205
  end
@@ -1,7 +1,7 @@
1
1
  module VagrantPlugins
2
2
  module CookbookFetcher
3
3
  NAME = "vagrant-cookbook-fetcher"
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  AUTHOR = "Clinton Wolfe"
6
6
  AUTHOR_EMAIL = "clintoncwolfe [at] gmail [dot] com"
7
7
  SUMMARY = "Fetch your Chef cookbooks whenever you provision"
metadata CHANGED
@@ -1,31 +1,26 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: vagrant-cookbook-fetcher
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0
4
5
  prerelease:
5
- version: 0.3.0
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Clinton Wolfe
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2016-04-01 00:00:00 Z
12
+ date: 2016-04-14 00:00:00.000000000 Z
14
13
  dependencies: []
15
-
16
14
  description: Fetch your Chef cookbooks whenever you provision
17
15
  email: clintoncwolfe [at] gmail [dot] com
18
16
  executables: []
19
-
20
17
  extensions: []
21
-
22
18
  extra_rdoc_files: []
23
-
24
- files:
19
+ files:
25
20
  - README.md
21
+ - lib/vagrant-cookbook-fetcher/command.rb
26
22
  - lib/vagrant-cookbook-fetcher/action_fetch_cookbooks.rb
27
23
  - lib/vagrant-cookbook-fetcher/action_set_chef_paths.rb
28
- - lib/vagrant-cookbook-fetcher/command.rb
29
24
  - lib/vagrant-cookbook-fetcher/config.rb
30
25
  - lib/vagrant-cookbook-fetcher/guts.rb
31
26
  - lib/vagrant-cookbook-fetcher/plugin.rb
@@ -33,30 +28,28 @@ files:
33
28
  - lib/vagrant-cookbook-fetcher.rb
34
29
  homepage: http://github.com/clintoncwolfe/vagrant-cookbook-fetcher
35
30
  licenses: []
36
-
37
31
  post_install_message:
38
32
  rdoc_options: []
39
-
40
- require_paths:
33
+ require_paths:
41
34
  - lib
42
- required_ruby_version: !ruby/object:Gem::Requirement
35
+ required_ruby_version: !ruby/object:Gem::Requirement
43
36
  none: false
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: "0"
48
- required_rubygems_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
42
  none: false
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: "0"
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
54
47
  requirements: []
55
-
56
48
  rubyforge_project: vagrant-cookbook-fetcher
57
- rubygems_version: 1.8.23.2
49
+ rubygems_version: 1.8.23
58
50
  signing_key:
59
51
  specification_version: 3
60
- summary: Whenever you run start, up, or provision, this plugin will dynamically fetch a list of checkouts from a URL; checkout each one; then create a combined roles directory, with symlinks.
52
+ summary: Whenever you run start, up, or provision, this plugin will dynamically fetch
53
+ a list of checkouts from a URL; checkout each one; then create a combined roles
54
+ directory, with symlinks.
61
55
  test_files: []
62
-