Class: PicsolveRabbitmqUploader::RabbitSettings
- Inherits:
-
Object
- Object
- PicsolveRabbitmqUploader::RabbitSettings
- Defined in:
- lib/picsolve_rabbitmq_uploader.rb
Overview
reads a psi config xml
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #config_file ⇒ Object
- #create_config_file ⇒ Object
-
#initialize ⇒ RabbitSettings
constructor
A new instance of RabbitSettings.
- #log ⇒ Object
- #read ⇒ Object
Constructor Details
#initialize ⇒ RabbitSettings
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
#config ⇒ Object (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_file ⇒ Object
42 43 44 |
# File 'lib/picsolve_rabbitmq_uploader.rb', line 42 def config_file @config_file ||= create_config_file end |
#create_config_file ⇒ Object
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 |
#log ⇒ Object
21 22 23 |
# File 'lib/picsolve_rabbitmq_uploader.rb', line 21 def log PicsolveRabbitmqUploader.logger end |
#read ⇒ Object
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 |