Sha256: 4890f19db800668bd35469d8212a5f4adf986cad72afcfd317a36ea6238465dc

Contents?: true

Size: 666 Bytes

Versions: 16

Compression:

Stored size: 666 Bytes

Contents

context = ChefDK::Generator.context
cookbook_dir = File.join(context.cookbook_root, context.cookbook_name)
libraries_dir = File.join(cookbook_dir, 'libraries')
helpers_path = File.join(cookbook_dir, 'libraries', "#{context.new_file_basename}.rb")

directory libraries_dir

def camelize(name)
  name.to_s.split(/[^a-zA-Z]/).map(&:capitalize).join
end

cookbook_class_name = camelize(context.cookbook_name)
helper_class_name = "#{camelize(context.new_file_basename)}Helpers"

template helpers_path do
  source 'helpers.rb.erb'
  helpers(ChefDK::Generator::TemplateHelper)
  variables(cookbook_class_name: cookbook_class_name, helper_class_name: helper_class_name)
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
chef-dk-4.13.3 lib/chef-dk/skeletons/code_generator/recipes/helpers.rb
chef-dk-4.12.0 lib/chef-dk/skeletons/code_generator/recipes/helpers.rb
chef-dk-4.11.0 lib/chef-dk/skeletons/code_generator/recipes/helpers.rb
chef-dk-4.10.0 lib/chef-dk/skeletons/code_generator/recipes/helpers.rb
chef-dk-4.9.7 lib/chef-dk/skeletons/code_generator/recipes/helpers.rb
chef-dk-4.7.73 lib/chef-dk/skeletons/code_generator/recipes/helpers.rb
chef-dk-3.13.1 lib/chef-dk/skeletons/code_generator/recipes/helpers.rb
chef-dk-4.6.35 lib/chef-dk/skeletons/code_generator/recipes/helpers.rb
chef-dk-3.12.10 lib/chef-dk/skeletons/code_generator/recipes/helpers.rb
chef-dk-3.12.0 lib/chef-dk/skeletons/code_generator/recipes/helpers.rb
chef-dk-4.5.0 lib/chef-dk/skeletons/code_generator/recipes/helpers.rb
chef-dk-4.4.27 lib/chef-dk/skeletons/code_generator/recipes/helpers.rb
chef-dk-4.3.13 lib/chef-dk/skeletons/code_generator/recipes/helpers.rb
chef-dk-4.2.0 lib/chef-dk/skeletons/code_generator/recipes/helpers.rb
chef-dk-4.1.7 lib/chef-dk/skeletons/code_generator/recipes/helpers.rb
chef-dk-4.0.60 lib/chef-dk/skeletons/code_generator/recipes/helpers.rb