Class: AppTap::CLI::Install

Inherits:
Thor::Group
  • Object
show all
Includes:
Helpers, Thor::Actions
Defined in:
lib/apptap/cli/install.rb

Instance Method Summary collapse

Methods included from Helpers

#app_config_path, #app_procfile_path, #brew_bin, #brew_command, #brew_dir, #brew_install_path, #brew_repo_url, #filter_config, #load_config, #procfile_config_end_token, #procfile_config_start_token

Instance Method Details

#generate_procfileObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/apptap/cli/install.rb', line 34

def generate_procfile
  say_status 'updating', app_procfile_path, :green

  filter_config(service_name) do |config_name, service_config|
    say_status 'adding', config_name, :green

    insert_into_file(app_procfile_path, after: "#{procfile_config_start_token}\n") do
      command = service_config['command']
      process_name = config_name

      "#{process_name}: #{File.join(brew_bin, command)}\n"
    end
  end
end

#install_servicesObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/apptap/cli/install.rb', line 12

def install_services
  say "Installing services..."

  filter_config(service_name) do |config_name, service_config|
    say_status 'installing', config_name, :green
    if service_config['formula']
      run("#{brew_command} install #{service_config['formula']}")
    else
      say_status 'error', "Missing 'formula' configuration for #{config_name}.", :red
    end
  end
end

#reset_procfileObject



25
26
27
28
29
30
31
32
# File 'lib/apptap/cli/install.rb', line 25

def reset_procfile
  say_status 'resetting', app_procfile_path, :green

  apptap_section_regexp = Regexp.new("#{procfile_config_start_token}(.*)#{procfile_config_end_token}", Regexp::MULTILINE)
  gsub_file app_procfile_path, apptap_section_regexp do |match|
    "#{procfile_config_start_token}\n#{procfile_config_end_token}"
  end
end