pixela 1.4.0 → 2.1.0

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: 375d6ec8ab2c9c4be2747ba45a7c820ced86af17de33af609d9dd1113838b029
4
- data.tar.gz: daf59f70e4899e6bb62dd3ea3f2f1e8406d9de8172b47e22b90a462d1cceee2e
3
+ metadata.gz: a3df84dc9f4591de4d69003caafb28e57d787a269dc70f9fed967d8787183579
4
+ data.tar.gz: 0e23cf942470fd6cbec58c8df6d157bc3bdd045cc7438162b67d170a241d327d
5
5
  SHA512:
6
- metadata.gz: 44f9c7ff48301f987d0978320fe637b4881680f9c18afecd5034ca475c1207fd23a11113f21588ad596f0e6018f213bfc70902b4d91043c144ba87bb07f367ad
7
- data.tar.gz: ac91d230a786cba5a1a3599fa9cb4ade64a2965dd1c3086be6a57ea9997c02af8937363e246da7d14e9518fa5ead6591767f533ed23f6b32da56562145801349
6
+ metadata.gz: d4abcca60067437ac06d9b6dc76b92bc10edf54eed1260412ab7570b8d18153d297908f7339bebe5fb41c91c1170bb636b6c8dd9791108201cea72035fca02c3
7
+ data.tar.gz: 36f6d832bfaf3b7a470ec39ef365a261180a7b34fededd5d0e196322807f1aa811db23f643ac6c29d5de4e426f110096478f8414d12f343c2fa8ea7f23e195f5
@@ -0,0 +1,121 @@
1
+ name: test
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+ types:
9
+ - opened
10
+ - synchronize
11
+ - reopened
12
+ schedule:
13
+ - cron: "0 10 * * 5" # JST 19:00 (Fri)
14
+
15
+ env:
16
+ CI: "true"
17
+
18
+ jobs:
19
+ test:
20
+ runs-on: ubuntu-latest
21
+
22
+ container: ${{ matrix.ruby }}
23
+
24
+ env:
25
+ BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}
26
+
27
+ strategy:
28
+ fail-fast: false
29
+
30
+ matrix:
31
+ ruby:
32
+ - ruby:2.4
33
+ - ruby:2.5
34
+ - ruby:2.6
35
+ - ruby:2.7
36
+ - rubylang/ruby:master-nightly-bionic
37
+ gemfile:
38
+ - faraday_1.gemfile
39
+ include:
40
+ - ruby: rubylang/ruby:master-nightly-bionic
41
+ allow_failures: "true"
42
+
43
+ steps:
44
+ - uses: actions/checkout@v2
45
+
46
+
47
+ - name: Cache gemfiles/vendor/bundle
48
+ uses: actions/cache@v1
49
+ id: cache_gem
50
+ with:
51
+ path: gemfiles/vendor/bundle
52
+ key: v1-gem-${{ runner.os }}-${{ matrix.ruby }}-${{ matrix.gemfile }}-${{ github.sha }}
53
+ restore-keys: |
54
+ v1-gem-${{ runner.os }}-${{ matrix.ruby }}-${{ matrix.gemfile }}-
55
+ continue-on-error: ${{ matrix.allow_failures == 'true' }}
56
+
57
+ - name: bundle update
58
+ run: |
59
+ set -xe
60
+ bundle config path vendor/bundle
61
+ bundle update --jobs $(nproc) --retry 3
62
+ continue-on-error: ${{ matrix.allow_failures == 'true' }}
63
+
64
+ - name: Setup Code Climate Test Reporter
65
+ uses: aktions/codeclimate-test-reporter@v1
66
+ with:
67
+ codeclimate-test-reporter-id: ${{ secrets.CC_TEST_REPORTER_ID }}
68
+ command: before-build
69
+ continue-on-error: true
70
+
71
+ - name: Run test
72
+ run: |
73
+ set -xe
74
+ bundle exec rspec
75
+ continue-on-error: ${{ matrix.allow_failures == 'true' }}
76
+
77
+ - name: Teardown Code Climate Test Reporter
78
+ uses: aktions/codeclimate-test-reporter@v1
79
+ with:
80
+ codeclimate-test-reporter-id: ${{ secrets.CC_TEST_REPORTER_ID }}
81
+ command: after-build
82
+ continue-on-error: true
83
+
84
+ - name: Invoke Pixela webhook
85
+ run: |
86
+ if [ -n "$PIXELA_WEBHOOK_URL" ]; then
87
+ curl -X POST $PIXELA_WEBHOOK_URL -H 'Content-Length:0'
88
+ fi
89
+ env:
90
+ PIXELA_WEBHOOK_URL: ${{ secrets.PIXELA_WEBHOOK_URL }}
91
+ if: always()
92
+ continue-on-error: true
93
+
94
+ - name: Slack Notification (not success)
95
+ uses: lazy-actions/slatify@master
96
+ if: "! success()"
97
+ continue-on-error: true
98
+ with:
99
+ job_name: ${{ format('*build* ({0}, {1})', matrix.ruby, matrix.gemfile) }}
100
+ type: ${{ job.status }}
101
+ icon_emoji: ":octocat:"
102
+ url: ${{ secrets.SLACK_WEBHOOK }}
103
+ token: ${{ secrets.GITHUB_TOKEN }}
104
+
105
+ notify:
106
+ needs:
107
+ - test
108
+
109
+ runs-on: ubuntu-latest
110
+
111
+ steps:
112
+ - name: Slack Notification (success)
113
+ uses: lazy-actions/slatify@master
114
+ if: always()
115
+ continue-on-error: true
116
+ with:
117
+ job_name: '*build*'
118
+ type: ${{ job.status }}
119
+ icon_emoji: ":octocat:"
120
+ url: ${{ secrets.SLACK_WEBHOOK }}
121
+ token: ${{ secrets.GITHUB_TOKEN }}
data/.gitignore CHANGED
@@ -10,5 +10,5 @@
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
12
 
13
- Gemfile.lock
13
+ *.lock
14
14
  .env
@@ -1,5 +1,44 @@
1
1
  ## Unreleased
2
- [full changelog](http://github.com/sue445/pixela/compare/v1.4.0...master)
2
+ [full changelog](http://github.com/sue445/pixela/compare/v2.1.0...master)
3
+
4
+ ## v2.1.0
5
+ [full changelog](http://github.com/sue445/pixela/compare/v2.0.0...v2.1.0)
6
+
7
+ * Add `Pixela::Client#update_profile`
8
+ * https://github.com/sue445/pixela/pull/81
9
+ * https://github.com/a-know/Pixela/releases/tag/v1.20.0
10
+
11
+ ## v2.0.0
12
+ [full changelog](http://github.com/sue445/pixela/compare/v1.5.0...v2.0.0)
13
+
14
+ ### :warning: Breaking changes :warning:
15
+ * Remove Channel and Notification
16
+ * https://github.com/sue445/pixela/pull/75
17
+ * https://github.com/a-know/Pixela/releases/tag/v1.19.0
18
+ * Drop support for faraday v0.x
19
+ * https://github.com/sue445/pixela/pull/77
20
+ * Drop support for ruby 2.3
21
+ * https://github.com/sue445/pixela/pull/78
22
+
23
+ ## v1.5.0
24
+ [full changelog](http://github.com/sue445/pixela/compare/v1.4.2...v1.5.0)
25
+
26
+ * Add `Pixela::Client#run_stopwatch` and `Pixela::Graph#run_stopwatch`
27
+ * https://github.com/sue445/pixela/pull/74
28
+ * https://github.com/a-know/Pixela/releases/tag/v1.18.0
29
+
30
+ ## v1.4.2
31
+ [full changelog](http://github.com/sue445/pixela/compare/v1.4.1...v1.4.2)
32
+
33
+ * Support `remind_by` of Notification
34
+ * https://github.com/sue445/pixela/pull/72
35
+ * https://github.com/a-know/Pixela/releases/tag/v1.17.0
36
+
37
+ ## v1.4.1
38
+ [full changelog](http://github.com/sue445/pixela/compare/v1.4.0...v1.4.1)
39
+
40
+ * Support faraday v1.0
41
+ * https://github.com/sue445/pixela/pull/63
3
42
 
4
43
  ## v1.4.0
5
44
  [full changelog](http://github.com/sue445/pixela/compare/v1.3.1...v1.4.0)
data/README.md CHANGED
@@ -3,7 +3,8 @@
3
3
  [Pixela](https://pixe.la/) API client for Ruby
4
4
 
5
5
  [![Gem Version](https://badge.fury.io/rb/pixela.svg)](https://badge.fury.io/rb/pixela)
6
- [![Build Status](https://travis-ci.org/sue445/pixela.svg?branch=master)](https://travis-ci.org/sue445/pixela)
6
+ [![CI activity of pixela-gem](https://pixe.la/v1/users/sue445/graphs/pixela-gem-ci?mode=badge)](https://pixe.la/v1/users/sue445/graphs/pixela-gem-ci.html)
7
+ [![Build Status](https://github.com/sue445/pixela/workflows/test/badge.svg?branch=master)](https://github.com/sue445/pixela/actions?query=workflow%3Atest)
7
8
  [![Maintainability](https://api.codeclimate.com/v1/badges/4c6316222717ee809b57/maintainability)](https://codeclimate.com/github/sue445/pixela/maintainability)
8
9
  [![Coverage Status](https://coveralls.io/repos/github/sue445/pixela/badge.svg)](https://coveralls.io/github/sue445/pixela)
9
10
 
@@ -13,5 +13,5 @@ Dotenv.load
13
13
 
14
14
  Pixela.config.debug_logger = Logger.new(STDOUT)
15
15
 
16
- require "pry"
17
- Pry.start
16
+ require "irb"
17
+ IRB.start
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in pixela.gemspec
6
+ gemspec path: "../"
7
+
8
+ gem "faraday", "~> 1.0"
@@ -5,11 +5,9 @@ require "faraday_curl"
5
5
  require "date"
6
6
 
7
7
  module Pixela
8
- autoload :Channel, "pixela/channel"
9
8
  autoload :Client, "pixela/client"
10
9
  autoload :Configuration, "pixela/configuration"
11
10
  autoload :Graph, "pixela/graph"
12
- autoload :Notification, "pixela/notification"
13
11
  autoload :Pixel, "pixela/pixel"
14
12
  autoload :Response, "pixela/response"
15
13
  autoload :Webhook, "pixela/webhook"
@@ -1,20 +1,19 @@
1
1
  module Pixela
2
2
  class Client
3
- autoload :ChannelMethods, "pixela/client/channel_methods"
4
3
  autoload :GraphMethods, "pixela/client/graph_methods"
5
- autoload :NotificationMethods, "pixela/client/notificaton_methods"
6
4
  autoload :PixelMethods, "pixela/client/pixel_methods"
5
+ autoload :ProfileMethods, "pixela/client/profile_methods"
7
6
  autoload :UserMethods, "pixela/client/user_methods"
8
7
  autoload :WebhookMethods, "pixela/client/webhook_methods"
9
8
 
10
- include ChannelMethods
11
9
  include GraphMethods
12
- include NotificationMethods
13
10
  include PixelMethods
11
+ include ProfileMethods
14
12
  include UserMethods
15
13
  include WebhookMethods
16
14
 
17
15
  API_ENDPOINT = "https://pixe.la/v1"
16
+ TOP_ENDPOINT = "https://pixe.la"
18
17
 
19
18
  # @!attribute [r] username
20
19
  # @return [String]
@@ -47,13 +46,6 @@ module Pixela
47
46
  Webhook.new(client: self, webhook_hash: webhook_hash)
48
47
  end
49
48
 
50
- # @param channel_id [String]
51
- #
52
- # @return [Pixela::Channel]
53
- def channel(channel_id)
54
- Channel.new(client: self, channel_id: channel_id)
55
- end
56
-
57
49
  private
58
50
 
59
51
  # @!attribute [r] token
@@ -63,8 +55,8 @@ module Pixela
63
55
  # @param request_headers [Hash]
64
56
  #
65
57
  # @return [Faraday::Connection]
66
- def connection(request_headers = user_token_headers)
67
- Faraday.new(url: API_ENDPOINT, headers: request_headers) do |conn|
58
+ def connection(request_headers: user_token_headers, endpoint: API_ENDPOINT)
59
+ Faraday.new(url: endpoint, headers: request_headers) do |conn|
68
60
  conn.request :json
69
61
  conn.response :mashify, mash_class: Pixela::Response
70
62
  conn.response :json
@@ -81,7 +73,7 @@ module Pixela
81
73
 
82
74
  def with_error_handling
83
75
  yield
84
- rescue Faraday::ClientError => error
76
+ rescue Faraday::ClientError, Faraday::ServerError => error
85
77
  begin
86
78
  body = JSON.parse(error.response[:body])
87
79
  raise PixelaError, body["message"]
@@ -110,10 +102,5 @@ module Pixela
110
102
 
111
103
  date.strftime("%Y%m%d")
112
104
  end
113
-
114
- def compact_hash(hash)
115
- # NOTE: Hash#compact is available since MRI 2.4+
116
- hash.reject { |_, v| v.nil? }
117
- end
118
105
  end
119
106
  end
@@ -33,7 +33,7 @@ module Pixela::Client::GraphMethods
33
33
  }
34
34
 
35
35
  with_error_handling do
36
- connection.post("users/#{username}/graphs", compact_hash(params)).body
36
+ connection.post("users/#{username}/graphs", params.compact).body
37
37
  end
38
38
  end
39
39
 
@@ -126,7 +126,7 @@ module Pixela::Client::GraphMethods
126
126
  end
127
127
 
128
128
  with_error_handling do
129
- connection.put("users/#{username}/graphs/#{graph_id}", compact_hash(params)).body
129
+ connection.put("users/#{username}/graphs/#{graph_id}", params.compact).body
130
130
  end
131
131
  end
132
132
 
@@ -170,7 +170,7 @@ module Pixela::Client::GraphMethods
170
170
 
171
171
  res =
172
172
  with_error_handling do
173
- connection.get("users/#{username}/graphs/#{graph_id}/pixels", compact_hash(params)).body
173
+ connection.get("users/#{username}/graphs/#{graph_id}/pixels", params.compact).body
174
174
  end
175
175
 
176
176
  res.pixels.map { |ymd| Date.parse(ymd) }
@@ -193,4 +193,25 @@ module Pixela::Client::GraphMethods
193
193
  connection.get("users/#{username}/graphs/#{graph_id}/stats").body
194
194
  end
195
195
  end
196
+
197
+ # This will start and end the measurement of the time.
198
+ #
199
+ # @param graph_id [String]
200
+ #
201
+ # @return [Pixela::Response]
202
+ #
203
+ # @raise [Pixela::PixelaError] API is failed
204
+ #
205
+ # @see https://docs.pixe.la/entry/post-stopwatch
206
+ #
207
+ # @example
208
+ # client.run_stopwatch(graph_id: "test-graph")
209
+ def run_stopwatch(graph_id:)
210
+ with_error_handling do
211
+ connection.post("users/#{username}/graphs/#{graph_id}/stopwatch").body
212
+ end
213
+ end
214
+
215
+ alias_method :start_stopwatch, :run_stopwatch
216
+ alias_method :end_stopwatch, :run_stopwatch
196
217
  end
@@ -22,7 +22,7 @@ module Pixela::Client::PixelMethods
22
22
  }
23
23
 
24
24
  with_error_handling do
25
- connection.post("users/#{username}/graphs/#{graph_id}", compact_hash(params)).body
25
+ connection.post("users/#{username}/graphs/#{graph_id}", params.compact).body
26
26
  end
27
27
  end
28
28
 
@@ -80,7 +80,7 @@ module Pixela::Client::PixelMethods
80
80
  }
81
81
 
82
82
  with_error_handling do
83
- connection.put("users/#{username}/graphs/#{graph_id}/#{to_ymd(date)}", compact_hash(params)).body
83
+ connection.put("users/#{username}/graphs/#{graph_id}/#{to_ymd(date)}", params.compact).body
84
84
  end
85
85
  end
86
86
 
@@ -0,0 +1,40 @@
1
+ module Pixela::Client::ProfileMethods
2
+ # Updates the profile information for the user corresponding to username
3
+ #
4
+ # @param display_name [String]
5
+ # @param gravatar_icon_email [String]
6
+ # @param title [String]
7
+ # @param timezone [String]
8
+ # @param about_url [String]
9
+ # @param contribute_urls [Array<String>]
10
+ # @param pinned_graph_id [String]
11
+ #
12
+ # @return [Pixela::Response]
13
+ #
14
+ # @raise [Pixela::PixelaError] API is failed
15
+ #
16
+ # @see https://docs.pixe.la/entry/put-profile
17
+ #
18
+ # @example
19
+ # client.update_profile(display_name: "a-know", gravatar_icon_email: "user@example.com", title: "my title", timezone: "Asia/Tokyo", about_url: "https://home.a-know.me", contribute_urls: ["https://pixe.la/","https://github.com/a-know/pi","https://blog.a-know.me/archive/category/Pixela"])
20
+ def update_profile(display_name: nil, gravatar_icon_email: nil, title: nil, timezone: nil,
21
+ about_url: nil, contribute_urls: [], pinned_graph_id: nil)
22
+
23
+ params = {
24
+ displayName: display_name,
25
+ gravatarIconEmail: gravatar_icon_email,
26
+ title: title,
27
+ timezone: timezone,
28
+ aboutURL: about_url,
29
+ pinnedGraphID: pinned_graph_id
30
+ }
31
+
32
+ unless contribute_urls.empty?
33
+ params[:contributeURLs] = contribute_urls
34
+ end
35
+
36
+ with_error_handling do
37
+ connection(endpoint: Pixela::Client::TOP_ENDPOINT).put("@#{username}", params.compact).body
38
+ end
39
+ end
40
+ end
@@ -21,7 +21,7 @@ module Pixela::Client::UserMethods
21
21
  }
22
22
 
23
23
  with_error_handling do
24
- connection(default_headers).post("users", params).body
24
+ connection(request_headers: default_headers).post("users", params).body
25
25
  end
26
26
  end
27
27
 
@@ -53,7 +53,7 @@ module Pixela::Client::WebhookMethods
53
53
  # client.invoke_webhook(webhook_hash: "<webhookHash>")
54
54
  def invoke_webhook(webhook_hash:)
55
55
  with_error_handling do
56
- connection(default_headers).post("users/#{username}/webhooks/#{webhook_hash}").body
56
+ connection(request_headers: default_headers).post("users/#{username}/webhooks/#{webhook_hash}").body
57
57
  end
58
58
  end
59
59
 
@@ -22,13 +22,6 @@ module Pixela
22
22
  Pixel.new(client: client, graph_id: graph_id, date: date)
23
23
  end
24
24
 
25
- # @param notification_id [String]
26
- #
27
- # @return [Pixela::Notification]
28
- def notification(notification_id)
29
- Notification.new(client: client, graph_id: graph_id, notification_id: notification_id)
30
- end
31
-
32
25
  # Create a new pixelation graph definition.
33
26
  #
34
27
  # @param name [String]
@@ -169,5 +162,22 @@ module Pixela
169
162
  def stats
170
163
  client.get_graph_stats(graph_id: graph_id)
171
164
  end
165
+
166
+ # This will start and end the measurement of the time.
167
+ #
168
+ # @return [Pixela::Response]
169
+ #
170
+ # @raise [Pixela::PixelaError] API is failed
171
+ #
172
+ # @see https://docs.pixe.la/entry/post-stopwatch
173
+ #
174
+ # @example
175
+ # client.graph("test-graph").run_stopwatch
176
+ def run_stopwatch
177
+ client.run_stopwatch(graph_id: graph_id)
178
+ end
179
+
180
+ alias_method :start_stopwatch, :run_stopwatch
181
+ alias_method :end_stopwatch, :run_stopwatch
172
182
  end
173
183
  end
@@ -1,3 +1,3 @@
1
1
  module Pixela
2
- VERSION = "1.4.0"
2
+ VERSION = "2.1.0"
3
3
  end
@@ -34,9 +34,9 @@ Gem::Specification.new do |spec|
34
34
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
35
35
  spec.require_paths = ["lib"]
36
36
 
37
- spec.required_ruby_version = ">= 2.3.0"
37
+ spec.required_ruby_version = ">= 2.4.0"
38
38
 
39
- spec.add_dependency "faraday"
39
+ spec.add_dependency "faraday", ">= 1.0.0"
40
40
  spec.add_dependency "faraday_curl"
41
41
  spec.add_dependency "faraday_middleware"
42
42
  spec.add_dependency "hashie"
@@ -44,12 +44,12 @@ Gem::Specification.new do |spec|
44
44
  spec.add_development_dependency "bundler", ">= 1.16"
45
45
  spec.add_development_dependency "coveralls"
46
46
  spec.add_development_dependency "dotenv"
47
- spec.add_development_dependency "pry-byebug"
48
- spec.add_development_dependency "rake", "~> 10.0"
47
+ spec.add_development_dependency "rake", ">= 10.0"
49
48
  spec.add_development_dependency "rspec", "~> 3.0"
50
49
  spec.add_development_dependency "rspec-its"
51
50
  spec.add_development_dependency "rspec-parameterized"
52
51
  spec.add_development_dependency "simplecov"
52
+ spec.add_development_dependency "unparser", ">= 0.4.5"
53
53
  spec.add_development_dependency "webmock"
54
54
  spec.add_development_dependency "yard"
55
55
  end
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: 1.4.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - sue445
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-23 00:00:00.000000000 Z
11
+ date: 2020-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 1.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 1.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: faraday_curl
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -108,32 +108,18 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: pry-byebug
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
111
  - !ruby/object:Gem::Dependency
126
112
  name: rake
127
113
  requirement: !ruby/object:Gem::Requirement
128
114
  requirements:
129
- - - "~>"
115
+ - - ">="
130
116
  - !ruby/object:Gem::Version
131
117
  version: '10.0'
132
118
  type: :development
133
119
  prerelease: false
134
120
  version_requirements: !ruby/object:Gem::Requirement
135
121
  requirements:
136
- - - "~>"
122
+ - - ">="
137
123
  - !ruby/object:Gem::Version
138
124
  version: '10.0'
139
125
  - !ruby/object:Gem::Dependency
@@ -192,6 +178,20 @@ dependencies:
192
178
  - - ">="
193
179
  - !ruby/object:Gem::Version
194
180
  version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: unparser
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: 0.4.5
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: 0.4.5
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: webmock
197
197
  requirement: !ruby/object:Gem::Requirement
@@ -229,9 +229,9 @@ extra_rdoc_files: []
229
229
  files:
230
230
  - ".coveralls.yml"
231
231
  - ".env.example"
232
+ - ".github/workflows/test.yml"
232
233
  - ".gitignore"
233
234
  - ".rspec"
234
- - ".travis.yml"
235
235
  - ".yardopts"
236
236
  - CHANGELOG.md
237
237
  - Gemfile
@@ -240,18 +240,16 @@ files:
240
240
  - Rakefile
241
241
  - bin/console
242
242
  - bin/setup
243
+ - gemfiles/faraday_1.gemfile
243
244
  - lib/pixela.rb
244
- - lib/pixela/channel.rb
245
245
  - lib/pixela/client.rb
246
- - lib/pixela/client/channel_methods.rb
247
246
  - lib/pixela/client/graph_methods.rb
248
- - lib/pixela/client/notificaton_methods.rb
249
247
  - lib/pixela/client/pixel_methods.rb
248
+ - lib/pixela/client/profile_methods.rb
250
249
  - lib/pixela/client/user_methods.rb
251
250
  - lib/pixela/client/webhook_methods.rb
252
251
  - lib/pixela/configuration.rb
253
252
  - lib/pixela/graph.rb
254
- - lib/pixela/notification.rb
255
253
  - lib/pixela/pixel.rb
256
254
  - lib/pixela/response.rb
257
255
  - lib/pixela/version.rb
@@ -264,7 +262,7 @@ metadata:
264
262
  homepage_uri: https://github.com/sue445/pixela
265
263
  source_code_uri: https://github.com/sue445/pixela
266
264
  changelog_uri: https://github.com/sue445/pixela/blob/master/CHANGELOG.md
267
- post_install_message:
265
+ post_install_message:
268
266
  rdoc_options: []
269
267
  require_paths:
270
268
  - lib
@@ -272,15 +270,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
272
270
  requirements:
273
271
  - - ">="
274
272
  - !ruby/object:Gem::Version
275
- version: 2.3.0
273
+ version: 2.4.0
276
274
  required_rubygems_version: !ruby/object:Gem::Requirement
277
275
  requirements:
278
276
  - - ">="
279
277
  - !ruby/object:Gem::Version
280
278
  version: '0'
281
279
  requirements: []
282
- rubygems_version: 3.0.6
283
- signing_key:
280
+ rubygems_version: 3.1.2
281
+ signing_key:
284
282
  specification_version: 4
285
283
  summary: Pixela API client for Ruby
286
284
  test_files: []
@@ -1,40 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.3
4
- - 2.4
5
- - 2.5
6
- - 2.6
7
- - ruby-head
8
- bundler_args: "--jobs=2"
9
- cache: bundler
10
- before_install:
11
- - travis_retry gem update --system || travis_retry gem update --system 2.7.8
12
- - travis_retry gem install bundler --no-document || travis_retry gem install bundler --no-document -v 1.17.3
13
- before_script:
14
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
15
- - chmod +x ./cc-test-reporter
16
- - ./cc-test-reporter before-build
17
- script:
18
- - RUBYOPT=$RSPEC_RUBYOPT bundle exec rspec
19
- after_script:
20
- - if [ "$PIXELA_WEBHOOK_URL" != "" ]; then curl -X POST $PIXELA_WEBHOOK_URL -H 'Content-Length:0'; fi
21
- - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
22
- branches:
23
- only:
24
- - master
25
- notifications:
26
- email: false
27
- slack:
28
- secure: ec/Q9tFK+TjW7ZVOWg8NPfa4IFfbU24ljqObG7YhlaYaIN63MMdMITfy17sQahm2T0x7jhAzxDo1pDTb9XoBs12cu2wogZltv+daZwATWYzipvUxQqge1yywnFn3QLfQyzAl5p1MYkxLpJeVDRD8wunmc2OikR4jMtl5KDk9e2sItHGJdfPY8mFhM+sKaLyy9mbGo02aqRqwhgXGFQg1lZ/D6qPZKPSAd+S+uJgma8En4P292APBN9hsgpjC4HGqiqhPumOyjmdiVZ//4QoYhIEaMGJiwKyv9GwS0cTfk6w9MNFRILhj4tN3kP8ZsI7h5oQy8+x0Deac9joTKMNVarvZkVFZWLZ3p8mthdsRNKZeYxkSgnrhwA/3CFe/THjolfROA61iQqWxFycdIqSieiGHZ57EvHo7HOSD5Kc0017X+UITjiWiKiSQPddPmYm5hl9lo9rBo1RaJRr6B5A2qrw2SBmNfH38+BDTMFZprJLN51LBJ4DEy4R0CClbyIk6DbODsWqQC+W+6sOCWOhrVXSeSVlxPz7hT24ezkcMLMvoA5k9f6Gi2cWWDD9CmRI2Upt+5lx0Ui1/9xbk4RG6/hue8L764jdQ2mqNtrAZJSjdfs9KxapoKFllezdwhNVJS4UoU6PT9DU227cHH3SWHYm9GHu/pQ6kdhBGcr/EMiY=
29
- matrix:
30
- allow_failures:
31
- - rvm: ruby-head
32
- include:
33
- - rvm: 2.6
34
- env: RSPEC_RUBYOPT="--jit"
35
- - rvm: ruby-head
36
- env: RSPEC_RUBYOPT="--jit"
37
- sudo: false
38
- env:
39
- global:
40
- - CC_TEST_REPORTER_ID=67b1bed21e42834690bb57b148b93d6bd23410d8e013afdf6a89d66f36011a95
@@ -1,106 +0,0 @@
1
- module Pixela
2
- class Channel
3
- # @!attribute [r] client
4
- # @return [Pixela::Client]
5
- attr_reader :client
6
-
7
- # @!attribute [r] id
8
- # @return [String]
9
- attr_reader :channel_id
10
-
11
- # @param client [Pixela::Client]
12
- # @param graph_id [String]
13
- def initialize(client:, channel_id:)
14
- @client = client
15
- @channel_id = channel_id
16
- end
17
-
18
- # Create a new channel settings for notification.
19
- #
20
- # @param name [String]
21
- # @param type [String]
22
- # @param detail [Hash]
23
- #
24
- # @return [Pixela::Response]
25
- #
26
- # @raise [Pixela::PixelaError] API is failed
27
- #
28
- # @see https://docs.pixe.la/entry/post-channel
29
- #
30
- # @example
31
- # client.channel("my-channel").create(name: "My slack channel", type: "slack", detail: {url: "https://hooks.slack.com/services/T035DA4QD/B06LMAV40/xxxx", userName: "Pixela Notification", channelName: "pixela-notify"})
32
- def create(name:, type:, detail:)
33
- client.create_channel(channel_id: channel_id, name: name, type: type, detail: detail)
34
- end
35
-
36
- # Create a new channel settings for slack notification.
37
- #
38
- # @param name [String]
39
- # @param url [String]
40
- # @param user_name [String]
41
- # @param channel_name [String]
42
- #
43
- # @return [Pixela::Response]
44
- #
45
- # @raise [Pixela::PixelaError] API is failed
46
- #
47
- # @see https://docs.pixe.la/entry/post-channel
48
- #
49
- # @example
50
- # client.channel("my-channel").create_with_slack(name: "My slack channel", url: "https://hooks.slack.com/services/T035DA4QD/B06LMAV40/xxxx", user_name: "Pixela Notification", channel_name: "pixela-notify")
51
- def create_with_slack(name:, url:, user_name:, channel_name:)
52
- client.create_slack_channel(channel_id: channel_id, name: name, url: url, user_name: user_name, channel_name: channel_name)
53
- end
54
-
55
- # Update predefined channel settings.
56
- #
57
- # @param name [String]
58
- # @param type [String]
59
- # @param detail [Hash]
60
- #
61
- # @return [Pixela::Response]
62
- #
63
- # @raise [Pixela::PixelaError] API is failed
64
- #
65
- # @see https://docs.pixe.la/entry/put-channel
66
- #
67
- # @example
68
- # client.channel("my-channel").update(name: "My slack channel", type: "slack", detail: {url: "https://hooks.slack.com/services/T035DA4QD/B06LMAV40/xxxx", userName: "Pixela Notification", channelName: "pixela-notify"})
69
- def update(name:, type:, detail:)
70
- client.update_channel(channel_id: channel_id, name: name, type: type, detail: detail)
71
- end
72
-
73
- # Update predefined slack channel settings.
74
- #
75
- # @param name [String]
76
- # @param url [String]
77
- # @param user_name [String]
78
- # @param channel_name [String]
79
- #
80
- # @return [Pixela::Response]
81
- #
82
- # @raise [Pixela::PixelaError] API is failed
83
- #
84
- # @see https://docs.pixe.la/entry/post-channel
85
- #
86
- # @example
87
- # client.channel("my-channel").update_with_slack(name: "My slack channel", url: "https://hooks.slack.com/services/T035DA4QD/B06LMAV40/xxxx", user_name: "Pixela Notification", channel_name: "pixela-notify")
88
- def update_with_slack(name:, url:, user_name:, channel_name:)
89
- client.update_slack_channel(channel_id: channel_id, name: name, url: url, user_name: user_name, channel_name: channel_name)
90
- end
91
-
92
- # Delete predefined channel settings.
93
- #
94
- # @see https://docs.pixe.la/entry/delete-channel
95
- #
96
- # @return [Pixela::Response]
97
- #
98
- # @raise [Pixela::PixelaError] API is failed
99
- #
100
- # @example
101
- # client.channel("my-channel").delete
102
- def delete
103
- client.delete_channel(channel_id: channel_id)
104
- end
105
- end
106
- end
@@ -1,148 +0,0 @@
1
- module Pixela::Client::ChannelMethods
2
- # Create a new channel settings for notification.
3
- #
4
- # @param channel_id [String]
5
- # @param name [String]
6
- # @param type [String]
7
- # @param detail [Hash]
8
- #
9
- # @return [Pixela::Response]
10
- #
11
- # @raise [Pixela::PixelaError] API is failed
12
- #
13
- # @see https://docs.pixe.la/entry/post-channel
14
- #
15
- # @example
16
- # client.create_channel(channel_id: "my-channel", name: "My slack channel", type: "slack", detail: {url: "https://hooks.slack.com/services/T035DA4QD/B06LMAV40/xxxx", userName: "Pixela Notification", channelName: "pixela-notify"})
17
- def create_channel(channel_id:, name:, type:, detail:)
18
- params = {
19
- id: channel_id,
20
- name: name,
21
- type: type,
22
- detail: detail,
23
- }
24
-
25
- with_error_handling do
26
- connection.post("users/#{username}/channels", compact_hash(params)).body
27
- end
28
- end
29
-
30
- # Create a new channel settings for slack notification.
31
- #
32
- # @param channel_id [String]
33
- # @param name [String]
34
- # @param url [String]
35
- # @param user_name [String]
36
- # @param channel_name [String]
37
- #
38
- # @return [Pixela::Response]
39
- #
40
- # @raise [Pixela::PixelaError] API is failed
41
- #
42
- # @see https://docs.pixe.la/entry/post-channel
43
- #
44
- # @example
45
- # client.create_slack_channel(channel_id: "my-channel", name: "My slack channel", url: "https://hooks.slack.com/services/T035DA4QD/B06LMAV40/xxxx", user_name: "Pixela Notification", channel_name: "pixela-notify")
46
- def create_slack_channel(channel_id:, name:, url:, user_name:, channel_name:)
47
- create_channel(
48
- channel_id: channel_id,
49
- name: name,
50
- type: "slack",
51
- detail: {
52
- url: url,
53
- userName: user_name,
54
- channelName: channel_name,
55
- },
56
- )
57
- end
58
-
59
- # Get all predefined channels.
60
- #
61
- # @see https://docs.pixe.la/entry/get-channels
62
- #
63
- # @return [Array<Pixela::Response>]
64
- #
65
- # @raise [Pixela::PixelaError] API is failed
66
- #
67
- # @example
68
- # client.get_channels
69
- def get_channels
70
- with_error_handling do
71
- connection.get("users/#{username}/channels").body.channels
72
- end
73
- end
74
-
75
- # Update predefined channel settings.
76
- #
77
- # @param channel_id [String]
78
- # @param name [String]
79
- # @param type [String]
80
- # @param detail [Hash]
81
- #
82
- # @return [Pixela::Response]
83
- #
84
- # @raise [Pixela::PixelaError] API is failed
85
- #
86
- # @see https://docs.pixe.la/entry/put-channel
87
- #
88
- # @example
89
- # client.update_channel(channel_id: "my-channel", name: "My slack channel", type: "slack", detail: {url: "https://hooks.slack.com/services/T035DA4QD/B06LMAV40/xxxx", userName: "Pixela Notification", channelName: "pixela-notify"})
90
- def update_channel(channel_id:, name:, type:, detail:)
91
- params = {
92
- name: name,
93
- type: type,
94
- detail: detail,
95
- }
96
-
97
- with_error_handling do
98
- connection.put("users/#{username}/channels/#{channel_id}", compact_hash(params)).body
99
- end
100
- end
101
-
102
- # Update predefined slack channel settings.
103
- #
104
- # @param channel_id [String]
105
- # @param name [String]
106
- # @param url [String]
107
- # @param user_name [String]
108
- # @param channel_name [String]
109
- #
110
- # @return [Pixela::Response]
111
- #
112
- # @raise [Pixela::PixelaError] API is failed
113
- #
114
- # @see https://docs.pixe.la/entry/post-channel
115
- #
116
- # @example
117
- # client.update_slack_channel(channel_id: "my-channel", name: "My slack channel", url: "https://hooks.slack.com/services/T035DA4QD/B06LMAV40/xxxx", user_name: "Pixela Notification", channel_name: "pixela-notify")
118
- def update_slack_channel(channel_id:, name:, url:, user_name:, channel_name:)
119
- update_channel(
120
- channel_id: channel_id,
121
- name: name,
122
- type: "slack",
123
- detail: {
124
- url: url,
125
- userName: user_name,
126
- channelName: channel_name,
127
- },
128
- )
129
- end
130
-
131
- # Delete predefined channel settings.
132
- #
133
- # @param channel_id [String]
134
- #
135
- # @see https://docs.pixe.la/entry/delete-channel
136
- #
137
- # @return [Pixela::Response]
138
- #
139
- # @raise [Pixela::PixelaError] API is failed
140
- #
141
- # @example
142
- # client.delete_channel(channel_id: "my-channel")
143
- def delete_channel(channel_id:)
144
- with_error_handling do
145
- connection.delete("users/#{username}/channels/#{channel_id}").body
146
- end
147
- end
148
- end
@@ -1,103 +0,0 @@
1
- module Pixela::Client::NotificationMethods
2
- # Create a notification rule.
3
- #
4
- # @param graph_id [String]
5
- # @param notification_id [String]
6
- # @param name [String]
7
- # @param target [String]
8
- # @param condition [String]
9
- # @param threshold [String]
10
- # @param channel_id [String]
11
- #
12
- # @return [Pixela::Response]
13
- #
14
- # @raise [Pixela::PixelaError] API is failed
15
- #
16
- # @see https://docs.pixe.la/entry/post-notification
17
- #
18
- # @example
19
- # client.create_notification(graph_id: "test-graph", notification_id: "my-notification-rule", name: "my notification rule", target: "quantity", condition: ">", threshold: "5", channel_id: "my-channel")
20
- def create_notification(graph_id:, notification_id:, name:, target:, condition:, threshold:, channel_id:)
21
- params = {
22
- id: notification_id,
23
- name: name,
24
- target: target,
25
- condition: condition,
26
- threshold: threshold,
27
- channelID: channel_id,
28
- }
29
-
30
- with_error_handling do
31
- connection.post("users/#{username}/graphs/#{graph_id}/notifications", compact_hash(params)).body
32
- end
33
- end
34
-
35
- # Get all predefined notifications.
36
- #
37
- # @param graph_id [String]
38
- #
39
- # @return [Array<Pixela::Response>]
40
- #
41
- # @raise [Pixela::PixelaError] API is failed
42
- #
43
- # @see https://docs.pixe.la/entry/get-notifications
44
- #
45
- # @example
46
- # client.get_notifications(graph_id: "test-graph")
47
- def get_notifications(graph_id:)
48
- with_error_handling do
49
- connection.get("users/#{username}/graphs/#{graph_id}/notifications").body.notifications
50
- end
51
- end
52
-
53
- # Update predefined notification rule.
54
- #
55
- # @param graph_id [String]
56
- # @param notification_id [String]
57
- # @param name [String]
58
- # @param target [String]
59
- # @param condition [String]
60
- # @param threshold [String]
61
- # @param channel_id [String]
62
- #
63
- # @return [Pixela::Response]
64
- #
65
- # @raise [Pixela::PixelaError] API is failed
66
- #
67
- # @see https://docs.pixe.la/entry/put-notification
68
- #
69
- # @example
70
- # client.update_notification(graph_id: "test-graph", notification_id: "my-notification-rule", name: "my notification rule", target: "quantity", condition: ">", threshold: "5", channel_id: "my-channel")
71
- def update_notification(graph_id:, notification_id:, name:, target:, condition:, threshold:, channel_id:)
72
- params = {
73
- name: name,
74
- target: target,
75
- condition: condition,
76
- threshold: threshold,
77
- channelID: channel_id,
78
- }
79
-
80
- with_error_handling do
81
- connection.put("users/#{username}/graphs/#{graph_id}/notifications/#{notification_id}", compact_hash(params)).body
82
- end
83
- end
84
-
85
- # Delete predefined notification settings.
86
- #
87
- # @param graph_id [String]
88
- # @param notification_id [String]
89
- #
90
- # @return [Pixela::Response]
91
- #
92
- # @raise [Pixela::PixelaError] API is failed
93
- #
94
- # @see https://docs.pixe.la/entry/delete-notification
95
- #
96
- # @example
97
- # client.delete_notification(graph_id: "test-graph", notification_id: "my-notification-rule")
98
- def delete_notification(graph_id:, notification_id:)
99
- with_error_handling do
100
- connection.delete("users/#{username}/graphs/#{graph_id}/notifications/#{notification_id}").body
101
- end
102
- end
103
- end
@@ -1,80 +0,0 @@
1
- module Pixela
2
- class Notification
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] notification_id
12
- # @return [String]
13
- attr_reader :notification_id
14
-
15
- # @param client [Pixela::Client]
16
- # @param graph_id [String]
17
- # @param notification_id [String]
18
- def initialize(client:, graph_id:, notification_id:)
19
- @client = client
20
- @graph_id = graph_id
21
- @notification_id = notification_id
22
- end
23
-
24
- # Create a notification rule.
25
- #
26
- # @param name [String]
27
- # @param target [String]
28
- # @param condition [String]
29
- # @param threshold [String]
30
- # @param channel_id [String]
31
- #
32
- # @return [Pixela::Response]
33
- #
34
- # @raise [Pixela::PixelaError] API is failed
35
- #
36
- # @see https://docs.pixe.la/entry/post-notification
37
- #
38
- # @example
39
- # client.graph("test-graph").notification("my-notification-rule").create(name: "my notification rule", target: "quantity", condition: ">", threshold: "5", channel_id: "my-channel")
40
- def create(name:, target:, condition:, threshold:, channel_id:)
41
- client.create_notification(graph_id: graph_id, notification_id: notification_id, name: name, target: target, condition: condition, threshold: threshold, channel_id: channel_id)
42
- end
43
-
44
- # Update predefined notification rule.
45
- #
46
- # @param graph_id [String]
47
- # @param notification_id [String]
48
- # @param name [String]
49
- # @param target [String]
50
- # @param condition [String]
51
- # @param threshold [String]
52
- # @param channel_id [String]
53
- #
54
- # @return [Pixela::Response]
55
- #
56
- # @raise [Pixela::PixelaError] API is failed
57
- #
58
- # @see https://docs.pixe.la/entry/put-notification
59
- #
60
- # @example
61
- # client.graph("test-graph").notification("my-notification-rule").update(name: "my notification rule", target: "quantity", condition: ">", threshold: "5", channel_id: "my-channel")
62
- def update(name:, target:, condition:, threshold:, channel_id:)
63
- client.update_notification(graph_id: graph_id, notification_id: notification_id, name: name, target: target, condition: condition, threshold: threshold, channel_id: channel_id)
64
- end
65
-
66
- # Delete predefined notification settings.
67
- #
68
- # @return [Pixela::Response]
69
- #
70
- # @raise [Pixela::PixelaError] API is failed
71
- #
72
- # @see https://docs.pixe.la/entry/delete-notification
73
- #
74
- # @example
75
- # client.graph("test-graph").notification("my-notification-rule").delete
76
- def delete
77
- client.delete_notification(graph_id: graph_id, notification_id: notification_id)
78
- end
79
- end
80
- end