Class: AwsEnvironmentConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/ebx/aws_environment_config.rb

Class Method Summary collapse

Class Method Details

.config_exists?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/ebx/aws_environment_config.rb', line 10

def config_exists?
  FileTest.file?(config_path)
end

.config_pathObject



6
7
8
# File 'lib/ebx/aws_environment_config.rb', line 6

def config_path
  File.expand_path("eb/environment.yml", Dir.pwd)
end

.create_dir(name) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/ebx/aws_environment_config.rb', line 29

def create_dir(name)
  dir = File.expand_path(name, Dir.pwd)

  raise "#{name} exists and is not a directory" if FileTest.file?(dir)
  unless FileTest.directory?(dir)
    Dir.mkdir(dir)
  end
end

.init_configObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/ebx/aws_environment_config.rb', line 18

def init_config
  create_dir('.ebextentions')
  create_dir('eb')

  unless FileTest.file?(config_path)
    FileUtils.cp(File.expand_path('../../generators/templates/environment.yml', __FILE__), config_path)
  end

  read_config
end

.read_configObject



14
15
16
# File 'lib/ebx/aws_environment_config.rb', line 14

def read_config
  @config ||= YAML.load_file(config_path)
end