Class: PicsolveRabbitmqUploader::RabbitSettings

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

Overview

reads a psi config xml

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRabbitSettings

Returns a new instance of RabbitSettings.



25
26
27
28
29
30
31
32
# File 'lib/picsolve_rabbitmq_uploader.rb', line 25

def initialize
  c = {}
  read.xpath('//rabbitmq').children.each do |child|
    next if child.name == 'text'
    c[child.name] = child.text
  end
  @config = c
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



19
20
21
# File 'lib/picsolve_rabbitmq_uploader.rb', line 19

def config
  @config
end

Instance Method Details

#config_fileObject



42
43
44
# File 'lib/picsolve_rabbitmq_uploader.rb', line 42

def config_file
  @config_file ||= create_config_file
end

#create_config_fileObject



46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/picsolve_rabbitmq_uploader.rb', line 46

def create_config_file
  paths = [
    'upload.xml',
    'PsiConfig.xml'
  ]
  paths.each do |f|
    log.debug "Testing for config file '#{f}'"
    return f if File.exist? f
  end

  fail "No config file found: #{paths}"
end

#logObject



21
22
23
# File 'lib/picsolve_rabbitmq_uploader.rb', line 21

def log
  PicsolveRabbitmqUploader.logger
end

#readObject



34
35
36
37
38
39
40
# File 'lib/picsolve_rabbitmq_uploader.rb', line 34

def read
  log.info "Parsing config file '#{config_file}'"
  f = File.open(config_file)
  doc = Nokogiri::HTML(f)
  f.close
  doc
end