-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecipe_steps.rb
More file actions
23 lines (23 loc) · 954 Bytes
/
Copy pathrecipe_steps.rb
File metadata and controls
23 lines (23 loc) · 954 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Given /^the cookbook has a '(.+)' named '(.+)' in the '(.+)' specific directory$/ do |file_type, filename, specificity|
cookbook_name, recipe_name = recipe.split('::')
type_dir = file_type == 'file' ? 'files' : 'templates'
specific_dir = nil
case specificity
when "host"
specific_dir = "host-#{client.node[:fqdn]}"
when "platform-version"
specific_dir = "#{client.node[:platform]}-#{client.node[:platform_version]}"
when "platform"
specific_dir = client.node[:platform]
when "default"
specific_dir = "default"
end
new_file_dir = File.expand_path(File.dirname(__FILE__) + "/../data/cookbooks/#{cookbook_name}/#{type_dir}/#{specific_dir}")
cleanup_dirs << new_file_dir unless new_file_dir =~ /default$/
system("mkdir -p #{new_file_dir}")
new_file_name = File.join(new_file_dir, filename)
cleanup_files << new_file_name
new_file = File.open(new_file_name, "w")
new_file.puts(specificity)
new_file.close
end