Class: ChefDK::Command::GeneratorCommands::App
- Inherits:
-
Base
- Object
- Base
- ChefDK::Command::GeneratorCommands::App
show all
- Defined in:
- lib/chef-dk/command/generator_commands/app.rb
Overview
## App chef generate app path/to/basename –generator-cookbook=path/to/generator
Generates a full “application” directory structure.
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Base
#needs_help?, #needs_version?, #run_with_default_options
Methods included from Helpers
#chefdk_home, #err, #git_bin_dir, #git_windows_bin_dir, #msg, #omnibus_apps_dir, #omnibus_bin_dir, #omnibus_chefdk_location, #omnibus_embedded_bin_dir, #omnibus_env, #omnibus_install?, #omnibus_root, #stderr, #stdout, #system_command, #usr_bin_path, #usr_bin_prefix
Constructor Details
#initialize(params) ⇒ App
Returns a new instance of App.
37
38
39
40
41
|
# File 'lib/chef-dk/command/generator_commands/app.rb', line 37
def initialize(params)
@params_valid = true
@app_name = nil
super
end
|
Instance Attribute Details
#app_name_or_path ⇒ Object
Returns the value of attribute app_name_or_path.
33
34
35
|
# File 'lib/chef-dk/command/generator_commands/app.rb', line 33
def app_name_or_path
@app_name_or_path
end
|
#errors ⇒ Object
Returns the value of attribute errors.
32
33
34
|
# File 'lib/chef-dk/command/generator_commands/app.rb', line 32
def errors
@errors
end
|
Instance Method Details
#app_full_path ⇒ Object
90
91
92
|
# File 'lib/chef-dk/command/generator_commands/app.rb', line 90
def app_full_path
File.expand_path(app_name_or_path, Dir.pwd)
end
|
#app_name ⇒ Object
74
75
76
|
# File 'lib/chef-dk/command/generator_commands/app.rb', line 74
def app_name
File.basename(app_full_path)
end
|
#app_root ⇒ Object
78
79
80
|
# File 'lib/chef-dk/command/generator_commands/app.rb', line 78
def app_root
File.dirname(app_full_path)
end
|
#cookbook_name ⇒ Object
86
87
88
|
# File 'lib/chef-dk/command/generator_commands/app.rb', line 86
def cookbook_name
app_name
end
|
#cookbook_root ⇒ Object
82
83
84
|
# File 'lib/chef-dk/command/generator_commands/app.rb', line 82
def cookbook_root
File.join(app_full_path, 'cookbooks')
end
|
#params_valid? ⇒ Boolean
100
101
102
|
# File 'lib/chef-dk/command/generator_commands/app.rb', line 100
def params_valid?
@params_valid
end
|
#read_and_validate_params ⇒ Object
94
95
96
97
98
|
# File 'lib/chef-dk/command/generator_commands/app.rb', line 94
def read_and_validate_params
arguments = parse_options(params)
@app_name_or_path = arguments[0]
@params_valid = false unless @app_name_or_path
end
|
#recipe ⇒ Object
66
67
68
|
# File 'lib/chef-dk/command/generator_commands/app.rb', line 66
def recipe
"app"
end
|
#recipe_name ⇒ Object
70
71
72
|
# File 'lib/chef-dk/command/generator_commands/app.rb', line 70
def recipe_name
"default"
end
|
#run ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/chef-dk/command/generator_commands/app.rb', line 43
def run
read_and_validate_params
if params_valid?
setup_context
chef_runner.converge
else
err(opt_parser)
1
end
rescue ChefDK::ChefRunnerError => e
err("ERROR: #{e}")
1
end
|