Class: Bosh::Gen::Generators::JobTemplateGenerator
- Includes:
- Thor::Actions
- Defined in:
- lib/bosh/gen/generators/job_template_generator.rb
Instance Method Summary collapse
- #add_template_to_spec ⇒ Object
- #check_file_path ⇒ Object
- #check_job ⇒ Object
- #check_root_is_release ⇒ Object
- #touch_template_erb ⇒ Object
Instance Method Details
#add_template_to_spec ⇒ Object
31 32 33 34 35 36 |
# 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 ⇒ Object
23 24 25 |
# 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 ⇒ Object
18 19 20 21 |
# 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 ⇒ Object
12 13 14 15 16 |
# 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 ⇒ Object
27 28 29 |
# File 'lib/bosh/gen/generators/job_template_generator.rb', line 27 def touch_template_erb create_file job_template_dir(template_name) end |