Class: Luban::Deployment::Project

Inherits:
Command
  • Object
show all
Includes:
Command::Tasks::Control, Command::Tasks::Deploy, Command::Tasks::Monitor, Command::Tasks::Provision, Luban::Deployment::Parameters::Project
Defined in:
lib/luban/deployment/cli/project.rb

Constant Summary

Constants included from Command::Tasks::Monitor

Command::Tasks::Monitor::Actions

Constants included from Command::Tasks::Control

Command::Tasks::Control::Actions

Constants included from Command::Tasks::Deploy

Command::Tasks::Deploy::Actions

Constants included from Command::Tasks::Provision

Command::Tasks::Provision::Actions

Constants included from Luban::Deployment::Parameters::General

Luban::Deployment::Parameters::General::DefaultLubanRootPath

Instance Attribute Summary collapse

Attributes included from Helpers::Configuration

#config

Instance Method Summary collapse

Methods included from Command::Tasks::Monitor

#monitor_tasks, #monitorable?

Methods included from Command::Tasks::Control

#control_tasks, #controllable?

Methods included from Command::Tasks::Deploy

#deployable?

Methods included from Command::Tasks::Provision

#provision_tasks, #provisionable?

Methods included from Luban::Deployment::Parameters::Project

#monitor_defined?, #process_monitor_via

Methods included from Luban::Deployment::Parameters::Base

#parameter

Methods inherited from Command

#base_templates_path, #controllable?, #default_templates, #default_templates_paths, default_worker_class, #deployable?, dispatch_task, inherited, #monitorable?, #provisionable?, #run_task, worker_class

Methods included from Luban::Deployment::Parameters::General

included

Methods included from Helpers::Configuration

#ask, #fetch, #find_template_file, #load_configuration_file, #primary, #release_roles, #role, #roles, #server, #set, #set_default, #syntax_error?

Instance Attribute Details

#appsObject (readonly)

Returns the value of attribute apps.



11
12
13
# File 'lib/luban/deployment/cli/project.rb', line 11

def apps
  @apps
end

Instance Method Details

#display_nameObject



13
# File 'lib/luban/deployment/cli/project.rb', line 13

def display_name; @display_name ||= "#{stage} #{project.camelcase}"; end

#init_application(args:, opts:) ⇒ Object



93
94
95
96
97
# File 'lib/luban/deployment/cli/project.rb', line 93

def init_application(args:, opts:)
  singleton_class.send(:include, Luban::Deployment::Helpers::Generator::Application)
  define_singleton_method(:application) { args[:application] }
  create_application_skeleton
end

#package_users_for(package_name, package_version, exclude: [], servers: []) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/luban/deployment/cli/project.rb', line 15

def package_users_for(package_name, package_version, exclude: [], servers: [])
  apps.values.inject([]) do |package_users, app|
    if !exclude.include?(app.name) and
        app.use_package?(package_name, package_version, servers: servers)
      package_users << app.display_name
    end
    package_users
  end
end

#password_for(user) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/luban/deployment/cli/project.rb', line 25

def password_for(user)
  @passwords_mutex.synchronize do
    if @passwords[user].nil?
      @passwords[user] = ask(prompt: "Password for #{user}", echo: false)
    end
    @passwords[user]
  end
end

#start_sequenceObject

Luban::Deployment::Command::Tasks::Control::Actions.each do |action|

define_method(action) do |args:, opts:|
  apps.each_value do |app|
    app.send(__method__, args: args, opts: opts) if app.controllable?
  end
end

end



66
# File 'lib/luban/deployment/cli/project.rb', line 66

def start_sequence; @start_sequence ||= apps.keys; end

#stop_sequenceObject



67
# File 'lib/luban/deployment/cli/project.rb', line 67

def stop_sequence; @stop_sequence ||= start_sequence.reverse; end