Sha256: b3ca70b8361a4b328a19decdb0b6d81f18c1224b63d7245f0a87bee82e07af08

Contents?: true

Size: 844 Bytes

Versions: 1

Compression:

Stored size: 844 Bytes

Contents

module Project
  require 'project/project'
  require 'project/workflow'
  require 'fileutils'
  require 'yaml'
  
  class Loader
    class << self
      def config_path(path=nil)
        path ? (@config_path = path) : @config_path
      end
    end
    
    def load!
      if File.exists?(self.class.config_path)
        config = YAML.load_file(self.class.config_path)
        Project.load_from_hash(config[:projects]) unless config[:projects].nil?
        Workflow.load_from_hash(config[:workflows]) unless config[:workflows].nil?
      else
        FileUtils.cp(ROOT + "/templates/example.yml", self.class.config_path, { :verbose => true })
        $stdout.puts "* No YAML file found at #{self.class.config_path}. One has been created for you, please edit it to your liking and try again."
        Kernel.exit(1)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
project-0.9.3 lib/project/loader.rb