vortex_client 0.5.5 → 0.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/vortex_client.rb +36 -20
  3. metadata +2 -2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.5
1
+ 0.5.6
data/lib/vortex_client.rb CHANGED
@@ -53,7 +53,23 @@ module Vortex
53
53
  return true
54
54
  end
55
55
 
56
- # Publish a document object to the web.
56
+ # Writes a document a document to the web. Same as publish, except
57
+ # that if document type is StructuredArticle publishDate
58
+ def write(object)
59
+ if(object.is_a? HtmlArticle or object.is_a? HtmlEvent or object.is_a? StructuredArticle)
60
+ uri = @uri.merge(object.url)
61
+ # puts "DEBUG: '" + object.class.to_s + "=" + object.properties
62
+ self.put_string(uri, object.content)
63
+ self.proppatch(uri, object.properties)
64
+ return uri.to_s
65
+ else
66
+ warn "Unknown vortex resource: " + object.class.to_s
67
+ end
68
+ end
69
+
70
+ # Publish a document object to the web. If content is a StructuredArticle
71
+ # stored as json, and publisDate is note set, then publishDate will be set
72
+ # to current time.
57
73
  #
58
74
  # Publishes a object by performing a PUT request to object.url with object.content
59
75
  # and then performing a PROPPATCH request to object.url with object.properties
@@ -64,15 +80,16 @@ module Vortex
64
80
  # article = Vortex::StructuredArticle(:title=>"My title")
65
81
  # vortex.publish(article)
66
82
  def publish(object)
67
- if(object.is_a? HtmlArticle or object.is_a? HtmlEvent or object.is_a? StructuredArticle)
68
- uri = @uri.merge(object.url)
69
- # puts "DEBUG: '" + object.class.to_s + "=" + object.properties
70
- self.put_string(uri, object.content)
71
- self.proppatch(uri, object.properties)
72
- return uri.to_s
73
- else
74
- warn "Unknown vortex resource: " + object.class.to_s
83
+ write(object)
84
+ uri = @uri.merge(object.url)
85
+ if(object.is_a? StructuredArticle) then
86
+ if(object.publishDate == nil)then
87
+ time = Time.now.httpdate.to_s
88
+ prop = '<v:publish-date xmlns:v="vrtx">' + time + '</v:publish-date>'
89
+ self.proppatch(uri, prop)
90
+ end
75
91
  end
92
+ return uri.to_s
76
93
  end
77
94
 
78
95
  # Creates collections
@@ -132,13 +149,13 @@ module Vortex
132
149
 
133
150
  def url
134
151
  if(@url)
135
- @url
152
+ return @url
136
153
  else
137
154
  if(filename)
138
- filename
155
+ return filename
139
156
  end
140
157
  if(title)
141
- StringUtils.create_filename(title) + ".html"
158
+ return StringUtils.create_filename(title) + ".html"
142
159
  else
143
160
  warn "Article must have either a full url or title. "
144
161
  end
@@ -266,13 +283,13 @@ module Vortex
266
283
 
267
284
  def url
268
285
  if(@url)
269
- @url
286
+ return @url
270
287
  else
271
288
  if(filename)
272
- filename
289
+ return filename
273
290
  end
274
291
  if(title)
275
- StringUtils.create_filename(title) + ".html"
292
+ return StringUtils.create_filename(title) + ".html"
276
293
  else
277
294
  warn "Article must have either a full url or title. "
278
295
  end
@@ -363,7 +380,6 @@ module Vortex
363
380
 
364
381
 
365
382
  # Vortex article stored as JSON data.
366
- # TODO: Fill out the stub.
367
383
  class StructuredArticle < HtmlArticle
368
384
 
369
385
  attr_accessor :title, :introduction, :content, :filename, :modifiedDate, :publishDate, :owner, :url, :picture, :hideAdditionalContent
@@ -379,13 +395,13 @@ module Vortex
379
395
 
380
396
  def url
381
397
  if(@url)
382
- @url
398
+ return @url
383
399
  else
384
- if(filename)
385
- filename
400
+ if(filename != nil)
401
+ return filename
386
402
  end
387
403
  if(title)
388
- StringUtils.create_filename(title) + ".html"
404
+ return StringUtils.create_filename(title) + ".html"
389
405
  else
390
406
  warn "Article must have either a full url or title. "
391
407
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 5
9
- version: 0.5.5
8
+ - 6
9
+ version: 0.5.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Thomas Flemming