Class: Kleiber::Symphony
- Inherits:
-
Object
- Object
- Kleiber::Symphony
- Defined in:
- lib/kleiber/symphony.rb
Overview
Model describes session of performances your vagrants. Provides api for control your symphony.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#projects ⇒ Object
readonly
Returns the value of attribute projects.
Instance Method Summary collapse
- #env ⇒ Object
-
#environment ⇒ Hash
Returns hash with definition all env variables of this symphony.
-
#initialize(name, projects, options) ⇒ Symphony
constructor
A new instance of Symphony.
-
#select_projects(only) ⇒ Array
Selects project from projects.
-
#task_list(list) ⇒ Hash
Defines symphony task values and environment varaibles, if it exists.
- #tasks ⇒ Object
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, ) @name = name @projects = projects @tasks = [:tasks] @env = [:env] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/kleiber/symphony.rb', line 8 def name @name end |
#projects ⇒ Object (readonly)
Returns the value of attribute projects.
8 9 10 |
# File 'lib/kleiber/symphony.rb', line 8 def projects @projects end |
Instance Method Details
#env ⇒ Object
21 22 23 |
# File 'lib/kleiber/symphony.rb', line 21 def env @env || {} end |
#environment ⇒ Hash
Returns hash with definition all env variables of this symphony
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
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
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 |
#tasks ⇒ Object
17 18 19 |
# File 'lib/kleiber/symphony.rb', line 17 def tasks @tasks || {} end |