gdata4ruby 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/lib/gdata4ruby/base.rb +6 -1
- data/lib/gdata4ruby/gdata_object.rb +40 -3
- data/lib/gdata4ruby/request.rb +2 -2
- metadata +2 -2
data/CHANGELOG
CHANGED
data/lib/gdata4ruby/base.rb
CHANGED
@@ -18,8 +18,11 @@
|
|
18
18
|
|
19
19
|
require "net/http"
|
20
20
|
require "net/https"
|
21
|
+
require 'time'
|
22
|
+
require 'cgi'
|
21
23
|
require 'gdata4ruby/request'
|
22
24
|
require 'gdata4ruby/utils/utils'
|
25
|
+
require 'rexml/document'
|
23
26
|
|
24
27
|
Net::HTTP.version_1_2
|
25
28
|
|
@@ -112,8 +115,10 @@ module GData4Ruby
|
|
112
115
|
end
|
113
116
|
|
114
117
|
while ret.is_a?(Net::HTTPRedirection)
|
115
|
-
puts "Redirect received, resending
|
118
|
+
puts "Redirect received, resending request" if @debug
|
119
|
+
request.parameters = nil
|
116
120
|
request.url = ret['location']
|
121
|
+
puts "sending #{request.type} to url = #{request.url.to_s}" if @debug
|
117
122
|
ret = do_request(request)
|
118
123
|
end
|
119
124
|
if not ret.is_a?(Net::HTTPSuccess)
|
@@ -17,6 +17,7 @@
|
|
17
17
|
#++
|
18
18
|
|
19
19
|
require 'gdata4ruby/service'
|
20
|
+
require 'time'
|
20
21
|
|
21
22
|
module GData4Ruby
|
22
23
|
#The GDataObject class represents any <entry> object returned by a Google Service. Includes
|
@@ -29,6 +30,18 @@ module GData4Ruby
|
|
29
30
|
#The entry title.
|
30
31
|
attr_accessor :title
|
31
32
|
|
33
|
+
#The raw date the document was published
|
34
|
+
attr_reader :published
|
35
|
+
|
36
|
+
#The raw date the document was last updated
|
37
|
+
attr_reader :updated
|
38
|
+
|
39
|
+
#The author/owner name
|
40
|
+
attr_reader :author_name
|
41
|
+
|
42
|
+
#The author/owner email
|
43
|
+
attr_reader :author_email
|
44
|
+
|
32
45
|
#The current instance etag for the entry
|
33
46
|
attr_reader :etag
|
34
47
|
|
@@ -54,6 +67,12 @@ module GData4Ruby
|
|
54
67
|
#The feedLink that represents the entry's ACL feed.
|
55
68
|
attr_reader :acl_uri
|
56
69
|
|
70
|
+
#The content uri for exporting the object content
|
71
|
+
attr_reader :content_uri
|
72
|
+
|
73
|
+
#The kind (type) of the object
|
74
|
+
attr_reader :kind
|
75
|
+
|
57
76
|
#Indicates whether the object exists on the Google servers, i.e. has been created/saved.
|
58
77
|
def exists?
|
59
78
|
return @exists
|
@@ -66,7 +85,7 @@ module GData4Ruby
|
|
66
85
|
@xml ||= ''
|
67
86
|
@service ||= service
|
68
87
|
@exists = false
|
69
|
-
@title = @etag = @acl_uri = @edit_uri = @parent_uri = @feed_uri = nil
|
88
|
+
@title = @content_uri = @etag = @acl_uri = @edit_uri = @parent_uri = @feed_uri = @kind = nil
|
70
89
|
@categories = @feed_links = []
|
71
90
|
@include_etag = true
|
72
91
|
attributes.each do |key, value|
|
@@ -87,6 +106,8 @@ module GData4Ruby
|
|
87
106
|
when "id"
|
88
107
|
puts 'setting id' if service.debug
|
89
108
|
@feed_uri = ele.text
|
109
|
+
when 'content'
|
110
|
+
@content_uri = ele.attributes['src'] if ele.attributes['src']
|
90
111
|
when 'resourceId'
|
91
112
|
@id = ele.text
|
92
113
|
when 'title'
|
@@ -95,16 +116,32 @@ module GData4Ruby
|
|
95
116
|
@categories << {:label => ele.attributes['label'],
|
96
117
|
:scheme => ele.attributes['scheme'],
|
97
118
|
:term => ele.attributes['term']}
|
119
|
+
if ele.attributes['scheme'] and ele.attributes['scheme'] == 'http://schemas.google.com/g/2005#kind'
|
120
|
+
@kind = if ele.attributes['label']
|
121
|
+
ele.attributes['label']
|
122
|
+
else
|
123
|
+
ele.attributes['term']
|
124
|
+
end
|
125
|
+
end
|
98
126
|
when 'link'
|
99
127
|
case ele.attributes['rel']
|
100
128
|
when 'http://schemas.google.com/docs/2007#parent'
|
101
129
|
@parent_uri = ele.attributes['href']
|
102
130
|
when 'edit'
|
103
131
|
@edit_uri = ele.attributes['href']
|
132
|
+
when 'http://schemas.google.com/acl/2007#accessControlList'
|
133
|
+
@acl_uri = ele.attributes['href'] if not @acl_uri
|
104
134
|
end
|
105
135
|
when 'feedLink'
|
106
136
|
@feed_links << {:rel => ele.attributes['rel'], :href => ele.attributes['href']}
|
107
|
-
@acl_uri = ele.attributes['href'] if ele.attributes['rel'].include? 'accessControlList'
|
137
|
+
@acl_uri = ele.attributes['href'] if ele.attributes['rel'].include? 'accessControlList' and not @acl_uri
|
138
|
+
when 'author'
|
139
|
+
ele.elements.each('name'){}.map {|e| @author_name = e.text}
|
140
|
+
ele.elements.each('email'){}.map {|e| @author_email = e.text}
|
141
|
+
when 'published'
|
142
|
+
@published = Time.parse(ele.text)
|
143
|
+
when 'updated'
|
144
|
+
@updated = Time.parse(ele.text)
|
108
145
|
end
|
109
146
|
end
|
110
147
|
return xml.root
|
@@ -133,7 +170,7 @@ module GData4Ruby
|
|
133
170
|
#Deletes the object.
|
134
171
|
def delete
|
135
172
|
if @exists
|
136
|
-
service.send_request(Request.new(:delete, @
|
173
|
+
service.send_request(Request.new(:delete, @edit_uri, nil, {"If-Match" => "*"}))
|
137
174
|
end
|
138
175
|
@exists = false
|
139
176
|
return true
|
data/lib/gdata4ruby/request.rb
CHANGED
@@ -49,8 +49,8 @@ module GData4Ruby
|
|
49
49
|
|
50
50
|
#A hash of additional query parameters (i.e. {'param' => 'value') to append to the request url
|
51
51
|
def parameters=(query_parameters)
|
52
|
-
raise ArgumentError, 'Query parameters must be a Hash' if query_parameters and not query_parameters.is_a? Hash
|
53
|
-
@parameters = "?#{query_parameters.to_a.collect{|a| a.join("=")}.join("&")}"
|
52
|
+
raise ArgumentError, 'Query parameters must be a Hash' if query_parameters != nil and not query_parameters.is_a? Hash
|
53
|
+
@parameters = query_parameters.is_a?(Hash) ? "?#{query_parameters.to_a.collect{|a| a.join("=")}.join("&")}" : nil
|
54
54
|
end
|
55
55
|
|
56
56
|
#The HTTP url to send the request to
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gdata4ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Reich
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-04-
|
12
|
+
date: 2010-04-29 00:00:00 +10:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|