Class: WhiskeyDisk::Config::NormalizeSshOptionsFilter

Inherits:
AbstractFilter
  • Object
show all
Defined in:
lib/whiskey_disk/config/filters/normalize_ssh_options_filter.rb

Instance Attribute Summary

Attributes inherited from AbstractFilter

#config

Instance Method Summary collapse

Methods inherited from AbstractFilter

#environment_name, #initialize, #project_name

Constructor Details

This class inherits a constructor from WhiskeyDisk::Config::AbstractFilter

Instance Method Details

#drop_empties(options_list) ⇒ Object


6
7
8
# File 'lib/whiskey_disk/config/filters/normalize_ssh_options_filter.rb', line 6

def drop_empties(options_list)
  options_list.select {|option| option and option != '' }
end

#drop_empty_ssh_options_for_domain(domain) ⇒ Object


10
11
12
13
14
15
16
17
# File 'lib/whiskey_disk/config/filters/normalize_ssh_options_filter.rb', line 10

def drop_empty_ssh_options_for_domain(domain)
  result = drop_empties([ domain['ssh_options'] ].flatten)
  if result and result != []
    domain.merge('ssh_options' => result)
  else
    domain.reject {|k,v| k == 'ssh_options' }
  end
end

#filter(data) ⇒ Object


23
24
25
# File 'lib/whiskey_disk/config/filters/normalize_ssh_options_filter.rb', line 23

def filter(data)
  data.merge('domain' => normalize_ssh_options(data['domain']))
end

#normalize_ssh_options(domains_list) ⇒ Object


19
20
21
# File 'lib/whiskey_disk/config/filters/normalize_ssh_options_filter.rb', line 19

def normalize_ssh_options(domains_list)
  domains_list.collect { |domain| drop_empty_ssh_options_for_domain(domain) }
end