pingboard 0.0.2 → 0.0.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 +4 -4
- data/README.md +18 -5
- data/lib/pingboard.rb +1 -0
- data/lib/pingboard/client.rb +15 -26
- data/lib/pingboard/request.rb +26 -0
- data/pingboard.gemspec +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e5f27fc777527c0f7a8bfb570aeafb4708a803c
|
4
|
+
data.tar.gz: a6d920da6bd600680a5794c8aea08933d4d099bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ed9b1ef5f2b240a6749ac3c39879c85cf326fc6c05e2895d2c54642153bac483701992934c976e597a3b51870f14c79f39e186d13f7f2d2f55577985b2c7a06
|
7
|
+
data.tar.gz: 61d4467adeeeb0db6315767ec84bc8bd9378e3f29ae135fdc145d82ce33288e6b014579bf248d8de7a8f3a32eff7fa4f7bbe4ef7ed688994b5f5f62021ef5561
|
data/README.md
CHANGED
@@ -2,21 +2,34 @@
|
|
2
2
|
|
3
3
|
[](https://rubygems.org/gems/pingboard)
|
4
4
|
[](https://travis-ci.org/bry/pingboard)
|
5
|
+
[](https://codeclimate.com/github/bry/pingboard)
|
6
|
+
[](https://inch-ci.org/github/bry/pingboard)
|
7
|
+
[](https://beerpay.io/bry/pingboard)
|
8
|
+
[](https://rubygems.org/gems/pingboard)
|
5
9
|
|
6
|
-
The Ruby interface to the Pingboard API
|
10
|
+
The Ruby client interface to the [Pingboard](https://pingboard.com/) [API](http://docs.pingboard.apiary.io/)
|
7
11
|
|
8
12
|
## Installation
|
9
13
|
|
14
|
+
### Install
|
10
15
|
```
|
11
16
|
gem install pingboard
|
12
17
|
```
|
13
18
|
|
19
|
+
### Gemfile
|
20
|
+
```
|
21
|
+
gem 'pingboard', '~> 0.0.3'
|
22
|
+
```
|
23
|
+
|
24
|
+
## Documentation
|
25
|
+
http://www.rubydoc.info/gems/pingboard
|
26
|
+
|
14
27
|
## Configuration
|
15
28
|
|
16
29
|
```ruby
|
17
30
|
client = Pingboard::Client.new do |config|
|
18
|
-
config.service_app_id = '
|
19
|
-
config.service_app_secret = '
|
31
|
+
config.service_app_id = 'SERVICE_APP_ID'
|
32
|
+
config.service_app_secret = 'SERVICE_APP_SECRET'
|
20
33
|
end
|
21
34
|
```
|
22
35
|
|
@@ -57,7 +70,7 @@ client.status_types
|
|
57
70
|
```
|
58
71
|
|
59
72
|
## Supported Ruby Versions
|
60
|
-
This library is [tested
|
73
|
+
This library is [tested](https://travis-ci.org/bry/pingboard) against the following Ruby versions:
|
61
74
|
|
62
75
|
* Ruby 2.0.0
|
63
76
|
* Ruby 2.1
|
@@ -66,7 +79,7 @@ This library is [tested against](travis) the following Ruby versions:
|
|
66
79
|
* Ruby 2.4.0
|
67
80
|
|
68
81
|
## Versioning
|
69
|
-
This library uses [Semantic Versioning 2.0.0](semver)
|
82
|
+
This library uses [Semantic Versioning 2.0.0](http://semver.org/)
|
70
83
|
|
71
84
|
## License
|
72
85
|
MIT License
|
data/lib/pingboard.rb
CHANGED
data/lib/pingboard/client.rb
CHANGED
@@ -12,42 +12,47 @@ module Pingboard
|
|
12
12
|
attr_accessor :connection, :service_app_id, :service_app_secret,
|
13
13
|
:access_token, :token_expires_in, :token_expiration_time
|
14
14
|
|
15
|
-
def initialize(options={})
|
15
|
+
def initialize(request=Pingboard::Request, options={})
|
16
16
|
options.each do |key, value|
|
17
17
|
instance_variable_set("@#{key}", value)
|
18
18
|
end
|
19
19
|
yield(self) if block_given?
|
20
20
|
@token_expiration_time = Time.now
|
21
|
+
@request = request
|
21
22
|
end
|
22
23
|
|
23
24
|
def search(query, options={})
|
24
|
-
options.merge(q: query)
|
25
|
-
|
25
|
+
options.merge!(q: query)
|
26
|
+
@request.new(self, :get, URL_API_VERSION_PATH + URL_SEARCH_USERS_PATH, options).do
|
26
27
|
end
|
27
28
|
|
28
29
|
def users(options={})
|
29
|
-
|
30
|
+
@request.new(self, :get, URL_API_VERSION_PATH + URL_USERS_PATH, options).do
|
30
31
|
end
|
31
32
|
|
32
33
|
def user(user_id, options={})
|
33
|
-
|
34
|
+
@request.new(self, :get, URL_API_VERSION_PATH + URL_USERS_PATH + "/#{user_id}", options).do
|
34
35
|
end
|
35
36
|
|
36
37
|
def status(status_id, options={})
|
37
|
-
|
38
|
+
@request.new(self, :get, URL_API_VERSION_PATH + URL_STATUSES_PATH + "/#{status_id}", options).do
|
38
39
|
end
|
39
40
|
|
40
41
|
def status_types
|
41
|
-
|
42
|
+
@request.new(self, :get, URL_API_VERSION_PATH + URL_STATUS_TYPES_PATH).do
|
42
43
|
end
|
43
44
|
|
44
|
-
|
45
|
-
private
|
46
|
-
|
47
45
|
def connection
|
48
46
|
@connection = Faraday.new(url: URL_HOSTNAME)
|
49
47
|
end
|
50
48
|
|
49
|
+
def access_token
|
50
|
+
@access_token = new_access_token if access_token_expired?
|
51
|
+
@access_token
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
51
56
|
def access_token_expired?
|
52
57
|
Time.now > token_expiration_time
|
53
58
|
end
|
@@ -59,11 +64,6 @@ module Pingboard
|
|
59
64
|
response_body['access_token']
|
60
65
|
end
|
61
66
|
|
62
|
-
def access_token
|
63
|
-
@access_token = new_access_token if access_token_expired?
|
64
|
-
@access_token
|
65
|
-
end
|
66
|
-
|
67
67
|
def access_token_request
|
68
68
|
@access_token_request = connection.post do |req|
|
69
69
|
req.url URL_OAUTH_TOKEN_PATH
|
@@ -75,16 +75,5 @@ module Pingboard
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
-
def perform_get_request(url_path, options={})
|
79
|
-
pingboard_response = connection.get do |req|
|
80
|
-
req.url "#{url_path}"
|
81
|
-
req.headers['Authorization'] = "Bearer #{access_token}"
|
82
|
-
options.each do |key, value|
|
83
|
-
req.params["#{key}"] = value
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
JSON.parse(pingboard_response.body)
|
88
|
-
end
|
89
78
|
end
|
90
79
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Pingboard
|
2
|
+
class Request
|
3
|
+
|
4
|
+
attr_accessor :client, :path, :http_verb
|
5
|
+
|
6
|
+
def initialize(client, http_verb, path, options={})
|
7
|
+
@client = client
|
8
|
+
@http_verb = http_verb
|
9
|
+
@path = path
|
10
|
+
@options = options
|
11
|
+
end
|
12
|
+
|
13
|
+
def do
|
14
|
+
response = @client.connection.public_send(@http_verb) do |req|
|
15
|
+
req.url "#{@path}"
|
16
|
+
req.headers['Authorization'] = "Bearer #{@client.access_token}"
|
17
|
+
@options.each do |key, value|
|
18
|
+
req.params["#{key}"] = value
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
JSON.parse(response.body)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
data/pingboard.gemspec
CHANGED
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = 'pingboard'
|
6
|
-
s.version = '0.0.
|
6
|
+
s.version = '0.0.3'
|
7
7
|
s.date = '2017-07-16'
|
8
8
|
s.summary = "The Pingboard API Ruby Client"
|
9
9
|
s.description = "A Ruby client interface for the Pingboard API"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pingboard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan B. Cabalo
|
@@ -19,6 +19,7 @@ files:
|
|
19
19
|
- README.md
|
20
20
|
- lib/pingboard.rb
|
21
21
|
- lib/pingboard/client.rb
|
22
|
+
- lib/pingboard/request.rb
|
22
23
|
- pingboard.gemspec
|
23
24
|
homepage: http://rubygems.org/gems/pingboard
|
24
25
|
licenses:
|