Class: Project

Inherits:
Object
  • Object
show all
Defined in:
lib/amazon-instance/project.rb

Class Method Summary collapse

Class Method Details

.list_available_projects(config_dir) ⇒ Object



23
24
25
26
27
# File 'lib/amazon-instance/project.rb', line 23

def self.list_available_projects(config_dir)
  Dir.foreach(pathname) do |file|
    puts file
  end
end

.load(name, environment, config_dir) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/amazon-instance/project.rb', line 2

def self.load(name, environment, config_dir)
  config = nil
  filename = config_dir+'projects/'+name+'.yml'

  if File.exist?(filename)
    File.open(filename) do |content|
      config_environments = YAML::load(content)
      
      if !config_environments[environment].nil?
        config = config_environments[environment]
      else
        raise 'Invalid environment name: '+environment
      end
    end
  else
    raise 'File: '+name+'.yml does not exist'
  end
  
  config
end