ruboty-gitlab 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +23 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/ruboty/gitlab.rb +9 -0
- data/lib/ruboty/gitlab/actions/base.rb +76 -0
- data/lib/ruboty/gitlab/actions/create_issue.rb +36 -0
- data/lib/ruboty/gitlab/actions/remember.rb +26 -0
- data/lib/ruboty/gitlab/version.rb +5 -0
- data/lib/ruboty/handlers/gitlab.rb +27 -0
- data/ruboty-gitlab.gemspec +26 -0
- metadata +117 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 6590533abe748dc2bfe011e06b36db34c9fc205e
|
|
4
|
+
data.tar.gz: b3502937b33bfb98f35251c6f90929a8d6b4991d
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 4d8964543e3df3251732f39b82b5a91498b57e5367aba915f67751b3211fe465795376961308030da42725cfa14e1ea8363395f96ccbd4911dcd520f36bda01a
|
|
7
|
+
data.tar.gz: b2020b7cd38a1432f4f7c5341e247d57ed18710f577e49d3efc5455f58adca68c4f5e85409e05cf96f1d59f91654a161c365934042e64e141953f409b46343f4
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 fakestarbaby
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Ruboty::Gitlab
|
|
2
|
+
|
|
3
|
+
Manage GitLab via Ruboty.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```ruby
|
|
8
|
+
# Gemfile
|
|
9
|
+
gem "ruboty-gitlab"
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
@ruboty create gitlab issue "<title>" on <project>[\n<description>] - Create a new issue
|
|
16
|
+
@ruboty remember my gitlab token <token> - Remember sender's GitLab private token
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## ENV
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
GITLAB_URL - GitLab URL (e.g. https://gitlab.example.co.jp)
|
|
23
|
+
```
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "ruboty/gitlab"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
require "active_support/core_ext/object/blank"
|
|
2
|
+
require "gitlab"
|
|
3
|
+
|
|
4
|
+
require "ruboty"
|
|
5
|
+
require "ruboty/gitlab/actions/base"
|
|
6
|
+
require "ruboty/gitlab/actions/create_issue"
|
|
7
|
+
require "ruboty/gitlab/actions/remember"
|
|
8
|
+
require "ruboty/gitlab/version"
|
|
9
|
+
require "ruboty/handlers/gitlab"
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
module Ruboty
|
|
2
|
+
module Gitlab
|
|
3
|
+
module Actions
|
|
4
|
+
class Base
|
|
5
|
+
NAMESPACE = "gitlab"
|
|
6
|
+
|
|
7
|
+
attr_reader :message
|
|
8
|
+
|
|
9
|
+
def initialize(message)
|
|
10
|
+
@message = message
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def private_tokens
|
|
16
|
+
message.robot.brain.data[NAMESPACE] ||= {}
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def require_private_token
|
|
20
|
+
message.reply("I don't know your gitlab private token")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def has_private_token?
|
|
24
|
+
!!private_token
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def private_token
|
|
28
|
+
@private_token ||= private_tokens[sender_name]
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def sender_name
|
|
32
|
+
message.from_name
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def projects
|
|
36
|
+
message.robot.brain.data[NAMESPACE][:projects] ||= {}
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def exists_project?
|
|
40
|
+
project.present?
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def search_project
|
|
44
|
+
client.search_projects(given_project).first
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def project
|
|
48
|
+
projects[given_project] ||= search_project
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def given_project
|
|
52
|
+
message[:project]
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def client
|
|
56
|
+
::Gitlab::Client.new(client_options)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def client_options
|
|
60
|
+
client_options_with_nil_value.reject {|key, value| value.nil? }
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def client_options_with_nil_value
|
|
64
|
+
{
|
|
65
|
+
endpoint: gitlab_endpoint_url,
|
|
66
|
+
private_token: private_token,
|
|
67
|
+
}
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def gitlab_endpoint_url
|
|
71
|
+
ENV["GITLAB_URL"] + "/api/v3"
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module Ruboty
|
|
2
|
+
module Gitlab
|
|
3
|
+
module Actions
|
|
4
|
+
class CreateIssue < Base
|
|
5
|
+
def call
|
|
6
|
+
case
|
|
7
|
+
when !has_private_token?
|
|
8
|
+
require_private_token
|
|
9
|
+
when !exists_project?
|
|
10
|
+
message.reply("Could not find that project")
|
|
11
|
+
else
|
|
12
|
+
create_issue
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def create_issue
|
|
19
|
+
message.reply("Created #{project.web_url}/issues/#{issue.iid}")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def issue
|
|
23
|
+
client.create_issue(project.id, given_title, { description: given_body })
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def given_title
|
|
27
|
+
message[:title]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def given_body
|
|
31
|
+
message[:description] || ""
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module Ruboty
|
|
2
|
+
module Gitlab
|
|
3
|
+
module Actions
|
|
4
|
+
class Remember < Base
|
|
5
|
+
def call
|
|
6
|
+
remember
|
|
7
|
+
report
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
def report
|
|
13
|
+
message.reply("Remembered #{sender_name}'s gitlab private token")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def remember
|
|
17
|
+
private_tokens[sender_name] = given_private_token
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def given_private_token
|
|
21
|
+
message[:token]
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module Ruboty
|
|
2
|
+
module Handlers
|
|
3
|
+
class Gitlab < Base
|
|
4
|
+
env :GITLAB_URL, "GITLAB_URL - GitLab URL (e.g. https://gitlab.example.co.jp)"
|
|
5
|
+
|
|
6
|
+
on(
|
|
7
|
+
/create gitlab issue "(?<title>.+)" on (?<project>.+)(?:\n(?<description>[\s\S]+))?\z/,
|
|
8
|
+
name: "create_issue",
|
|
9
|
+
description: "Create a new issue",
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
on(
|
|
13
|
+
/remember my gitlab token (?<token>.+)\z/,
|
|
14
|
+
name: "remember",
|
|
15
|
+
description: "Remember sender's GitLab private token",
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
def create_issue(message)
|
|
19
|
+
Ruboty::Gitlab::Actions::CreateIssue.new(message).call
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def remember(message)
|
|
23
|
+
Ruboty::Gitlab::Actions::Remember.new(message).call
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'ruboty/gitlab/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "ruboty-gitlab"
|
|
8
|
+
spec.version = Ruboty::Gitlab::VERSION
|
|
9
|
+
spec.authors = ["fakestarbaby"]
|
|
10
|
+
spec.email = ["fakestarbaby@gmail.com"]
|
|
11
|
+
spec.summary = %q{Manage GitLab via Ruboty.}
|
|
12
|
+
spec.description = spec.summary
|
|
13
|
+
spec.homepage = "https://github.com/fakestarbaby/ruboty-gitlab"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
+
spec.require_paths = ['lib']
|
|
20
|
+
|
|
21
|
+
spec.add_dependency "ruboty"
|
|
22
|
+
spec.add_dependency "gitlab"
|
|
23
|
+
|
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
26
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: ruboty-gitlab
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.2
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- fakestarbaby
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-01-13 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: ruboty
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: gitlab
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: bundler
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '1.11'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '1.11'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rake
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '10.0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '10.0'
|
|
69
|
+
description: Manage GitLab via Ruboty.
|
|
70
|
+
email:
|
|
71
|
+
- fakestarbaby@gmail.com
|
|
72
|
+
executables:
|
|
73
|
+
- console
|
|
74
|
+
- setup
|
|
75
|
+
extensions: []
|
|
76
|
+
extra_rdoc_files: []
|
|
77
|
+
files:
|
|
78
|
+
- ".gitignore"
|
|
79
|
+
- Gemfile
|
|
80
|
+
- LICENSE.txt
|
|
81
|
+
- README.md
|
|
82
|
+
- Rakefile
|
|
83
|
+
- bin/console
|
|
84
|
+
- bin/setup
|
|
85
|
+
- lib/ruboty/gitlab.rb
|
|
86
|
+
- lib/ruboty/gitlab/actions/base.rb
|
|
87
|
+
- lib/ruboty/gitlab/actions/create_issue.rb
|
|
88
|
+
- lib/ruboty/gitlab/actions/remember.rb
|
|
89
|
+
- lib/ruboty/gitlab/version.rb
|
|
90
|
+
- lib/ruboty/handlers/gitlab.rb
|
|
91
|
+
- ruboty-gitlab.gemspec
|
|
92
|
+
homepage: https://github.com/fakestarbaby/ruboty-gitlab
|
|
93
|
+
licenses:
|
|
94
|
+
- MIT
|
|
95
|
+
metadata: {}
|
|
96
|
+
post_install_message:
|
|
97
|
+
rdoc_options: []
|
|
98
|
+
require_paths:
|
|
99
|
+
- lib
|
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
101
|
+
requirements:
|
|
102
|
+
- - ">="
|
|
103
|
+
- !ruby/object:Gem::Version
|
|
104
|
+
version: '0'
|
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
|
+
requirements:
|
|
107
|
+
- - ">="
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: '0'
|
|
110
|
+
requirements: []
|
|
111
|
+
rubyforge_project:
|
|
112
|
+
rubygems_version: 2.4.5.1
|
|
113
|
+
signing_key:
|
|
114
|
+
specification_version: 4
|
|
115
|
+
summary: Manage GitLab via Ruboty.
|
|
116
|
+
test_files: []
|
|
117
|
+
has_rdoc:
|