senju 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -5
- data/exe/senju +1 -108
- data/lib/senju.rb +2 -1
- data/lib/senju/command.rb +97 -0
- data/lib/senju/diff.rb +18 -0
- data/lib/senju/gitlab.rb +9 -3
- data/lib/senju/init.rb +6 -0
- data/lib/senju/projects.rb +47 -0
- data/lib/senju/repository.rb +2 -15
- data/lib/senju/version.rb +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc49b90adbca31b1b5abd87f73e36b7f102a17bbb0604019abfbac29c6fb43f3
|
4
|
+
data.tar.gz: 78acead080465e4a637bbb8bd249c872499a50b0f54e35e56704819fea273cbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f2f7906d336c0a6918cda5b66611da23a4955f8239440299776f1d100ea5c3653e6091b18d0140f8271568e2e3ab0ada68000be54ca07252f606f17c05ae998
|
7
|
+
data.tar.gz: 24fd3b009b5ef2ac38c3bb28f231d2500cd9583d42f1ab79939d45d3c450bb5a5c17cbdf2fed1c38ca36e6593fac8e50bae3d7cfe6bc59955769a666fc48ba8d
|
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# Senju
|
2
2
|
|
3
|
-
|
3
|
+
Multi issue management serivces integration platform (CLI)
|
4
|
+
|
5
|
+
* Github
|
6
|
+
* GitLab
|
7
|
+
* Trello
|
4
8
|
|
5
9
|
## Installation
|
6
10
|
|
@@ -20,16 +24,18 @@ Edit `~/.senju/credentials`.
|
|
20
24
|
<type>: <access token>
|
21
25
|
```
|
22
26
|
|
23
|
-
###
|
27
|
+
### Projects
|
24
28
|
|
25
|
-
Edit `~/.senju/
|
29
|
+
Edit `~/.senju/projects`.
|
26
30
|
|
27
31
|
```
|
28
|
-
<
|
29
|
-
repo: <team/repository
|
32
|
+
<project name>:
|
33
|
+
repo: <team/repository>
|
30
34
|
type: <repository type>
|
31
35
|
```
|
32
36
|
|
37
|
+
or interactively `$ senju add <name>`.
|
38
|
+
|
33
39
|
## Usage
|
34
40
|
|
35
41
|
All repository issues.
|
data/exe/senju
CHANGED
@@ -1,111 +1,4 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require "bundler/setup"
|
3
3
|
require "senju"
|
4
|
-
require "
|
5
|
-
require "colorize"
|
6
|
-
require "tty-markdown"
|
7
|
-
require "rumoji"
|
8
|
-
|
9
|
-
COLORS = %w{green blue light_blue}
|
10
|
-
|
11
|
-
def link_to(text, url)
|
12
|
-
"\e]8;;#{url}\e\\#{text}\e]8;;\e\\"
|
13
|
-
end
|
14
|
-
|
15
|
-
def print_issue(issue)
|
16
|
-
print link_to("##{issue.no} ".colorize(:blue).bold, issue.url) + issue.title
|
17
|
-
if issue.labels.length != 0
|
18
|
-
issue.labels.each do |label|
|
19
|
-
print " [#{label}]".colorize(:light_blue)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
print "\n"
|
23
|
-
end
|
24
|
-
|
25
|
-
def color_patch(patch)
|
26
|
-
patch.split("\n").map do |line|
|
27
|
-
case line
|
28
|
-
when /^(---|\+\+\+|\\\\)/
|
29
|
-
"\033[90m#{line.chomp}\033[0m"
|
30
|
-
when /^\+/
|
31
|
-
"\033[32m#{line.chomp}\033[0m"
|
32
|
-
when /^-/
|
33
|
-
"\033[31m#{line.chomp}\033[0m"
|
34
|
-
when /^@@/
|
35
|
-
"\033[36m#{line.chomp}\033[0m"
|
36
|
-
else
|
37
|
-
line.chomp
|
38
|
-
end
|
39
|
-
end.join("\n") + "\n"
|
40
|
-
end
|
41
|
-
|
42
|
-
def exec(repo, command, option)
|
43
|
-
puts "================= #{repo.name} ====================".colorize(:green).bold
|
44
|
-
|
45
|
-
if command.to_i != 0
|
46
|
-
issue = repo.issue(command.to_i)
|
47
|
-
print_issue issue
|
48
|
-
puts "Opened by #{issue.owner} at #{issue.created_at}"
|
49
|
-
|
50
|
-
puts "\n" + Rumoji.decode(TTY::Markdown.parse(issue.body))
|
51
|
-
|
52
|
-
if option == "-v" || option == "comments"
|
53
|
-
repo.comments(command.to_i).each do |comment|
|
54
|
-
#color = COLORS[comment.owner[0].ord % 3]
|
55
|
-
puts "\nComment: #{comment.owner} at #{comment.created_at}".bold
|
56
|
-
puts Rumoji.decode(TTY::Markdown.parse(comment.body))
|
57
|
-
end
|
58
|
-
elsif option == "diff"
|
59
|
-
repo.changes(command.to_i).each do |change|
|
60
|
-
puts "\n#{change.filename}".bold
|
61
|
-
puts color_patch(change.patch)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
return
|
66
|
-
end
|
67
|
-
|
68
|
-
case command
|
69
|
-
when "issues"
|
70
|
-
repo.issues.each do |issue|
|
71
|
-
print_issue(issue)
|
72
|
-
end
|
73
|
-
when "mr"
|
74
|
-
command = option
|
75
|
-
option = ARGV[3]
|
76
|
-
issue = repo.pull_request(command.to_i)
|
77
|
-
print_issue issue
|
78
|
-
puts "Opened by #{issue.owner} at #{issue.created_at}"
|
79
|
-
|
80
|
-
puts "\n" + Rumoji.decode(TTY::Markdown.parse(issue.body))
|
81
|
-
|
82
|
-
if option == "-v" || option == "comments"
|
83
|
-
repo.comments(command.to_i).each do |comment|
|
84
|
-
#color = COLORS[comment.owner[0].ord % 3]
|
85
|
-
puts "\nComment: #{comment.owner} at #{comment.created_at}".bold
|
86
|
-
puts Rumoji.decode(TTY::Markdown.parse(comment.body))
|
87
|
-
end
|
88
|
-
elsif option == "diff"
|
89
|
-
repo.changes(command.to_i).each do |change|
|
90
|
-
puts "\n#{change.filename}".bold
|
91
|
-
puts color_patch(change.patch)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
when "pr"
|
95
|
-
repo.pull_requests.each do |issue|
|
96
|
-
print_issue(issue)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
repo = ARGV[0]
|
102
|
-
command = ARGV[1] || "issues"
|
103
|
-
option = ARGV[2]
|
104
|
-
|
105
|
-
if repo
|
106
|
-
exec(Senju::Repository.find(repo), command, option)
|
107
|
-
else
|
108
|
-
Senju::Repository.all.each do |repo|
|
109
|
-
exec(repo, command, option)
|
110
|
-
end
|
111
|
-
end
|
4
|
+
require "senju/command"
|
data/lib/senju.rb
CHANGED
@@ -0,0 +1,97 @@
|
|
1
|
+
require "ap"
|
2
|
+
require "colorize"
|
3
|
+
require "tty-markdown"
|
4
|
+
require "rumoji"
|
5
|
+
require "senju/diff"
|
6
|
+
require "senju/init"
|
7
|
+
|
8
|
+
COLORS = %w{green blue light_blue}
|
9
|
+
|
10
|
+
def link_to(text, url)
|
11
|
+
"\e]8;;#{url}\e\\#{text}\e]8;;\e\\"
|
12
|
+
end
|
13
|
+
|
14
|
+
def print_issue(issue)
|
15
|
+
print link_to("##{issue.no} ".colorize(:blue).bold, issue.url) + issue.title
|
16
|
+
if issue.labels.length != 0
|
17
|
+
issue.labels.each do |label|
|
18
|
+
print " [#{label}]".colorize(:light_blue)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
print "\n"
|
22
|
+
end
|
23
|
+
|
24
|
+
def exec(repo, command, option)
|
25
|
+
puts "================= #{repo.name} ====================".colorize(:green).bold
|
26
|
+
|
27
|
+
if command.to_i != 0
|
28
|
+
issue = repo.issue(command.to_i)
|
29
|
+
print_issue issue
|
30
|
+
puts "Opened by #{issue.owner} at #{issue.created_at}"
|
31
|
+
|
32
|
+
puts "\n" + Rumoji.decode(TTY::Markdown.parse(issue.body))
|
33
|
+
|
34
|
+
if option == "-v" || option == "comments"
|
35
|
+
repo.comments(command.to_i).each do |comment|
|
36
|
+
#color = COLORS[comment.owner[0].ord % 3]
|
37
|
+
puts "\nComment: #{comment.owner} at #{comment.created_at}".bold
|
38
|
+
puts Rumoji.decode(TTY::Markdown.parse(comment.body))
|
39
|
+
end
|
40
|
+
elsif option == "diff"
|
41
|
+
repo.changes(command.to_i).each do |change|
|
42
|
+
puts "\n#{change.filename}".bold
|
43
|
+
puts Senju::Diff.print(change.patch)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
return
|
48
|
+
end
|
49
|
+
|
50
|
+
case command
|
51
|
+
when "issues"
|
52
|
+
repo.issues.each do |issue|
|
53
|
+
print_issue(issue)
|
54
|
+
end
|
55
|
+
when "mr"
|
56
|
+
command = option
|
57
|
+
option = ARGV[3]
|
58
|
+
issue = repo.pull_request(command.to_i)
|
59
|
+
print_issue issue
|
60
|
+
puts "Opened by #{issue.owner} at #{issue.created_at}"
|
61
|
+
|
62
|
+
puts "\n" + Rumoji.decode(TTY::Markdown.parse(issue.body))
|
63
|
+
|
64
|
+
if option == "-v" || option == "comments"
|
65
|
+
repo.comments(command.to_i).each do |comment|
|
66
|
+
#color = COLORS[comment.owner[0].ord % 3]
|
67
|
+
puts "\nComment: #{comment.owner} at #{comment.created_at}".bold
|
68
|
+
puts Rumoji.decode(TTY::Markdown.parse(comment.body))
|
69
|
+
end
|
70
|
+
elsif option == "diff"
|
71
|
+
repo.changes(command.to_i).each do |change|
|
72
|
+
puts "\n#{change.filename}".bold
|
73
|
+
puts Senju::Diff.print(change.patch)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
when "pr"
|
77
|
+
repo.pull_requests.each do |issue|
|
78
|
+
print_issue(issue)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
repo = ARGV[0]
|
84
|
+
command = ARGV[1] || "issues"
|
85
|
+
option = ARGV[2]
|
86
|
+
|
87
|
+
if ARGV[0] == "init"
|
88
|
+
Senju.init
|
89
|
+
elsif ARGV[0] == "add"
|
90
|
+
Senju::Projects.add_interactive(ARGV[1])
|
91
|
+
elsif repo
|
92
|
+
exec(Senju::Repository.find(repo), command, option)
|
93
|
+
else
|
94
|
+
Senju::Repository.all.each do |repo|
|
95
|
+
exec(repo, command, option)
|
96
|
+
end
|
97
|
+
end
|
data/lib/senju/diff.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
class Senju::Diff
|
2
|
+
def self.print(patch)
|
3
|
+
patch.split("\n").map do |line|
|
4
|
+
case line
|
5
|
+
when /^(---|\+\+\+|\\\\)/
|
6
|
+
"\033[90m#{line.chomp}\033[0m"
|
7
|
+
when /^\+/
|
8
|
+
"\033[32m#{line.chomp}\033[0m"
|
9
|
+
when /^-/
|
10
|
+
"\033[31m#{line.chomp}\033[0m"
|
11
|
+
when /^@@/
|
12
|
+
"\033[36m#{line.chomp}\033[0m"
|
13
|
+
else
|
14
|
+
line.chomp
|
15
|
+
end
|
16
|
+
end.join("\n") + "\n"
|
17
|
+
end
|
18
|
+
end
|
data/lib/senju/gitlab.rb
CHANGED
@@ -2,9 +2,15 @@ require 'gitlab'
|
|
2
2
|
class Senju::Gitlab
|
3
3
|
attr_reader :client
|
4
4
|
|
5
|
-
def initialize(
|
6
|
-
|
7
|
-
|
5
|
+
def initialize(access_token_or_hash)
|
6
|
+
if access_token_or_hash.is_a? Hash
|
7
|
+
options = access_token_or_hash
|
8
|
+
endpoint ||= "https://#{options["host"]}/api/v4"
|
9
|
+
@client = Gitlab.client(endpoint: endpoint, private_token: options["token"])
|
10
|
+
else
|
11
|
+
endpoint ||= "https://gitlab.com/api/v4"
|
12
|
+
@client = Gitlab.client(endpoint: endpoint, private_token: access_token)
|
13
|
+
end
|
8
14
|
end
|
9
15
|
|
10
16
|
def method_missing(method, *args, &block)
|
data/lib/senju/init.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
class Senju::Projects
|
3
|
+
PATH = Dir.home + '/.senju/projects'
|
4
|
+
|
5
|
+
def self.load
|
6
|
+
if File.exist? PATH
|
7
|
+
@data = YAML.load_file(PATH)
|
8
|
+
else
|
9
|
+
@data = {}
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.write
|
14
|
+
YAML.dump(@data, File.open(PATH, 'w'))
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.data
|
18
|
+
self.load
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.[](conf)
|
22
|
+
data[conf]
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.[]=(name, table)
|
26
|
+
data[name] = table
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.add_interactive(name)
|
30
|
+
print "Repository type [github, gitlab, trello]: "
|
31
|
+
|
32
|
+
type = STDIN.gets.chomp
|
33
|
+
case type
|
34
|
+
when "github", "gitlab"
|
35
|
+
print "Repository path (team/repository): "
|
36
|
+
repo = STDIN.gets.chomp
|
37
|
+
when "trello"
|
38
|
+
print "board id (like aBcDeF1234): "
|
39
|
+
repo = STDIN.gets.chomp
|
40
|
+
end
|
41
|
+
|
42
|
+
self[name] = { "repo" => repo, "type" => type }
|
43
|
+
write
|
44
|
+
|
45
|
+
print "Senju project add successfly.\n".colorize(:green)
|
46
|
+
end
|
47
|
+
end
|
data/lib/senju/repository.rb
CHANGED
@@ -1,21 +1,8 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
class Senju::Repos
|
3
|
-
attr_reader :data
|
4
|
-
def initialize(filepath = nil)
|
5
|
-
filepath ||= Dir.home + '/.senju/repos'
|
6
|
-
@data = YAML.load_file(filepath)
|
7
|
-
end
|
8
|
-
|
9
|
-
def [](conf)
|
10
|
-
@data[conf]
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
1
|
class Senju::Repository
|
15
2
|
attr_reader :name, :options, :type
|
16
3
|
|
17
4
|
def self.all
|
18
|
-
Senju::
|
5
|
+
Senju::Projects.data.map do |repository, config|
|
19
6
|
new(repository, config)
|
20
7
|
end
|
21
8
|
end
|
@@ -25,7 +12,7 @@ class Senju::Repository
|
|
25
12
|
end
|
26
13
|
|
27
14
|
def self.find(name)
|
28
|
-
new(name, Senju::
|
15
|
+
new(name, Senju::Projects[name])
|
29
16
|
end
|
30
17
|
|
31
18
|
def initialize(name, options)
|
data/lib/senju/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: senju
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akira SUENAMI
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|
@@ -169,11 +169,15 @@ files:
|
|
169
169
|
- exe/senju
|
170
170
|
- lib/senju.rb
|
171
171
|
- lib/senju/change.rb
|
172
|
+
- lib/senju/command.rb
|
172
173
|
- lib/senju/comment.rb
|
173
174
|
- lib/senju/credentials.rb
|
175
|
+
- lib/senju/diff.rb
|
174
176
|
- lib/senju/github.rb
|
175
177
|
- lib/senju/gitlab.rb
|
178
|
+
- lib/senju/init.rb
|
176
179
|
- lib/senju/issue.rb
|
180
|
+
- lib/senju/projects.rb
|
177
181
|
- lib/senju/repository.rb
|
178
182
|
- lib/senju/trello.rb
|
179
183
|
- lib/senju/version.rb
|
@@ -198,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
202
|
version: '0'
|
199
203
|
requirements: []
|
200
204
|
rubyforge_project:
|
201
|
-
rubygems_version: 2.7.
|
205
|
+
rubygems_version: 2.7.7
|
202
206
|
signing_key:
|
203
207
|
specification_version: 4
|
204
208
|
summary: Transparent wrapper of some task management and collabolation tools.
|