oos4ruby 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/lib/oos4ruby/bean.rb +3 -5
- data/lib/oos4ruby/collection.rb +0 -4
- data/lib/oos4ruby/contact.rb +1 -2
- data/lib/oos4ruby/site.rb +4 -3
- data/lib/oos4ruby/user.rb +3 -5
- data/lib/oos4ruby/version.rb +1 -1
- data/test/test_oos4ruby.rb +17 -1
- data/website/index.html +35 -99
- metadata +15 -4
data/History.txt
CHANGED
data/lib/oos4ruby/bean.rb
CHANGED
@@ -103,9 +103,7 @@ module Bean #:nodoc:
|
|
103
103
|
|
104
104
|
def contains?(elem, value)
|
105
105
|
xpath = @xml.first(elem)
|
106
|
-
return
|
107
|
-
|
108
|
-
return false
|
106
|
+
return xpath && xpath.text == value
|
109
107
|
end
|
110
108
|
|
111
109
|
def update!
|
@@ -139,7 +137,7 @@ module Bean #:nodoc:
|
|
139
137
|
|
140
138
|
protected
|
141
139
|
def add_category(term, scheme)
|
142
|
-
|
140
|
+
self.add_category(@xml, term, scheme)
|
143
141
|
end
|
144
142
|
|
145
143
|
def update_category(new_term, new_scheme, old_term = nil, old_scheme = nil)
|
@@ -148,7 +146,7 @@ module Bean #:nodoc:
|
|
148
146
|
end
|
149
147
|
|
150
148
|
def remove_category(term = nil, scheme = nil)
|
151
|
-
|
149
|
+
self.remove_category(@xml, term, scheme)
|
152
150
|
end
|
153
151
|
|
154
152
|
def self.make_id
|
data/lib/oos4ruby/collection.rb
CHANGED
data/lib/oos4ruby/contact.rb
CHANGED
data/lib/oos4ruby/site.rb
CHANGED
@@ -42,7 +42,8 @@ class Site < Bean::BeanClass
|
|
42
42
|
raise Oos4ruby::UnknownUser if slug.nil?
|
43
43
|
|
44
44
|
uri = SITES_URL + "/#{slug}"
|
45
|
-
|
45
|
+
uri << "?page=#{opts[:page].to_i}" if opts[:page]
|
46
|
+
|
46
47
|
getter = HTTPInvoker.new uri, auth
|
47
48
|
|
48
49
|
worked = getter.get
|
@@ -205,8 +206,8 @@ class Site < Bean::BeanClass
|
|
205
206
|
if @categories_added
|
206
207
|
@categories_added.each { |cat|
|
207
208
|
add_category cat.term, cat.scheme
|
208
|
-
@tags << cat if cat.scheme == @tags_scheme
|
209
|
-
@lists << cat if cat.scheme == @lists_scheme
|
209
|
+
(@tags ||= []) << cat if cat.scheme == @tags_scheme
|
210
|
+
(@lists ||=[]) << cat if cat.scheme == @lists_scheme
|
210
211
|
}
|
211
212
|
@categories_added.clear
|
212
213
|
end
|
data/lib/oos4ruby/user.rb
CHANGED
@@ -41,7 +41,7 @@ class User < Bean::BeanClass
|
|
41
41
|
if worked
|
42
42
|
if slug #response is an Entry
|
43
43
|
entry = Entry.new getter.body
|
44
|
-
return User.new(entry, auth
|
44
|
+
return User.new(entry, auth)
|
45
45
|
else
|
46
46
|
#response is a feed
|
47
47
|
feed = Feed.read getter.body
|
@@ -64,13 +64,11 @@ class User < Bean::BeanClass
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def sites( opts = {} )
|
67
|
-
@sites_collection
|
68
|
-
@sites_collection
|
67
|
+
@sites_collection ||= Site.find_by_user(@auth, @slug, opts)
|
69
68
|
end
|
70
69
|
|
71
70
|
def contacts( opts = {} )
|
72
|
-
@contacts_collection
|
73
|
-
@contacts_collection
|
71
|
+
@contacts_collection ||= Contact.find_by_user(@auth, @slug, opts)
|
74
72
|
end
|
75
73
|
|
76
74
|
def avatar
|
data/lib/oos4ruby/version.rb
CHANGED
data/test/test_oos4ruby.rb
CHANGED
@@ -86,7 +86,7 @@ class TestOos4ruby < Test::Unit::TestCase
|
|
86
86
|
|
87
87
|
def setup
|
88
88
|
@oos = Oos4ruby::Oos.new
|
89
|
-
@oos.auth_user('david.calavera@11870.com', '
|
89
|
+
@oos.auth_user('david.calavera@11870.com', '85a9526f48b90283713f70d483afbfd5')
|
90
90
|
end
|
91
91
|
|
92
92
|
def assert_user_not_nil(user)
|
@@ -147,6 +147,22 @@ class TestOos4ruby < Test::Unit::TestCase
|
|
147
147
|
def test_contains?
|
148
148
|
assert_equal(true, @oos.user.sites.contains?('oos:locality', 'Madrid'))
|
149
149
|
end
|
150
|
+
|
151
|
+
def test_contact_sites
|
152
|
+
assert_not_nil(@oos.user.contacts.last.data.sites)
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_create_media
|
156
|
+
file_path = '/home/david/Pantallazo-1.png'
|
157
|
+
medias = @oos.user.sites.first.multimedia
|
158
|
+
|
159
|
+
media = nil
|
160
|
+
assert_nothing_raised {
|
161
|
+
media = medias.create!(:file => file_path,
|
162
|
+
:content_length => File.size(file_path), :content_type => 'image/png' )
|
163
|
+
}
|
164
|
+
assert_not_nil media
|
165
|
+
end
|
150
166
|
|
151
167
|
end
|
152
168
|
|
data/website/index.html
CHANGED
@@ -33,54 +33,24 @@
|
|
33
33
|
<h1>oos4ruby</h1>
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/oos4ruby"; return false'>
|
35
35
|
<p>Get Version</p>
|
36
|
-
<a href="http://rubyforge.org/projects/oos4ruby" class="numbers">0.1.
|
36
|
+
<a href="http://rubyforge.org/projects/oos4ruby" class="numbers">0.1.7</a>
|
37
37
|
</div>
|
38
|
-
<h1
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
<p>The class “Oos4ruby::Oos” is the endpoint to interact with the api. This class provides the authentication methods in addition to the search and user management methods.</p>
|
57
|
-
|
58
|
-
|
59
|
-
<p><pre class='syntax'><span class="ident">oos</span> <span class="punct">=</span> <span class="constant">Oos4ruby</span><span class="punct">::</span><span class="constant">Oos</span><span class="punct">.</span><span class="ident">new</span></pre></p>
|
60
|
-
|
61
|
-
|
62
|
-
<p>Authenticate as an application in order to perform searches or explore the user contents:</p>
|
63
|
-
|
64
|
-
|
65
|
-
<p><pre class='syntax'><span class="ident">oos</span><span class="punct">.</span><span class="ident">auth_app</span> <span class="punct">'</span><span class="string">your appToken</span><span class="punct">',</span> <span class="punct">'</span><span class="string">your secret key</span><span class="punct">'</span></pre></p>
|
66
|
-
|
67
|
-
|
68
|
-
<p>Authenticate as a user in order to manage his contents:</p>
|
69
|
-
|
70
|
-
|
71
|
-
<p><pre class='syntax'><span class="ident">oos</span><span class="punct">.</span><span class="ident">auth_user</span> <span class="punct">'</span><span class="string">user email in 11870.com</span><span class="punct">',</span> <span class="punct">'</span><span class="string">user authorization token</span><span class="punct">'</span></pre></p>
|
72
|
-
|
73
|
-
|
74
|
-
<p>Method to perform a search inside 11870:</p>
|
75
|
-
|
76
|
-
|
77
|
-
<p><pre class='syntax'><span class="ident">oos</span><span class="punct">.</span><span class="ident">search</span> <span class="symbol">:q</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">cheap restaurants in new york</span><span class="punct">'</span></pre></p>
|
78
|
-
|
79
|
-
|
80
|
-
<p>How to obtain the services or places saved by a user:</p>
|
81
|
-
|
82
|
-
|
83
|
-
<p><pre class='syntax'>
|
38
|
+
<h1>&#x2192; ‘oos4ruby’</h1>
|
39
|
+
<h2>What</h2>
|
40
|
+
<p>oos4ruby is a ruby library to interact with the 11870 <span class="caps">API</span>.</p>
|
41
|
+
<h2>Installing</h2>
|
42
|
+
<p><pre class='syntax'><span class="ident">sudo</span> <span class="ident">gem</span> <span class="ident">install</span> <span class="ident">oos4ruby</span></pre></p>
|
43
|
+
<h2>The basics</h2>
|
44
|
+
<p>The class “Oos4ruby::Oos” is the endpoint to interact with the api. This class provides the authentication methods in addition to the search and user management methods.</p>
|
45
|
+
<p><pre class='syntax'><span class="ident">oos</span> <span class="punct">=</span> <span class="constant">Oos4ruby</span><span class="punct">::</span><span class="constant">Oos</span><span class="punct">.</span><span class="ident">new</span></pre></p>
|
46
|
+
<p>Authenticate as an application in order to perform searches or explore the user contents:</p>
|
47
|
+
<p><pre class='syntax'><span class="ident">oos</span><span class="punct">.</span><span class="ident">auth_app</span> <span class="punct">'</span><span class="string">your appToken</span><span class="punct">',</span> <span class="punct">'</span><span class="string">your secret key</span><span class="punct">'</span></pre></p>
|
48
|
+
<p>Authenticate as a user in order to manage his contents:</p>
|
49
|
+
<p><pre class='syntax'><span class="ident">oos</span><span class="punct">.</span><span class="ident">auth_user</span> <span class="punct">'</span><span class="string">user email in 11870.com</span><span class="punct">',</span> <span class="punct">'</span><span class="string">user authorization token</span><span class="punct">'</span></pre></p>
|
50
|
+
<p>Method to perform a search inside 11870:</p>
|
51
|
+
<p><pre class='syntax'><span class="ident">oos</span><span class="punct">.</span><span class="ident">search</span> <span class="symbol">:q</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">cheap restaurants in new york</span><span class="punct">'</span></pre></p>
|
52
|
+
<p>How to obtain the services or places saved by a user:</p>
|
53
|
+
<p><pre class='syntax'>
|
84
54
|
<span class="comment">#if your app is authenticated with this user authorization token</span>
|
85
55
|
<span class="ident">user</span> <span class="punct">=</span> <span class="ident">oos</span><span class="punct">.</span><span class="ident">user</span>
|
86
56
|
<span class="comment">#if your app is authenticated to expore contents</span>
|
@@ -88,12 +58,8 @@
|
|
88
58
|
|
89
59
|
<span class="ident">sites</span> <span class="punct">=</span> <span class="ident">user</span><span class="punct">.</span><span class="ident">sites</span>
|
90
60
|
</pre></p>
|
91
|
-
|
92
|
-
|
93
|
-
<p>How to add a review from a site that doesn’t exist in 11870:</p>
|
94
|
-
|
95
|
-
|
96
|
-
<p><pre class='syntax'>
|
61
|
+
<p>How to add a review from a site that doesn’t exist in 11870:</p>
|
62
|
+
<p><pre class='syntax'>
|
97
63
|
<span class="ident">oos</span><span class="punct">.</span><span class="ident">user</span><span class="punct">.</span><span class="ident">sites</span><span class="punct">.</span><span class="ident">create!</span> <span class="punct">{</span><span class="symbol">:title</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">this site doesn</span><span class="punct">'</span><span class="ident">t</span> <span class="ident">exist</span><span class="punct">'</span><span class="string">,
|
98
64
|
:user_address => </span><span class="punct">'</span><span class="ident">the</span> <span class="ident">address</span><span class="punct">'</span><span class="string">,
|
99
65
|
:locality => {:name => </span><span class="punct">'</span><span class="constant">Madrid</span><span class="punct">'</span><span class="string">, :slug => </span><span class="punct">'/</span><span class="ident">es</span><span class="punct">/</span><span class="ident">madrid</span><span class="punct">'</span><span class="string">},
|
@@ -101,56 +67,26 @@
|
|
101
67
|
:summary => </span><span class="punct">'</span><span class="ident">review</span> <span class="ident">title</span><span class="punct">'</span><span class="string">, :content => </span><span class="punct">'</span><span class="ident">review</span> <span class="ident">content</span><span class="punct">'</span><span class="string">
|
102
68
|
:tags => [</span><span class="punct">'</span><span class="ident">tapas</span><span class="punct">'</span><span class="string">, </span><span class="punct">'</span><span class="ident">tipical</span> <span class="ident">spanish</span><span class="punct">'</span><span class="string">], :lists => [</span><span class="punct">'</span><span class="ident">food</span><span class="punct">'</span><span class="string">]}<span class="normal">
|
103
69
|
</span></span></pre></p>
|
104
|
-
|
105
|
-
|
106
|
-
<p>How to add a review from a site that exists in 11870:</p>
|
107
|
-
|
108
|
-
|
109
|
-
<p><pre class='syntax'>
|
70
|
+
<p>How to add a review from a site that exists in 11870:</p>
|
71
|
+
<p><pre class='syntax'>
|
110
72
|
<span class="ident">oos</span><span class="punct">.</span><span class="ident">user</span><span class="punct">.</span><span class="ident">sites</span><span class="punct">.</span><span class="ident">create!</span> <span class="punct">{</span><span class="symbol">:id</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">11870 site id</span><span class="punct">',</span>
|
111
73
|
<span class="symbol">:summary</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">review title</span><span class="punct">',</span> <span class="symbol">:content</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">review content</span><span class="punct">'}</span>
|
112
74
|
</pre></p>
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
<h2>Forum</h2>
|
128
|
-
|
129
|
-
|
130
|
-
<p><a href="http://groups.google.com/group/api-11870">http://groups.google.com/group/api-11870</a></p>
|
131
|
-
|
132
|
-
|
133
|
-
<h2>How to submit patches</h2>
|
134
|
-
|
135
|
-
|
136
|
-
<p>Read the <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/">8 steps for fixing other people’s code</a> and for section <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups">8b: Submit patch to Google Groups</a>, use the Google Group above.</p>
|
137
|
-
|
138
|
-
|
139
|
-
<p>The trunk repository is <code>http://api-11870.googlecode.com/svn/trunk/oos4ruby</code> for anonymous access.</p>
|
140
|
-
|
141
|
-
|
142
|
-
<h2>License</h2>
|
143
|
-
|
144
|
-
|
145
|
-
<p>This code is free to use under the terms of the <span class="caps">BSD</span> license.</p>
|
146
|
-
|
147
|
-
|
148
|
-
<h2>Contact</h2>
|
149
|
-
|
150
|
-
|
151
|
-
<p>Comments are welcome. Send an email to <a href="mailto:david.calavera@gmail.com">David Calavera</a> email via the <a href="http://groups.google.com/group/api-11870">forum</a></p>
|
75
|
+
<p>How to obtain all user contacts in 11870:</p>
|
76
|
+
<p><pre class='syntax'><span class="ident">contacts</span> <span class="punct">=</span> <span class="ident">user</span><span class="punct">.</span><span class="ident">contacts</span></pre></p>
|
77
|
+
<p>How to obtain the multimedia feed associated with a review:</p>
|
78
|
+
<p><pre class='syntax'><span class="ident">media_collection</span> <span class="punct">=</span> <span class="ident">user</span><span class="punct">.</span><span class="ident">sites</span><span class="punct">[</span><span class="number">0</span><span class="punct">].</span><span class="ident">multimedia</span></pre></p>
|
79
|
+
<h2>Forum</h2>
|
80
|
+
<p><a href="http://groups.google.com/group/api-11870">http://groups.google.com/group/api-11870</a></p>
|
81
|
+
<h2>How to submit patches</h2>
|
82
|
+
<p>Read the <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/">8 steps for fixing other people’s code</a> and for section <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups">8b: Submit patch to Google Groups</a>, use the Google Group above.</p>
|
83
|
+
<p>The trunk repository is <code>http://api-11870.googlecode.com/svn/trunk/oos4ruby</code> for anonymous access.</p>
|
84
|
+
<h2>License</h2>
|
85
|
+
<p>This code is free to use under the terms of the <span class="caps">BSD</span> license.</p>
|
86
|
+
<h2>Contact</h2>
|
87
|
+
<p>Comments are welcome. Send an email to <a href="mailto:david.calavera@gmail.com">David Calavera</a> email via the <a href="http://groups.google.com/group/api-11870">forum</a></p>
|
152
88
|
<p class="coda">
|
153
|
-
<a href="FIXME email">David Calavera</a>,
|
89
|
+
<a href="FIXME email">David Calavera</a>, 16th March 2009<br>
|
154
90
|
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
155
91
|
</p>
|
156
92
|
</div>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oos4ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Calavera
|
@@ -9,11 +9,12 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-03-16 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: mime-types
|
17
|
+
type: :runtime
|
17
18
|
version_requirement:
|
18
19
|
version_requirements: !ruby/object:Gem::Requirement
|
19
20
|
requirements:
|
@@ -21,6 +22,16 @@ dependencies:
|
|
21
22
|
- !ruby/object:Gem::Version
|
22
23
|
version: "1.5"
|
23
24
|
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: hoe
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.8.0
|
34
|
+
version:
|
24
35
|
description: oos4ruby is a ruby binding for the 11870 API
|
25
36
|
email: david.calavera@gmail.com
|
26
37
|
executables: []
|
@@ -98,10 +109,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
109
|
requirements: []
|
99
110
|
|
100
111
|
rubyforge_project: oos4r
|
101
|
-
rubygems_version: 1.1
|
112
|
+
rubygems_version: 1.3.1
|
102
113
|
signing_key:
|
103
114
|
specification_version: 2
|
104
115
|
summary: oos4ruby is a ruby binding for the 11870 API
|
105
116
|
test_files:
|
106
|
-
- test/test_oos4ruby.rb
|
107
117
|
- test/test_helper.rb
|
118
|
+
- test/test_oos4ruby.rb
|