Sha256: c2095e9b48805957990ba153f57e20bb65be69ddd993604424b4f3230bd461dc

Contents?: true

Size: 1.27 KB

Versions: 3

Compression:

Stored size: 1.27 KB

Contents

module Bebox
  module ProjectCommands

    include Bebox::CommandsHelper

    def self.extended(base)
      base.load_commands
    end

    def load_commands
      load_environment_commands
      load_node_commands
      load_role_profile_commands
      load_prepare_commands
      load_provision_commands
    end

    # Load environment commands
    def load_environment_commands
      self.extend Bebox::EnvironmentCommands
    end

    # Load node commands if there are environments configured
    def load_node_commands
      (self.extend Bebox::NodeCommands) if Bebox::Environment.list(project_root).count > 0
    end

    # Load role/profile commands
    def load_role_profile_commands
      if Bebox::Node.count_all_nodes_by_type(project_root, 'nodes') > 0
        self.extend Bebox::RoleCommands
        self.extend Bebox::ProfileCommands
      end
    end

    # Load prepare commands if there are at least one node
    def load_prepare_commands
      (self.extend Bebox::PrepareCommands) if Bebox::Node.count_all_nodes_by_type(project_root, 'nodes') > 0
    end

    # Load provision commands if there are nodes prepared
    def load_provision_commands
      (self.extend Bebox::ProvisionCommands) if Bebox::Node.count_all_nodes_by_type(project_root, 'prepared_nodes') > 0
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bebox-0.1.5 lib/bebox/commands/project_commands.rb
bebox-0.1.4 lib/bebox/commands/project_commands.rb
bebox-0.1.3 lib/bebox/commands/project_commands.rb