Class: Ronin::CLI::Commands::New::Project Private
- Inherits:
-
Ronin::CLI::Command
- Object
- Core::CLI::Command
- Ronin::CLI::Command
- Ronin::CLI::Commands::New::Project
- Includes:
- Core::CLI::Generator
- Defined in:
- lib/ronin/cli/commands/new/project.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Creates new Ruby project directory.
Usage
ronin new project [options] DIR
Options
--git Initializes a git repo
--ruby-version VERSION The desired ruby version for the project
--rakefile Creates a Rakefile
-D, --dockerfile Adds a Dockerfile to the new project
-h, --help Print help information
Arguments
PATH The directory to create
Instance Method Summary collapse
-
#run(path) ⇒ Object
private
Runs the
ronin new project
command.
Instance Method Details
#run(path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Runs the ronin new project
command.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/ronin/cli/commands/new/project.rb', line 81 def run(path) @project_name = File.basename(path) @ruby_version = [:ruby_version] mkdir path mkdir File.join(path,'lib') erb '.ruby-version.erb', File.join(path,'.ruby-version') erb 'Gemfile.erb', File.join(path,'Gemfile') if [:rakefile] cp 'Rakefile', path end if [:dockerfile] erb 'Dockerfile.erb', File.join(path,'Dockerfile') end project_file = File.join(path,"#{@project_name}.rb") erb 'project.rb.erb', project_file chmod '+x', project_file if [:git] cp '.gitignore', path Dir.chdir(path) do sh 'git', 'init', '-q', '-b', 'main' sh 'git', 'add', '.' sh 'git', 'commit', '-q', '-m', 'Initial commit.' end end end |