Class: Magnesium::XML

Inherits:
Object
  • Object
show all
Defined in:
lib/magnesium/support/xml.rb

Class Method Summary collapse

Class Method Details

.closeXML(file) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/magnesium/support/xml.rb', line 29

def self.closeXML(file)
  begin
    file.close
  rescue
    error
  #ensure
  end
end

.modify_attribute(filepath, path, attribute, value) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/magnesium/support/xml.rb', line 38

def self.modify_attribute(filepath,path,attribute,value)
  begin
    file = File.read(filepath)
    doc = Document.new file

    doc.elements.each(path) do |e|
      e.add_attribute(attribute,value)
    end
    File.delete(filepath)
    f = File.new(filepath,'w+')
    puts 'M: Let\'s review the config file.'
    puts '............................................................'
    f.puts doc.write
  rescue
    error
  #ensure
  end
end

.new_document(file) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/magnesium/support/xml.rb', line 19

def self.new_document(file)
  begin
    doc = Document.new file
    return doc
  rescue
    error
  #ensure
  end
end

.openXML(path) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/magnesium/support/xml.rb', line 9

def self.openXML(path)
  begin
    file = File.read(path)
    return file
  rescue
    error
  #ensure
  end
end