jirack 0.1.0
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 +46 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +58 -0
- data/LICENSE.txt +21 -0
- data/README.md +69 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/jirack +10 -0
- data/bin/setup +8 -0
- data/exe/jirack +7 -0
- data/jirack.gemspec +41 -0
- data/lib/jirack.rb +10 -0
- data/lib/jirack/command.rb +139 -0
- data/lib/jirack/credential.rb +54 -0
- data/lib/jirack/issue_extension.rb +26 -0
- data/lib/jirack/sprint.rb +51 -0
- data/lib/jirack/status_extension.rb +18 -0
- data/lib/jirack/version.rb +3 -0
- metadata +150 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 133170d577ed5d1bfe19958e9517beca7dafd130
|
|
4
|
+
data.tar.gz: 43c53ca37d6f07320b8443b35fd4256a5eb597d4
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 9662ccdc4c0b79ce3d5ea8d7c7135092ee704aaa1a19f3dc17d2414250ecd1e92a86d73d55ace7a64276e63bb40540f99fdc6662c88cc1929314e5e355216ef0
|
|
7
|
+
data.tar.gz: 0a33598287be0ea0e323c3c939334136dbfd8feec1bcd8ee193ffadabcfa094fe43f0a2b65d75c59cdc53488be115a0f974cf3bd4827d1b279fe542ca63acf41
|
data/.gitignore
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/.bundle/
|
|
2
|
+
/.yardoc
|
|
3
|
+
/_yardoc/
|
|
4
|
+
/coverage/
|
|
5
|
+
/doc/
|
|
6
|
+
/pkg/
|
|
7
|
+
/spec/reports/
|
|
8
|
+
/tmp/
|
|
9
|
+
|
|
10
|
+
# rspec failure tracking
|
|
11
|
+
.rspec_status
|
|
12
|
+
|
|
13
|
+
### https://raw.github.com/github/gitignore/5f15ed83c7a3d5db29845edae5205ca2d795c3d8/Global/macOS.gitignore
|
|
14
|
+
|
|
15
|
+
# General
|
|
16
|
+
.DS_Store
|
|
17
|
+
.AppleDouble
|
|
18
|
+
.LSOverride
|
|
19
|
+
|
|
20
|
+
# Icon must end with two \r
|
|
21
|
+
Icon
|
|
22
|
+
|
|
23
|
+
# Thumbnails
|
|
24
|
+
._*
|
|
25
|
+
|
|
26
|
+
# Files that might appear in the root of a volume
|
|
27
|
+
.DocumentRevisions-V100
|
|
28
|
+
.fseventsd
|
|
29
|
+
.Spotlight-V100
|
|
30
|
+
.TemporaryItems
|
|
31
|
+
.Trashes
|
|
32
|
+
.VolumeIcon.icns
|
|
33
|
+
.com.apple.timemachine.donotpresent
|
|
34
|
+
|
|
35
|
+
# Directories potentially created on remote AFP share
|
|
36
|
+
.AppleDB
|
|
37
|
+
.AppleDesktop
|
|
38
|
+
Network Trash Folder
|
|
39
|
+
Temporary Items
|
|
40
|
+
.apdisk
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
|
|
44
|
+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
|
45
|
+
.idea
|
|
46
|
+
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at keigo.kimpara@gi-no.jp. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
jirack (0.1.0)
|
|
5
|
+
jira-ruby
|
|
6
|
+
slack-incoming-webhooks
|
|
7
|
+
thor
|
|
8
|
+
|
|
9
|
+
GEM
|
|
10
|
+
remote: https://rubygems.org/
|
|
11
|
+
specs:
|
|
12
|
+
activesupport (5.1.5)
|
|
13
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
14
|
+
i18n (~> 0.7)
|
|
15
|
+
minitest (~> 5.1)
|
|
16
|
+
tzinfo (~> 1.1)
|
|
17
|
+
concurrent-ruby (1.0.5)
|
|
18
|
+
diff-lcs (1.3)
|
|
19
|
+
i18n (0.9.5)
|
|
20
|
+
concurrent-ruby (~> 1.0)
|
|
21
|
+
jira-ruby (1.5.0)
|
|
22
|
+
activesupport
|
|
23
|
+
multipart-post
|
|
24
|
+
oauth (~> 0.5, >= 0.5.0)
|
|
25
|
+
minitest (5.11.3)
|
|
26
|
+
multipart-post (2.0.0)
|
|
27
|
+
oauth (0.5.4)
|
|
28
|
+
rake (10.5.0)
|
|
29
|
+
rspec (3.7.0)
|
|
30
|
+
rspec-core (~> 3.7.0)
|
|
31
|
+
rspec-expectations (~> 3.7.0)
|
|
32
|
+
rspec-mocks (~> 3.7.0)
|
|
33
|
+
rspec-core (3.7.1)
|
|
34
|
+
rspec-support (~> 3.7.0)
|
|
35
|
+
rspec-expectations (3.7.0)
|
|
36
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
37
|
+
rspec-support (~> 3.7.0)
|
|
38
|
+
rspec-mocks (3.7.0)
|
|
39
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
40
|
+
rspec-support (~> 3.7.0)
|
|
41
|
+
rspec-support (3.7.1)
|
|
42
|
+
slack-incoming-webhooks (0.2.0)
|
|
43
|
+
thor (0.20.0)
|
|
44
|
+
thread_safe (0.3.6)
|
|
45
|
+
tzinfo (1.2.5)
|
|
46
|
+
thread_safe (~> 0.1)
|
|
47
|
+
|
|
48
|
+
PLATFORMS
|
|
49
|
+
ruby
|
|
50
|
+
|
|
51
|
+
DEPENDENCIES
|
|
52
|
+
bundler (~> 1.16)
|
|
53
|
+
jirack!
|
|
54
|
+
rake (~> 10.0)
|
|
55
|
+
rspec (~> 3.0)
|
|
56
|
+
|
|
57
|
+
BUNDLED WITH
|
|
58
|
+
1.16.1
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 kimpara
|
|
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,69 @@
|
|
|
1
|
+
# Jirack
|
|
2
|
+
|
|
3
|
+
Jiraのステータスを更新しつつ、stackに通知をするコマンド.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
install it yourself as:
|
|
9
|
+
|
|
10
|
+
$ gem install jirack
|
|
11
|
+
or
|
|
12
|
+
$ gem install specific_install
|
|
13
|
+
$ gem specific_install https://github.com/rhythm191/jirack.git master
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
認証情報などをセットアップをします。
|
|
19
|
+
認証情報は`~/.jirack`に保存されます。
|
|
20
|
+
|
|
21
|
+
$ jirack config
|
|
22
|
+
|
|
23
|
+
自分の担当しているissueを確認する。
|
|
24
|
+
|
|
25
|
+
$ jirack list
|
|
26
|
+
|
|
27
|
+
自分の担当しているissueの総ポイント数を確認する
|
|
28
|
+
|
|
29
|
+
$ jirack list --sum-point
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
チケットをステータスを前に進める。(ex. チケット9999を次のステータスにする)
|
|
33
|
+
`-m message`でslackにメッセージを通知する。
|
|
34
|
+
|
|
35
|
+
$ jirack forward 9999
|
|
36
|
+
or
|
|
37
|
+
$ jirack forward 9999 -m "release has been completed"
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
チケットのステータスを後ろに戻す。(ex. チケット9999を前のステータスにする)
|
|
41
|
+
`-m message`でslackにメッセージを通知する。
|
|
42
|
+
|
|
43
|
+
$ jirack back 9999
|
|
44
|
+
or
|
|
45
|
+
$ jirack back 9999 -m "release has been completed"
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
slackにメッセージだけを送る。(ex. チケット9999についてのメッセージを送る)
|
|
49
|
+
|
|
50
|
+
$ jirack notify 9999 -m "something message"
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
## Development
|
|
54
|
+
|
|
55
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
56
|
+
|
|
57
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
58
|
+
|
|
59
|
+
## Contributing
|
|
60
|
+
|
|
61
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/rhythm191/jirack. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
62
|
+
|
|
63
|
+
## License
|
|
64
|
+
|
|
65
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
66
|
+
|
|
67
|
+
## Code of Conduct
|
|
68
|
+
|
|
69
|
+
Everyone interacting in the Jirack project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/rhythm191/jirack/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "jirack"
|
|
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(__FILE__)
|
data/bin/jirack
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "bundler/setup"
|
|
5
|
+
|
|
6
|
+
# require "rubygems"
|
|
7
|
+
# jirack_gemspec = Gem::Specification.load(File.expand_path("../../jirack.gemspec", __FILE__))
|
|
8
|
+
# jirack_gemspec.instance_variable_set(:@full_gem_path, File.expand_path("../..", __FILE__))
|
|
9
|
+
# jirack_gemspec.activate if jirack_gemspec.respond_to?(:activate)
|
|
10
|
+
load File.expand_path("../../exe/jirack", __FILE__)
|
data/bin/setup
ADDED
data/exe/jirack
ADDED
data/jirack.gemspec
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "jirack/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "jirack"
|
|
8
|
+
spec.version = Jirack::VERSION
|
|
9
|
+
spec.authors = ["rhythm191"]
|
|
10
|
+
spec.email = ["sac2ndg+develop@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{jira and slack manipulate tool.}
|
|
13
|
+
spec.description = %q{jira and slack manipulate tool.}
|
|
14
|
+
spec.homepage = "https://github.com/rhythm191/jirack.git"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
19
|
+
# if spec.respond_to?(:metadata)
|
|
20
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
|
21
|
+
# else
|
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
|
23
|
+
# "public gem pushes."
|
|
24
|
+
# end
|
|
25
|
+
|
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
|
28
|
+
end
|
|
29
|
+
spec.bindir = "exe"
|
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
31
|
+
spec.require_paths = ["lib"]
|
|
32
|
+
|
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
35
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
36
|
+
|
|
37
|
+
spec.add_dependency 'thor'
|
|
38
|
+
spec.add_dependency 'jira-ruby'
|
|
39
|
+
spec.add_dependency 'slack-incoming-webhooks'
|
|
40
|
+
|
|
41
|
+
end
|
data/lib/jirack.rb
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'jirack'
|
|
3
|
+
require 'thor'
|
|
4
|
+
require 'uri'
|
|
5
|
+
require 'jira-ruby'
|
|
6
|
+
require 'slack/incoming/webhooks'
|
|
7
|
+
|
|
8
|
+
module Jirack
|
|
9
|
+
class Command < Thor
|
|
10
|
+
|
|
11
|
+
desc 'config', 'setting config'
|
|
12
|
+
def config
|
|
13
|
+
cred = Jirack::Credential.new
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
host = ask "input host (ex. 'mydomain.atlassian.net') #{ cred.host&.empty? ? '' : "(#{cred.host})" }:"
|
|
17
|
+
cred.host = host unless host.empty?
|
|
18
|
+
|
|
19
|
+
project_name = ask "input project name #{ cred.project_name&.empty? ? '' : "(#{cred.project_name})" }:"
|
|
20
|
+
cred.project_name = project_name unless project_name.empty?
|
|
21
|
+
|
|
22
|
+
username = ask "input user name #{ cred.username&.empty? ? '' : "(#{cred.username})" }:"
|
|
23
|
+
cred.username = username unless username.empty?
|
|
24
|
+
|
|
25
|
+
password = ask '(required!)input password:', echo: false
|
|
26
|
+
cred.password = password
|
|
27
|
+
|
|
28
|
+
puts ''
|
|
29
|
+
|
|
30
|
+
slack_webhook_url = ask "input slack webhook urk #{ cred.slack_webhook_url&.empty? ? '' : "(#{cred.slack_webhook_url})" }:"
|
|
31
|
+
cred.slack_webhook_url = slack_webhook_url unless slack_webhook_url.empty?
|
|
32
|
+
|
|
33
|
+
cred.store
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
desc 'list', 'show your active issue'
|
|
37
|
+
method_option 'sum-point', type: :boolean, desc: 'show your all issue point'
|
|
38
|
+
def list
|
|
39
|
+
cred = Jirack::Credential.new
|
|
40
|
+
client = cred.jira_client
|
|
41
|
+
|
|
42
|
+
active_sprint = active_sprint(client, project_board(client, cred.project_name)['id'].to_i)
|
|
43
|
+
|
|
44
|
+
if options.key?('sum-point')
|
|
45
|
+
sum_points = active_sprint_issue(client, cred.project_name, active_sprint['name']).inject(0.0) {|sum, issue| sum + issue.points }
|
|
46
|
+
puts "#{ active_sprint['name'] } points: #{ sum_points }"
|
|
47
|
+
else
|
|
48
|
+
puts "#{ active_sprint['name'] } issues: "
|
|
49
|
+
active_sprint_issue(client, cred.project_name, active_sprint['name']).each do |issue|
|
|
50
|
+
puts "#{ issue.key }: #{ issue.summary }(#{issue.id}) [#{ issue.points }] #{ issue.status.name } "
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
desc 'forward issue_number', 'forward issue status'
|
|
56
|
+
method_option 'message', :aliases => '-m', desc: 'notify slack message'
|
|
57
|
+
def forward(issue_number)
|
|
58
|
+
cred = Jirack::Credential.new
|
|
59
|
+
client = cred.jira_client
|
|
60
|
+
|
|
61
|
+
issue = client.Issue.find("#{ cred.project_name }-#{ issue_number }", { extend: 'transitions' })
|
|
62
|
+
|
|
63
|
+
next_status = issue.status.next_status(client, cred.workflow_ids)
|
|
64
|
+
|
|
65
|
+
next_transition = issue.transitions.all.find {|transition| transition.to.id == next_status.id }
|
|
66
|
+
|
|
67
|
+
transition = JIRA::Resource::Transition.new(client, :attrs => {id: next_transition.id }, :issue_id => issue.id)
|
|
68
|
+
transition.save(transition: { id: next_transition.id })
|
|
69
|
+
|
|
70
|
+
# slack に通知
|
|
71
|
+
if options.key? :message
|
|
72
|
+
slack = Slack::Incoming::Webhooks.new cred.slack_webhook_url
|
|
73
|
+
slack.post "<@#{ issue.reporter.name }> #{ issue.summary }(#{ issue_url(issue) }) #{ options[:message] }"
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
puts "#{ cred.project_name }-#{ issue_number } forward to #{ next_transition.to.name }"
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
desc 'back issue_number', 'back issue status'
|
|
80
|
+
method_option 'message', :aliases => '-m', desc: 'notify slack message'
|
|
81
|
+
def back(issue_number)
|
|
82
|
+
cred = Jirack::Credential.new
|
|
83
|
+
client = cred.jira_client
|
|
84
|
+
|
|
85
|
+
issue = client.Issue.find("#{ cred.project_name }-#{ issue_number }", { extend: 'transitions' })
|
|
86
|
+
|
|
87
|
+
next_status = issue.status.next_status(client, cred.workflow_ids)
|
|
88
|
+
|
|
89
|
+
next_transition = issue.transitions.all.find {|transition| transition.to.id != next_status.id }
|
|
90
|
+
|
|
91
|
+
transition = JIRA::Resource::Transition.new(client, :attrs => {id: next_transition.id }, :issue_id => issue.id)
|
|
92
|
+
transition.save(transition: { id: next_transition.id })
|
|
93
|
+
|
|
94
|
+
# slack に通知
|
|
95
|
+
if options.key? :message
|
|
96
|
+
slack = Slack::Incoming::Webhooks.new cred.slack_webhook_url
|
|
97
|
+
slack.post "<@#{ issue.reporter.name }> #{ issue.summary }(#{ issue_url(issue) }) #{ options[:message] }"
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
puts "#{ cred.project_name }-#{ issue_number } back to #{ next_transition.to.name }"
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
desc 'notify issue_number', 'notify issue message'
|
|
104
|
+
method_option 'message', :aliases => '-m', required: true, desc: 'notify slack message'
|
|
105
|
+
def notify(issue_number)
|
|
106
|
+
cred = Jirack::Credential.new
|
|
107
|
+
client = cred.jira_client
|
|
108
|
+
|
|
109
|
+
issue = client.Issue.find("#{ cred.project_name }-#{ issue_number }")
|
|
110
|
+
|
|
111
|
+
# slack に通知
|
|
112
|
+
if options.key? :message
|
|
113
|
+
slack = Slack::Incoming::Webhooks.new cred.slack_webhook_url
|
|
114
|
+
slack.post "<@#{ issue.reporter.name }> #{ issue.summary }(#{ issue_url(issue) }) #{ options[:message] }"
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
puts "#{ cred.project_name }-#{ issue_number } notify slack"
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
private
|
|
121
|
+
|
|
122
|
+
def project_board(client, project_name)
|
|
123
|
+
client.Agile.all['values'].find {|board| board['name'] == project_name }
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def active_sprint(client, board_id)
|
|
127
|
+
client.Agile.get_sprints(board_id, state: 'active')['values'].first
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def active_sprint_issue(client, project_name, sprint_name)
|
|
131
|
+
JIRA::Resource::Issue.jql(client, "project=\"#{ project_name }\" AND assignee = currentuser() AND cf[10007] = \"#{ sprint_name }\"")
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def issue_url(issue)
|
|
135
|
+
uri = URI.parse(issue.self)
|
|
136
|
+
"https://#{ uri.host }/browse/#{ issue.key }"
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'json'
|
|
3
|
+
require 'jira-ruby'
|
|
4
|
+
|
|
5
|
+
module Jirack
|
|
6
|
+
class Credential
|
|
7
|
+
|
|
8
|
+
attr_accessor :username, :host, :project_name, :password, :slack_webhook_url, :workflow_ids
|
|
9
|
+
|
|
10
|
+
CREDENTIAL_FILE_PATH = '~/.jirack'
|
|
11
|
+
|
|
12
|
+
def initialize(filename = CREDENTIAL_FILE_PATH)
|
|
13
|
+
if File.exists?(File.expand_path(filename))
|
|
14
|
+
json = open(File.expand_path(filename)) {|io| JSON.load(io) }
|
|
15
|
+
@username = json['username']
|
|
16
|
+
@host = json['host']
|
|
17
|
+
@project_name = json['project_name']
|
|
18
|
+
@workflow_ids = json['workflow_ids']
|
|
19
|
+
@password = json['password']
|
|
20
|
+
@slack_webhook_url = json['slack_webhook_url']
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def to_json
|
|
25
|
+
hash = {}
|
|
26
|
+
instance_variables.each {|var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
|
27
|
+
hash['workflow_ids'] = [1, 3, 10_603, 10_600, 10_604, 10_001]
|
|
28
|
+
hash.to_json
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def store
|
|
32
|
+
File.open(File.expand_path(CREDENTIAL_FILE_PATH), 'w', 0600) do |file|
|
|
33
|
+
file.puts self.to_json
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def domain
|
|
38
|
+
"https://#{ @host }"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def jira_client
|
|
42
|
+
client_options = {
|
|
43
|
+
:username => @username,
|
|
44
|
+
:password => @password,
|
|
45
|
+
:site => domain,
|
|
46
|
+
:context_path => '',
|
|
47
|
+
:auth_type => :basic,
|
|
48
|
+
:read_timeout => 120
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
JIRA::Client.new(client_options)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'jirack'
|
|
3
|
+
require 'jira-ruby'
|
|
4
|
+
|
|
5
|
+
module Jirack
|
|
6
|
+
module IssueExtention
|
|
7
|
+
def sprint
|
|
8
|
+
Sprint.new self.customfield_10007
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def points
|
|
12
|
+
self.customfield_10004.to_i
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def key_id
|
|
16
|
+
self.key.split('-')[1].to_i
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
JIRA::Resource::Issue.send(:include, Jirack::IssueExtention)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'jirack'
|
|
3
|
+
require 'jira-ruby'
|
|
4
|
+
|
|
5
|
+
module Jirack
|
|
6
|
+
class Sprint
|
|
7
|
+
|
|
8
|
+
attr_accessor :name, :state, :start_date, :end_date
|
|
9
|
+
|
|
10
|
+
def initialize(field_string)
|
|
11
|
+
sprint_array = field_string[0].split(',')
|
|
12
|
+
|
|
13
|
+
@name = sprint_array[3].split('=')[1]
|
|
14
|
+
@state = sprint_array[2].split('=')[1]
|
|
15
|
+
|
|
16
|
+
start_date_string = sprint_array[5].split('=')[1]
|
|
17
|
+
if start_date_string != '<null>'
|
|
18
|
+
@start_date = DateTime.parse(start_date_string)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end_date_string = sprint_array[6].split('=')[1]
|
|
22
|
+
if end_date_string != '<null>'
|
|
23
|
+
@start_date = DateTime.parse(end_date_string)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def number
|
|
28
|
+
@name.split(' ')[1].to_i
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def active?
|
|
32
|
+
@state == 'ACTIVE'
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def future?
|
|
36
|
+
@state == 'FUTURE'
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def self.active_sprint(client)
|
|
40
|
+
cred = Jirack::Credential.new
|
|
41
|
+
|
|
42
|
+
JIRA::Resource::Issue.jql(client, "project=\"#{ cred.project_name }\" AND assignee = currentuser()").find do |issue|
|
|
43
|
+
issue.sprint.active?
|
|
44
|
+
end.sprint
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def to_s
|
|
48
|
+
"Jirack::Sprint name: #{ @name }, state: #{ @state }, start_date: #{ @start_date }, end_date: #{ @end_date }"
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'jirack'
|
|
3
|
+
require 'jira-ruby'
|
|
4
|
+
|
|
5
|
+
module Jirack
|
|
6
|
+
module StatusExtension
|
|
7
|
+
|
|
8
|
+
def next_status(client, workflow_ids)
|
|
9
|
+
index = workflow_ids.index {|id| self.id.to_i == id }
|
|
10
|
+
|
|
11
|
+
return if index + 1 == workflow_ids.size
|
|
12
|
+
|
|
13
|
+
client.Status.all.find {|status| status.id.to_i == workflow_ids[index + 1] }
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
JIRA::Resource::Status.send(:include, Jirack::StatusExtension)
|
metadata
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: jirack
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- rhythm191
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2018-02-26 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.16'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.16'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: thor
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: jira-ruby
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: slack-incoming-webhooks
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :runtime
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
description: jira and slack manipulate tool.
|
|
98
|
+
email:
|
|
99
|
+
- sac2ndg+develop@gmail.com
|
|
100
|
+
executables:
|
|
101
|
+
- jirack
|
|
102
|
+
extensions: []
|
|
103
|
+
extra_rdoc_files: []
|
|
104
|
+
files:
|
|
105
|
+
- ".gitignore"
|
|
106
|
+
- ".rspec"
|
|
107
|
+
- ".travis.yml"
|
|
108
|
+
- CODE_OF_CONDUCT.md
|
|
109
|
+
- Gemfile
|
|
110
|
+
- Gemfile.lock
|
|
111
|
+
- LICENSE.txt
|
|
112
|
+
- README.md
|
|
113
|
+
- Rakefile
|
|
114
|
+
- bin/console
|
|
115
|
+
- bin/jirack
|
|
116
|
+
- bin/setup
|
|
117
|
+
- exe/jirack
|
|
118
|
+
- jirack.gemspec
|
|
119
|
+
- lib/jirack.rb
|
|
120
|
+
- lib/jirack/command.rb
|
|
121
|
+
- lib/jirack/credential.rb
|
|
122
|
+
- lib/jirack/issue_extension.rb
|
|
123
|
+
- lib/jirack/sprint.rb
|
|
124
|
+
- lib/jirack/status_extension.rb
|
|
125
|
+
- lib/jirack/version.rb
|
|
126
|
+
homepage: https://github.com/rhythm191/jirack.git
|
|
127
|
+
licenses:
|
|
128
|
+
- MIT
|
|
129
|
+
metadata: {}
|
|
130
|
+
post_install_message:
|
|
131
|
+
rdoc_options: []
|
|
132
|
+
require_paths:
|
|
133
|
+
- lib
|
|
134
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - ">="
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: '0'
|
|
139
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
|
+
requirements:
|
|
141
|
+
- - ">="
|
|
142
|
+
- !ruby/object:Gem::Version
|
|
143
|
+
version: '0'
|
|
144
|
+
requirements: []
|
|
145
|
+
rubyforge_project:
|
|
146
|
+
rubygems_version: 2.6.11
|
|
147
|
+
signing_key:
|
|
148
|
+
specification_version: 4
|
|
149
|
+
summary: jira and slack manipulate tool.
|
|
150
|
+
test_files: []
|