Module: Rares::Modules::Shell

Included in:
Rares::Main
Defined in:
lib/rares/modules/shell.rb

Instance Method Summary collapse

Instance Method Details

#copy_fixture(file_path, options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rares/modules/shell.rb', line 10

def copy_fixture(file_path, options={})
  fixture_path = "#{recipe_folder}/fixtures/#{file_path}"
  result_path  = "#{current_dir}/#{file_path}"

  return if File.file?(result_path) && !(options[:force] == true) && no?("The #{result_path} already exists. Override?")

  FileUtils.mkdir_p result_path.split("/")[0..-2].join("/")

  if File.file?(result_path)
    puts "Overrided #{file_path}"
  else
    puts "Created #{file_path}"
  end

  FileUtils.cp_r fixture_path, result_path, remove_destination: true
end

#ensure_changes_commited!Object



4
5
6
7
8
# File 'lib/rares/modules/shell.rb', line 4

def ensure_changes_commited!
  unless `git status`.include?("nothing to commit")
    raise Rares::Exceptions::Exit, "Commit your changes first"
  end
end

#run(command) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/rares/modules/shell.rb', line 27

def run(command)
  command_with_cd = "cd #{current_dir} && #{command}"
  puts "Will execute: #{command_with_cd}"
  result = `#{command_with_cd}`
  puts result

  result
end