Class: Wixgem::User
- Inherits:
-
Object
- Object
- Wixgem::User
- Defined in:
- lib/user.rb
Instance Method Summary collapse
- #create(xml_doc) ⇒ Object
-
#initialize(name, user_hash) ⇒ User
constructor
A new instance of User.
Constructor Details
#initialize(name, user_hash) ⇒ User
Returns a new instance of User.
7 8 9 10 |
# File 'lib/user.rb', line 7 def initialize(name, user_hash) @user_name = name @user_hash = user_hash end |
Instance Method Details
#create(xml_doc) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/user.rb', line 11 def create(xml_doc) wix = REXML::XPath.match(xml_doc, "/Wix")[0] wix.add_attribute('xmlns:Util', 'http://schemas.microsoft.com/wix/UtilExtension') match = REXML::XPath.match(xml_doc, "/Wix") fragment = match[0].add_element 'Fragment' component_group = fragment.add_element 'ComponentGroup' component_group.add_attribute('Id', "cg_#{SecureRandom.uuid.gsub(/-/,'')}") component = component_group.add_element 'Component' component.add_attribute('Id', "c_#{SecureRandom.uuid.gsub(/-/,'')}") component.add_attribute('Directory', 'INSTALLDIR') user_element = component.add_element 'Util:User' user_element.add_attribute('Id', "user_#{SecureRandom.uuid.gsub(/-/,'')}") user_element.add_attribute('Name', @user_name) @user_hash.each { |attrib, value| user_element.add_attribute(attrib.to_s, value) } return xml_doc end |