Sha256: f7a766c64a226a9149ac6ff694042b58fb05ce743a2a474431f4bfd41e6aa6e2

Contents?: true

Size: 668 Bytes

Versions: 52

Compression:

Stored size: 668 Bytes

Contents

context = ChefCLI::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(ChefCLI::Generator::TemplateHelper)
  variables(cookbook_class_name: cookbook_class_name, helper_class_name: helper_class_name)
end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
chef-cli-3.0.7 lib/chef-cli/skeletons/code_generator/recipes/helpers.rb
chef-cli-3.0.4 lib/chef-cli/skeletons/code_generator/recipes/helpers.rb
chef-cli-3.0.1 lib/chef-cli/skeletons/code_generator/recipes/helpers.rb
chef-cli-2.0.10 lib/chef-cli/skeletons/code_generator/recipes/helpers.rb
chef-cli-2.0.0 lib/chef-cli/skeletons/code_generator/recipes/helpers.rb
chef-cli-1.0.16 lib/chef-cli/skeletons/code_generator/recipes/helpers.rb
chef-cli-1.0.14 lib/chef-cli/skeletons/code_generator/recipes/helpers.rb
chef-cli-1.0.13 lib/chef-cli/skeletons/code_generator/recipes/helpers.rb
chef-cli-1.0.11 lib/chef-cli/skeletons/code_generator/recipes/helpers.rb
chef-cli-1.0.9 lib/chef-cli/skeletons/code_generator/recipes/helpers.rb
chef-cli-1.0.6 lib/chef-cli/skeletons/code_generator/recipes/helpers.rb
chef-cli-1.0.3 lib/chef-cli/skeletons/code_generator/recipes/helpers.rb