lib/gemstrapper.rb
def init(options)
		options = default_options(options[:project_name]).update(options)

		new_files = []

		files = template_files_for_gem(options)

		#require 'pry';binding.pry

		files.each do |file|
			## creates directories
			# converting project name placeholder to actual project name and stripping off erb extension
			new_file_path = file.gsub('project_name', options[:project_name]).gsub('.erb', '')

			new_file_path.gsub!('project_file_name', options[:project_file_name])
			# converting executable_name placeholder for any executable file names into valid names for the gem
			new_file_path.gsub!('executable_name', options[:project_file_name])

			directory = File.dirname(new_file_path)

			unless File.exist? directory
				FileUtils.mkdir_p directory
			end

			data = process_template(File.join(TEMPLATES_DIRECTORY, file), options)
			File.write(new_file_path, data)
			new_files << new_file_path
		end

		## modifying executable files to be executable
		# TODO: Check windows compatibility with this feature
		exe_files = new_files.select {|f| f.include? 'bin/'}.each do |file|
			File.chmod(0755, file)
		end

		#reporting
		new_files.each do |nf|
			puts "#{nf} created"
		end
	end
##
# Initialises a gem folder structure based on the project name passed in from the command
# line and populates it with command files and configuration
# @param [Hash] options The options passed in from the command line execution
# @return [void]
Initialises a gem folder structure based on the project name passed in from the command
line and populates it with command files and configuration
Initialises a gem folder structure based on the project name passed in from the command line and populates it with command files and configuration
def init(options)
		options = default_options(options[:project_name]).update(options)
		new_files = []
		files = template_files_for_gem(options)
		files.each do |file|
			new_file_path = file.gsub('project_name', options[:project_name]).gsub('.erb', '')
			new_file_path.gsub!('project_file_name', options[:project_file_name])
			new_file_path.gsub!('executable_name', options[:project_file_name])
			directory = File.dirname(new_file_path)
			unless File.exist? directory
				FileUtils.mkdir_p directory
			end
			data = process_template(File.join(TEMPLATES_DIRECTORY, file), options)
			File.write(new_file_path, data)
			new_files << new_file_path
		end
		exe_files = new_files.select {|f| f.include? 'bin/'}.each do |file|
			File.chmod(0755, file)
		end
		new_files.each do |nf|
			puts "#{nf} created"
		end
	end
def init ( options ) options = default_options ( options [ :project_name ] ) . update ( options ) new_files = [ ] files = template_files_for_gem ( options ) files . each do | file | new_file_path = file . gsub ( 'project_name' , options [ :project_name ] ) . gsub ( '.erb' , '' ) new_file_path . gsub! ( 'project_file_name' , options [ :project_file_name ] ) new_file_path . gsub! ( 'executable_name' , options [ :project_file_name ] ) directory = File . dirname ( new_file_path ) unless File . exist? directory FileUtils . mkdir_p directory end data = process_template ( File . join ( TEMPLATES_DIRECTORY , file ) , options ) File . write ( new_file_path , data ) new_files << new_file_path end exe_files = new_files . select { | f | f . include? 'bin/' } . each do | file | File . chmod ( 0755 , file ) end new_files . each do | nf | puts "#{nf} created" end end
Initialises a gem folder structure based on the project name passed in from the command
line and populates it with command files and configuration
Initialises a gem folder structure based on the project name passed in from the command line and populates it with command files and configuration
#require 'pry';binding.pry ## creates directories # converting project name placeholder to actual project name and stripping off erb extension # converting executable_name placeholder for any executable file names into valid names for the gem ## modifying executable files to be executable # TODO: Check windows compatibility with this feature #reporting
None
void
options
options The options passed in from the command line execution
options The options passed in from the command line execution