Class: ChefCLI::Command::DescribeCookbook
- Defined in:
- lib/chef-cli/command/describe_cookbook.rb
Instance Attribute Summary collapse
-
#cookbook_path ⇒ Object
readonly
Returns the value of attribute cookbook_path.
-
#ui ⇒ Object
readonly
Returns the value of attribute ui.
Instance Method Summary collapse
- #apply_params!(params) ⇒ Object
- #check_cookbook_path ⇒ Object
-
#initialize(*args) ⇒ DescribeCookbook
constructor
A new instance of DescribeCookbook.
- #run(params = []) ⇒ Object
Methods inherited from Base
#check_license_acceptance, #needs_help?, #needs_version?, #run_with_default_options
Methods included from Helpers
#err, #git_bin_dir, #git_windows_bin_dir, #msg, #omnibus_bin_dir, #omnibus_embedded_bin_dir, #omnibus_env, #omnibus_expand_path, #omnibus_install?, #omnibus_root, #package_home, #stderr, #stdout, #system_command, #usr_bin_path, #usr_bin_prefix
Constructor Details
#initialize(*args) ⇒ DescribeCookbook
Returns a new instance of DescribeCookbook.
74 75 76 77 78 |
# File 'lib/chef-cli/command/describe_cookbook.rb', line 74 def initialize(*args) super @cookbook_path = nil @ui = UI.new end |
Instance Attribute Details
#cookbook_path ⇒ Object (readonly)
Returns the value of attribute cookbook_path.
71 72 73 |
# File 'lib/chef-cli/command/describe_cookbook.rb', line 71 def cookbook_path @cookbook_path end |
#ui ⇒ Object (readonly)
Returns the value of attribute ui.
72 73 74 |
# File 'lib/chef-cli/command/describe_cookbook.rb', line 72 def ui @ui end |
Instance Method Details
#apply_params!(params) ⇒ Object
103 104 105 106 107 108 109 110 111 112 |
# File 'lib/chef-cli/command/describe_cookbook.rb', line 103 def apply_params!(params) remaining_args = (params) if remaining_args.size != 1 ui.err(opt_parser) false else @cookbook_path = File.(remaining_args.first) true end end |
#check_cookbook_path ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/chef-cli/command/describe_cookbook.rb', line 87 def check_cookbook_path unless File.exist?(cookbook_path) ui.err("Given cookbook path '#{cookbook_path}' does not exist or is not readable") return false end mdrb_path = File.join(cookbook_path, "metadata.rb") mdjson_path = File.join(cookbook_path, "metadata.json") unless File.exist?(mdrb_path) || File.exist?(mdjson_path) ui.err("Given cookbook path '#{cookbook_path}' does not appear to be a cookbook, it does not contain a metadata.rb or metadata.json") return false end true end |