Module: Hpricot

Defined in:
lib/webdavtools/hpricot_extensions.rb

Overview

Extensions to the Hpricot XML parser.

Defined Under Namespace

Classes: Elem

Instance Method Summary collapse

Instance Method Details

#basenameObject



90
91
92
# File 'lib/webdavtools/hpricot_extensions.rb', line 90

def basename
  File.basename(self.at("d:href").innerText)
end

#dateProperty(name) ⇒ Object

TODO: Move to vortex_lib.rb



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/webdavtools/hpricot_extensions.rb', line 95

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

TODO: Make list of recognized namespace prefixes configurable Get property. Example:

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


54
55
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
# File 'lib/webdavtools/hpricot_extensions.rb', line 54

def property(name)

  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.



114
115
116
# File 'lib/webdavtools/hpricot_extensions.rb', line 114

def proppatch(properties)
  WebDAV.proppatch(href, properties)
end

#type_convert_value(value) ⇒ Object

TODO Not used. Delete???



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/webdavtools/hpricot_extensions.rb', line 37

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