pr-notifier 0.1.0 → 0.2.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
  SHA1:
3
- metadata.gz: 5fbf1d82c388d4da73caffb272ccb1b50027bf4f
4
- data.tar.gz: 8fae66044f989a72da6736589392d7e167df7af3
3
+ metadata.gz: 4d06a9da2304c7b76ebbfa6e11c2b92b9a7305aa
4
+ data.tar.gz: 91d7233d66581839c23fafd37ffaa8bd97110dae
5
5
  SHA512:
6
- metadata.gz: 5dd418cff694a22ac7df7af55cda916dc76fb2670db3e3d5438e47655c58b389eea5fd176c757d9f00df5dadbce31ec0c380c910f2097791b99934a071943938
7
- data.tar.gz: 1d3b5534b97c64da45ea56a78be003f045b2b63c0e382cc2f5d827a1d0b0674612dbad263574b0d426ae348d6456ab8f522a93ce37f38472e8160159933f6ec7
6
+ metadata.gz: 2effbc19a67d8a331cc07685a911bc74dc11bfbbc34c388b25eb7c526861e1823337075da988305fae1608895d84a745b3a44b5166a78297260be5ff21a442c6
7
+ data.tar.gz: 4a8c2ad6f60638cfed097b3d8384569b3e2e8513191401ca8fd65d8d6aabbe544b812b9d17022206d92018ece404822517561598a99b1c66689c890fa994473e
data/bin/pr-notifier CHANGED
@@ -4,6 +4,9 @@ require "pr-notifier"
4
4
  require "optparse"
5
5
 
6
6
  OptionParser.new do |opts|
7
+ opts.on('-d', '--dry-run', 'DRY RUN') do |v|
8
+ @dry_run = v
9
+ end
7
10
  opts.on('-g', '--gh-token VALUE', 'GitHub access token ENV:GH_TOKEN') do |v|
8
11
  @gh_token = v
9
12
  end
@@ -31,4 +34,5 @@ PrNotifier.run(
31
34
  channel: @channel,
32
35
  username: @username,
33
36
  template: @template,
37
+ dry_run: @dry_run,
34
38
  )
data/lib/pr-notifier.rb CHANGED
@@ -5,7 +5,7 @@ require "slack-notifier"
5
5
 
6
6
  module PrNotifier
7
7
  module_function
8
- def run(gh_token: nil, repos: nil, webhook_url: nil, channel: nil, username: nil, template: nil)
8
+ def run(gh_token: nil, repos: nil, webhook_url: nil, channel: nil, username: nil, template: nil, dry_run: false)
9
9
  gh_token ||= ENV['GH_TOKEN']
10
10
  repos = (repos || ENV['GH_REPOS'])&.split(',')
11
11
  webhook_url ||= ENV["SLACK_WEBHOOK_URL"]
@@ -20,8 +20,13 @@ module PrNotifier
20
20
  gh_client = Github.new(access_token: gh_token)
21
21
  prs = repos.each_with_object([]) { |repo, prs| prs.concat(gh_client.fetch_prs_by(repo)) }
22
22
 
23
- notifier = Slack::Notifier.new(webhook_url, channel: channel, username: username)
24
- notifier.ping(message(pull_requests: prs))
23
+ send_message = message(pull_requests: prs)
24
+ if dry_run
25
+ puts send_message
26
+ else
27
+ notifier = Slack::Notifier.new(webhook_url, channel: channel, username: username)
28
+ notifier.ping(message(pull_requests: prs))
29
+ end
25
30
  end
26
31
 
27
32
  def message(pull_requests:)
@@ -1,3 +1,3 @@
1
1
  module PrNotifier
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pr-notifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - hatappi