class Object
Public Instance Methods
get_boxen_template(target_dir)
click to toggle source
# File bin/cardboardify, line 38 def get_boxen_template(target_dir) Dir.chdir(target_dir) do download = `curl -s -L https://github.com/boxen/puppet-template/archive/master.tar.gz | tar zx --strip-components 1` setup_bundle = `bundle install --binstubs .bundle/binstubs --path .bundle --quiet` remove_git = `rm -rf .git` git_init = `git init .` end end
modify_template_files(module_name, application_name)
click to toggle source
# File bin/cardboardify, line 30 def modify_template_files(module_name, application_name) Dir.chdir(module_name) do FileUtils.mv "spec/fixtures/modules/template/", "spec/fixtures/modules/#{application_name}/" FileUtils.mv "spec/classes/template_spec.rb", "spec/classes/#{application_name}_spec.rb" remove_template_references(application_name) end end
remove_template_references(application_name)
click to toggle source
# File bin/cardboardify, line 47 def remove_template_references(application_name) files_to_fix = ["manifests/init.pp", "spec/classes/#{application_name}_spec.rb"] files_to_fix.each do | file_to_fix | replace = "" File.open(file_to_fix) do |file| file.lines.each do |line| replace << line.gsub(/template/,"#{application_name}") end end File.open(file_to_fix, "w") {|file| file.puts replace} end end
run(args)
click to toggle source
# File bin/cardboardify, line 5 def run(args) if args[0].nil? abort "cardboardify: Please specify the name of the module you wish to make" elsif args.length > 1 abort "cardboardify: Too many arguments, one at a time please." end application_name = args[0] module_name = "puppet-#{args[0]}" if File.exists?(module_name) warn "cardboardify: #{module_name}/ already exists" return 1 elsif File.exists?(module_name.downcase) warn "cardboardify: '#{module_name.downcase}' exists, which could conflict with `#{module_name}'" return 1 else puts "cardboardify: Creating '#{module_name}', this may take a few minutes" FileUtils.mkdir_p(module_name) get_boxen_template(module_name) modify_template_files(module_name, application_name) puts "cardboardify complete!" return 0 end end