Class: Xnlogic::CLI::Deploy

Inherits:
Object
  • Object
show all
Defined in:
lib/xnlogic/cli/deploy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, thor) ⇒ Deploy



7
8
9
10
11
# File 'lib/xnlogic/cli/deploy.rb', line 7

def initialize(options, thor)
  @options = {}.merge options
  @thor = thor
  @app = Pathname.pwd
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



5
6
7
# File 'lib/xnlogic/cli/deploy.rb', line 5

def app
  @app
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/xnlogic/cli/deploy.rb', line 5

def options
  @options
end

#thorObject (readonly)

Returns the value of attribute thor.



5
6
7
# File 'lib/xnlogic/cli/deploy.rb', line 5

def thor
  @thor
end

Instance Method Details

#options_fileObject



13
14
15
# File 'lib/xnlogic/cli/deploy.rb', line 13

def options_file
  app + 'config/deploy_options.yaml'
end

#server_profile(hostname) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/xnlogic/cli/deploy.rb', line 17

def server_profile(hostname)
  opts = {
    hostname: hostname,
    api_hostname: options.fetch('api_hostname', hostname),
    ssh_user: options['ssh_user'],
    ssh_key:  options['ssh_key']
  }
  base_templates = {
    "server_profiles/profile.rb.tt" => "server_profiles/#{hostname.gsub('.', '_')}.rb",
  }
  Xnlogic.ui.info ""
  Xnlogic.ui.info "Creating server profile for #{ hostname }"
  Xnlogic.ui.info ""
  base_templates.each do |src, dst|
    thor.template("deploy/#{src}", app.join(dst), opts)
  end
end