class Chef::Knife::RoleFromFile

Public Class Methods

new(argv=[]) click to toggle source

Create a new instance of the current class configured for the given arguments and options

Calls superclass method
# File lib/chef/knife/chop/role_from_file.rb, line 11
def initialize(argv=[])
  super(argv)
  @rsrctype = 'role'
  @location = 'roles'
end

Public Instance Methods

run() click to toggle source
# File lib/chef/knife/chop/role_from_file.rb, line 17
def run
  @name_args.each do |arg|
    updated = loader.load_from("roles", arg)

    updated.save

    output(format_for_display(updated)) if config[:print_after]

    ui.info("Updated Role #{updated.name}!")
  end
end

Private Instance Methods

translate_all_roles() click to toggle source

# File lib/chef/knife/chop/role_from_file.rb, line 34
def translate_all_roles
  roles = find_all_roles
  if roles.empty?
    ui.fatal("Unable to find any role files in '#{roles_path}'")
    exit(1)
  end
  roles.each do |env|
    translate_role(env)
  end
end
translate_role(env) click to toggle source

# File lib/chef/knife/chop/role_from_file.rb, line 46
def translate_role(env)
  updated = loader.load_from("roles", env)
  updated.translate(@config,env)
  output(format_for_display(updated)) if config[:print_after]
  ui.info("Translated Role #{updated.name}")
end