pixela 0.1.1 → 0.2.0
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/.coveralls.yml +1 -0
- data/CHANGELOG.md +7 -1
- data/README.md +1 -0
- data/lib/pixela.rb +2 -0
- data/lib/pixela/client.rb +7 -0
- data/lib/pixela/client/graph_methods.rb +16 -2
- data/lib/pixela/client/pixel_methods.rb +18 -0
- data/lib/pixela/client/user_methods.rb +9 -0
- data/lib/pixela/graph.rb +105 -0
- data/lib/pixela/pixel.rb +84 -0
- data/lib/pixela/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 245d38a5c8da2a19b31e3d621bab11be044147077ddc1d8926ce8cae228152be
|
4
|
+
data.tar.gz: 378bf2f361bbf229c93142175f7365389273a9f0cafaa7dbaedf0eeeb14af943
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57847e630f6b0c341cd8ba1ca75df3d23fbe8948cb4d36c8e947299d9c55818f94fe1ff81ecfa7462f1fd645aa92e0869c51c33b07ac3de8a42ecd782de46443
|
7
|
+
data.tar.gz: 62f09e06bb0654249d494b216b467c2e27c821e227b670d1befb035047033c976fd1c41be4ae7712c54b2e9891bd1cc2cf1e2cb056c0a373155c7a5534c99958
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
repo_token: Q6A7yXGKoFD4xsC1GFAacIyLiIK9mV0JK
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
## Unreleased
|
2
|
-
[full changelog](http://github.com/sue445/pixela/compare/v0.
|
2
|
+
[full changelog](http://github.com/sue445/pixela/compare/v0.2.0...master)
|
3
|
+
|
4
|
+
## v0.2.0
|
5
|
+
[full changelog](http://github.com/sue445/pixela/compare/v0.1.1...v0.2.0)
|
6
|
+
|
7
|
+
* Impl resource methods
|
8
|
+
* https://github.com/sue445/pixela/pull/17
|
3
9
|
|
4
10
|
## v0.1.1
|
5
11
|
[full changelog](http://github.com/sue445/pixela/compare/v0.1.0...v0.1.1)
|
data/README.md
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
[](https://badge.fury.io/rb/pixela)
|
6
6
|
[](https://travis-ci.org/sue445/pixela)
|
7
7
|
[](https://codeclimate.com/github/sue445/pixela/maintainability)
|
8
|
+
[](https://coveralls.io/github/sue445/pixela)
|
8
9
|
|
9
10
|
## Installation
|
10
11
|
|
data/lib/pixela.rb
CHANGED
data/lib/pixela/client.rb
CHANGED
@@ -27,6 +27,13 @@ module Pixela
|
|
27
27
|
%Q(#<Pixela::Client:0x#{"%016X" % object_id} @username="#{username}">)
|
28
28
|
end
|
29
29
|
|
30
|
+
# @param graph_id [String]
|
31
|
+
#
|
32
|
+
# @return [Pixela::Graph]
|
33
|
+
def graph(graph_id)
|
34
|
+
Graph.new(client: self, graph_id: graph_id)
|
35
|
+
end
|
36
|
+
|
30
37
|
private
|
31
38
|
|
32
39
|
# @!attribute [r] token
|
@@ -12,6 +12,9 @@ module Pixela::Client::GraphMethods
|
|
12
12
|
# @raise [Pixela::PixelaError] API is failed
|
13
13
|
#
|
14
14
|
# @see https://pixe.la/#api-graph
|
15
|
+
#
|
16
|
+
# @example
|
17
|
+
# client.create_graph(graph_id: "test-graph", name: "graph-name", unit: "commit", type: "int", color: "shibafu")
|
15
18
|
def create_graph(graph_id:, name:, unit:, type:, color:)
|
16
19
|
params = {
|
17
20
|
id: graph_id,
|
@@ -33,6 +36,9 @@ module Pixela::Client::GraphMethods
|
|
33
36
|
# @raise [Pixela::PixelaError] API is failed
|
34
37
|
#
|
35
38
|
# @see https://pixe.la/#api-graph
|
39
|
+
#
|
40
|
+
# @example
|
41
|
+
# client.get_graphs
|
36
42
|
def get_graphs
|
37
43
|
with_error_handling do
|
38
44
|
connection.get("users/#{username}/graphs", nil, user_token_headers).body.graphs
|
@@ -46,9 +52,11 @@ module Pixela::Client::GraphMethods
|
|
46
52
|
#
|
47
53
|
# @return [String]
|
48
54
|
#
|
49
|
-
# @raise [Pixela::PixelaError] API is failed
|
50
|
-
#
|
51
55
|
# @see https://pixe.la/#api-graph
|
56
|
+
#
|
57
|
+
# @example
|
58
|
+
# client.graph_url(graph_id: "test-graph")
|
59
|
+
# client.graph_url(graph_id: "test-graph", date: Date.new(2018, 3, 31))
|
52
60
|
def graph_url(graph_id:, date: nil)
|
53
61
|
url = "#{Pixela::Client::API_ENDPOINT}/users/#{username}/graphs/#{graph_id}"
|
54
62
|
|
@@ -69,6 +77,9 @@ module Pixela::Client::GraphMethods
|
|
69
77
|
# @raise [Pixela::PixelaError] API is failed
|
70
78
|
#
|
71
79
|
# @see https://pixe.la/#api-graph
|
80
|
+
#
|
81
|
+
# @example
|
82
|
+
# client.update_graph(graph_id: "test-graph", name: "graph-name", unit: "commit", color: "shibafu")
|
72
83
|
def update_graph(graph_id:, name:, unit:, color:)
|
73
84
|
params = {
|
74
85
|
name: name,
|
@@ -90,6 +101,9 @@ module Pixela::Client::GraphMethods
|
|
90
101
|
# @raise [Pixela::PixelaError] API is failed
|
91
102
|
#
|
92
103
|
# @see https://pixe.la/#api-graph
|
104
|
+
#
|
105
|
+
# @example
|
106
|
+
# client.delete_graph("test-graph")
|
93
107
|
def delete_graph(graph_id)
|
94
108
|
with_error_handling do
|
95
109
|
connection.delete("users/#{username}/graphs/#{graph_id}", nil, user_token_headers).body
|
@@ -10,6 +10,9 @@ module Pixela::Client::PixelMethods
|
|
10
10
|
# @raise [Pixela::PixelaError] API is failed
|
11
11
|
#
|
12
12
|
# @see https://pixe.la/#api-pixel
|
13
|
+
#
|
14
|
+
# @example
|
15
|
+
# client.create_pixel(graph_id: "test-graph", date: Date.new(2018, 9, 15), quantity: 5)
|
13
16
|
def create_pixel(graph_id:, date: Date.today, quantity:)
|
14
17
|
params = {
|
15
18
|
date: to_ymd(date),
|
@@ -31,6 +34,9 @@ module Pixela::Client::PixelMethods
|
|
31
34
|
# @raise [Pixela::PixelaError] API is failed
|
32
35
|
#
|
33
36
|
# @see https://pixe.la/#api-pixel
|
37
|
+
#
|
38
|
+
# @example
|
39
|
+
# client.get_pixel(graph_id: "test-graph", date: Date.new(2018, 9, 15))
|
34
40
|
def get_pixel(graph_id:, date: Date.today)
|
35
41
|
with_error_handling do
|
36
42
|
connection.get("users/#{username}/graphs/#{graph_id}/#{to_ymd(date)}", nil, user_token_headers).body
|
@@ -48,6 +54,9 @@ module Pixela::Client::PixelMethods
|
|
48
54
|
# @raise [Pixela::PixelaError] API is failed
|
49
55
|
#
|
50
56
|
# @see https://pixe.la/#api-pixel
|
57
|
+
#
|
58
|
+
# @example
|
59
|
+
# client.update_pixel(graph_id: "test-graph", date: Date.new(2018, 9, 15), quantity: 7)
|
51
60
|
def update_pixel(graph_id:, date: Date.today, quantity:)
|
52
61
|
params = {
|
53
62
|
quantity: quantity.to_s,
|
@@ -68,6 +77,9 @@ module Pixela::Client::PixelMethods
|
|
68
77
|
# @raise [Pixela::PixelaError] API is failed
|
69
78
|
#
|
70
79
|
# @see https://pixe.la/#api-pixel
|
80
|
+
#
|
81
|
+
# @example
|
82
|
+
# client.delete_pixel(graph_id: "test-graph", date: Date.new(2018, 9, 15))
|
71
83
|
def delete_pixel(graph_id:, date: Date.today)
|
72
84
|
with_error_handling do
|
73
85
|
connection.delete("users/#{username}/graphs/#{graph_id}/#{to_ymd(date)}", nil, user_token_headers).body
|
@@ -83,6 +95,9 @@ module Pixela::Client::PixelMethods
|
|
83
95
|
# @raise [Pixela::PixelaError] API is failed
|
84
96
|
#
|
85
97
|
# @see https://pixe.la/#api-pixel
|
98
|
+
#
|
99
|
+
# @example
|
100
|
+
# client.increment_pixel(graph_id: "test-graph")
|
86
101
|
def increment_pixel(graph_id:)
|
87
102
|
with_error_handling do
|
88
103
|
connection.put("users/#{username}/graphs/#{graph_id}/increment", nil, user_token_headers).body
|
@@ -98,6 +113,9 @@ module Pixela::Client::PixelMethods
|
|
98
113
|
# @raise [Pixela::PixelaError] API is failed
|
99
114
|
#
|
100
115
|
# @see https://pixe.la/#api-pixel
|
116
|
+
#
|
117
|
+
# @example
|
118
|
+
# client.decrement_pixel(graph_id: "test-graph")
|
101
119
|
def decrement_pixel(graph_id:)
|
102
120
|
with_error_handling do
|
103
121
|
connection.put("users/#{username}/graphs/#{graph_id}/decrement", nil, user_token_headers).body
|
@@ -9,6 +9,9 @@ module Pixela::Client::UserMethods
|
|
9
9
|
# @raise [Pixela::PixelaError] API is failed
|
10
10
|
#
|
11
11
|
# @see https://pixe.la/#api-user
|
12
|
+
#
|
13
|
+
# @example
|
14
|
+
# client.create_user(agree_terms_of_service: true, not_minor: true)
|
12
15
|
def create_user(agree_terms_of_service:, not_minor:)
|
13
16
|
params = {
|
14
17
|
token: token,
|
@@ -31,6 +34,9 @@ module Pixela::Client::UserMethods
|
|
31
34
|
# @raise [Pixela::PixelaError] API is failed
|
32
35
|
#
|
33
36
|
# @see https://pixe.la/#api-user
|
37
|
+
#
|
38
|
+
# @example
|
39
|
+
# client.update_user(new_token: "thisissecret")
|
34
40
|
def update_user(new_token:)
|
35
41
|
params = {
|
36
42
|
newToken: new_token,
|
@@ -53,6 +59,9 @@ module Pixela::Client::UserMethods
|
|
53
59
|
# @raise [Pixela::PixelaError] API is failed
|
54
60
|
#
|
55
61
|
# @see https://pixe.la/#api-user
|
62
|
+
#
|
63
|
+
# @example
|
64
|
+
# client.delete_user
|
56
65
|
def delete_user
|
57
66
|
with_error_handling do
|
58
67
|
connection.delete("users/#{username}", nil, user_token_headers).body
|
data/lib/pixela/graph.rb
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
module Pixela
|
2
|
+
class Graph
|
3
|
+
# @!attribute [r] client
|
4
|
+
# @return [Pixela::Client]
|
5
|
+
attr_reader :client
|
6
|
+
|
7
|
+
# @!attribute [r] graph_id
|
8
|
+
# @return [String]
|
9
|
+
attr_reader :graph_id
|
10
|
+
|
11
|
+
# @param client [Pixela::Client]
|
12
|
+
# @param graph_id [String]
|
13
|
+
def initialize(client:, graph_id:)
|
14
|
+
@client = client
|
15
|
+
@graph_id = graph_id
|
16
|
+
end
|
17
|
+
|
18
|
+
# @param date [Date,Time]
|
19
|
+
#
|
20
|
+
# @return [Pixela::Pixel]
|
21
|
+
def pixel(date = Date.today)
|
22
|
+
Pixel.new(client: client, graph_id: graph_id, date: date)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Create a new pixelation graph definition.
|
26
|
+
#
|
27
|
+
# @param name [String]
|
28
|
+
# @param unit [String]
|
29
|
+
# @param type [String]
|
30
|
+
# @param color [String]
|
31
|
+
#
|
32
|
+
# @return [Hashie::Mash]
|
33
|
+
#
|
34
|
+
# @raise [Pixela::PixelaError] API is failed
|
35
|
+
#
|
36
|
+
# @see https://pixe.la/#api-graph
|
37
|
+
#
|
38
|
+
# @example
|
39
|
+
# client.graph("test-graph").create(name: "graph-name", unit: "commit", type: "int", color: "shibafu")
|
40
|
+
def create(name:, unit:, type:, color:)
|
41
|
+
client.create_graph(graph_id: graph_id, name: name, unit: unit, type: type, color: color)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Get graph url
|
45
|
+
#
|
46
|
+
# @param date [Date,Time]
|
47
|
+
#
|
48
|
+
# @return [String]
|
49
|
+
#
|
50
|
+
# @see https://pixe.la/#api-graph
|
51
|
+
#
|
52
|
+
# @example
|
53
|
+
# client.graph("test-graph").url
|
54
|
+
# client.graph("test-graph").url(date: Date.new(2018, 3, 31))
|
55
|
+
def url(date: nil)
|
56
|
+
client.graph_url(graph_id: graph_id, date: date)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Update predefined pixelation graph definitions.
|
60
|
+
#
|
61
|
+
# @param name [String]
|
62
|
+
# @param unit [String]
|
63
|
+
# @param color [String]
|
64
|
+
#
|
65
|
+
# @return [Hashie::Mash]
|
66
|
+
#
|
67
|
+
# @raise [Pixela::PixelaError] API is failed
|
68
|
+
#
|
69
|
+
# @see https://pixe.la/#api-graph
|
70
|
+
#
|
71
|
+
# @example
|
72
|
+
# client.graph("test-graph").update(name: "graph-name", unit: "commit", color: "shibafu")
|
73
|
+
def update(name:, unit:, color:)
|
74
|
+
client.update_graph(graph_id: graph_id, name: name, unit: unit, color: color)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Increment quantity "Pixel" of the day (UTC).
|
78
|
+
#
|
79
|
+
# @return [Hashie::Mash]
|
80
|
+
#
|
81
|
+
# @raise [Pixela::PixelaError] API is failed
|
82
|
+
#
|
83
|
+
# @see https://pixe.la/#api-pixel
|
84
|
+
#
|
85
|
+
# @example
|
86
|
+
# client.graph("test-graph").increment
|
87
|
+
def increment
|
88
|
+
client.increment_pixel(graph_id: graph_id)
|
89
|
+
end
|
90
|
+
|
91
|
+
# Decrement quantity "Pixel" of the day (UTC).
|
92
|
+
#
|
93
|
+
# @return [Hashie::Mash]
|
94
|
+
#
|
95
|
+
# @raise [Pixela::PixelaError] API is failed
|
96
|
+
#
|
97
|
+
# @see https://pixe.la/#api-pixel
|
98
|
+
#
|
99
|
+
# @example
|
100
|
+
# client.graph("test-graph").decrement
|
101
|
+
def decrement
|
102
|
+
client.decrement_pixel(graph_id: graph_id)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
data/lib/pixela/pixel.rb
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
module Pixela
|
2
|
+
class Pixel
|
3
|
+
# @!attribute [r] client
|
4
|
+
# @return [Pixela::Client]
|
5
|
+
attr_reader :client
|
6
|
+
|
7
|
+
# @!attribute [r] graph_id
|
8
|
+
# @return [String]
|
9
|
+
attr_reader :graph_id
|
10
|
+
|
11
|
+
# @!attribute [r] date
|
12
|
+
# @return [Date]
|
13
|
+
attr_reader :date
|
14
|
+
|
15
|
+
# @param client [Pixela::Client]
|
16
|
+
# @param graph_id [String]
|
17
|
+
# @param date [Date,Time]
|
18
|
+
def initialize(client:, graph_id:, date:)
|
19
|
+
@client = client
|
20
|
+
@graph_id = graph_id
|
21
|
+
@date = date
|
22
|
+
end
|
23
|
+
|
24
|
+
# It records the quantity of the specified date as a "Pixel".
|
25
|
+
#
|
26
|
+
# @param quantity [Integer,Float]
|
27
|
+
#
|
28
|
+
# @return [Hashie::Mash]
|
29
|
+
#
|
30
|
+
# @raise [Pixela::PixelaError] API is failed
|
31
|
+
#
|
32
|
+
# @see https://pixe.la/#api-pixel
|
33
|
+
#
|
34
|
+
# @example
|
35
|
+
# client.graph("test-graph").pixel(Date.new(2018, 9, 15)).create(quantity: 5)
|
36
|
+
def create(quantity:)
|
37
|
+
client.create_pixel(graph_id: graph_id, date: date, quantity: quantity)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Get registered quantity as "Pixel".
|
41
|
+
#
|
42
|
+
# @return [Hashie::Mash]
|
43
|
+
#
|
44
|
+
# @raise [Pixela::PixelaError] API is failed
|
45
|
+
#
|
46
|
+
# @see https://pixe.la/#api-pixel
|
47
|
+
#
|
48
|
+
# @example
|
49
|
+
# client.graph("test-graph").pixel(Date.new(2018, 9, 15)).get
|
50
|
+
def get
|
51
|
+
client.get_pixel(graph_id: graph_id, date: date)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Update the quantity already registered as a "Pixel".
|
55
|
+
#
|
56
|
+
# @param quantity [Integer,Float]
|
57
|
+
#
|
58
|
+
# @return [Hashie::Mash]
|
59
|
+
#
|
60
|
+
# @raise [Pixela::PixelaError] API is failed
|
61
|
+
#
|
62
|
+
# @see https://pixe.la/#api-pixel
|
63
|
+
#
|
64
|
+
# @example
|
65
|
+
# client.graph("test-graph").pixel(Date.new(2018, 9, 15)).update(quantity: 7)
|
66
|
+
def update(quantity:)
|
67
|
+
client.update_pixel(graph_id: graph_id, date: date, quantity: quantity)
|
68
|
+
end
|
69
|
+
|
70
|
+
# Delete the registered "Pixel".
|
71
|
+
#
|
72
|
+
# @return [Hashie::Mash]
|
73
|
+
#
|
74
|
+
# @raise [Pixela::PixelaError] API is failed
|
75
|
+
#
|
76
|
+
# @see https://pixe.la/#api-pixel
|
77
|
+
#
|
78
|
+
# @example
|
79
|
+
# client.graph("test-graph").pixel(Date.new(2018, 9, 15)).delete
|
80
|
+
def delete
|
81
|
+
client.delete_pixel(graph_id: graph_id, date: date)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
data/lib/pixela/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pixela
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sue445
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -227,6 +227,7 @@ executables: []
|
|
227
227
|
extensions: []
|
228
228
|
extra_rdoc_files: []
|
229
229
|
files:
|
230
|
+
- ".coveralls.yml"
|
230
231
|
- ".env.example"
|
231
232
|
- ".gitignore"
|
232
233
|
- ".rspec"
|
@@ -245,6 +246,8 @@ files:
|
|
245
246
|
- lib/pixela/client/pixel_methods.rb
|
246
247
|
- lib/pixela/client/user_methods.rb
|
247
248
|
- lib/pixela/configuration.rb
|
249
|
+
- lib/pixela/graph.rb
|
250
|
+
- lib/pixela/pixel.rb
|
248
251
|
- lib/pixela/version.rb
|
249
252
|
- pixela.gemspec
|
250
253
|
homepage: https://github.com/sue445/pixela
|