Class: Kleiber::Symphony

Inherits:
Object
  • Object
show all
Defined in:
lib/kleiber/symphony.rb

Overview

Model describes session of performances your vagrants. Provides api for control your symphony.

Author:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, projects, options) ⇒ Symphony

Returns a new instance of Symphony.



10
11
12
13
14
15
# File 'lib/kleiber/symphony.rb', line 10

def initialize(name, projects, options)
  @name     = name
  @projects = projects
  @tasks    = options[:tasks]
  @env      = options[:env]
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/kleiber/symphony.rb', line 8

def name
  @name
end

#projectsObject (readonly)

Returns the value of attribute projects.



8
9
10
# File 'lib/kleiber/symphony.rb', line 8

def projects
  @projects
end

Instance Method Details

#envObject



21
22
23
# File 'lib/kleiber/symphony.rb', line 21

def env
  @env || {}
end

#environmentHash

Returns hash with definition all env variables of this symphony

Returns:

  • (Hash)

    env variables hash



58
59
60
61
62
# File 'lib/kleiber/symphony.rb', line 58

def environment
  projects.reduce(env) do |result, project|
    result.merge(project.environment)
  end
end

#select_projects(only) ⇒ Array

Selects project from projects

Parameters:

  • only (Array)

    projects for filter

Returns:

  • (Array)

    result array



43
44
45
# File 'lib/kleiber/symphony.rb', line 43

def select_projects(only)
  only.empty? ? projects : projects.select { |p| only.include?(p.name) }
end

#task_list(list) ⇒ Hash

Defines symphony task values and environment varaibles, if it exists

Parameters:

  • list (Hash)

    list of tasks to run

Returns:

  • (Hash)

    task list with symphony values



50
51
52
53
54
# File 'lib/kleiber/symphony.rb', line 50

def task_list(list)
  list.each_with_object({}) do |(name, task), hash|
    hash[name] = tasks[name] || task
  end
end

#tasksObject



17
18
19
# File 'lib/kleiber/symphony.rb', line 17

def tasks
  @tasks || {}
end