ringioAPI 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/README.mkdn CHANGED
@@ -8,7 +8,7 @@ Provides a wrapper for the [API of Ringio][ringio] in Ruby, using classes that i
8
8
 
9
9
  Available classes at the moment are:
10
10
 
11
- Contact, Feed, Note, User
11
+ Contact, Feed, Note, Ring, User
12
12
 
13
13
 
14
14
  ## Installing
@@ -29,7 +29,7 @@ You can configure the API token like this:
29
29
  require 'ringioAPI'
30
30
  RingioAPI::Base.user = 'RINGIO API TOKEN'
31
31
 
32
- Currently there is a bug in Rails 3.0.1 that makes JSON objects not parse the root node.
32
+ Currently there is a bug in Rails 3.0.X that makes JSON objects be parsed wrong.
33
33
  Check the possible solutions and patches in [the corresponding thread in the Rails forums for developers][bug]
34
34
 
35
35
 
@@ -51,7 +51,7 @@ In the root of the project, run:
51
51
 
52
52
  For example, to get the contact with id = 14 :
53
53
 
54
- contact14 = Ringio::Contact.find(14)
54
+ contact14 = RingioAPI::Contact.find(14)
55
55
 
56
56
  To change the title of that contact:
57
57
 
@@ -64,7 +64,7 @@ To destroy that contact:
64
64
 
65
65
  To create a Contact for the user with person_id = 78 :
66
66
 
67
- newContact = Ringio::Contact.new(:name => 'New contact name', :userId => 78)
67
+ newContact = RingioAPI::Contact.new(:name => 'New contact name', :userId => 78)
68
68
  newContact.save
69
69
 
70
70
  If you have problems, check Ringio API specifications for details.
@@ -1,6 +1,60 @@
1
1
  module RingioAPI
2
2
 
3
3
  class Contact < Base
4
+
5
+ # override methods as a TEMPORARY solution of the JSON parsing bugs of Rails
6
+
7
+ # move the nested resource to the root
8
+ def self.find(contact_id)
9
+ super(contact_id).contact
10
+ end
11
+
12
+ def save
13
+
14
+ # change the array of Datum objects to an array of hashes just to make it easy to parse as JSON
15
+ new_data = []
16
+ begin
17
+ old_data = self.data
18
+ self.data.each do |d|
19
+ if d
20
+ new_data << {:type => d.type, :value => d.value, :is_primary => d.is_primary, :rel => d.rel}
21
+ end
22
+ end
23
+ self.data = new_data
24
+ rescue NoMethodError
25
+ end
26
+
27
+ result = super
28
+
29
+ # restore the array of Datums
30
+ begin
31
+ self.data = old_data
32
+ rescue NoMethodError
33
+ end
34
+
35
+
36
+ # move the fields returned after an update response to their proper place in the root
37
+ begin
38
+ self.id = self.contact.id
39
+ rescue NoMethodError
40
+ end
41
+ begin
42
+ self.last_updated = self.contact.last_updated
43
+ rescue NoMethodError
44
+ end
45
+ begin
46
+ self.date_created = self.contact.last_updated
47
+ rescue NoMethodError
48
+ end
49
+
50
+ # clean the unused nested resource
51
+ begin
52
+ self.contact = nil
53
+ rescue NoMethodError
54
+ end
55
+
56
+ result
57
+ end
4
58
 
5
59
  end
6
60
 
@@ -1,7 +1,52 @@
1
1
  module RingioAPI
2
2
 
3
3
  class Note < Base
4
-
4
+
5
+ # override methods as a temporary solution of the JSON parsing bugs of Rails
6
+ def self.find(note_id)
7
+ super(note_id).note
8
+ end
9
+
10
+ def save
11
+
12
+ result = super
13
+
14
+ # move the fields returned after an update response to their proper place in the root
15
+ begin
16
+ self.id = self.note.id
17
+ rescue NoMethodError
18
+ end
19
+ begin
20
+ self.contact_id = self.note.contact_id
21
+ rescue NoMethodError
22
+ end
23
+ begin
24
+ self.author_id = self.note.author_id
25
+ rescue NoMethodError
26
+ end
27
+ begin
28
+ self.body = self.note.body
29
+ rescue NoMethodError
30
+ end
31
+ begin
32
+ self.last_updated = self.note.last_updated
33
+ rescue NoMethodError
34
+ end
35
+ begin
36
+ self.date_created = self.note.last_updated
37
+ rescue NoMethodError
38
+ end
39
+
40
+ # clean the unused nested resource
41
+ begin
42
+ self.note = nil
43
+ rescue NoMethodError
44
+ end
45
+
46
+ result
47
+ end
48
+
49
+
5
50
  end
6
51
 
7
52
  end
@@ -0,0 +1,32 @@
1
+ module RingioAPI
2
+
3
+ class Ring < Base
4
+
5
+ # override methods as a temporary solution of the JSON parsing bugs of Rails
6
+ def self.find(ring_id)
7
+ super(ring_id).ring
8
+ end
9
+
10
+ def save
11
+
12
+ result = super
13
+
14
+ # move the fields returned after an update response to their proper place in the root
15
+ begin
16
+ self.id = self.ring.id
17
+ rescue NoMethodError
18
+ end
19
+
20
+ # clean the unused nested resource
21
+ begin
22
+ self.ring = nil
23
+ rescue NoMethodError
24
+ end
25
+
26
+ result
27
+ end
28
+
29
+
30
+ end
31
+
32
+ end
@@ -1,7 +1,12 @@
1
1
  module RingioAPI
2
2
 
3
3
  class User < Base
4
-
4
+
5
+ # override methods as a temporary solution of the JSON parsing bugs of Rails
6
+ def self.find(user_id)
7
+ super(user_id).user
8
+ end
9
+
5
10
  end
6
11
 
7
12
  end
@@ -1,3 +1,3 @@
1
1
  module RingioAPI
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
data/lib/ringioAPI.rb CHANGED
@@ -2,4 +2,5 @@ require 'ringioAPI/base.rb'
2
2
  require 'ringioAPI/contact.rb'
3
3
  require 'ringioAPI/feed.rb'
4
4
  require 'ringioAPI/note.rb'
5
+ require 'ringioAPI/ring.rb'
5
6
  require 'ringioAPI/user.rb'
data/ringioAPI.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.platform = Gem::Platform::RUBY
9
9
 
10
10
  spec.required_rubygems_version = ">= 1.3.6"
11
- spec.add_dependency "activeresource", "~>3.0.0"
11
+ spec.add_dependency "activeresource", ">= 3.0.3"
12
12
 
13
13
  spec.files = Dir['*'] + Dir['lib/*.rb'] + Dir['lib/ringioAPI/*.rb']
14
14
  spec.require_paths = ["lib"]
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 8
9
- version: 0.0.8
8
+ - 9
9
+ version: 0.0.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - "\xC3\x81lvaro Mart\xC3\xADn Fraguas"
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-02 00:00:00 +01:00
17
+ date: 2010-12-13 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -23,13 +23,13 @@ dependencies:
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
24
  none: false
25
25
  requirements:
26
- - - ~>
26
+ - - ">="
27
27
  - !ruby/object:Gem::Version
28
28
  segments:
29
29
  - 3
30
30
  - 0
31
- - 0
32
- version: 3.0.0
31
+ - 3
32
+ version: 3.0.3
33
33
  type: :runtime
34
34
  version_requirements: *id001
35
35
  description: "\tIMPORTANT: this project has just started, so the functionality is not complete yet.\n Provides a wrapper for the Ringio API in Ruby, using ActiveResource.\n\n You can configure it for example by adding a file with this in config/initializers/ :\n\n require 'ringioAPI'\n RingioAPI::Base.user = 'RINGIO API TOKEN'\n"
@@ -48,6 +48,7 @@ files:
48
48
  - lib/ringioAPI.rb
49
49
  - lib/ringioAPI/version.rb
50
50
  - lib/ringioAPI/feed.rb
51
+ - lib/ringioAPI/ring.rb
51
52
  - lib/ringioAPI/base.rb
52
53
  - lib/ringioAPI/user.rb
53
54
  - lib/ringioAPI/note.rb