grizzly-weibo 0.3.7 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +13 -0
- data/lib/grizzly.rb +2 -0
- data/lib/grizzly/client.rb +9 -1
- data/lib/grizzly/comment.rb +10 -0
- data/lib/grizzly/errors/arguement.rb +17 -0
- data/lib/grizzly/status.rb +3 -1
- data/lib/grizzly/user.rb +4 -0
- data/lib/grizzly/version.rb +1 -1
- metadata +6 -4
data/README.markdown
CHANGED
@@ -30,6 +30,13 @@ client = Grizzly::Client.new(access_token)
|
|
30
30
|
status = client.status_update("Dude. Weibo is awesome!")
|
31
31
|
```
|
32
32
|
|
33
|
+
### Status Comments
|
34
|
+
Weibo supports adding comments to status updates. All comments for a status can be fetched in the following way.
|
35
|
+
Note that we pass the id of the status that we are intrested in
|
36
|
+
```ruby
|
37
|
+
comments = client.comments(status.id)
|
38
|
+
```
|
39
|
+
|
33
40
|
Note that all method calls made with Grizzly will always return a domain object. More often than not this domain object
|
34
41
|
is a representation of what ever JSON object has been returned by Weibo's API. In this case we get all sorts of handy
|
35
42
|
information on the status we just updated including the user that the status belongs to. So you can do...
|
@@ -98,9 +105,15 @@ end
|
|
98
105
|
### Error Handling
|
99
106
|
Grizzly has its own set of errors that it can throw. ```Grizzly::Errors::NoAccessToken``` is thrown when the client is created with out an access token. ```Grizzly::Errors::WeiboAPI``` is thrown when ever there is an error returned by an end point of the API. This will return both a message and a weibo error code. ```Grizzly::Errors::Timeout``` will be thrown when the Weibo API is taking too long to respond to a response. There currently is a five second limit on the request time of each request made by Grizzly. Note that when your using a cursor class described above this time out applies to each request the cursor makes not the total time that the cursor takes to build the results of a given GET from the api.
|
100
107
|
|
108
|
+
### Development
|
109
|
+
Please feed free to fork, develop and send pull requests. If you plan to do this then you will need a valid weibo access token. Place this token in an access_token.yml file that can be found under the spec folder. Currently this file is in the git ignore list however you can copy the same file. Once you have done this add your access token to the file and specs will pick it up.
|
110
|
+
|
101
111
|
### Pull Requests
|
102
112
|
The changes are that what you want to do with the API is not supported. Let me know if that is the case and I will add support for anything you need to do. I will also accept any pull requests with new features included. I did not intend to release this gem full supported with each end point mapped.
|
103
113
|
|
114
|
+
### Contributors
|
115
|
+
* realalien (Zhu Jia Cheng)
|
116
|
+
|
104
117
|
### License
|
105
118
|
Copyright (c) 2012 Stewart Matheson
|
106
119
|
|
data/lib/grizzly.rb
CHANGED
@@ -4,6 +4,8 @@ require 'grizzly/client'
|
|
4
4
|
require 'grizzly/cursor'
|
5
5
|
require 'grizzly/status'
|
6
6
|
require 'grizzly/user'
|
7
|
+
require 'grizzly/comment'
|
7
8
|
require 'grizzly/errors/no_access_token'
|
8
9
|
require 'grizzly/errors/weibo_api'
|
9
10
|
require 'grizzly/errors/timeout'
|
11
|
+
require 'grizzly/errors/arguement'
|
data/lib/grizzly/client.rb
CHANGED
@@ -14,9 +14,17 @@ module Grizzly
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def status_update(status)
|
17
|
-
|
17
|
+
if status.nil?
|
18
|
+
e = Grizzly::Errors::Arguement.new
|
19
|
+
e.add_error({ :status => "You must set a status" })
|
20
|
+
raise e
|
21
|
+
end
|
18
22
|
request = Grizzly::Request.new(:post, "/statuses/update", { :access_token => @access_token }, { :status => status } )
|
19
23
|
Grizzly::Status.new request.response
|
20
24
|
end
|
25
|
+
|
26
|
+
def comments(status_id)
|
27
|
+
Grizzly::Cursor.new(Grizzly::Comment, "/comments/show", {:access_token => @access_token, :id => status_id})
|
28
|
+
end
|
21
29
|
end
|
22
30
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Grizzly
|
2
|
+
module Errors
|
3
|
+
class Arguement < StandardError
|
4
|
+
def initialize
|
5
|
+
@errors = []
|
6
|
+
end
|
7
|
+
|
8
|
+
def to_s
|
9
|
+
"End point has been called with the incorrect parameters" << @errors.join(", ")
|
10
|
+
end
|
11
|
+
|
12
|
+
def add_error error
|
13
|
+
@errors << error
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/grizzly/status.rb
CHANGED
data/lib/grizzly/user.rb
CHANGED
data/lib/grizzly/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grizzly-weibo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -101,7 +101,9 @@ extra_rdoc_files: []
|
|
101
101
|
files:
|
102
102
|
- lib/grizzly/base.rb
|
103
103
|
- lib/grizzly/client.rb
|
104
|
+
- lib/grizzly/comment.rb
|
104
105
|
- lib/grizzly/cursor.rb
|
106
|
+
- lib/grizzly/errors/arguement.rb
|
105
107
|
- lib/grizzly/errors/no_access_token.rb
|
106
108
|
- lib/grizzly/errors/timeout.rb
|
107
109
|
- lib/grizzly/errors/weibo_api.rb
|
@@ -126,7 +128,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
126
128
|
version: '0'
|
127
129
|
segments:
|
128
130
|
- 0
|
129
|
-
hash:
|
131
|
+
hash: -687538747363796953
|
130
132
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
133
|
none: false
|
132
134
|
requirements:
|
@@ -135,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
137
|
version: '0'
|
136
138
|
requirements: []
|
137
139
|
rubyforge_project:
|
138
|
-
rubygems_version: 1.8.
|
140
|
+
rubygems_version: 1.8.24
|
139
141
|
signing_key:
|
140
142
|
specification_version: 3
|
141
143
|
summary: An api wrapper for Weibo V2
|