solicit 0.1.3 → 0.1.4

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: f5b1cad9b91d13d346961819928a674b6824888f0e818158fbbdb7704d89baa9
4
- data.tar.gz: 0ac5da6eaf980b98278586226619c5588ae079862a1556be2c42b061a842c97a
3
+ metadata.gz: 28afc0d984a9b486938fd856dfcc52bd5c41cb3efd805fbe971f0244a2a148a9
4
+ data.tar.gz: 32c9c9b211bae525eccc274d81f5ecd474e7058811e72960c4182aec2e0c9dfd
5
5
  SHA512:
6
- metadata.gz: 0bf4790797bfbc9ff95d9a5d0b210b5cf7965286f83f27d89be6ee3276200a8bab430950448d08bbbf4e14c3fce1b4638474dfabb4e366d1144b08ce930f3508
7
- data.tar.gz: 33060e277208026d64bf1b38bcd3ba25a00706f7e544cc4fa62115d058250b82187e0e1f4c9b8c63c710ba7fff6c5b14391b6175e00162eb8435f803fde2a5a9
6
+ metadata.gz: 6a91c4ca2760f2c77d3d59b75fc16f9237fda4562e9db9fedbbaeb592fb0fc7c8350e75c784955c27c50efe2f42f0eb98b5c2a843c04291f95cca3555ae3c05b
7
+ data.tar.gz: db2294ee3ebd39beaffac1882dd49bf75e6b5cbed233f95de41e4ed66dcea1ed7555fb52a950f0040ec7679be34f075dab48b68b82b17e9c28b66b291b414b44
@@ -15,7 +15,7 @@ module Solicit
15
15
  def notify
16
16
  PostToSlack.perform(
17
17
  url: Solicit.slack_webhook_url,
18
- channel: Solicit.labels_map[payload.dig(:label, :name).to_sym],
18
+ channel: Solicit.labels_map.stringify_keys[payload.dig(:label, :name).to_s],
19
19
  username: Solicit.slack_username,
20
20
  payload: payload
21
21
  )
@@ -34,9 +34,11 @@ module Solicit
34
34
  end
35
35
 
36
36
  def ensure_can_notify
37
+ label = payload.dig(:label, :name).to_s
37
38
  head :ok unless request_is_from_github? &&
38
39
  payload[:action] == 'labeled' &&
39
- Solicit.labels_map.key?(payload.dig(:label, :name).to_sym) &&
40
+ Solicit.labels_map.stringify_keys.key?(label) &&
41
+ Solicit.needs_more_assignees.call(payload[:pull_request], label) &&
40
42
  payload.dig(:pull_request, :number) &&
41
43
  payload.dig(:repository, :url)
42
44
  end
@@ -1,24 +1,27 @@
1
1
  module Solicit
2
2
  class PostToSlack
3
+ attr_reader :text
4
+
3
5
  def initialize(url:, channel:, username:, payload:)
4
6
  @url = url
5
7
  @channel = channel
6
8
  @username = username
7
9
  @payload = payload
10
+ @text = I18n.t(:"engines.solicit.title", title_options)
8
11
  end
9
12
 
10
13
  def self.perform(*args)
11
- new(*args).perform
14
+ new(*args).tap(&:perform)
12
15
  end
13
16
 
14
17
  def perform
15
18
  Slack::Notifier.new(@url, channel: @channel, username: @username).ping(
16
- text: I18n.t(:"engines.solicit.title", title_options),
19
+ text: text,
17
20
  attachments: [{
18
21
  title: I18n.t(:"engines.solicit.review"),
19
22
  callback_id: callback_id,
20
23
  color: :warning,
21
- actions: Array(claim_action),
24
+ actions: [claim_action],
22
25
  }]
23
26
  )
24
27
  end
@@ -27,9 +30,10 @@ module Solicit
27
30
 
28
31
  def title_options
29
32
  {
30
- link: @payload.dig(:pull_request, :html_url),
31
- title: @payload.dig(:pull_request, :title),
32
- label: @payload.dig(:label, :name),
33
+ author: author_name,
34
+ link: @payload.dig(:pull_request, :html_url),
35
+ title: @payload.dig(:pull_request, :title),
36
+ label: @payload.dig(:label, :name),
33
37
  }
34
38
  end
35
39
 
@@ -50,5 +54,11 @@ module Solicit
50
54
  value: @payload.dig(:label, :name),
51
55
  }
52
56
  end
57
+
58
+ def author_name
59
+ Solicit.contributors_map.detect do |_, value|
60
+ value[:handle] == @payload.dig(:sender, :login)
61
+ end&.dig(1, 'name') || I18n.t(:"engines.solicit.someone")
62
+ end
53
63
  end
54
64
  end
@@ -4,4 +4,5 @@ en:
4
4
  volunteer: "%{name} has volunteered! :%{emoji}:"
5
5
  claim: "I'll do it!"
6
6
  review: "Review this PR"
7
- title: "PR <%{link}|%{title}> now has a %{label} label!"
7
+ someone: "Someone"
8
+ title: "%{author} has added a %{label} label to a PR: <%{link}|%{title}>"
@@ -1,3 +1,3 @@
1
1
  module Solicit
2
- VERSION = "0.1.3"
2
+ VERSION = '0.1.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solicit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Optimal Workshop
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-16 00:00:00.000000000 Z
11
+ date: 2019-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -162,8 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
162
  - !ruby/object:Gem::Version
163
163
  version: '0'
164
164
  requirements: []
165
- rubyforge_project:
166
- rubygems_version: 2.7.8
165
+ rubygems_version: 3.0.3
167
166
  signing_key:
168
167
  specification_version: 4
169
168
  summary: Solicit reviewers for your github pull requests on Slack