ruboty-packman 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: 68256f0d58eef17fb1ce4aa6adc1dd1b90f7b366280f51d58e59913d00d3b68c
4
- data.tar.gz: 1ae0dad8e9271590d1c3f1797db9a3cf0fdd40c85263901b0bf445f16e861808
3
+ metadata.gz: d66db31edf9ea582775545692a316457b10b68bb239b9357d3386144c7b74bf1
4
+ data.tar.gz: 2ca8314ece0feac2e6d93629d1e7aa5d3100101476d4dfd775c9ef07dcda393b
5
5
  SHA512:
6
- metadata.gz: eef3381f1e9a6bc0c778987848bfce640a3c547565c7b05cab3a9901ab44b6f19b8a9c6c65eba114faa3adcc176b587a7ccd1a11e3da3db229027b04f3f9695d
7
- data.tar.gz: 412b8a9d020b9808aba18558e0e6aee45370d5b50d8f42921f6f4f850cbf1bf53a95638cbfb509de5498e0a98fde346b07e60ad729e3d8b71c3187acea6f6192
6
+ metadata.gz: '08595c6d6d15666222d1d79dc5e910a18e559a9ab15bf188c6a482fb44cdac097207d99c4697d470088cbb41b2b979a3d5e3f7fa32bcb1b314c5c5e5d5623a19'
7
+ data.tar.gz: e2b9a821899172775d616b7ac732823d84ef1323dce0a7dcf6fe0fe3d0e65a7166114302d7f002b1bbe2e115704de405253f0841c8e763c84c6d3a6b02c77774
@@ -4,28 +4,38 @@ module Ruboty
4
4
  module Handlers
5
5
  class Packman < Base
6
6
  on(
7
- /packman add (?<organization>.+) (?<repository>.+)\z/,
8
- name: 'add',
9
- description: '[packman] add repository'
7
+ /packman register (?<organization>.+)\/(?<repository>.+)\z/,
8
+ name: 'register',
9
+ description: '[packman] register repository'
10
10
  )
11
11
 
12
12
  on(
13
- /packman pull-request (?<organization>.+) (?<repository>.+)\z/,
13
+ /packman pull-request (?<organization>.+)\/(?<repository>.+)\z/,
14
14
  name: 'pull_request',
15
15
  description: '[packman] library update'
16
16
  )
17
17
 
18
- def add(message)
19
- action_class(message).add
18
+ on(
19
+ /packman remove (?<organization>.+)\/(?<repository>.+)\z/,
20
+ name: 'remove',
21
+ description: '[packman] remove repository'
22
+ )
23
+
24
+ def register(message)
25
+ action_handler(message).register
20
26
  end
21
27
 
22
28
  def pull_request(message)
23
- action_class(message).pull_request
29
+ action_handler(message).pull_request
30
+ end
31
+
32
+ def remove(message)
33
+ action_handler(message).remove
24
34
  end
25
35
 
26
36
  private
27
37
 
28
- def action_class(message)
38
+ def action_handler(message)
29
39
  Ruboty::Packman::Actions::Packman.new(message)
30
40
  end
31
41
  end
@@ -4,30 +4,44 @@ module Ruboty
4
4
  class Packman < Ruboty::Actions::Base
5
5
  NAMESPACE = 'packman'
6
6
 
7
- def add
7
+ def register
8
8
  if repositories.include?(repo.full_name)
9
- message.reply("already added. #{repo.full_name}")
9
+ message.reply("already registered. #{repo.full_name}")
10
10
  return
11
11
  end
12
12
 
13
+ message.reply("registering...")
13
14
  repo.sync!
14
15
 
15
16
  repositories << repo.full_name
16
- message.reply("added! #{repo.full_name}")
17
+ message.reply("registered:tada: #{repo.full_name}")
17
18
  end
18
19
 
19
20
  def pull_request
20
21
  unless repositories.include?(repo.full_name)
21
- message.reply("invalid. #{repo.full_name}")
22
+ message.reply("not registered. please register #{repo.full_name}")
22
23
  return
23
24
  end
24
25
 
26
+ message.reply("please wait...")
25
27
  repo.sync!
26
28
  repo.bundle_update!
27
29
  repo.push!
28
- repo.pull_request!
30
+ url = repo.pull_request!
29
31
 
30
- message.reply("pull-requested! #{repo.full_name}")
32
+ message.reply("pull-requested:tada: #{url}")
33
+ end
34
+
35
+ def remove
36
+ unless repositories.include?(repo.full_name)
37
+ message.reply("not registered. #{repo.full_name}")
38
+ return
39
+ end
40
+
41
+ repo.clean!
42
+ repositories.delete(repo.full_name)
43
+
44
+ message.reply("removed. #{repo.full_name}")
31
45
  end
32
46
 
33
47
  private
@@ -43,17 +43,22 @@ module Ruboty
43
43
  end
44
44
 
45
45
  def pull_request!
46
- Octokit::Client.new(api_endpoint: api_endpoint, access_token: token).create_pull_request(
46
+ pr = Octokit::Client.new(api_endpoint: api_endpoint, access_token: token).create_pull_request(
47
47
  full_name,
48
48
  'master',
49
49
  branch_name,
50
50
  "bundle update #{Time.now.strftime('%Y-%m-%d %H:%M:%S')}",
51
51
  'Pull requested from [packman](https://github.com/kimromi/ruboty-packman).'
52
52
  )
53
+ pr[:html_url]
53
54
  rescue Octokit::UnprocessableEntity => e
54
55
  puts e
55
56
  end
56
57
 
58
+ def clean!
59
+ FileUtils.rm_rf(sync_directory) if cloned?
60
+ end
61
+
57
62
  private
58
63
 
59
64
  def repos_dir
@@ -1,5 +1,5 @@
1
1
  module Ruboty
2
2
  module Packman
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruboty-packman
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
  - kimromi