smart_todo 1.7.0 → 1.8.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: 7bbca316fba93242bc5ea22479579407ed9ce3ed93a6bd618978223f96f0626d
4
- data.tar.gz: c91cf35475f5a32da647f6ed649ac7d50d85a929908aa29f1768a9b1d6db75da
3
+ metadata.gz: a7cac40289c5fb2fdf4bb143ee7cca9b1c74ce41c7e1fa426f7efc17364a2683
4
+ data.tar.gz: c93946f4131f64068e9c249c760829a33f3e88ae669f322bb00ea0647f68eb20
5
5
  SHA512:
6
- metadata.gz: 1668111d5578d6c64f2ff7df6071f9ede6ccc4aeb01bf1c5cdccea8d514cf29caad0b2b576bb3bb60eaaaa309f44b723e066c62b39b50ab17e418372a29c4dad
7
- data.tar.gz: 25636e700c032b2bc0509791f8884f9e9f6cb78ae09103db503d69739e48507c07c8a8fc6579f4f441c1f08caf09f19274ad19061305b9ad9b82efc5c41e9711
6
+ metadata.gz: a6a84fd8bd731f7b31fe0033be57a50ba018af724ae29cfa16a4c9a0a96766e6335ee1c1145976002519aff1f69d6a28a3bf220963e42f55c28b051f02c85d80
7
+ data.tar.gz: 562151dd8c4fc2b8d55d72c004a701ef2c10f01d3e84f632b1a945ee969469e7dffd5473c7f109548ca105175b1a893f1e039a9ee091b3cb8034af7e47116082
@@ -12,7 +12,7 @@ jobs:
12
12
  name: Ruby ${{ matrix.version }}
13
13
  strategy:
14
14
  matrix:
15
- version: [3.0, 3.1, 3.2]
15
+ version: [3.0, 3.1, 3.2, 3.3]
16
16
 
17
17
  steps:
18
18
  - uses: actions/checkout@v2
@@ -8,10 +8,9 @@ jobs:
8
8
 
9
9
  steps:
10
10
  - uses: actions/checkout@v2
11
- - name: Set up Ruby 3.0
11
+ - name: Set up Ruby
12
12
  uses: ruby/setup-ruby@v1
13
13
  with:
14
- ruby-version: 3.0
15
14
  bundler-cache: true
16
15
  - name: Install gems
17
16
  run: |
data/.rubocop.yml CHANGED
@@ -2,7 +2,6 @@ inherit_gem:
2
2
  rubocop-shopify: rubocop.yml
3
3
 
4
4
  AllCops:
5
- TargetRubyVersion: 3.0
6
5
  NewCops: disable
7
6
  SuggestExtensions: false
8
7
  Exclude:
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.3.0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smart_todo (1.7.0)
4
+ smart_todo (1.8.0)
5
5
  prism (~> 0.15)
6
6
 
7
7
  GEM
@@ -13,35 +13,37 @@ GEM
13
13
  crack (0.4.5)
14
14
  rexml
15
15
  hashdiff (1.0.1)
16
- json (2.6.3)
16
+ json (2.7.1)
17
+ language_server-protocol (3.17.0.3)
17
18
  minitest (5.14.4)
18
- parallel (1.23.0)
19
- parser (3.2.2.3)
19
+ parallel (1.24.0)
20
+ parser (3.3.0.5)
20
21
  ast (~> 2.4.1)
21
22
  racc
22
23
  prism (0.17.0)
23
24
  public_suffix (4.0.6)
24
- racc (1.7.0)
25
+ racc (1.7.3)
25
26
  rainbow (3.1.1)
26
27
  rake (13.0.6)
27
- regexp_parser (2.8.1)
28
- rexml (3.2.5)
29
- rubocop (1.52.1)
28
+ regexp_parser (2.9.0)
29
+ rexml (3.2.6)
30
+ rubocop (1.62.1)
30
31
  json (~> 2.3)
32
+ language_server-protocol (>= 3.17.0)
31
33
  parallel (~> 1.10)
32
- parser (>= 3.2.2.3)
34
+ parser (>= 3.3.0.2)
33
35
  rainbow (>= 2.2.2, < 4.0)
34
36
  regexp_parser (>= 1.8, < 3.0)
35
37
  rexml (>= 3.2.5, < 4.0)
36
- rubocop-ast (>= 1.28.0, < 2.0)
38
+ rubocop-ast (>= 1.31.1, < 2.0)
37
39
  ruby-progressbar (~> 1.7)
38
40
  unicode-display_width (>= 2.4.0, < 3.0)
39
- rubocop-ast (1.29.0)
40
- parser (>= 3.2.1.0)
41
+ rubocop-ast (1.31.2)
42
+ parser (>= 3.3.0.4)
41
43
  rubocop-shopify (2.14.0)
42
44
  rubocop (~> 1.51)
43
45
  ruby-progressbar (1.13.0)
44
- unicode-display_width (2.4.2)
46
+ unicode-display_width (2.5.0)
45
47
  webmock (3.11.2)
46
48
  addressable (>= 2.3.6)
47
49
  crack (>= 0.3.2)
@@ -59,4 +61,4 @@ DEPENDENCIES
59
61
  webmock
60
62
 
61
63
  BUNDLED WITH
62
- 2.2.25
64
+ 2.5.7
data/dev.yml CHANGED
@@ -4,7 +4,7 @@ type:
4
4
  - ruby
5
5
 
6
6
  up:
7
- - ruby: 3.0.2
7
+ - ruby
8
8
  - bundler
9
9
 
10
10
  console:
@@ -39,9 +39,9 @@ module SmartTodo
39
39
  #
40
40
  # @see https://api.slack.com/methods/users.lookupByEmail
41
41
  def lookup_user_by_email(email)
42
- headers = { "Content-Type" => "application/x-www-form-urlencoded" }
43
-
44
- request(:get, "/api/users.lookupByEmail?email=#{CGI.escape(email)}", nil, headers)
42
+ headers = default_headers.merge("Content-Type" => "application/x-www-form-urlencoded")
43
+ request = Net::HTTP::Get.new("/api/users.lookupByEmail?email=#{CGI.escape(email)}", headers)
44
+ dispatch(request)
45
45
  end
46
46
 
47
47
  # Send a message to a Slack channel or to a user
@@ -55,7 +55,10 @@ module SmartTodo
55
55
  #
56
56
  # @see https://api.slack.com/methods/chat.postMessage
57
57
  def post_message(channel, text)
58
- request(:post, "/api/chat.postMessage", JSON.dump(channel: channel, text: text))
58
+ headers = default_headers
59
+ request = Net::HTTP::Post.new("/api/chat.postMessage", headers)
60
+ request.body = JSON.dump(channel: channel, text: text)
61
+ dispatch(request)
59
62
  end
60
63
 
61
64
  private
@@ -67,27 +70,19 @@ module SmartTodo
67
70
  #
68
71
  # @raise [Net::HTTPError] in case the request to Slack failed
69
72
  # @raise [SlackClient::Error] in case Slack returns a { ok: false } in the body
70
- def request(method, endpoint, data = nil, headers = {})
71
- response = case method
72
- when :post, :patch
73
- @client.public_send(method, endpoint, data, default_headers.merge(headers))
74
- else
75
- @client.public_send(method, endpoint, default_headers.merge(headers))
76
- end
73
+ def dispatch(request, max_attempts = 5)
74
+ response = @client.request(request)
75
+ attempts = 1
77
76
 
78
- slack_response!(response)
79
- end
77
+ while response.is_a?(Net::HTTPTooManyRequests) && attempts < max_attempts
78
+ sleep([Integer(response["Retry-After"]), 600].min)
79
+ response = @client.request(request)
80
+ attempts += 1
81
+ end
80
82
 
81
- # Check if the response to Slack was a 200 and the Slack API request was successful
82
- #
83
- # @param response [Net::HTTPResponse] a net Net::HTTPResponse subclass
84
- # (Net::HTTPOK, Net::HTTPNotFound ...)
85
- # @return [Hash]
86
- #
87
- # @raise [Net::HTTPError] in case the request to Slack failed
88
- # @raise [SlackClient::Error] in case Slack returns a { ok: false } in the body
89
- def slack_response!(response)
90
- raise(Net::HTTPError.new("Request to slack failed", response)) unless response.code_type < Net::HTTPSuccess
83
+ unless response.code_type < Net::HTTPSuccess
84
+ raise(Net::HTTPError.new("Request to slack failed", response))
85
+ end
91
86
 
92
87
  body = JSON.parse(response.body)
93
88
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SmartTodo
4
- VERSION = "1.7.0"
4
+ VERSION = "1.8.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_todo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-08 00:00:00.000000000 Z
11
+ date: 2024-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prism
@@ -97,6 +97,7 @@ files:
97
97
  - ".github/workflows/rubocop.yml"
98
98
  - ".gitignore"
99
99
  - ".rubocop.yml"
100
+ - ".ruby-version"
100
101
  - CODE_OF_CONDUCT.md
101
102
  - Gemfile
102
103
  - Gemfile.lock
@@ -147,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
148
  - !ruby/object:Gem::Version
148
149
  version: '0'
149
150
  requirements: []
150
- rubygems_version: 3.4.22
151
+ rubygems_version: 3.5.13
151
152
  signing_key:
152
153
  specification_version: 4
153
154
  summary: Enhance todo's comments in your codebase.