lib/minke/generators/processor.rb in minke-1.12.9 vs lib/minke/generators/processor.rb in minke-1.13.0
- old
+ new
@@ -3,29 +3,29 @@
##
# Process handles the creation of new projects from a generator template.
class Processor
def self.load_generators
- puts '# Loading installed generators'
Gem::Specification.find_all.each do |spec|
if spec.metadata != nil && spec.metadata['entrypoint'] != nil
require spec.metadata['entrypoint']
end
end
end
- def initialize variables, docker_runner
+ def initialize variables, docker_runner, logger
+ @logger = logger
@variables = variables
@docker_runner = docker_runner
end
def process generator_name, output_folder
generator = get_generator generator_name
# process the files
- puts '# Modifiying templates'
- puts "#{generator.template_location}"
+ @logger.info '# Modifiying templates'
+ @logger.debug "#{generator.template_location}"
process_directory generator.template_location, '**/*', output_folder, @variables.application_name
process_directory generator.template_location, '**/.*', output_folder, @variables.application_name
# run generate command if present
@@ -35,42 +35,42 @@
run_command_in_container image, generator.generate_settings.command unless generator.generate_settings.command == nil
end
# write the shell script
- Minke::Generators::write_bash_script output_folder + "/_build/minke.sh"
+ Minke::Generators::write_bash_script output_folder + "/_build/minke"
Minke::Generators::create_rvm_files output_folder + "/_build/", @variables.application_name
end
def build_image docker_file
- puts "## Building custom docker image"
+ @logger.info "## Building custom docker image"
image_name = @variables.application_name + "-buildimage"
- puts @docker_runner.build_image docker_file, image_name
+ @docker_runner.build_image docker_file, image_name
end
def fetch_image docker_image
@docker_runner.pull_image docker_image unless @docker_runner.find_image docker_image
docker_image
end
def run_command_in_container build_image, command
- puts command
+ @logger.debug command
begin
container, success = @docker_runner.create_and_run_container build_image, ["#{File.expand_path(@variables.src_root)}:/src"], nil, '/src', command
# throw exception if failed
- @helper.fatal_error "Unable to run command #{command}" unless success
+ @helper.fatal_error " #{command}" unless success
#command = Minke::Helpers.replace_vars_in_section generator.generate_command, '##SERVICE_NAME##', APPLICATION_NAME
#container, ret = Minke::Docker.create_and_run_container config, command
ensure
@docker_runner.delete_container container
end
end
def process_directory template_location, folder, output_folder, service_name
Dir.glob("#{template_location}/#{folder}").each do |file_name|
- puts "## Processing #{file_name}"
+ @logger.debug "## Processing #{file_name}"
process_file template_location, file_name, output_folder, service_name
end
end
def process_file template_location, original, output_folder, service_name