Module: Hpricot
- Defined in:
- lib/davclient/hpricot_extensions.rb
Overview
Extensions to the Hpricot XML parser.
Defined Under Namespace
Classes: Elem
Instance Method Summary collapse
- #basename ⇒ Object
-
#content ⇒ Object
Get content from resources on server Example: webpage = WebDAV.find("http://example.org/index.html") print "html src: " + page.content.
- #content=(string) ⇒ Object
-
#dateProperty(name) ⇒ Object
TODO: Move to vortex_lib.rb.
-
#property(name) ⇒ Object
Get property for resource or collection.
-
#proppatch(properties) ⇒ Object
Set the items WebDAV properties.
-
#type_convert_value(value) ⇒ Object
TODO Not used.
Instance Method Details
#basename ⇒ Object
94 95 96 |
# File 'lib/davclient/hpricot_extensions.rb', line 94 def basename File.basename(self.at("d:href").innerText) end |
#content ⇒ Object
Get content from resources on server Example:
webpage = WebDAV.find("http://example.org/index.html")
print "html src: " + page.content
40 41 42 43 44 |
# File 'lib/davclient/hpricot_extensions.rb', line 40 def content if(!isCollection?) WebDAV.get(self.at("d:href").innerText) end end |
#content=(string) ⇒ Object
46 47 48 49 50 |
# File 'lib/davclient/hpricot_extensions.rb', line 46 def content=(string) if(!isCollection?) WebDAV.put_string(href,string) end end |
#dateProperty(name) ⇒ Object
TODO: Move to vortex_lib.rb
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/davclient/hpricot_extensions.rb', line 114 def dateProperty(name) date = self.property(name) if(date =~ /\dZ$/)then # Fix for bug in vortex: # # Some date properties are in xmlshcema datetime format, but # all tough the time seems to be localtime the timezone is # specified as Z not CEST. Fix is to set timezone and add # 2 hours. date = date.gsub(/\dZ$/," CEST") time = Time.parse(date) time = time + (60 * 60 * 2) return time end time = Time.parse(date) return time end |
#property(name) ⇒ Object
Get property for resource or collection. Example:
page = WebDAV.find(url)
print page.property("published-date")
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/davclient/hpricot_extensions.rb', line 56 def property(name) # TODO: Make list of recognized namespace prefixes configurable property = property = self.at(name) if(property)then returnValue = property.innerText return returnValue end property = property = self.at(name.downcase) if(property)then return property.innerText end vrtx_property = self.at("v:" + name) if(vrtx_property)then return vrtx_property.innerText end vrtx_property = self.at("v:" + name.downcase) if(vrtx_property)then return vrtx_property.innerText end dav_property = self.at("d:" +name) if( dav_property)then return dav_property.innerText end dav_property = self.at("d:" +name.downcase) if( dav_property)then return dav_property.innerText end return nil end |
#proppatch(properties) ⇒ Object
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
107 108 109 |
# File 'lib/davclient/hpricot_extensions.rb', line 107 def proppatch(properties) WebDAV.proppatch(href, properties) end |
#type_convert_value(value) ⇒ Object
TODO Not used. Delete???
134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/davclient/hpricot_extensions.rb', line 134 def type_convert_value(value) if(returnValue == "true")then return true end if(returnValue == "false")then return false end # Number format??? ## Dato format return returnValue end |