class Lightning::Bolt::Storm
Public Instance Methods
strike(schematics)
click to toggle source
# File lib/lightning/bolt/cli.rb, line 10 def strike(schematics) puts battle.report('english') end
thunder()
click to toggle source
# File lib/lightning/bolt/cli.rb, line 17 def thunder() install('payload.yml') end
Private Instance Methods
install(template_file)
click to toggle source
# File lib/lightning/bolt/cli.rb, line 21 def install(template_file) install_path = options[:install] ? options[:install] : '.' filename = options[:name] ? options[:name] : template_file template = File.read(File.join(File.dirname(__FILE__),'templates',template_file)) success = false msg = '' file = File.join(install_path, filename) if File.exists?(file) warn "[skip] `#{filename}' already exists" if yes?("Would you like to overwrite the existing file?") msg = "#{filename} has been overwritten" success=true end elsif File.exists?(file.downcase) warn "[skip] `#{filename.downcase}' exists, which could conflict with `#{filename}'" if yes?("Would you like to overwrite the existing file?") msg = "#{filename} has been overwritten" success=true end elsif !File.exists?(File.dirname(file)) warn "[skip] directory `#{File.dirname(file)}' does not exist" if yes?("Would you like to make the directory?") FileUtils.mkdir_p(install_path) msg = "The directory #{install_path} was created" success=true end else msg = "There were no issues with the installation" success=true end if success puts "[add] writing `#{filename}'" File.open(file, "w") { |f| f.write(template) } puts "#{msg}" puts "[done] Lightning Bolt was successfully installed. Stay safe." else puts "[error] Lightning Bolt was not successfully installed." end end