Class: MonkeyKing::CloneCommand
- Inherits:
-
Mothership
- Object
- Mothership
- MonkeyKing::CloneCommand
- Defined in:
- lib/monkey_king/clone_command.rb
Instance Method Summary collapse
Instance Method Details
#clone ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/monkey_king/clone_command.rb', line 10 def clone repo = input[:repo] sub_dir = Array(input[:dir]) directory = repo.split('/').last.split('.').first parser = MonkeyKing::Parser.new raise 'Failed to clone' unless system("git clone #{repo} #{directory}") deployment_yaml_files = [] sub_dir.each do |d| deployment_yaml_files += Dir.glob("#{directory}/#{d}/*.yml") end deployment_yaml_files.each do |file| puts "Transforming #{file}..." transformed_content = parser.transform(file) File.open(file, "w") do |overwrite_file| overwrite_file.write transformed_content end end puts "Done." end |
#replace ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/monkey_king/clone_command.rb', line 36 def replace globs = input[:globs] parser = MonkeyKing::Parser.new if globs.empty? raise 'no globs given in the argument' end deployment_yaml_files = [] deployment_yaml_files += Dir.glob(globs) deployment_yaml_files.each do |file| extension = file.split('.').last if extension == 'yml' puts "Transforming #{file}..." transformed_content = parser.transform(file) File.open(file, "w") do |overwrite_file| overwrite_file.write transformed_content end else puts "skipping non-yaml file #{file}..." end end puts "Done." end |