oos4ruby 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -35,3 +35,7 @@
35
35
  == 0.1.6 2008-04-03
36
36
 
37
37
  * 1 connection bug fixed
38
+
39
+ == 0.1.7 2009-03-16
40
+
41
+ * User pagination
@@ -103,9 +103,7 @@ module Bean #:nodoc:
103
103
 
104
104
  def contains?(elem, value)
105
105
  xpath = @xml.first(elem)
106
- return true if xpath && xpath.text == value
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
- Bean.add_category(@xml, term, scheme)
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
- Bean.remove_category(@xml, term, scheme)
149
+ self.remove_category(@xml, term, scheme)
152
150
  end
153
151
 
154
152
  def self.make_id
@@ -85,10 +85,6 @@ class Collection < Array
85
85
  return get_page!(@feed.self_link)
86
86
  end
87
87
 
88
- def to_s
89
- @entries.join("\n")
90
- end
91
-
92
88
  =begin rdoc
93
89
  method to create a resource into a collection.
94
90
  opts available keys:
@@ -33,8 +33,7 @@ class Contact < Bean::BeanClass
33
33
  returns the user associated with this contact
34
34
  =end
35
35
  def data
36
- @data = User.find @auth, @xml.link('userInfo') unless @data
37
- @data
36
+ @data ||= User.find @auth, @xml.link('userInfo')
38
37
  end
39
38
 
40
39
  def trusted?
@@ -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
@@ -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, slug)
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 = Site.find_by_user(@auth, @slug, opts) unless @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 = Contact.find_by_user(@auth, @slug, opts) unless @contacts_collection
73
- @contacts_collection
71
+ @contacts_collection ||= Contact.find_by_user(@auth, @slug, opts)
74
72
  end
75
73
 
76
74
  def avatar
@@ -2,7 +2,7 @@ module Oos4ruby #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- TINY = 6
5
+ TINY = 7
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -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', '3beedf801db0d373919f6462345d6f76')
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
 
@@ -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.5</a>
36
+ <a href="http://rubyforge.org/projects/oos4ruby" class="numbers">0.1.7</a>
37
37
  </div>
38
- <h1>&#x2192; &#8216;oos4ruby&#8217;</h1>
39
-
40
-
41
- <h2>What</h2>
42
-
43
-
44
- <p>oos4ruby is a ruby library to interact with the 11870 <span class="caps">API</span>.</p>
45
-
46
-
47
- <h2>Installing</h2>
48
-
49
-
50
- <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>
51
-
52
-
53
- <h2>The basics</h2>
54
-
55
-
56
- <p>The class &#8220;Oos4ruby::Oos&#8221; 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">=&gt;</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>&amp;#x2192; &#8216;oos4ruby&#8217;</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 &#8220;Oos4ruby::Oos&#8221; 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">=&gt;</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&#8217;t exist in 11870:</p>
94
-
95
-
96
- <p><pre class='syntax'>
61
+ <p>How to add a review from a site that doesn&#8217;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">=&gt;</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 =&gt; </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 =&gt; {:name =&gt; </span><span class="punct">'</span><span class="constant">Madrid</span><span class="punct">'</span><span class="string">, :slug =&gt; </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 =&gt; </span><span class="punct">'</span><span class="ident">review</span> <span class="ident">title</span><span class="punct">'</span><span class="string">, :content =&gt; </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 =&gt; [</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 =&gt; [</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">=&gt;</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">=&gt;</span> <span class="punct">'</span><span class="string">review title</span><span class="punct">',</span> <span class="symbol">:content</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">review content</span><span class="punct">'}</span>
112
74
  </pre></p>
113
-
114
-
115
- <p>How to obtain all user contacts in 11870:</p>
116
-
117
-
118
- <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>
119
-
120
-
121
- <p>How to obtain the multimedia feed associated with a review:</p>
122
-
123
-
124
- <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>
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&#8217;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&#8217;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>, 13th November 2007<br>
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.6
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: 2008-04-03 00:00:00 +02:00
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.0
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