Module: Luban::Deployment::Service::Configurator::Base

Included in:
Application::Configurator, Luban::Deployment::Service::Configurator
Defined in:
lib/luban/deployment/cli/service/configurator.rb

Instance Method Summary collapse

Instance Method Details

#available_profile_templates(format: "erb") ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/luban/deployment/cli/service/configurator.rb', line 21

def available_profile_templates(format: "erb")
  return @available_profile_templates unless @available_profile_templates.nil?
  templates = []
  [profile_templates_path, stage_profile_templates_path].each do |path|
    Dir.chdir(path) { templates |= Dir["**/*.#{format}"] } if path.directory?
  end
  @available_profile_templates = templates
end

#default_templatesObject



42
# File 'lib/luban/deployment/cli/service/configurator.rb', line 42

def default_templates; task.opts.default_templates; end

#exclude_template?(template) ⇒ Boolean

Returns:

  • (Boolean)


40
# File 'lib/luban/deployment/cli/service/configurator.rb', line 40

def exclude_template?(template); false; end

#excluded_profile_templates(format: "erb") ⇒ Object



35
36
37
38
# File 'lib/luban/deployment/cli/service/configurator.rb', line 35

def excluded_profile_templates(format: "erb")
  @excluded_profile_templates ||= 
    available_profile_templates(format: format).select { |t| exclude_template?(t) }
end

#init_profileObject



44
45
46
47
48
49
# File 'lib/luban/deployment/cli/service/configurator.rb', line 44

def init_profile
  return if default_templates.empty?
  puts "  Initializing #{service_name} profile"
  assure_dirs(profile_templates_path, stage_profile_path)
  upload_profile_templates(default_templates)
end

#profile_templates(format: "erb") ⇒ Object



30
31
32
33
# File 'lib/luban/deployment/cli/service/configurator.rb', line 30

def profile_templates(format: "erb")
  @profile_templates ||= 
    available_profile_templates(format: format).reject { |t| exclude_template?(t) }
end

#profile_templates_pathObject



11
12
13
14
# File 'lib/luban/deployment/cli/service/configurator.rb', line 11

def profile_templates_path
  @profile_templates_path ||= 
    config_finder[:application].profile_templates_path.join(profile_name)
end

#stage_profile_pathObject



6
7
8
9
# File 'lib/luban/deployment/cli/service/configurator.rb', line 6

def stage_profile_path
  @stage_profile_path ||= 
    config_finder[:application].stage_profile_path.join(profile_name)
end

#stage_profile_templates_pathObject



16
17
18
19
# File 'lib/luban/deployment/cli/service/configurator.rb', line 16

def stage_profile_templates_path
  @stage_profile_templates_path ||= 
    config_finder[:application].stage_profile_templates_path.join(profile_name)
end

#update_profileObject



51
52
53
54
55
# File 'lib/luban/deployment/cli/service/configurator.rb', line 51

def update_profile
  assure_dirs(stage_profile_path)
  render_profile
  cleanup_profile
end