Class: Cumuli::ProjectManager::Manager

Inherits:
Object
  • Object
show all
Defined in:
lib/cumuli/project_manager/manager.rb

Constant Summary collapse

DEFAULT_PROJECT_PATH =
Dir.pwd

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = DEFAULT_PROJECT_PATH) ⇒ Manager

Returns a new instance of Manager.



8
9
10
11
12
# File 'lib/cumuli/project_manager/manager.rb', line 8

def initialize(path=DEFAULT_PROJECT_PATH)
  @path = path
  @config_path = "#{path}/config/projects.yml"
  @procfile_path = "#{path}/Procfile"
end

Instance Attribute Details

#config_pathObject

Returns the value of attribute config_path.



6
7
8
# File 'lib/cumuli/project_manager/manager.rb', line 6

def config_path
  @config_path
end

#procfile_pathObject

Returns the value of attribute procfile_path.



6
7
8
# File 'lib/cumuli/project_manager/manager.rb', line 6

def procfile_path
  @procfile_path
end

Instance Method Details

#configObject



43
44
45
# File 'lib/cumuli/project_manager/manager.rb', line 43

def config
  @config ||= YAML.load( File.read(config_path) )
end

#projectsObject



39
40
41
# File 'lib/cumuli/project_manager/manager.rb', line 39

def projects
  @projects ||= config.map{ |name, opts| Cumuli::ProjectManager::Project.new(name, opts) }
end

#publishObject



14
15
16
17
18
19
20
# File 'lib/cumuli/project_manager/manager.rb', line 14

def publish
  File.open(procfile_path, 'w') do |f|
    projects.each do |project|
      f.write project.to_procfile
    end
  end
end

#setupObject



22
23
24
25
26
27
28
29
# File 'lib/cumuli/project_manager/manager.rb', line 22

def setup
  publish
  submodules_init
  system('git submodule init')
  system('git submodule update')
  system("git submodule foreach git pull")
  setup_projects
end

#setup_projectsObject



35
36
37
# File 'lib/cumuli/project_manager/manager.rb', line 35

def setup_projects
  projects.each { |project| project.setup }
end

#submodules_initObject



31
32
33
# File 'lib/cumuli/project_manager/manager.rb', line 31

def submodules_init
  projects.each { |project| project.submodule_init }
end