plurky 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ef8f40f7f9ca48b65f13082ea8f60eac0bff4f2f
4
- data.tar.gz: 1a9bc7e527e2d793c3a73ee3223cd8363e16a8c0
3
+ metadata.gz: 1e3653b3e77fb39e242f9acdd7ab436e0c1d5145
4
+ data.tar.gz: 770c3bc16d9eec76592317d6f0483bc1d7b5ac9e
5
5
  SHA512:
6
- metadata.gz: 6aa1a8ca92439966215e2814baa6243ae932701c51546a8856893048b4656fa4c303ae3309e24e42701778b285196b07ac75fb84cb63fad47cd8d1a23bb42077
7
- data.tar.gz: 4233c96b0e1bc085fafd148e9000d96f152deccc5bdcfeb4f84c5e35c04fb4e192a70887797e186a02d354e8388f81523044c1f40cded60abde4a39a03705833
6
+ metadata.gz: 3144972a478ce0bed3c6464ca5276d4ee74e1e4cee5d370fe42d1c06eb09e824a2a5424195b7cfd3a36ee5d16168d7e621ac5c213e0fc837d231b6eaec04f0ce
7
+ data.tar.gz: 00a813bcbbbd046bcf531bef4bcfc52141d77d3634fd2622b8deb7d92b5fa50d22b2583363f4ed86e92b8ea755f2488fddc7e61c89c68b39691db9404c206d1a
data/.rspec CHANGED
@@ -1,3 +1,4 @@
1
1
  --color
2
+ --fail-fast
2
3
  --order random
3
4
  --format doc
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012 Chun-wei Kuo
1
+ Copyright (c) 2012 - 2013 Chun-wei Kuo
2
2
 
3
3
  MIT License
4
4
 
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
19
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
20
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
21
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -33,7 +33,7 @@ Or install it yourself as:
33
33
  * This gem: http://rdoc.info/gems/plurky
34
34
  * Plurk API 2.0: http://www.plurk.com/API
35
35
 
36
- ## Usage
36
+ ## Examples
37
37
 
38
38
  ```ruby
39
39
  require 'plurky'
@@ -70,11 +70,21 @@ After configuration, requests can be made like so:
70
70
  Plurky.get '/APP/Timeline/getPlurks'
71
71
  ```
72
72
 
73
+ ## Implemented APIs
74
+
75
+ * status
76
+
77
+ ## The access token
78
+
79
+ Plurky will not support obtaining access token.
80
+ You can get it from the [test console][].
81
+
82
+ [test console]: http://www.plurk.com/OAuth/test
83
+
73
84
  ## TODO
74
85
 
75
- * Complete the tests.
86
+ * Improve test coverage.
76
87
  * Add APIs.
77
- * Add support of obtaining access token.
78
88
 
79
89
  ## Credits
80
90
 
@@ -84,7 +94,7 @@ Most of the code are copy-pasted from the [twitter][] gem.
84
94
 
85
95
  ## Copyright
86
96
 
87
- Copyright (c) 2013 Chun-wei Kuo. See [LICENSE][] for details.
97
+ Copyright (c) 2012 - 2013 Chun-wei Kuo. See [LICENSE][] for details.
88
98
 
89
99
  [license]: https://github.com/Domon/plurky/blob/master/LICENSE.md
90
100
 
@@ -0,0 +1,7 @@
1
+ require 'plurky/api/timeline'
2
+
3
+ module Plurky
4
+ module API
5
+ include Plurky::API::Timeline
6
+ end
7
+ end
@@ -0,0 +1,27 @@
1
+ module Plurky
2
+ module API
3
+ module Timeline
4
+ # Returns a status
5
+ #
6
+ # @see http://www.plurk.com/API#/APP/Timeline/getPlurk
7
+ # @return [Hashie::Mash] The requested status.
8
+ # @param id [Integer] A status ID.
9
+ # @example Return the status with the ID 1001647781
10
+ # Plurky.status(1001647781)
11
+ def status(id)
12
+ object_from_response(:get, "/APP/Timeline/getPlurk", { :plurk_id => id }).plurk
13
+ end
14
+
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]
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,10 +1,13 @@
1
1
  require 'faraday'
2
2
  require 'simple_oauth'
3
3
  require 'uri'
4
+ require 'plurky/api'
4
5
  require 'plurky/configurable'
5
6
 
6
7
  module Plurky
8
+ # Wrapper for the Plurk API 2.0
7
9
  class Client
10
+ include Plurky::API
8
11
  include Plurky::Configurable
9
12
 
10
13
  # Initializes a new Client object
File without changes
@@ -1,3 +1,3 @@
1
1
  module Plurky
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -23,7 +23,7 @@ Gem::Specification.new do |gem|
23
23
  gem.add_dependency 'hashie', '~> 2.0.5'
24
24
 
25
25
  gem.add_development_dependency 'rake'
26
- gem.add_development_dependency 'rspec'
26
+ gem.add_development_dependency 'rspec', '~> 2.14.0.rc1'
27
27
  gem.add_development_dependency 'webmock'
28
28
  gem.add_development_dependency 'pry-nav'
29
29
  gem.add_development_dependency 'coveralls'
@@ -0,0 +1 @@
1
+ {"plurk_users": {"1": {"verified_account": false, "default_lang": "en", "display_name": "amix", "dateformat": 0, "nick_name": "amix", "has_profile_image": 1, "location": "", "bday_privacy": 2, "date_of_birth": "Mon, 13 May 1985 00:01:00 GMT", "karma": 69.6, "full_name": "Amir Salihefendic", "gender": 1, "name_color": "0A9C17", "timezone": "Europe\/Amsterdam", "id": 1, "avatar": 34}}, "user": {"verified_account": false, "default_lang": "en", "display_name": "amix", "dateformat": 0, "nick_name": "amix", "has_profile_image": 1, "location": "", "bday_privacy": 2, "date_of_birth": "Mon, 13 May 1985 00:01:00 GMT", "karma": 69.6, "full_name": "Amir Salihefendic", "gender": 1, "name_color": "0A9C17", "timezone": "Europe\/Amsterdam", "id": 1, "avatar": 34}, "plurk": {"replurkers_count": 4, "replurkable": true, "favorite_count": 6, "is_unread": 0, "favorers": [24228, 89434, 3184175, 3633219, 5386772, 6693159], "user_id": 1, "plurk_type": 0, "replurked": false, "content": "<a href=\"http:\/\/ridiculousfish.com\/shell\/index.html\" class=\"ex_link\" rel=\"nofollow\">Finally, a command line shell for the 90s<\/a> <img class=\"emoticon_my\" src=\"http:\/\/emos.plurk.com\/b6ebb0a088fa352ee03ed6f760fb319d_w16_h16.png\" width=\"16\" height=\"16\" \/>", "replurker_id": null, "owner_id": 1, "responses_seen": 0, "qualifier": "likes", "plurk_id": 1001647781, "response_count": 8, "limited_to": null, "no_comments": 0, "posted": "Wed, 06 Jun 2012 12:37:42 GMT", "lang": "en", "content_raw": "http:\/\/ridiculousfish.com\/shell\/index.html (Finally, a command line shell for the 90s) http:\/\/emos.plurk.com\/b6ebb0a088fa352ee03ed6f760fb319d_w16_h16.png", "replurkers": [23118, 3184175, 4853404, 6649986], "favorite": true}}
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe Plurky::API::Timeline do
4
+ subject(:client) { Plurky::Client.new }
5
+
6
+ describe "#status" do
7
+ before do
8
+ stub_get("/APP/Timeline/getPlurk", :plurk_id => 1001647781).
9
+ to_return(json_response("status.json"))
10
+ end
11
+
12
+ it "requests the correct resource" do
13
+ client.status(1001647781)
14
+ expect(a_get("/APP/Timeline/getPlurk", :plurk_id => 1001647781)).to have_been_made
15
+ end
16
+
17
+ it "returns a correct Hashie::Mash" do
18
+ status = client.status(1001647781)
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"
21
+ end
22
+ end
23
+
24
+ end
@@ -10,7 +10,7 @@ describe Plurky::Client do
10
10
  }
11
11
  end
12
12
 
13
- subject { Plurky::Client.new(configuration) }
13
+ subject(:client) { Plurky::Client.new(configuration) }
14
14
 
15
15
  context "with module configuration" do
16
16
  before do
@@ -26,9 +26,9 @@ describe Plurky::Client do
26
26
  end
27
27
 
28
28
  it "inherits the module configuration" do
29
- client = Plurky.client
29
+ cached_client = Plurky.client
30
30
  configuration.each do |key, value|
31
- client.instance_variable_get(:"@#{key}").should == value
31
+ expect(cached_client.instance_variable_get(:"@#{key}")).to eq value
32
32
  end
33
33
  end
34
34
 
@@ -37,9 +37,9 @@ describe Plurky::Client do
37
37
  let(:different_configuration) { configuration.update :oauth_token_secret => 'OS' }
38
38
 
39
39
  it "overrides the module configuration" do
40
- client = Plurky::Client.new(different_configuration)
40
+ different_client = Plurky::Client.new(different_configuration)
41
41
  different_configuration.each do |key, value|
42
- client.instance_variable_get(:"@#{key}").should == value
42
+ expect(different_client.instance_variable_get(:"@#{key}")).to eq value
43
43
  end
44
44
  end
45
45
 
@@ -48,12 +48,13 @@ describe Plurky::Client do
48
48
 
49
49
  describe "#credentials?" do
50
50
  it "returns true if all credentials are present" do
51
- client = Plurky::Client.new(configuration)
52
- client.credentials?.should be_true
51
+ client_with_all_credentials = Plurky::Client.new(configuration)
52
+ expect(client_with_all_credentials.credentials?).to be_true
53
53
  end
54
54
  it "returns false if any credentials are missing" do
55
- client = Plurky::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :oauth_token => 'OT')
56
- client.credentials?.should be_false
55
+ client_with_missing_credentials =
56
+ Plurky::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :oauth_token => 'OT')
57
+ expect(client_with_missing_credentials.credentials?).to be_false
57
58
  end
58
59
  end
59
60
 
@@ -62,8 +63,8 @@ describe Plurky::Client do
62
63
  let(:params) { { :user => 34 } }
63
64
 
64
65
  it "knows how to make get request" do
65
- subject.should_receive(:request).with(:get, path, params)
66
- subject.get path, params
66
+ expect(client).to receive(:request).with(:get, path, params)
67
+ client.get path, params
67
68
  end
68
69
  end
69
70
 
@@ -72,14 +73,14 @@ describe Plurky::Client do
72
73
  let(:params) { { :image => "" } }
73
74
 
74
75
  it "knows how to make post request" do
75
- subject.should_receive(:request).with(:post, path, params)
76
- subject.post path, params
76
+ expect(client).to receive(:request).with(:post, path, params)
77
+ client.post path, params
77
78
  end
78
79
  end
79
80
 
80
81
  describe "#connection" do
81
82
  it "looks like Faraday connection" do
82
- subject.send(:connection).should respond_to(:run_request)
83
+ expect(client.send(:connection)).to respond_to(:run_request)
83
84
  end
84
85
  end
85
86
 
@@ -89,13 +90,13 @@ describe Plurky::Client do
89
90
  describe "#auth_header" do
90
91
  it "creates the correct auth headers" do
91
92
  uri = URI("http://www.plurk.com/APP/Profile/getPublicProfile")
92
- authorization = subject.send(:auth_header, :get, uri, { :user_id => 34 })
93
- authorization.options[:signature_method].should == "HMAC-SHA1"
94
- authorization.options[:version].should == "1.0"
95
- authorization.options[:consumer_key].should == "CK"
96
- authorization.options[:consumer_secret].should == "CS"
97
- authorization.options[:token].should == "OT"
98
- authorization.options[:token_secret].should == "OTS"
93
+ authorization = client.send(:auth_header, :get, uri, { :user_id => 34 })
94
+ expect(authorization.options[:signature_method]).to eq "HMAC-SHA1"
95
+ expect(authorization.options[:version]).to eq "1.0"
96
+ expect(authorization.options[:consumer_key]).to eq "CK"
97
+ expect(authorization.options[:consumer_secret]).to eq "CS"
98
+ expect(authorization.options[:token]).to eq "OT"
99
+ expect(authorization.options[:token_secret]).to eq "OTS"
99
100
  end
100
101
  end
101
102
 
@@ -4,12 +4,12 @@ describe Plurky do
4
4
 
5
5
  describe ".client" do
6
6
  it "returns a Plurky::Client" do
7
- Plurky.client.should be_a Plurky::Client
7
+ expect(Plurky.client).to be_a Plurky::Client
8
8
  end
9
9
 
10
10
  context "when the options don't change" do
11
11
  it "caches the client" do
12
- Plurky.client.should == Plurky.client
12
+ expect(Plurky.client).to eq Plurky.client
13
13
  end
14
14
  end
15
15
 
@@ -21,15 +21,18 @@ describe Plurky do
21
21
  config.consumer_secret = 'CS'
22
22
  end
23
23
  client2 = Plurky.client
24
- client1.should_not == client2
24
+ expect(client1).not_to eq client2
25
25
  end
26
26
  end
27
27
  end
28
28
 
29
29
  describe ".respond_to?" do
30
30
  it "delegates to Plurky::Client" do
31
- Plurky.should respond_to :get
31
+ expect(Plurky).to respond_to :get
32
32
  end
33
33
  end
34
34
 
35
+ describe ".configure" do
36
+ end
37
+
35
38
  end
@@ -6,4 +6,41 @@ require 'webmock/rspec'
6
6
  require 'plurky'
7
7
 
8
8
  RSpec.configure do |config|
9
+ config.expect_with :rspec do |c|
10
+ # Enable only the `expect` syntax
11
+ c.syntax = :expect
12
+ end
13
+ end
14
+
15
+ def plurk_url(path)
16
+ URI.join(Plurky::Default::ENDPOINT, path).to_s
17
+ end
18
+
19
+ def a_get(path, query = {})
20
+ a_request(:get, plurk_url(path)).with(:query => query)
21
+ end
22
+
23
+ def stub_get(path, query = {})
24
+ stub_request(:get, plurk_url(path)).with(:query => query)
25
+ end
26
+
27
+ def fixtures_path
28
+ File.expand_path("../fixtures", __FILE__)
29
+ end
30
+
31
+ def fixture_path(file)
32
+ File.join(fixtures_path, file)
33
+ end
34
+
35
+ def fixture(file)
36
+ File.new(fixture_path(file))
37
+ end
38
+
39
+ def json_response(file)
40
+ {
41
+ :body => fixture(file),
42
+ :headers => {
43
+ :content_type => "application/json; charset=utf-8"
44
+ }
45
+ }
9
46
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plurky
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chun-wei Kuo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-05 00:00:00.000000000 Z
11
+ date: 2013-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -84,16 +84,16 @@ dependencies:
84
84
  name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ~>
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: 2.14.0.rc1
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ~>
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: 2.14.0.rc1
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: webmock
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -151,13 +151,18 @@ files:
151
151
  - README.md
152
152
  - Rakefile
153
153
  - lib/plurky.rb
154
+ - lib/plurky/api.rb
155
+ - lib/plurky/api/timeline.rb
154
156
  - lib/plurky/client.rb
155
157
  - lib/plurky/configurable.rb
156
158
  - lib/plurky/default.rb
157
159
  - lib/plurky/response/mashify.rb
158
160
  - lib/plurky/response/parse_json.rb
161
+ - lib/plurky/status.rb
159
162
  - lib/plurky/version.rb
160
163
  - plurky.gemspec
164
+ - spec/fixtures/status.json
165
+ - spec/plurky/api/timeline_spec.rb
161
166
  - spec/plurky/client_spec.rb
162
167
  - spec/plurky_spec.rb
163
168
  - spec/spec_helper.rb
@@ -185,6 +190,8 @@ signing_key:
185
190
  specification_version: 4
186
191
  summary: Yet another Plurk API wrapper
187
192
  test_files:
193
+ - spec/fixtures/status.json
194
+ - spec/plurky/api/timeline_spec.rb
188
195
  - spec/plurky/client_spec.rb
189
196
  - spec/plurky_spec.rb
190
197
  - spec/spec_helper.rb