Module: RocketApi::Commands::Dirs

Included in:
RocketCommands
Defined in:
lib/rocket_api/commands/dirs.rb

Instance Method Summary collapse

Instance Method Details

#create_dir(dir_name) ⇒ Object

Parameters:

  • dir_name (String)

Raises:

  • (StandardError)


16
17
18
19
20
21
22
23
# File 'lib/rocket_api/commands/dirs.rb', line 16

def create_dir(dir_name)
  raise "#{RocketApi::FOLDER_EXIST} #{dir_name}" if is_exist?(dir_name)

  system 'mkdir', '-p', "#{dir_name}"
  puts "#{RocketApi::CREATE_SUCCESS} #{dir_name}"
rescue StandardError => e
  raise e, "#{dir_name} err: #{e.message}"
end

#create_repo(dirs) ⇒ Object

Parameters:

  • dirs (Array)


5
6
7
8
9
10
11
# File 'lib/rocket_api/commands/dirs.rb', line 5

def create_repo(dirs)
  dirs.each do |dir|
    create_dir(dir)
  rescue StandardError => e
    puts "#{CREATE_FAILED} #{e.message}"
  end
end