gojira 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (7) hide show
  1. data/LICENSE +20 -0
  2. data/README.md +22 -0
  3. data/bin/gj +97 -0
  4. data/bin/gojira +97 -0
  5. data/bin/gojira.rb +97 -0
  6. data/lib/gojira_api.rb +90 -0
  7. metadata +86 -0
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Sean Sorrell
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,22 @@
1
+ # gojira
2
+ gojira is a command line interface to Atlassian Jira. It currently supports reading and updating of issues and comments. More features (search, comments) are planned.
3
+
4
+ ## installation
5
+ 'gem install gojira' should do the trick. This will install two executable links - 'gojira' and 'gj'.
6
+ gojira will look for a config file at ~/.gojira
7
+ expected format is:
8
+ full path to jira
9
+ username
10
+ password
11
+
12
+ ## usage
13
+ ### commands:
14
+ * gojira i[ssues] - show all issues assigned to you
15
+ * gojira i[ssue] issue - show information about an issue with the given key
16
+ * gojira p[rojects] - show all projects on the current Jira instance
17
+ * gojira u[pdate] issue - show all valid actions that can be performed on an issue
18
+ * gojira u[pdate] issue action_id - move the issue to the specified status
19
+
20
+ ### arguments:
21
+ issue => an internal gojira ID (ie. from 'gojira issues')
22
+ action_id => an internal gojira action_ID (ie. from 'gojira update issue')
data/bin/gj ADDED
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/env ruby
2
+ require 'gojira_api.rb'
3
+
4
+ CONFIG_PATH = File.join(ENV['HOME'], '.gojira')
5
+
6
+ class Gojira
7
+ attr_reader :gojira
8
+
9
+ def initialize(url, user, pass)
10
+ @gojira = GojiraAPI.new url
11
+ @gojira.login user,pass
12
+ end
13
+
14
+ def self.load_config
15
+ if not File.exist? CONFIG_PATH
16
+ puts "no config found at ~/.gojira \nformat: \n\tpath\n\tuser\n\tpass"
17
+ exit
18
+ end
19
+ File.read(CONFIG_PATH).split("\n")
20
+ end
21
+
22
+ def run(args)
23
+ parse_args(args)
24
+ end
25
+
26
+
27
+ def show_projects
28
+ output = @gojira.projects.map do |project|
29
+ "#{project.key} - #{project.url}"
30
+ end
31
+ print output
32
+ end
33
+
34
+ def show_issues issue_id=nil
35
+ output = @gojira.user_issues.enum_with_index.map do |issue,id|
36
+ "#{id} #{format_issue issue,issue_id}"
37
+ end
38
+ output = output[issue_id] if issue_id
39
+ print output
40
+ end
41
+
42
+ def update_status(issue,new_action=nil)
43
+ issue = externalize_issue(issue)
44
+ valid_actions = @gojira.valid_actions(issue)
45
+ output = valid_actions.enum_with_index.map do |action,id|
46
+ "#{id} - #{format_action action}"
47
+ end
48
+ if new_action
49
+ if (resp = @gojira.set_action issue, valid_actions[new_action.to_i][:id])
50
+ output = "set to #{resp[:name]}"
51
+ else
52
+ output = "failed to perform action - maybe it is invalid?"
53
+ end
54
+ end
55
+ print output
56
+ end
57
+
58
+ protected
59
+ def print out
60
+ puts out
61
+ return out
62
+ end
63
+
64
+ def format_issue(issue, verbose=false)
65
+ status = @gojira.issue_status issue.key
66
+ priority = @gojira.issue_priority issue.key
67
+
68
+ "#{issue.key} - #{issue.summary} \n\t #{status[:name]} - #{priority[:name]} \n #{issue.description if verbose}\n\n"
69
+ end
70
+
71
+ def format_action(action)
72
+ "#{action[:name]}"
73
+ end
74
+
75
+ def externalize_issue(key)
76
+ @gojira.user_issues[key.to_i].key
77
+ end
78
+
79
+ def parse_args(args)
80
+ command = args[0]
81
+ case command
82
+ when /i/
83
+ then show_issues args[1]
84
+ when /p/
85
+ then show_projects
86
+ when /u/
87
+ then update_status args[1], args[2]
88
+ else
89
+ show_issues
90
+ end
91
+ end
92
+ end
93
+
94
+
95
+
96
+ gj = Gojira.new *Gojira.load_config
97
+ gj.run ARGV
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/env ruby
2
+ require 'gojira_api.rb'
3
+
4
+ CONFIG_PATH = File.join(ENV['HOME'], '.gojira')
5
+
6
+ class Gojira
7
+ attr_reader :gojira
8
+
9
+ def initialize(url, user, pass)
10
+ @gojira = GojiraAPI.new url
11
+ @gojira.login user,pass
12
+ end
13
+
14
+ def self.load_config
15
+ if not File.exist? CONFIG_PATH
16
+ puts "no config found at ~/.gojira \nformat: \n\tpath\n\tuser\n\tpass"
17
+ exit
18
+ end
19
+ File.read(CONFIG_PATH).split("\n")
20
+ end
21
+
22
+ def run(args)
23
+ parse_args(args)
24
+ end
25
+
26
+
27
+ def show_projects
28
+ output = @gojira.projects.map do |project|
29
+ "#{project.key} - #{project.url}"
30
+ end
31
+ print output
32
+ end
33
+
34
+ def show_issues issue_id=nil
35
+ output = @gojira.user_issues.enum_with_index.map do |issue,id|
36
+ "#{id} #{format_issue issue,issue_id}"
37
+ end
38
+ output = output[issue_id] if issue_id
39
+ print output
40
+ end
41
+
42
+ def update_status(issue,new_action=nil)
43
+ issue = externalize_issue(issue)
44
+ valid_actions = @gojira.valid_actions(issue)
45
+ output = valid_actions.enum_with_index.map do |action,id|
46
+ "#{id} - #{format_action action}"
47
+ end
48
+ if new_action
49
+ if (resp = @gojira.set_action issue, valid_actions[new_action.to_i][:id])
50
+ output = "set to #{resp[:name]}"
51
+ else
52
+ output = "failed to perform action - maybe it is invalid?"
53
+ end
54
+ end
55
+ print output
56
+ end
57
+
58
+ protected
59
+ def print out
60
+ puts out
61
+ return out
62
+ end
63
+
64
+ def format_issue(issue, verbose=false)
65
+ status = @gojira.issue_status issue.key
66
+ priority = @gojira.issue_priority issue.key
67
+
68
+ "#{issue.key} - #{issue.summary} \n\t #{status[:name]} - #{priority[:name]} \n #{issue.description if verbose}\n\n"
69
+ end
70
+
71
+ def format_action(action)
72
+ "#{action[:name]}"
73
+ end
74
+
75
+ def externalize_issue(key)
76
+ @gojira.user_issues[key.to_i].key
77
+ end
78
+
79
+ def parse_args(args)
80
+ command = args[0]
81
+ case command
82
+ when /i/
83
+ then show_issues args[1]
84
+ when /p/
85
+ then show_projects
86
+ when /u/
87
+ then update_status args[1], args[2]
88
+ else
89
+ show_issues
90
+ end
91
+ end
92
+ end
93
+
94
+
95
+
96
+ gj = Gojira.new *Gojira.load_config
97
+ gj.run ARGV
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/env ruby
2
+ require 'gojira_api.rb'
3
+
4
+ CONFIG_PATH = File.join(ENV['HOME'], '.gojira')
5
+
6
+ class Gojira
7
+ attr_reader :gojira
8
+
9
+ def initialize(url, user, pass)
10
+ @gojira = GojiraAPI.new url
11
+ @gojira.login user,pass
12
+ end
13
+
14
+ def self.load_config
15
+ if not File.exist? CONFIG_PATH
16
+ puts "no config found at ~/.gojira \nformat: \n\tpath\n\tuser\n\tpass"
17
+ exit
18
+ end
19
+ File.read(CONFIG_PATH).split("\n")
20
+ end
21
+
22
+ def run(args)
23
+ parse_args(args)
24
+ end
25
+
26
+
27
+ def show_projects
28
+ output = @gojira.projects.map do |project|
29
+ "#{project.key} - #{project.url}"
30
+ end
31
+ print output
32
+ end
33
+
34
+ def show_issues issue_id=nil
35
+ output = @gojira.user_issues.enum_with_index.map do |issue,id|
36
+ "#{id} #{format_issue issue,issue_id}"
37
+ end
38
+ output = output[issue_id] if issue_id
39
+ print output
40
+ end
41
+
42
+ def update_status(issue,new_action=nil)
43
+ issue = externalize_issue(issue)
44
+ valid_actions = @gojira.valid_actions(issue)
45
+ output = valid_actions.enum_with_index.map do |action,id|
46
+ "#{id} - #{format_action action}"
47
+ end
48
+ if new_action
49
+ if (resp = @gojira.set_action issue, valid_actions[new_action.to_i][:id])
50
+ output = "set to #{resp[:name]}"
51
+ else
52
+ output = "failed to perform action - maybe it is invalid?"
53
+ end
54
+ end
55
+ print output
56
+ end
57
+
58
+ protected
59
+ def print out
60
+ puts out
61
+ return out
62
+ end
63
+
64
+ def format_issue(issue, verbose=false)
65
+ status = @gojira.issue_status issue.key
66
+ priority = @gojira.issue_priority issue.key
67
+
68
+ "#{issue.key} - #{issue.summary} \n\t #{status[:name]} - #{priority[:name]} \n #{issue.description if verbose}\n\n"
69
+ end
70
+
71
+ def format_action(action)
72
+ "#{action[:name]}"
73
+ end
74
+
75
+ def externalize_issue(key)
76
+ @gojira.user_issues[key.to_i].key
77
+ end
78
+
79
+ def parse_args(args)
80
+ command = args[0]
81
+ case command
82
+ when /i/
83
+ then show_issues args[1]
84
+ when /p/
85
+ then show_projects
86
+ when /u/
87
+ then update_status args[1], args[2]
88
+ else
89
+ show_issues
90
+ end
91
+ end
92
+ end
93
+
94
+
95
+
96
+ gj = Gojira.new *Gojira.load_config
97
+ gj.run ARGV
@@ -0,0 +1,90 @@
1
+ require 'jira4r'
2
+ class GojiraAPI
3
+ attr_reader :user
4
+ def initialize(url)
5
+ @jira = Jira4R::JiraTool.new 2, url
6
+ @jira.logger=Logger.new("/dev/null")
7
+ end
8
+
9
+ def login(user,pass)
10
+ @user = user
11
+ @jira.login user, pass
12
+ end
13
+
14
+ def projects
15
+ @jira.getProjectsNoSchemes
16
+ end
17
+
18
+ def user_issues(limit = 100)
19
+ @jira.getIssuesFromJqlSearch "assignee = currentUser()", limit
20
+ end
21
+
22
+ def issue(key)
23
+ @jira.getIssue(key)
24
+ end
25
+
26
+ def priorities
27
+ @priorities ||= @jira.getPriorities.map do |p|
28
+ {
29
+ :id => p.id,
30
+ :name => p.name,
31
+ :desc => p.description
32
+ }
33
+ end
34
+ end
35
+
36
+ def priority(id)
37
+ priorities.find { |p| p[:id] == id }
38
+ end
39
+
40
+ def statuses
41
+ @statuses ||= @jira.getStatuses.map do |s|
42
+ {
43
+ :id => s.id,
44
+ :name => s.name,
45
+ :desc => s.description,
46
+ }
47
+ end
48
+ end
49
+
50
+ def status(id)
51
+ statuses.find{|s| s[:id] == id}
52
+ end
53
+
54
+ def issue_status(key)
55
+ issue = issue(key)
56
+ status(issue.status)
57
+ end
58
+
59
+ def issue_priority(key)
60
+ issue = issue(key)
61
+ priority(issue.priority)
62
+ end
63
+
64
+ def valid_actions(key)
65
+ @jira.getAvailableActions(key).map do |action|
66
+ {
67
+ :id => action.id,
68
+ :name => action.name
69
+ }
70
+ end
71
+ end
72
+
73
+ def add_comment(key, body)
74
+ comment = Jira4R::V2::RemoteComment.new
75
+ comment.body = body
76
+ @jira.addComment key, comment rescue return
77
+ comment
78
+ end
79
+
80
+ def set_action(issue_key, action_key)
81
+ action = valid_actions(issue_key).find {|action| action[:id] == action_key}
82
+ return if not action
83
+ @jira.progressWorkflowAction(issue_key, action_key, []) rescue return
84
+ action
85
+ end
86
+
87
+ def method_missing(sym, *args, &block)
88
+ @jira.send sym, *args, &block
89
+ end
90
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gojira
3
+ version: !ruby/object:Gem::Version
4
+ hash: 25
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 1
10
+ version: 0.1.1
11
+ platform: ruby
12
+ authors:
13
+ - Sean Sorrell
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-01-23 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: wireframe-jira4r
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ description: gojira provides the ability to view tickets and move them through a Jira workflow
36
+ email: seansorrell@gmail.com
37
+ executables:
38
+ - gojira
39
+ - gj
40
+ extensions: []
41
+
42
+ extra_rdoc_files: []
43
+
44
+ files:
45
+ - bin/gj
46
+ - bin/gojira
47
+ - bin/gojira.rb
48
+ - lib/gojira_api.rb
49
+ - LICENSE
50
+ - README.md
51
+ has_rdoc: true
52
+ homepage: http://github.com/rudle/gojira
53
+ licenses: []
54
+
55
+ post_install_message:
56
+ rdoc_options: []
57
+
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ hash: 3
66
+ segments:
67
+ - 0
68
+ version: "0"
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
77
+ version: "0"
78
+ requirements: []
79
+
80
+ rubyforge_project:
81
+ rubygems_version: 1.3.7
82
+ signing_key:
83
+ specification_version: 3
84
+ summary: a git-like command interface to Atlassian Jira
85
+ test_files: []
86
+