Module: ProxyMgr::Config::Validators

Defined in:
lib/proxymgr/config.rb

Class Method Summary collapse

Class Method Details

.array_of_strings(key, ary) ⇒ Object



102
103
104
105
106
107
108
# File 'lib/proxymgr/config.rb', line 102

def array_of_strings(key, ary)
  ary.each_with_index do |value, i|
    should("#{key}[#{i}] should be a string") do
      value.is_a? String
    end
  end
end

.executable(key, exe) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
# File 'lib/proxymgr/config.rb', line 90

def executable(key, exe)
  should("#{key} should be an executable") do
    if exe =~ /^\//
      File.executable? exe
    else
      ENV['PATH'].split(':').find do |e|
        File.executable? File.join(e, exe)
      end
    end
  end
end

.fullpath(key, value) ⇒ Object



86
87
88
# File 'lib/proxymgr/config.rb', line 86

def fullpath(key, value)
  should("#{key} should be a valid full path") { value =~ /^\// }
end

.svconfig(key, type) ⇒ Object



110
111
112
113
114
115
116
117
118
# File 'lib/proxymgr/config.rb', line 110

def svconfig(key, type)
  should("#{key} should be a service config implementation") do
    begin
      ServiceConfig.const_get(type.capitalize)
    rescue NameError
      false
    end
  end
end