Class: Mimas::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/mimas/config.rb

Defined Under Namespace

Classes: DSL, InvalidConfiguration, Options, Services, Site

Constant Summary collapse

DEFAULT_DIRECTORY =
"deploy"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



26
27
28
29
30
# File 'lib/mimas/config.rb', line 26

def initialize
  @sites        = {}
  @servers      = {}
  @hooks        = Hooks.new
end

Instance Attribute Details

#hooksObject (readonly)

Returns the value of attribute hooks.



24
25
26
# File 'lib/mimas/config.rb', line 24

def hooks
  @hooks
end

#serversObject (readonly)

Returns the value of attribute servers.



24
25
26
# File 'lib/mimas/config.rb', line 24

def servers
  @servers
end

#sitesObject (readonly)

Returns the value of attribute sites.



24
25
26
# File 'lib/mimas/config.rb', line 24

def sites
  @sites
end

Class Method Details

.build(source) ⇒ Object



20
21
22
# File 'lib/mimas/config.rb', line 20

def self.build(source)
  DSL.new(source).config
end

.currentObject



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

def self.current
  @current ||= load
end

.load(path = File.join(Dir.pwd, DEFAULT_DIRECTORY, "mimas.rb")) ⇒ Object



9
10
11
12
13
14
# File 'lib/mimas/config.rb', line 9

def self.load(path = File.join(Dir.pwd, DEFAULT_DIRECTORY, "mimas.rb"))
  if File.exist?(path)
    source = File.read(path)
    @current = build(source)
  end
end

.open(&block) ⇒ Object



16
17
18
# File 'lib/mimas/config.rb', line 16

def self.open(&block)
  DSL.new(&block).config
end

Instance Method Details

#ruby_versionObject



32
33
34
35
36
37
38
# File 'lib/mimas/config.rb', line 32

def ruby_version
  @ruby_version ||= begin
    File.read(File.join(Dir.pwd, ".ruby-version")).chomp
  rescue Errno::ENOENT
    RUBY_VERSION
  end
end