class Bosh::Gen::Generators::JobTemplateGenerator

Public Instance Methods

add_template_to_spec() click to toggle source
# File lib/bosh/gen/generators/job_template_generator.rb, line 31
def add_template_to_spec
  current_spec = YAML.load_file(job_dir("spec"))
  current_spec["templates"] ||= {}
  current_spec["templates"][template_name] = file_path
  create_file job_dir("spec"), YAML.dump(current_spec), :force => true
end
check_file_path() click to toggle source
# File lib/bosh/gen/generators/job_template_generator.rb, line 23
def check_file_path
  raise Thor::Error.new("'#{file_path}' must be a relative path, such as 'config/httpd.conf'") if file_path[0] == "/"
end
check_job() click to toggle source
# File lib/bosh/gen/generators/job_template_generator.rb, line 18
def check_job
  raise Thor::Error.new("'#{job_name}' job does not yet exist; either create or fix spelling") unless File.exist?(job_dir(""))
  raise Thor::Error.new("'jobs/#{job_name}/spec' is missing") unless File.exist?(job_dir("spec"))
end
check_root_is_release() click to toggle source
# File lib/bosh/gen/generators/job_template_generator.rb, line 12
def check_root_is_release
  unless File.exist?("jobs") && File.exist?("packages")
    raise Thor::Error.new("run inside a BOSH release project")
  end
end
touch_template_erb() click to toggle source
# File lib/bosh/gen/generators/job_template_generator.rb, line 27
def touch_template_erb
  create_file job_template_dir(template_name)
end

Private Instance Methods

file_name() click to toggle source
# File lib/bosh/gen/generators/job_template_generator.rb, line 39
def file_name
  File.basename(file_path)
end
job_dir(path) click to toggle source
# File lib/bosh/gen/generators/job_template_generator.rb, line 47
def job_dir(path)
  File.join("jobs", job_name, path)
end
job_template_dir(path) click to toggle source
# File lib/bosh/gen/generators/job_template_generator.rb, line 51
def job_template_dir(path)
  File.join("jobs", job_name, "templates", path)
end
template_name() click to toggle source
# File lib/bosh/gen/generators/job_template_generator.rb, line 43
def template_name
  "#{file_name}.erb"
end