Class: Rdm::CLI::Init
- Inherits:
-
Object
- Object
- Rdm::CLI::Init
- Defined in:
- lib/rdm/cli/init.rb
Instance Attribute Summary collapse
-
#console ⇒ Object
Returns the value of attribute console.
-
#current_dir ⇒ Object
Returns the value of attribute current_dir.
-
#test ⇒ Object
Returns the value of attribute test.
Class Method Summary collapse
Instance Method Summary collapse
- #check_preconditions! ⇒ Object
- #generate ⇒ Object
-
#initialize(current_dir:, test:, console:) ⇒ Init
constructor
A new instance of Init.
- #run ⇒ Object
Constructor Details
#initialize(current_dir:, test:, console:) ⇒ Init
Returns a new instance of Init.
11 12 13 14 15 |
# File 'lib/rdm/cli/init.rb', line 11 def initialize(current_dir:, test:, console:) @current_dir = current_dir @test = test @console = console end |
Instance Attribute Details
#console ⇒ Object
Returns the value of attribute console.
10 11 12 |
# File 'lib/rdm/cli/init.rb', line 10 def console @console end |
#current_dir ⇒ Object
Returns the value of attribute current_dir.
10 11 12 |
# File 'lib/rdm/cli/init.rb', line 10 def current_dir @current_dir end |
#test ⇒ Object
Returns the value of attribute test.
10 11 12 |
# File 'lib/rdm/cli/init.rb', line 10 def test @test end |
Class Method Details
Instance Method Details
#check_preconditions! ⇒ Object
36 37 38 39 40 |
# File 'lib/rdm/cli/init.rb', line 36 def check_preconditions! return unless current_dir.empty? puts 'Current directory was not specified!' exit 1 end |
#generate ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/rdm/cli/init.rb', line 28 def generate Rdm::Gen::Init.generate( current_dir: current_dir, test: test, console: console ) end |
#run ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rdm/cli/init.rb', line 17 def run check_preconditions! begin generate rescue Errno::ENOENT => e puts "Error occurred. Possible reasons:\n #{current_dir} not found. Please run on empty directory \n#{e.inspect}" rescue Rdm::Errors::ProjectAlreadyInitialized puts 'Error. Project was already initialized.' end end |