Module Hpricot
In: lib/davclient/hpricot_extensions.rb
lib/davclient/hpricot_extensions.rb

Extensions to the Hpricot XML parser.

Methods

Classes and Modules

Class Hpricot::Elem

Public Instance methods

[Source]

    # File lib/davclient/hpricot_extensions.rb, line 94
94:   def basename
95:     File.basename(self.at("d:href").innerText)
96:   end

[Source]

    # File lib/davclient/hpricot_extensions.rb, line 94
94:   def basename
95:     File.basename(self.at("d:href").innerText)
96:   end

Get content from resources on server Example:

   webpage = WebDAV.find("http://example.org/index.html")
   print "html src: " + page.content

[Source]

    # File lib/davclient/hpricot_extensions.rb, line 40
40:   def content
41:     if(!isCollection?)
42:       WebDAV.get(self.at("d:href").innerText)
43:     end
44:   end

Get content from resources on server Example:

   webpage = WebDAV.find("http://example.org/index.html")
   print "html src: " + page.content

[Source]

    # File lib/davclient/hpricot_extensions.rb, line 40
40:   def content
41:     if(!isCollection?)
42:       WebDAV.get(self.at("d:href").innerText)
43:     end
44:   end

[Source]

    # File lib/davclient/hpricot_extensions.rb, line 46
46:   def content=(string)
47:     if(!isCollection?)
48:       WebDAV.put_string(href,string)
49:     end
50:   end

[Source]

    # File lib/davclient/hpricot_extensions.rb, line 46
46:   def content=(string)
47:     if(!isCollection?)
48:       WebDAV.put_string(href,string)
49:     end
50:   end

Get property for resource or collection. Example:

   page = WebDAV.find(url)
   print page.property("published-date")

[Source]

    # File lib/davclient/hpricot_extensions.rb, line 56
56:   def property(name)
57: 
58:     # TODO: Make list of recognized namespace prefixes configurable
59: 
60:     property = property = self.at(name)
61:     if(property)then
62:       returnValue = property.innerText
63:       return returnValue
64:     end
65: 
66:     property = property = self.at(name.downcase)
67:     if(property)then
68:       return property.innerText
69:     end
70: 
71:     vrtx_property = self.at("v:" + name)
72:     if(vrtx_property)then
73:       return vrtx_property.innerText
74:     end
75: 
76:     vrtx_property = self.at("v:" + name.downcase)
77:     if(vrtx_property)then
78:       return vrtx_property.innerText
79:     end
80: 
81:     dav_property = self.at("d:" +name)
82:     if( dav_property)then
83:       return dav_property.innerText
84:     end
85: 
86:     dav_property = self.at("d:" +name.downcase)
87:     if( dav_property)then
88:       return dav_property.innerText
89:     end
90: 
91:     return nil
92:   end

Get property for resource or collection. Example:

   page = WebDAV.find(url)
   print page.property("published-date")

[Source]

    # File lib/davclient/hpricot_extensions.rb, line 56
56:   def property(name)
57: 
58:     # TODO: Make list of recognized namespace prefixes configurable
59: 
60:     property = property = self.at(name)
61:     if(property)then
62:       returnValue = property.innerText
63:       return returnValue
64:     end
65: 
66:     property = property = self.at(name.downcase)
67:     if(property)then
68:       return property.innerText
69:     end
70: 
71:     vrtx_property = self.at("v:" + name)
72:     if(vrtx_property)then
73:       return vrtx_property.innerText
74:     end
75: 
76:     vrtx_property = self.at("v:" + name.downcase)
77:     if(vrtx_property)then
78:       return vrtx_property.innerText
79:     end
80: 
81:     dav_property = self.at("d:" +name)
82:     if( dav_property)then
83:       return dav_property.innerText
84:     end
85: 
86:     dav_property = self.at("d:" +name.downcase)
87:     if( dav_property)then
88:       return dav_property.innerText
89:     end
90: 
91:     return nil
92:   end

Set the items WebDAV properties. Properties must be a string with XML. Example:

   find(url) do |item|
      if(item.href =~ /html$/) then
        item.proppatch("<d:getcontenttype>text/html</d:getcontenttype>")
      end
   end

[Source]

     # File lib/davclient/hpricot_extensions.rb, line 107
107:   def proppatch(properties)
108:     WebDAV.proppatch(href, properties)
109:   end

Set the items WebDAV properties. Properties must be a string with XML. Example:

   find(url) do |item|
      if(item.href =~ /html$/) then
        item.proppatch("<d:getcontenttype>text/html</d:getcontenttype>")
      end
   end

[Source]

     # File lib/davclient/hpricot_extensions.rb, line 107
107:   def proppatch(properties)
108:     WebDAV.proppatch(href, properties)
109:   end

[Validate]