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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbd9c38bce70da0d2342696429f2134f5fe83dc3d1ce78700a5e0495b34b64fa
4
- data.tar.gz: dc1595b8c1933918359afcc20071b8bc9cf4fa14228cb7bbab75ac587a2c339e
3
+ metadata.gz: 1e324737e723e18a31a7f909771be43a3f12528375747c3d5c2eb40389f3243d
4
+ data.tar.gz: e2b59967a4f5a79d4278f9982bfe23b7fd70b2af18acc29653d185052936cd7d
5
5
  SHA512:
6
- metadata.gz: 5602f7337b1c274af570a02f53ada0c77f010254dd4ede21098c4127f1cc73ab94155c2b286ca186d9e9657476acbb28755ca03bc62a028ac68171bae98fa12b
7
- data.tar.gz: a0931a40c579bb7cb26b3d80a901850426c4e651f3741e0cd7692c96aeaa9d42939187c66694cebb6fc571e197e24d370d2919de39f6e9b6a05ff3790ea48e29
6
+ metadata.gz: 4b7d41ba7582b77f39872a2fb91ff30beb3b8849c90b08172569db68c48290aecfe3fc3eadd1ff69fad590252760088eee3608c05127a02fe44f4c82645dd675
7
+ data.tar.gz: 10cf6d6778b51c4890faaf8c1f1e2a8ef16679beef4030b389c86dad2d46a717c551edc8cd483a3810544c9c45280aad770428788d702c0d1d08a2e8bdb3c6f7
data/.yardopts ADDED
@@ -0,0 +1,2 @@
1
+ --markup markdown
2
+ --no-private
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## Unreleased
2
- [full changelog](http://github.com/sue445/pixela/compare/v0.1.0...master)
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, "pixela/client"
8
- autoload :Configure, "pixela/configure"
8
+ autoload :Client, "pixela/client"
9
+ autoload :Configuration, "pixela/configuration"
9
10
 
10
- # @return [Pixela::Configure]
11
+ # @return [Pixela::Configuration]
11
12
  def self.config
12
- @config ||= Configure.new
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,String]
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 = "https://pixe.la/v1/users/#{username}/graphs/#{graph_id}"
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:, quantity:)
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:, quantity:)
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
@@ -1,5 +1,5 @@
1
1
  module Pixela
2
- class Configure
2
+ class Configuration
3
3
  # @!attribute debug_logger
4
4
  # @return [Logger]
5
5
  attr_accessor :debug_logger
@@ -1,3 +1,3 @@
1
1
  module Pixela
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/pixela.gemspec CHANGED
@@ -49,4 +49,5 @@ Gem::Specification.new do |spec|
49
49
  spec.add_development_dependency "rspec-its"
50
50
  spec.add_development_dependency "simplecov"
51
51
  spec.add_development_dependency "webmock"
52
+ spec.add_development_dependency "yard"
52
53
  end
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.0
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/configure.rb
247
+ - lib/pixela/configuration.rb
233
248
  - lib/pixela/version.rb
234
249
  - pixela.gemspec
235
250
  homepage: https://github.com/sue445/pixela