plurky 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +3 -0
- data/Gemfile +3 -0
- data/LICENSE.md +22 -0
- data/README.md +78 -0
- data/Rakefile +7 -0
- data/lib/plurky.rb +33 -0
- data/lib/plurky/client.rb +67 -0
- data/lib/plurky/configurable.rb +63 -0
- data/lib/plurky/default.rb +76 -0
- data/lib/plurky/response/mashify.rb +28 -0
- data/lib/plurky/response/parse_json.rb +26 -0
- data/lib/plurky/version.rb +3 -0
- data/plurky.gemspec +29 -0
- data/spec/plurky/client_spec.rb +102 -0
- data/spec/plurky_spec.rb +35 -0
- data/spec/spec_helper.rb +5 -0
- metadata +175 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 40f33d5e82d63deb9bb4439dc315cd45666c5c06
|
4
|
+
data.tar.gz: 1b59ba2b8f1305237f039756018f05e990786c97
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b73fbaa28eace153210a838aeac0fd88059ce6e1d4a54c4c2cd2d2ce55aed9d7f96baa934027bbcd47ef8419739c92da5afec5323e84c530428a661055607db3
|
7
|
+
data.tar.gz: 8fe93ebba45058ba2d52f1955192762682b404a980c186a5f39a224a40e92b3a8d545faf726680a179934b61401a9c4ee191ab20817ab8cf70bf10f80938fd79
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Chun-wei Kuo
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# Plurky
|
2
|
+
|
3
|
+
Yet another Plurk API wrapper. Or something to play when the Plurk team is busy optimizing the site.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's `Gemfile`:
|
8
|
+
|
9
|
+
gem 'plurky'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install plurky
|
18
|
+
|
19
|
+
## Documentation
|
20
|
+
|
21
|
+
* This gem: http://rdoc.info/gems/plurky
|
22
|
+
* Plurk API 2.0: http://www.plurk.com/API
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
require 'plurky'
|
28
|
+
|
29
|
+
client = Plurky.client
|
30
|
+
client.get '/APP/Profile/getPublicProfile', :user_id => 34
|
31
|
+
```
|
32
|
+
|
33
|
+
## Configuration
|
34
|
+
|
35
|
+
Applications that make requests on behalf of a single Plurk user can pass global configuration options as a block to the `Plurky.configure` method.
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
Plurky.configure do |config|
|
39
|
+
config.consumer_key = YOUR_CONSUMER_KEY
|
40
|
+
config.consumer_secret = YOUR_CONSUMER_SECRET
|
41
|
+
config.oauth_token = YOUR_OAUTH_TOKEN
|
42
|
+
config.oauth_token_secret = YOUR_OAUTH_TOKEN_SECRET
|
43
|
+
end
|
44
|
+
```
|
45
|
+
|
46
|
+
Alternately, you can set the following environment variables:
|
47
|
+
|
48
|
+
```
|
49
|
+
PLURK_CONSUMER_KEY
|
50
|
+
PLURK_CONSUMER_SECRET
|
51
|
+
PLURK_OAUTH_TOKEN
|
52
|
+
PLURK_OAUTH_TOKEN_SECRET
|
53
|
+
```
|
54
|
+
|
55
|
+
After configuration, requests can be made like so:
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
Plurky.get '/APP/Timeline/getPlurks'
|
59
|
+
```
|
60
|
+
|
61
|
+
## TODO
|
62
|
+
|
63
|
+
* Complete the tests.
|
64
|
+
* Add APIs.
|
65
|
+
* Add support of obtaining access token.
|
66
|
+
|
67
|
+
## Credits
|
68
|
+
|
69
|
+
Most of the code are copy-pasted from the [twitter][] gem.
|
70
|
+
|
71
|
+
[twitter]: https://github.com/sferik/twitter
|
72
|
+
|
73
|
+
## Copyright
|
74
|
+
|
75
|
+
Copyright (c) 2012 Chun-wei Kuo. See [LICENSE][] for details.
|
76
|
+
|
77
|
+
[license]: https://github.com/Domon/plurky/blob/master/LICENSE.md
|
78
|
+
|
data/Rakefile
ADDED
data/lib/plurky.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'plurky/client'
|
2
|
+
require 'plurky/configurable'
|
3
|
+
require 'plurky/version'
|
4
|
+
|
5
|
+
module Plurky
|
6
|
+
class << self
|
7
|
+
include Plurky::Configurable
|
8
|
+
|
9
|
+
# Delegate to a Plurky::Client
|
10
|
+
#
|
11
|
+
# @return [Plurky::Client]
|
12
|
+
def client
|
13
|
+
@client = Plurky::Client.new(options) unless defined?(@client) && @client.cache_key == options.hash
|
14
|
+
@client
|
15
|
+
end
|
16
|
+
|
17
|
+
# Delegate to Plurky::Client
|
18
|
+
#
|
19
|
+
def respond_to?(method, include_private = false)
|
20
|
+
client.respond_to?(method, include_private) || super(method, include_private)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def method_missing(method_name, *args, &block)
|
26
|
+
return super unless client.respond_to?(method_name)
|
27
|
+
client.send(method_name, *args, &block)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
Plurky.setup
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'simple_oauth'
|
3
|
+
require 'uri'
|
4
|
+
require 'plurky/configurable'
|
5
|
+
|
6
|
+
module Plurky
|
7
|
+
class Client
|
8
|
+
include Plurky::Configurable
|
9
|
+
|
10
|
+
# Initializes a new Client object
|
11
|
+
#
|
12
|
+
# @param options [Hash]
|
13
|
+
# @return [Plurky::Client]
|
14
|
+
def initialize(options = {})
|
15
|
+
Plurky::Configurable.keys.each do |key|
|
16
|
+
instance_variable_set(:"@#{key}", options[key] || Plurky.instance_variable_get(:"@#{key}"))
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# Perform an HTTP GET request
|
21
|
+
def get(path, params = {})
|
22
|
+
request(:get, path, params)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Perform an HTTP POST request
|
26
|
+
def post(path, params = {})
|
27
|
+
request(:post, path, params)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
# Returns a Faraday::Connection object
|
33
|
+
#
|
34
|
+
# @return [Faraday::Connection]
|
35
|
+
def connection
|
36
|
+
@connection ||= Faraday.new(@endpoint, @connection_options.merge(:builder => @middleware))
|
37
|
+
end
|
38
|
+
|
39
|
+
# Perform an HTTP request
|
40
|
+
def request(method, path, params = {})
|
41
|
+
request_headers = {}
|
42
|
+
if credentials?
|
43
|
+
uri = URI(@endpoint) + path
|
44
|
+
authorization = auth_header(method, uri, params)
|
45
|
+
request_headers[:authorization] = authorization.to_s
|
46
|
+
end
|
47
|
+
|
48
|
+
response = connection.run_request(method, path, nil, request_headers) do |request|
|
49
|
+
unless params.empty?
|
50
|
+
case request.method
|
51
|
+
when :post, :put
|
52
|
+
request.body = params
|
53
|
+
else
|
54
|
+
request.params.update(params)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
response.env
|
59
|
+
end
|
60
|
+
|
61
|
+
def auth_header(method, uri, params = {})
|
62
|
+
signature_params = [:post, :put].include?(method) && params.values.any? { |value| value.respond_to?(:to_io) } ? {} : params
|
63
|
+
SimpleOAuth::Header.new(method, uri, signature_params, credentials)
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'plurky/default'
|
2
|
+
|
3
|
+
module Plurky
|
4
|
+
module Configurable
|
5
|
+
attr_writer :consumer_key, :consumer_secret, :oauth_token, :oauth_token_secret
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def keys
|
9
|
+
@keys ||= [
|
10
|
+
:consumer_key,
|
11
|
+
:consumer_secret,
|
12
|
+
:oauth_token,
|
13
|
+
:oauth_token_secret,
|
14
|
+
:endpoint,
|
15
|
+
:connection_options,
|
16
|
+
:middleware
|
17
|
+
]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Allow configuration options to be set in a block
|
22
|
+
def configure
|
23
|
+
yield self
|
24
|
+
self
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [Boolean]
|
28
|
+
def credentials?
|
29
|
+
credentials.values.all?
|
30
|
+
end
|
31
|
+
|
32
|
+
# @return [Fixnum]
|
33
|
+
def cache_key
|
34
|
+
options.hash
|
35
|
+
end
|
36
|
+
|
37
|
+
def reset!
|
38
|
+
Plurky::Configurable.keys.each do |key|
|
39
|
+
instance_variable_set(:"@#{key}", Plurky::Default.options[key])
|
40
|
+
end
|
41
|
+
self
|
42
|
+
end
|
43
|
+
alias setup reset!
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
# @return [Hash]
|
48
|
+
def credentials
|
49
|
+
{
|
50
|
+
:consumer_key => @consumer_key,
|
51
|
+
:consumer_secret => @consumer_secret,
|
52
|
+
:token => @oauth_token,
|
53
|
+
:token_secret => @oauth_token_secret
|
54
|
+
}
|
55
|
+
end
|
56
|
+
|
57
|
+
# @return [Hash]
|
58
|
+
def options
|
59
|
+
Hash[Plurky::Configurable.keys.map{ |key| [key, instance_variable_get(:"@#{key}")] }]
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'plurky/configurable'
|
2
|
+
require 'plurky/response/parse_json'
|
3
|
+
require 'plurky/response/mashify'
|
4
|
+
require 'plurky/version'
|
5
|
+
|
6
|
+
module Plurky
|
7
|
+
module Default
|
8
|
+
ENDPOINT = 'http://www.plurk.com/'
|
9
|
+
|
10
|
+
CONNECTION_OPTIONS = {
|
11
|
+
:headers => {
|
12
|
+
:accept => 'application/json',
|
13
|
+
:user_agent => "Plurky Ruby Gem #{Plurky::VERSION}"
|
14
|
+
},
|
15
|
+
:open_timeout => 5,
|
16
|
+
:raw => true,
|
17
|
+
:ssl => { :verify => false },
|
18
|
+
:timeout => 10
|
19
|
+
}
|
20
|
+
|
21
|
+
MIDDLEWARE = Faraday::Builder.new(
|
22
|
+
&Proc.new do |builder|
|
23
|
+
builder.use Faraday::Request::Multipart
|
24
|
+
builder.use Faraday::Request::UrlEncoded
|
25
|
+
|
26
|
+
builder.use Plurky::Response::Mashify
|
27
|
+
builder.use Plurky::Response::ParseJson
|
28
|
+
builder.adapter Faraday.default_adapter
|
29
|
+
end
|
30
|
+
)
|
31
|
+
|
32
|
+
class << self
|
33
|
+
|
34
|
+
# @return [String]
|
35
|
+
def consumer_key
|
36
|
+
ENV['PLURK_CONSUMER_KEY']
|
37
|
+
end
|
38
|
+
|
39
|
+
# @return [String]
|
40
|
+
def consumer_secret
|
41
|
+
ENV['PLURK_CONSUMER_SECRET']
|
42
|
+
end
|
43
|
+
|
44
|
+
# @return [String]
|
45
|
+
def oauth_token
|
46
|
+
ENV['PLURK_OAUTH_TOKEN']
|
47
|
+
end
|
48
|
+
|
49
|
+
# @return [String]
|
50
|
+
def oauth_token_secret
|
51
|
+
ENV['PLURK_OAUTH_TOKEN_SECRET']
|
52
|
+
end
|
53
|
+
|
54
|
+
# @return [String]
|
55
|
+
def endpoint
|
56
|
+
ENDPOINT
|
57
|
+
end
|
58
|
+
|
59
|
+
# @return [Hash]
|
60
|
+
def connection_options
|
61
|
+
CONNECTION_OPTIONS
|
62
|
+
end
|
63
|
+
|
64
|
+
# @return [Faraday::Builder]
|
65
|
+
def middleware
|
66
|
+
MIDDLEWARE
|
67
|
+
end
|
68
|
+
|
69
|
+
# @return [Hash]
|
70
|
+
def options
|
71
|
+
Hash[Plurky::Configurable.keys.map { |key| [key, send(key)] }]
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'hashie/mash'
|
3
|
+
|
4
|
+
module Plurky
|
5
|
+
module Response
|
6
|
+
class Mashify < Faraday::Response::Middleware
|
7
|
+
|
8
|
+
def parse(body)
|
9
|
+
case body
|
10
|
+
when Hash
|
11
|
+
Hashie::Mash.new body
|
12
|
+
when Array
|
13
|
+
body.map { |item| item.is_a?(Hash) ? Hashie::Mash.new(item) : item }
|
14
|
+
else
|
15
|
+
body
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Overrides Faraday::Response::Middleware#on_complete
|
20
|
+
def on_complete(env)
|
21
|
+
unless [204, 301, 302, 304].include?(env[:status])
|
22
|
+
env[:body] = parse(env[:body])
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module Plurky
|
5
|
+
module Response
|
6
|
+
class ParseJson < Faraday::Response::Middleware
|
7
|
+
|
8
|
+
def parse(body)
|
9
|
+
case body
|
10
|
+
when /\A^\s*$\z/, nil
|
11
|
+
nil
|
12
|
+
else
|
13
|
+
MultiJson.load(body, :symbolize_keys => true)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Overrides Faraday::Response::Middleware#on_complete
|
18
|
+
def on_complete(env)
|
19
|
+
unless [204, 301, 302, 304].include?(env[:status])
|
20
|
+
env[:body] = parse(env[:body])
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/plurky.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'plurky/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "plurky"
|
8
|
+
gem.version = Plurky::VERSION
|
9
|
+
gem.authors = ["Chun-wei Kuo"]
|
10
|
+
gem.email = ["Dendoh@gmail.com"]
|
11
|
+
gem.description = %q{Yet another Plurk API wrapper}
|
12
|
+
gem.summary = %q{Yet another Plurk API wrapper}
|
13
|
+
gem.homepage = "https://github.com/Domon/plurky"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency 'faraday', '~> 0.8.4'
|
21
|
+
gem.add_dependency 'simple_oauth', '~> 0.1.9'
|
22
|
+
gem.add_dependency 'multi_json', '~> 1.3.7'
|
23
|
+
gem.add_dependency 'hashie', '~> 2.0.5'
|
24
|
+
|
25
|
+
gem.add_development_dependency 'rake'
|
26
|
+
gem.add_development_dependency 'rspec'
|
27
|
+
gem.add_development_dependency 'webmock'
|
28
|
+
gem.add_development_dependency 'pry-nav'
|
29
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Plurky::Client do
|
4
|
+
let(:configuration) do
|
5
|
+
{
|
6
|
+
:consumer_key => 'CK',
|
7
|
+
:consumer_secret => 'CS',
|
8
|
+
:oauth_token => 'OT',
|
9
|
+
:oauth_token_secret => 'OTS'
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
subject { Plurky::Client.new(configuration) }
|
14
|
+
|
15
|
+
context "with module configuration" do
|
16
|
+
before do
|
17
|
+
Plurky.configure do |config|
|
18
|
+
configuration.each do |key, value|
|
19
|
+
config.send("#{key}=", value)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
after do
|
25
|
+
Plurky.reset!
|
26
|
+
end
|
27
|
+
|
28
|
+
it "inherits the module configuration" do
|
29
|
+
client = Plurky.client
|
30
|
+
configuration.each do |key, value|
|
31
|
+
client.instance_variable_get(:"@#{key}").should == value
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "with class configuration" do
|
36
|
+
|
37
|
+
let(:different_configuration) { configuration.update :oauth_token_secret => 'OS' }
|
38
|
+
|
39
|
+
it "overrides the module configuration" do
|
40
|
+
client = Plurky::Client.new(different_configuration)
|
41
|
+
different_configuration.each do |key, value|
|
42
|
+
client.instance_variable_get(:"@#{key}").should == value
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#credentials?" do
|
50
|
+
it "returns true if all credentials are present" do
|
51
|
+
client = Plurky::Client.new(configuration)
|
52
|
+
client.credentials?.should be_true
|
53
|
+
end
|
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
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "#get" do
|
61
|
+
let(:path) { '/APP/Profile/getPublicProfile' }
|
62
|
+
let(:params) { { :user => 34 } }
|
63
|
+
|
64
|
+
it "knows how to make get request" do
|
65
|
+
subject.should_receive(:request).with(:get, path, params)
|
66
|
+
subject.get path, params
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "#post" do
|
71
|
+
let(:path) { '/APP/Timeline/uploadPicture' }
|
72
|
+
let(:params) { { :image => "" } }
|
73
|
+
|
74
|
+
it "knows how to make post request" do
|
75
|
+
subject.should_receive(:request).with(:post, path, params)
|
76
|
+
subject.post path, params
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "#connection" do
|
81
|
+
it "looks like Faraday connection" do
|
82
|
+
subject.send(:connection).should respond_to(:run_request)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "#request" do
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "#auth_header" do
|
90
|
+
it "creates the correct auth headers" do
|
91
|
+
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"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
data/spec/plurky_spec.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Plurky do
|
4
|
+
|
5
|
+
describe ".client" do
|
6
|
+
it "returns a Plurky::Client" do
|
7
|
+
Plurky.client.should be_a Plurky::Client
|
8
|
+
end
|
9
|
+
|
10
|
+
context "when the options don't change" do
|
11
|
+
it "caches the client" do
|
12
|
+
Plurky.client.should == Plurky.client
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context "when the options change" do
|
17
|
+
it "creates a new client" do
|
18
|
+
client1 = Plurky.client
|
19
|
+
Plurky.configure do |config|
|
20
|
+
config.consumer_key = 'CK'
|
21
|
+
config.consumer_secret = 'CS'
|
22
|
+
end
|
23
|
+
client2 = Plurky.client
|
24
|
+
client1.should_not == client2
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe ".respond_to?" do
|
30
|
+
it "delegates to Plurky::Client" do
|
31
|
+
Plurky.should respond_to :get
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,175 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: plurky
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chun-wei Kuo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-06-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.8.4
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.8.4
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: simple_oauth
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.1.9
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.1.9
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: multi_json
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.3.7
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.3.7
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: hashie
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.0.5
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.0.5
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: webmock
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry-nav
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: Yet another Plurk API wrapper
|
126
|
+
email:
|
127
|
+
- Dendoh@gmail.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- .gitignore
|
133
|
+
- .rspec
|
134
|
+
- Gemfile
|
135
|
+
- LICENSE.md
|
136
|
+
- README.md
|
137
|
+
- Rakefile
|
138
|
+
- lib/plurky.rb
|
139
|
+
- lib/plurky/client.rb
|
140
|
+
- lib/plurky/configurable.rb
|
141
|
+
- lib/plurky/default.rb
|
142
|
+
- lib/plurky/response/mashify.rb
|
143
|
+
- lib/plurky/response/parse_json.rb
|
144
|
+
- lib/plurky/version.rb
|
145
|
+
- plurky.gemspec
|
146
|
+
- spec/plurky/client_spec.rb
|
147
|
+
- spec/plurky_spec.rb
|
148
|
+
- spec/spec_helper.rb
|
149
|
+
homepage: https://github.com/Domon/plurky
|
150
|
+
licenses: []
|
151
|
+
metadata: {}
|
152
|
+
post_install_message:
|
153
|
+
rdoc_options: []
|
154
|
+
require_paths:
|
155
|
+
- lib
|
156
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - '>='
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
requirements: []
|
167
|
+
rubyforge_project:
|
168
|
+
rubygems_version: 2.0.3
|
169
|
+
signing_key:
|
170
|
+
specification_version: 4
|
171
|
+
summary: Yet another Plurk API wrapper
|
172
|
+
test_files:
|
173
|
+
- spec/plurky/client_spec.rb
|
174
|
+
- spec/plurky_spec.rb
|
175
|
+
- spec/spec_helper.rb
|