class Kameleon::CLI::Template
Public Class Methods
Source
# File lib/kameleon/cli.rb, line 55 def self.source_root Kameleon.env.repositories_path end
Public Instance Methods
Source
# File lib/kameleon/cli.rb, line 137 def commands puts Template.all_commands.keys - ["commands"] end
Source
# File lib/kameleon/cli.rb, line 124 def erb(path) if File.directory?(path) erb_file = Pathname.new(path).join(Kameleon.default_values[:extend_yaml_erb]) elsif File.file?(path) and path.end_with?(".yaml") erb_file = Pathname.new(path.gsub(%r{^(.+?/)?([^/]+?)(\.yaml)?$},'\1.\2') + Kameleon.default_values[:extend_yaml_erb]) else fail KameleonError, "Invalid path '#{path}', please give a path to a yaml file or a directory" end Kameleon.ui.verbose("Create extend recipe ERB '#{erb_file}'") copy_file(Pathname.new(Kameleon.erb_dirpath).join("extend.yaml.erb"), erb_file) end
Source
# File lib/kameleon/cli.rb, line 76 def import(template_name) Kameleon.env.root_dir = Kameleon.env.repositories_path template_path = File.join(Kameleon.env.repositories_path, template_name) unless template_name.end_with? '.yaml' template_path = template_path + '.yaml' end # Manage global as it is not passed to env by default if options[:global] Kameleon.env.global.merge!(options[:global]) end begin tpl = RecipeTemplate.new(template_path) tpl.resolve! :strict => false rescue raise if Kameleon.ui.level("verbose") raise TemplateNotFound, "Template '#{template_name}' invalid (try" \ " --verbose) or not found. To see all templates, run the command "\ "`kameleon template list`" else tpl.all_files.each do |path| relative_path = path.relative_path_from(Kameleon.env.repositories_path) dst = File.join(Kameleon.env.workspace, relative_path) copy_file(path, dst) chmod(dst, File.stat(path).mode, {:verbose=>false}) end end end
Source
# File lib/kameleon/cli.rb, line 108 def info(template_name) Kameleon.env.root_dir = Kameleon.env.repositories_path template_path = File.join(Kameleon.env.repositories_path, template_name) unless template_name.end_with? '.yaml' template_path = template_path + '.yaml' end # Manage global as it is not passed to env by default if options[:global] Kameleon.env.global.merge!(options[:global]) end tpl = RecipeTemplate.new(template_path) tpl.resolve! :strict => false tpl.display_info(false) end
Source
# File lib/kameleon/cli.rb, line 66 def list Kameleon.ui.shell.say "Recipe templates available in: ", :red, false Kameleon.ui.shell.say Kameleon.env.repositories_path.to_s, :yellow Utils.list_recipes(Kameleon.env.repositories_path, options[:filter], options[:progress], true) end