Class: Fairy::Conf::DefaultConf

Inherits:
Fairy::Conf show all
Defined in:
lib/fairy/share/conf.rb,
lib/fairy/share/conf.rb

Overview

def method_missing(method, *args, &b) del = “#prefix_#methodmethod.id2namemethod.id2name.upcase” if respond_to?(del) __send__(del, *args, &b) else super end

  end
end
BJobConf = JobConf
NJobConf = JobConf

Constant Summary

Constants inherited from Fairy::Conf

PROPS

Instance Method Summary collapse

Methods inherited from Fairy::Conf

#HOME, #base_conf=, configure_common_conf, def_prop, def_prop_relative_path, #props, #set_values

Constructor Details

#initializeDefaultConf

Returns a new instance of DefaultConf.



216
217
218
219
220
221
# File 'lib/fairy/share/conf.rb', line 216

def initialize
  super

  @default_host = `hostname`.chomp
  @hosts = {}
end

Instance Method Details

#[](host) ⇒ Object



223
224
225
226
227
228
# File 'lib/fairy/share/conf.rb', line 223

def [](host)
  unless @hosts[host]
    @hosts[host] = Conf.new
  end
  @hosts[host]
end

#load_all_confObject



237
238
239
240
241
242
243
244
245
246
247
248
249
250
# File 'lib/fairy/share/conf.rb', line 237

def load_all_conf
  loaded = false
  for path in CONF_PATH
    if path
      if File.exist?(path)
 load_conf path
 loaded = true
      end
    end
  end
# unless loaded
#   puts "warnfairy.confファイルが見つかりません"
# end
end

#load_conf(conf) ⇒ Object



252
253
254
255
256
257
258
259
260
261
262
263
264
# File 'lib/fairy/share/conf.rb', line 252

def load_conf(conf)
  begin
    load conf
  rescue LoadError
    puts "設定ファイル #{conf} をロードできませんでした."
    exit 1
  rescue
    puts "設定ファイル #{@conf} をロード中に例外が発生しました."
    p $!
    p $@
    exit 2
  end
end

#value(prop) ⇒ Object



230
231
232
233
234
235
# File 'lib/fairy/share/conf.rb', line 230

def value(prop)
  conf = @hosts[@default_host]
  v = conf && conf.value(prop)
  return v if v
  @values[prop]
end