plurky 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e3653b3e77fb39e242f9acdd7ab436e0c1d5145
4
- data.tar.gz: 770c3bc16d9eec76592317d6f0483bc1d7b5ac9e
3
+ metadata.gz: affb4e7ec7a48a10738ad091a74854036152f2c1
4
+ data.tar.gz: da49cd20f548798bad06215c03233d2a02263471
5
5
  SHA512:
6
- metadata.gz: 3144972a478ce0bed3c6464ca5276d4ee74e1e4cee5d370fe42d1c06eb09e824a2a5424195b7cfd3a36ee5d16168d7e621ac5c213e0fc837d231b6eaec04f0ce
7
- data.tar.gz: 00a813bcbbbd046bcf531bef4bcfc52141d77d3634fd2622b8deb7d92b5fa50d22b2583363f4ed86e92b8ea755f2488fddc7e61c89c68b39691db9404c206d1a
6
+ metadata.gz: 07365e2b2057b6e5bf220d8a62ff1db54456eca470732f881a02cdc4cb485b9daff18242157a76216148e26ccbfbc2ffde5157aecdd0511ec058fcabd25fbf4c
7
+ data.tar.gz: fee12dc511e6387c2e154b626b694f42ac80b35638911c24d5ce69d0478332c7c5eb2f796a4419398d80a054e0f1fe1f37041b4a50f65fec678ec4b714f089dc
data/README.md CHANGED
@@ -85,6 +85,8 @@ You can get it from the [test console][].
85
85
 
86
86
  * Improve test coverage.
87
87
  * Add APIs.
88
+ * Catch errors from Plurk.
89
+ * APIs should return consistent data. (e.g. status & update.)
88
90
 
89
91
  ## Credits
90
92
 
@@ -6,21 +6,24 @@ module Plurky
6
6
  # @see http://www.plurk.com/API#/APP/Timeline/getPlurk
7
7
  # @return [Hashie::Mash] The requested status.
8
8
  # @param id [Integer] A status ID.
9
+ # @param options [Hash] A customizable set of options.
9
10
  # @example Return the status with the ID 1001647781
10
11
  # Plurky.status(1001647781)
11
- def status(id)
12
- object_from_response(:get, "/APP/Timeline/getPlurk", { :plurk_id => id }).plurk
12
+ def status(id, options = {})
13
+ get("/APP/Timeline/getPlurk", options.merge(:plurk_id => id))
13
14
  end
14
15
 
15
- private
16
-
17
- # @param method [Symbol]
18
- # @param url [String]
19
- # @param params [Hash]
20
- # @return [Hashie::Mash]
21
- def object_from_response(method, url, params = {})
22
- response = send(method, url, params)
23
- response[:body]
16
+ # Updates the authenticating user's status
17
+ #
18
+ # @see http://www.plurk.com/API#/APP/Timeline/plurkAdd
19
+ # @return [Hashie::Mash] The created status.
20
+ # @param content [String] The content of the status update, up to 140 characters.
21
+ # @param qualifier [String] The qualifier of the status update.
22
+ # @param options [Hash] A customizable set of options.
23
+ # @example Update the authenticating user's status
24
+ # Plurky.update("I'm plurking with Plurky!", "says")
25
+ def update(content, qualifier, options = {})
26
+ post("/APP/Timeline/plurkAdd", options.merge(:content => content, :qualifier => qualifier))
24
27
  end
25
28
  end
26
29
  end
@@ -58,7 +58,7 @@ module Plurky
58
58
  end
59
59
  end
60
60
  end
61
- response.env
61
+ response.body
62
62
  end
63
63
 
64
64
  def auth_header(method, uri, params = {})
@@ -1,3 +1,3 @@
1
1
  module Plurky
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -0,0 +1 @@
1
+ {"replurkers": [], "responses_seen": 0, "qualifier": "says", "replurkers_count": 0, "plurk_id": 1132701414, "response_count": 0, "anonymous": false, "replurkable": true, "limited_to": null, "favorite_count": 0, "is_unread": 0, "lang": "en", "favorers": [], "content_raw": "I'm plurking with Plurky!", "user_id": 5621917, "plurk_type": 0, "replurked": false, "favorite": false, "no_comments": 0, "content": "I'm plurking with Plurky!", "replurker_id": null, "posted": "Sun, 09 Jun 2013 14:37:02 GMT", "owner_id": 5621917}
@@ -17,7 +17,25 @@ describe Plurky::API::Timeline do
17
17
  it "returns a correct Hashie::Mash" do
18
18
  status = client.status(1001647781)
19
19
  expect(status).to be_a Hashie::Mash
20
- expect(status.content_raw).to eq "http://ridiculousfish.com/shell/index.html (Finally, a command line shell for the 90s) http://emos.plurk.com/b6ebb0a088fa352ee03ed6f760fb319d_w16_h16.png"
20
+ expect(status.plurk.content_raw).to eq "http://ridiculousfish.com/shell/index.html (Finally, a command line shell for the 90s) http://emos.plurk.com/b6ebb0a088fa352ee03ed6f760fb319d_w16_h16.png"
21
+ end
22
+ end
23
+
24
+ describe "#update" do
25
+ before do
26
+ stub_post("/APP/Timeline/plurkAdd", :content => "I'm plurking with Plurky!", :qualifier => "says").
27
+ to_return(json_response("update.json"))
28
+ end
29
+
30
+ it "requests the correct resource" do
31
+ client.update("I'm plurking with Plurky!", "says")
32
+ expect(a_post("/APP/Timeline/plurkAdd", :content => "I'm plurking with Plurky!", :qualifier => "says")).to have_been_made
33
+ end
34
+
35
+ it "returns a correct Hashie::Mash" do
36
+ status = client.update("I'm plurking with Plurky!", "says")
37
+ expect(status).to be_a Hashie::Mash
38
+ expect(status.content_raw).to eq "I'm plurking with Plurky!"
21
39
  end
22
40
  end
23
41
 
@@ -20,10 +20,18 @@ def a_get(path, query = {})
20
20
  a_request(:get, plurk_url(path)).with(:query => query)
21
21
  end
22
22
 
23
+ def a_post(path, data = {})
24
+ a_request(:post, plurk_url(path)).with(:body => data)
25
+ end
26
+
23
27
  def stub_get(path, query = {})
24
28
  stub_request(:get, plurk_url(path)).with(:query => query)
25
29
  end
26
30
 
31
+ def stub_post(path, data = {})
32
+ stub_request(:post, plurk_url(path)).with(:body => data)
33
+ end
34
+
27
35
  def fixtures_path
28
36
  File.expand_path("../fixtures", __FILE__)
29
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plurky
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chun-wei Kuo
@@ -162,6 +162,7 @@ files:
162
162
  - lib/plurky/version.rb
163
163
  - plurky.gemspec
164
164
  - spec/fixtures/status.json
165
+ - spec/fixtures/update.json
165
166
  - spec/plurky/api/timeline_spec.rb
166
167
  - spec/plurky/client_spec.rb
167
168
  - spec/plurky_spec.rb
@@ -191,6 +192,7 @@ specification_version: 4
191
192
  summary: Yet another Plurk API wrapper
192
193
  test_files:
193
194
  - spec/fixtures/status.json
195
+ - spec/fixtures/update.json
194
196
  - spec/plurky/api/timeline_spec.rb
195
197
  - spec/plurky/client_spec.rb
196
198
  - spec/plurky_spec.rb