Class: Rdm::CLI::Init

Inherits:
Object
  • Object
show all
Defined in:
lib/rdm/cli/init.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current_path, test, console, stdout) ⇒ Init

Returns a new instance of Init.



10
11
12
13
14
15
# File 'lib/rdm/cli/init.rb', line 10

def initialize(current_path, test, console, stdout)
  @current_path = current_path
  @test         = test
  @console      = console
  @stdout       = stdout
end

Class Method Details

.run(current_path:, test:, console:, stdout: $stdout) ⇒ Object



5
6
7
# File 'lib/rdm/cli/init.rb', line 5

def run(current_path:, test:, console:, stdout: $stdout)
  Rdm::CLI::Init.new(current_path, test, console, stdout).run
end

Instance Method Details

#runObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rdm/cli/init.rb', line 17

def run
  generated_files_list = Rdm::Gen::Init.generate(
    current_path: @current_path,
    test:         @test,
    console:      @console,
    stdout:       @stdout
  )

  generated_files_list.compact.each { |file| @stdout.puts "Generated: #{file}" }
rescue Errno::ENOENT => e
  @stdout.puts "Error occurred. Possible reasons:\n #{@current_path} not found. Please run on empty directory \n#{e.inspect}"
rescue Rdm::Errors::ProjectAlreadyInitialized
  @stdout.puts 'Error. Project was already initialized'
rescue Rdm::Errors::InvalidParams => e
  @stdout.puts e.message
rescue Rdm::Errors::InvalidProjectDir => e
  @stdout.puts "#{e.message} doesn't exist. Initialize new rdm project with existing directory"
end