Class: Arli::Commands::Generate
- Extended by:
- Forwardable
- Includes:
- Helpers::SystemCommands
- Defined in:
- lib/arli/commands/generate.rb
Constant Summary
Constants included from Helpers::Output
Helpers::Output::CHAR_FAILURE, Helpers::Output::CHAR_SUCCESS
Instance Attribute Summary collapse
-
#dir ⇒ Object
Returns the value of attribute dir.
-
#settings ⇒ Object
Returns the value of attribute settings.
Attributes inherited from Base
Instance Method Summary collapse
- #additional_info ⇒ Object
- #run ⇒ Object
- #run_with_info(message, command = nil) ⇒ Object
- #setup ⇒ Object
Methods included from Helpers::SystemCommands
#backup!, #handle_preexisting_folder, #run_system_command
Methods included from Helpers::Output
#___, #__p, #__pf, #__pt, #abort?, #action_fail, #action_ok, #backup?, #cursor, #debug, #debug?, disable!, enable!, enabled?, #error, #fuck, #header, #hr, #indent_cursor, #info, #ok, #overwrite?, #print_action_failure, #print_action_starting, #print_action_success, #print_target_dir, #quiet?, #raise_invalid_arli_command!, #report_exception, #verbose?
Methods inherited from Base
#initialize, #library_path, #params, #runtime, #temp_path
Constructor Details
This class inherits a constructor from Arli::Commands::Base
Instance Attribute Details
#dir ⇒ Object
Returns the value of attribute dir.
16 17 18 |
# File 'lib/arli/commands/generate.rb', line 16 def dir @dir end |
#settings ⇒ Object
Returns the value of attribute settings.
16 17 18 |
# File 'lib/arli/commands/generate.rb', line 16 def settings @settings end |
Instance Method Details
#additional_info ⇒ Object
70 71 72 73 |
# File 'lib/arli/commands/generate.rb', line 70 def additional_info "\nGenerating project #{project_name.bold.green} into #{workspace.bold.yellow}\n" + "Template: #{template_repo.bold.red}\n" end |
#run ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/arli/commands/generate.rb', line 31 def run Dir.chdir(workspace) do run_with_info( "Grabbing the template from\n • #{template_repo.bold.green}...", "git clone -v #{template_repo} #{project_name} 2>&1" ) Dir.chdir(project_name) do FileUtils.rm_rf('.git') FileUtils.rm_rf('example') run_with_info( "Configuring the new project #{project_name.bold.yellow}", 'git init .' ) run_with_info('Customizing your README and other files...') rename_files! configure_template! run_with_info( 'Running setup of the dependencies...', 'bin/setup' ) run_with_info("The project #{project_name.bold.yellow} is ready.\n" + 'Follow README.md for build instructions.') end end __pt hr end |
#run_with_info(message, command = nil) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/arli/commands/generate.rb', line 58 def run_with_info(, command = nil) indent = ' ' ok_indent = indent + ' ✔ '.green err_indent = indent + ' X '.red info("\n" + .magenta) return unless command info(indent + command.bold.yellow) o, e, s = run_system_command(command) info(ok_indent + o.chomp.gsub(/\n/, "\n#{ok_indent}").blue) if o && o.chomp != '' warn(err_indent + +e.chomp.gsub(/\n/, "\n#{err_indent}").red) if e && e.chomp != '' end |
#setup ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/arli/commands/generate.rb', line 18 def setup config.generate.project_name = config.runtime.argv.first self.settings = config.generate raise ::Arli::Errors::RequiredArgumentsMissing, 'Project name is required' unless project_name raise ::Arli::Errors::RequiredArgumentsMissing, 'Template Repo is missing' unless template_repo self.dir = settings.workspace + '/' + project_name handle_preexisting_folder(dir) if Dir.exist?(dir) FileUtils.mkdir_p(workspace) unless Dir.exist?(workspace) end |