Class: Bosh::Gen::Generators::BlacksmithForgeGenerator

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/bosh/gen/generators/blacksmith_forge_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



11
12
13
# File 'lib/bosh/gen/generators/blacksmith_forge_generator.rb', line 11

def self.source_root
  File.join(File.dirname(__FILE__), "blacksmith_forge_generator", "templates")
end

Instance Method Details

#check_nameObject

Raises:

  • (Thor::Error)


25
26
27
# File 'lib/bosh/gen/generators/blacksmith_forge_generator.rb', line 25

def check_name
  raise Thor::Error.new("'#{name}' is not a valid BOSH id") unless "#{name}-blacksmith-plans".bosh_valid_id?
end

#check_root_is_releaseObject

FYI, bosh-gen (the CLI) will eventually call Thor, telling it to ‘start()` Don’t bother looking for a start() function anywhere; Thor just calls all of the public methods of this class.



19
20
21
22
23
# File 'lib/bosh/gen/generators/blacksmith_forge_generator.rb', line 19

def check_root_is_release
  unless File.exist?("jobs") && File.exist?("packages")
    raise Thor::Error.new("run inside a BOSH release project")
  end
end

#copy_filesObject



29
30
31
32
# File 'lib/bosh/gen/generators/blacksmith_forge_generator.rb', line 29

def copy_files
  generator_job_templates_path = File.join(self.class.source_root, "jobs/%job_name%")
  directory "jobs/%job_name%", "jobs/#{job_name}"
end