Class: YMDP::Compiler::Domains

Inherits:
Base
  • Object
show all
Defined in:
lib/ymdp/compiler/domains.rb

Overview

Covers all the domains and the actions that are taken on all domains at once.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#base_path, base_path, #configuration, configuration, configure, #content_variables, display_path, #display_path, #paths, #servers

Constructor Details

#initialize(options = nil) ⇒ Domains

Returns a new instance of Domains.



20
21
22
23
24
25
26
27
28
# File 'lib/ymdp/compiler/domains.rb', line 20

def initialize(options=nil)
  @options = options
  @servers = @options[:servers]
  @domains = @options[:domain] || all_domains
  @domains = Array(@domains)
  @message = @options[:message]

  commit if @options[:commit]
end

Instance Attribute Details

#domainsObject

Returns the value of attribute domains.



18
19
20
# File 'lib/ymdp/compiler/domains.rb', line 18

def domains
  @domains
end

#gitObject

Returns the value of attribute git.



18
19
20
# File 'lib/ymdp/compiler/domains.rb', line 18

def git
  @git
end

#git_hashObject

Returns the value of attribute git_hash.



18
19
20
# File 'lib/ymdp/compiler/domains.rb', line 18

def git_hash
  @git_hash
end

#messageObject

Returns the value of attribute message.



18
19
20
# File 'lib/ymdp/compiler/domains.rb', line 18

def message
  @message
end

#optionsObject

Returns the value of attribute options.



18
19
20
# File 'lib/ymdp/compiler/domains.rb', line 18

def options
  @options
end

Instance Method Details

#all_domainsObject

Returns all domains.



42
43
44
# File 'lib/ymdp/compiler/domains.rb', line 42

def all_domains
  servers.servers.keys
end

#clean_tmp_dirObject

Perform a block, starting with a clean ‘tmp’ directory and ending with one.



69
70
71
72
73
74
75
# File 'lib/ymdp/compiler/domains.rb', line 69

def clean_tmp_dir
  system "rm -rf #{TMP_PATH}"
  system "mkdir #{TMP_PATH}"
  yield
  system "rm -rf #{TMP_PATH}"
  system "mkdir #{TMP_PATH}"
end

#commitObject

Commit to git and store the hash of the commit.



48
49
50
51
52
# File 'lib/ymdp/compiler/domains.rb', line 48

def commit
  @git = YMDP::GitHelper.new
  @git.do_commit(@message)
  @git_hash = git.get_hash(options[:branch])    
end

#compileObject

Compile the source code for all domains into their usable destination files.



32
33
34
35
36
37
38
# File 'lib/ymdp/compiler/domains.rb', line 32

def compile
  Timer.new(:title => "YMDP").time do
    clean_tmp_dir do
      process_domains
    end
  end
end

#process_domainsObject

Process source code for each domain in turn.



56
57
58
59
60
61
62
63
64
65
# File 'lib/ymdp/compiler/domains.rb', line 56

def process_domains
  domains.each do |domain|
    params = options
    params[:host] = configuration.host
    params[:server] = servers[domain]["server"]
    compiler = YMDP::Compiler::Base.new(domain, git_hash, params)
    
    compiler.process_all
  end
end