Sha256: 15f339b09ea937fb514e6342464ecf2457567f1d97c4aa7d1ee753cd4237e046

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

module Cumuli
  module ProjectManager
    class Manager
      DEFAULT_PROJECT_PATH = Dir.pwd

      attr_accessor :config_path, :procfile_path

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

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

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

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

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

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

      def project(name)
        projects.detect{|p| p.name == name}
      end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cumuli-0.5.0 lib/cumuli/project_manager/manager.rb