Class: Dotcode::CLI::Commands::Apply
- Inherits:
-
Dry::CLI::Command
- Object
- Dry::CLI::Command
- Dotcode::CLI::Commands::Apply
- Defined in:
- lib/dotcode/cli.rb
Overview
apply
Instance Method Summary collapse
- #call(workdir:) ⇒ Object
- #exec_dotcode_yml_commands_in_template_dir ⇒ Object
- #load_dotcode_yml_in_workdir ⇒ Object
- #sync_files ⇒ Object
Instance Method Details
#call(workdir:) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/dotcode/cli.rb', line 38 def call(workdir:, **) @workdir = workdir load_dotcode_yml_in_workdir exec_dotcode_yml_commands_in_template_dir sync_files end |
#exec_dotcode_yml_commands_in_template_dir ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/dotcode/cli.rb', line 57 def exec_dotcode_yml_commands_in_template_dir dotcode_file_entries = YAML.load_file(File.join(__dir__, "../../templates", @template_name, "dotcode.yml")) dotcode_file_entries.map do |entry| system entry["shell"] if entry.key?("shell") end end |
#load_dotcode_yml_in_workdir ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/dotcode/cli.rb', line 46 def load_dotcode_yml_in_workdir dotcode_yml_path = File.join(Dir.pwd, @workdir, ".code.yml") raise_error ".code.yml not found" unless File.exist? dotcode_yml_path @dotcode_yml = YAML.load_file(dotcode_yml_path) @template_name = @dotcode_yml["template"] raise_error "\"template:\" key not found in .code.yml" unless @template_name end |
#sync_files ⇒ Object
65 66 67 68 |
# File 'lib/dotcode/cli.rb', line 65 def sync_files system "rsync -rv '#{File.join(__dir__, "../../templates", @template_name, "_tmpl")}/' '#{File.join(Dir.pwd, @workdir)}'" end |