Class: Rebi::Config

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/rebi/config.rb

Instance Method Summary collapse

Instance Method Details

#app_descriptionObject



22
23
24
# File 'lib/rebi/config.rb', line 22

def app_description
  data[:app_description] || "Created via rebi"
end

#app_nameObject



18
19
20
# File 'lib/rebi/config.rb', line 18

def app_name
  data[:app_name]
end

#config_fileObject



5
6
7
# File 'lib/rebi/config.rb', line 5

def config_file
  @config_file ||= "#{Rebi.root}/config/rebi.yml"
end

#config_file=(path) ⇒ Object



9
10
11
# File 'lib/rebi/config.rb', line 9

def config_file=path
  @config_file = Pathname.new(path).realpath.to_s
end

#env_by_name(name) ⇒ Object



40
41
42
43
44
45
46
47
48
49
# File 'lib/rebi/config.rb', line 40

def env_by_name name
  data[:stages].each do |stg_name, stg_conf|
    stg = stage stg_name
    stg_conf.keys.each do |env_name|
      env_conf = Rebi::ConfigEnvironment.new(stg_name, env_name, stg[env_name] || {})
      return env_conf if env_conf.name == name
    end
  end
  return nil
end

#environment(stg_name, env_name) ⇒ Object



34
35
36
37
38
# File 'lib/rebi/config.rb', line 34

def environment stg_name, env_name
  stg = stage stg_name
  raise(Rebi::Error::ConfigNotFound.new("Environment config: #{env_name}")) unless stg.key?(env_name)
  return Rebi::ConfigEnvironment.new(stg_name, env_name, stg[env_name] || {})
end

#reload!Object



13
14
15
16
# File 'lib/rebi/config.rb', line 13

def reload!
  @data = nil
  return data
end

#stage(stage) ⇒ Object



26
27
28
# File 'lib/rebi/config.rb', line 26

def stage stage
  data[:stages][stage] || raise(Rebi::Error::ConfigNotFound.new("Stage: #{stage}"))
end

#stagesObject



51
52
53
# File 'lib/rebi/config.rb', line 51

def stages
  data[:stages].keys
end

#timeoutObject



30
31
32
# File 'lib/rebi/config.rb', line 30

def timeout
  (data[:timeout] || 60*10).second
end