pixela 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +2 -0
- data/CHANGELOG.md +7 -1
- data/README.md +9 -1
- data/lib/pixela.rb +5 -4
- data/lib/pixela/client.rb +4 -0
- data/lib/pixela/client/graph_methods.rb +12 -2
- data/lib/pixela/client/pixel_methods.rb +16 -4
- data/lib/pixela/client/user_methods.rb +6 -0
- data/lib/pixela/{configure.rb → configuration.rb} +1 -1
- data/lib/pixela/version.rb +1 -1
- data/pixela.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e324737e723e18a31a7f909771be43a3f12528375747c3d5c2eb40389f3243d
|
4
|
+
data.tar.gz: e2b59967a4f5a79d4278f9982bfe23b7fd70b2af18acc29653d185052936cd7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b7d41ba7582b77f39872a2fb91ff30beb3b8849c90b08172569db68c48290aecfe3fc3eadd1ff69fad590252760088eee3608c05127a02fe44f4c82645dd675
|
7
|
+
data.tar.gz: 10cf6d6778b51c4890faaf8c1f1e2a8ef16679beef4030b389c86dad2d46a717c551edc8cd483a3810544c9c45280aad770428788d702c0d1d08a2e8bdb3c6f7
|
data/.yardopts
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
## Unreleased
|
2
|
-
[full changelog](http://github.com/sue445/pixela/compare/v0.1.
|
2
|
+
[full changelog](http://github.com/sue445/pixela/compare/v0.1.1...master)
|
3
|
+
|
4
|
+
## v0.1.1
|
5
|
+
[full changelog](http://github.com/sue445/pixela/compare/v0.1.0...v0.1.1)
|
6
|
+
|
7
|
+
* Add default value to date args
|
8
|
+
* https://github.com/sue445/pixela/pull/14
|
3
9
|
|
4
10
|
## v0.1.0
|
5
11
|
* first release
|
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
[Pixela](https://pixe.la/) API client for Ruby
|
4
4
|
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/pixela.svg)](https://badge.fury.io/rb/pixela)
|
5
6
|
[![Build Status](https://travis-ci.org/sue445/pixela.svg?branch=master)](https://travis-ci.org/sue445/pixela)
|
6
7
|
[![Maintainability](https://api.codeclimate.com/v1/badges/4c6316222717ee809b57/maintainability)](https://codeclimate.com/github/sue445/pixela/maintainability)
|
7
8
|
|
@@ -41,7 +42,14 @@ client.create_pixel(graph_id: "test-graph", date: Date.today, quantity: 5)
|
|
41
42
|
|
42
43
|
All methods are followings
|
43
44
|
|
44
|
-
https://www.rubydoc.info/gems/pixela
|
45
|
+
https://www.rubydoc.info/gems/pixela/Pixela/Client
|
46
|
+
|
47
|
+
## Configuration
|
48
|
+
```ruby
|
49
|
+
Pixela.config.debug_logger = Logger.new(STDOUT)
|
50
|
+
```
|
51
|
+
|
52
|
+
* `debug_logger`: Enable debug logging if `Logger` is set
|
45
53
|
|
46
54
|
## Development
|
47
55
|
|
data/lib/pixela.rb
CHANGED
@@ -2,14 +2,15 @@ require "pixela/version"
|
|
2
2
|
require "faraday"
|
3
3
|
require "faraday_middleware"
|
4
4
|
require "faraday_curl"
|
5
|
+
require "date"
|
5
6
|
|
6
7
|
module Pixela
|
7
|
-
autoload :Client,
|
8
|
-
autoload :
|
8
|
+
autoload :Client, "pixela/client"
|
9
|
+
autoload :Configuration, "pixela/configuration"
|
9
10
|
|
10
|
-
# @return [Pixela::
|
11
|
+
# @return [Pixela::Configuration]
|
11
12
|
def self.config
|
12
|
-
@config ||=
|
13
|
+
@config ||= Configuration.new
|
13
14
|
end
|
14
15
|
|
15
16
|
class PixelaError < StandardError
|
data/lib/pixela/client.rb
CHANGED
@@ -10,6 +10,8 @@ module Pixela
|
|
10
10
|
|
11
11
|
API_ENDPOINT = "https://pixe.la/v1"
|
12
12
|
|
13
|
+
# @!attribute [r] username
|
14
|
+
# @return [String]
|
13
15
|
attr_reader :username
|
14
16
|
|
15
17
|
# @param username [String]
|
@@ -27,6 +29,8 @@ module Pixela
|
|
27
29
|
|
28
30
|
private
|
29
31
|
|
32
|
+
# @!attribute [r] token
|
33
|
+
# @return [String]
|
30
34
|
attr_reader :token
|
31
35
|
|
32
36
|
def connection
|
@@ -9,6 +9,8 @@ module Pixela::Client::GraphMethods
|
|
9
9
|
#
|
10
10
|
# @return [Hashie::Mash]
|
11
11
|
#
|
12
|
+
# @raise [Pixela::PixelaError] API is failed
|
13
|
+
#
|
12
14
|
# @see https://pixe.la/#api-graph
|
13
15
|
def create_graph(graph_id:, name:, unit:, type:, color:)
|
14
16
|
params = {
|
@@ -28,6 +30,8 @@ module Pixela::Client::GraphMethods
|
|
28
30
|
#
|
29
31
|
# @return [Array<Hashie::Mash>]
|
30
32
|
#
|
33
|
+
# @raise [Pixela::PixelaError] API is failed
|
34
|
+
#
|
31
35
|
# @see https://pixe.la/#api-graph
|
32
36
|
def get_graphs
|
33
37
|
with_error_handling do
|
@@ -38,13 +42,15 @@ module Pixela::Client::GraphMethods
|
|
38
42
|
# Get graph url
|
39
43
|
#
|
40
44
|
# @param graph_id [String]
|
41
|
-
# @param date [Date,Time
|
45
|
+
# @param date [Date,Time]
|
42
46
|
#
|
43
47
|
# @return [String]
|
44
48
|
#
|
49
|
+
# @raise [Pixela::PixelaError] API is failed
|
50
|
+
#
|
45
51
|
# @see https://pixe.la/#api-graph
|
46
52
|
def graph_url(graph_id:, date: nil)
|
47
|
-
url = "
|
53
|
+
url = "#{Pixela::Client::API_ENDPOINT}/users/#{username}/graphs/#{graph_id}"
|
48
54
|
|
49
55
|
url << "?date=#{to_ymd(date)}" if date
|
50
56
|
|
@@ -60,6 +66,8 @@ module Pixela::Client::GraphMethods
|
|
60
66
|
#
|
61
67
|
# @return [Hashie::Mash]
|
62
68
|
#
|
69
|
+
# @raise [Pixela::PixelaError] API is failed
|
70
|
+
#
|
63
71
|
# @see https://pixe.la/#api-graph
|
64
72
|
def update_graph(graph_id:, name:, unit:, color:)
|
65
73
|
params = {
|
@@ -79,6 +87,8 @@ module Pixela::Client::GraphMethods
|
|
79
87
|
#
|
80
88
|
# @return [Hashie::Mash]
|
81
89
|
#
|
90
|
+
# @raise [Pixela::PixelaError] API is failed
|
91
|
+
#
|
82
92
|
# @see https://pixe.la/#api-graph
|
83
93
|
def delete_graph(graph_id)
|
84
94
|
with_error_handling do
|
@@ -7,8 +7,10 @@ module Pixela::Client::PixelMethods
|
|
7
7
|
#
|
8
8
|
# @return [Hashie::Mash]
|
9
9
|
#
|
10
|
+
# @raise [Pixela::PixelaError] API is failed
|
11
|
+
#
|
10
12
|
# @see https://pixe.la/#api-pixel
|
11
|
-
def create_pixel(graph_id:, date
|
13
|
+
def create_pixel(graph_id:, date: Date.today, quantity:)
|
12
14
|
params = {
|
13
15
|
date: to_ymd(date),
|
14
16
|
quantity: quantity.to_s,
|
@@ -26,8 +28,10 @@ module Pixela::Client::PixelMethods
|
|
26
28
|
#
|
27
29
|
# @return [Hashie::Mash]
|
28
30
|
#
|
31
|
+
# @raise [Pixela::PixelaError] API is failed
|
32
|
+
#
|
29
33
|
# @see https://pixe.la/#api-pixel
|
30
|
-
def get_pixel(graph_id:, date:)
|
34
|
+
def get_pixel(graph_id:, date: Date.today)
|
31
35
|
with_error_handling do
|
32
36
|
connection.get("users/#{username}/graphs/#{graph_id}/#{to_ymd(date)}", nil, user_token_headers).body
|
33
37
|
end
|
@@ -41,8 +45,10 @@ module Pixela::Client::PixelMethods
|
|
41
45
|
#
|
42
46
|
# @return [Hashie::Mash]
|
43
47
|
#
|
48
|
+
# @raise [Pixela::PixelaError] API is failed
|
49
|
+
#
|
44
50
|
# @see https://pixe.la/#api-pixel
|
45
|
-
def update_pixel(graph_id:, date
|
51
|
+
def update_pixel(graph_id:, date: Date.today, quantity:)
|
46
52
|
params = {
|
47
53
|
quantity: quantity.to_s,
|
48
54
|
}
|
@@ -59,8 +65,10 @@ module Pixela::Client::PixelMethods
|
|
59
65
|
#
|
60
66
|
# @return [Hashie::Mash]
|
61
67
|
#
|
68
|
+
# @raise [Pixela::PixelaError] API is failed
|
69
|
+
#
|
62
70
|
# @see https://pixe.la/#api-pixel
|
63
|
-
def delete_pixel(graph_id:, date:)
|
71
|
+
def delete_pixel(graph_id:, date: Date.today)
|
64
72
|
with_error_handling do
|
65
73
|
connection.delete("users/#{username}/graphs/#{graph_id}/#{to_ymd(date)}", nil, user_token_headers).body
|
66
74
|
end
|
@@ -72,6 +80,8 @@ module Pixela::Client::PixelMethods
|
|
72
80
|
#
|
73
81
|
# @return [Hashie::Mash]
|
74
82
|
#
|
83
|
+
# @raise [Pixela::PixelaError] API is failed
|
84
|
+
#
|
75
85
|
# @see https://pixe.la/#api-pixel
|
76
86
|
def increment_pixel(graph_id:)
|
77
87
|
with_error_handling do
|
@@ -85,6 +95,8 @@ module Pixela::Client::PixelMethods
|
|
85
95
|
#
|
86
96
|
# @return [Hashie::Mash]
|
87
97
|
#
|
98
|
+
# @raise [Pixela::PixelaError] API is failed
|
99
|
+
#
|
88
100
|
# @see https://pixe.la/#api-pixel
|
89
101
|
def decrement_pixel(graph_id:)
|
90
102
|
with_error_handling do
|
@@ -6,6 +6,8 @@ module Pixela::Client::UserMethods
|
|
6
6
|
#
|
7
7
|
# @return [Hashie::Mash]
|
8
8
|
#
|
9
|
+
# @raise [Pixela::PixelaError] API is failed
|
10
|
+
#
|
9
11
|
# @see https://pixe.la/#api-user
|
10
12
|
def create_user(agree_terms_of_service:, not_minor:)
|
11
13
|
params = {
|
@@ -26,6 +28,8 @@ module Pixela::Client::UserMethods
|
|
26
28
|
#
|
27
29
|
# @return [Hashie::Mash]
|
28
30
|
#
|
31
|
+
# @raise [Pixela::PixelaError] API is failed
|
32
|
+
#
|
29
33
|
# @see https://pixe.la/#api-user
|
30
34
|
def update_user(new_token:)
|
31
35
|
params = {
|
@@ -46,6 +50,8 @@ module Pixela::Client::UserMethods
|
|
46
50
|
#
|
47
51
|
# @return [Hashie::Mash]
|
48
52
|
#
|
53
|
+
# @raise [Pixela::PixelaError] API is failed
|
54
|
+
#
|
49
55
|
# @see https://pixe.la/#api-user
|
50
56
|
def delete_user
|
51
57
|
with_error_handling do
|
data/lib/pixela/version.rb
CHANGED
data/pixela.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pixela
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sue445
|
@@ -206,6 +206,20 @@ dependencies:
|
|
206
206
|
- - ">="
|
207
207
|
- !ruby/object:Gem::Version
|
208
208
|
version: '0'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: yard
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '0'
|
209
223
|
description: Pixela API client for Ruby
|
210
224
|
email:
|
211
225
|
- sue445@sue445.net
|
@@ -217,6 +231,7 @@ files:
|
|
217
231
|
- ".gitignore"
|
218
232
|
- ".rspec"
|
219
233
|
- ".travis.yml"
|
234
|
+
- ".yardopts"
|
220
235
|
- CHANGELOG.md
|
221
236
|
- Gemfile
|
222
237
|
- LICENSE.txt
|
@@ -229,7 +244,7 @@ files:
|
|
229
244
|
- lib/pixela/client/graph_methods.rb
|
230
245
|
- lib/pixela/client/pixel_methods.rb
|
231
246
|
- lib/pixela/client/user_methods.rb
|
232
|
-
- lib/pixela/
|
247
|
+
- lib/pixela/configuration.rb
|
233
248
|
- lib/pixela/version.rb
|
234
249
|
- pixela.gemspec
|
235
250
|
homepage: https://github.com/sue445/pixela
|