Class: DrushDeploy::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/drush_deploy/configuration.rb

Defined Under Namespace

Classes: Error

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(drush = 'drush') ⇒ Configuration

Returns a new instance of Configuration.



29
30
31
32
# File 'lib/drush_deploy/configuration.rb', line 29

def initialize(drush = 'drush')
  @drush = drush
  load_configuration
end

Instance Attribute Details

#aliasesObject (readonly)

Returns the value of attribute aliases.



10
11
12
# File 'lib/drush_deploy/configuration.rb', line 10

def aliases
  @aliases
end

#drushObject (readonly)

Returns the value of attribute drush.



10
11
12
# File 'lib/drush_deploy/configuration.rb', line 10

def drush
  @drush
end

Class Method Details

.normalize_value(val) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/drush_deploy/configuration.rb', line 16

def self.normalize_value(val) 
  if val.is_a? Hash
    val.inject({}) do |result,(k,v)|
      result[k.gsub(/-/,'_').to_sym] = normalize_value(v)
      result
    end
  elsif val.is_a? Array
    val.map &:normalize_value
  else
    val
  end
end

.unserialize_php(php) ⇒ Object



12
13
14
# File 'lib/drush_deploy/configuration.rb', line 12

def self.unserialize_php(php)
  normalize_value PHP.unserialize(php)
end

Instance Method Details

#load_configurationObject



34
35
36
37
38
39
40
41
42
# File 'lib/drush_deploy/configuration.rb', line 34

def load_configuration
  @aliases = PHP.unserialize(`#{@drush} eval 'print serialize(_drush_sitealias_all_list());'`).inject({}) do |h,(k,v)|
    if k != '@none'
      h[k.sub(/^@/,'')] = v
    end
    h
  end
  @normalized_aliases = {}
end

#load_source(sitename) ⇒ Object



57
58
59
# File 'lib/drush_deploy/configuration.rb', line 57

def load_source(sitename)
  site = lookup_site(sitename)
end

#lookup_site(sitename) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/drush_deploy/configuration.rb', line 44

def lookup_site(sitename)
  sitename = sitename.sub(/^@/,'')
  site = @normalized_aliases[sitename]
  unless site
    site = @aliases[sitename]        
    if site
      @normalized_aliases[sitename] = site = normalize_alias(site)
    end
  end
  site
end