jirify 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d03cf4e22128db92ed1bcaa20349039cd51fb4da6b6c5565fe483ee6b6c9f7a4
4
+ data.tar.gz: 25930d9803d3509c8ba451a39e872a964adb06931c50a1867a65d90dd3b539ee
5
+ SHA512:
6
+ metadata.gz: 68e76713ff0fe0a24a42a1fca1543b603e484d862c622dfee773c6819ed1026d25a2c1c43c2fbbc2ff152073c2c6b04d4a7d762dd0fb60703bca032c77cd8de7
7
+ data.tar.gz: '029525775c64357bac4fd9ca7bb82dfbd7436d98242ab405cb96e084b60382531b6308a7f3b2b7c96ec306cd287e0d7546fdf375dbe6feb19cc3c3f1d5c6911c'
data/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # jirify
2
+ A simple ruby gem that helps me work with jira
3
+
4
+ # How to use
5
+ 1. Run `gem install jirify`.
6
+ 1. Execute `jira setup` and go through the setup process OR if you had the previous `config.yml` file you can just do `mv config.yml ~/.jirify`
7
+ 1. Execute `jira` and `jira <command> help` to learn about available commands.
data/bin/jira ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'jirify'
3
+
4
+ Jirify::CLI.start
@@ -0,0 +1,25 @@
1
+ module Jirify
2
+ class CLI < Thor
3
+ desc "mine", "List all of the issues assigned to you in the current sprint"
4
+ method_option :in_progress, type: :boolean, aliases: '-i', desc: "Show only issues in progress"
5
+ method_option :in_review, type: :boolean, aliases: '-r', desc: "Show only issues in review"
6
+ method_option :closed, type: :boolean, aliases: '-c', desc: "Show only closed issues"
7
+ method_option :todo, type: :boolean, aliases: '-t', desc: "Show only issues in todo"
8
+ method_option :all, type: :boolean, aliases: '-a', desc: "Show all assigned issues in Project - not limited to sprint"
9
+ method_option :status, banner: "<status>", type: :string, aliases: '-s', desc: "Show only issues with the specified status"
10
+ method_option :statuses, banner: "<statuses>", type: :array, desc: "Show only issues with the specified statuses"
11
+ def mine
12
+ if options[:status]
13
+ statuses = [options[:status]]
14
+ else
15
+ statuses = []
16
+ statuses << "To Do" if options[:todo]
17
+ statuses << "In Progress" if options[:in_progress]
18
+ statuses << "In Review" if options[:in_review]
19
+ statuses << "Closed" if options[:closed]
20
+ end
21
+
22
+ Jirify::Issues.mine(options[:verbose], statuses, options[:all])
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,37 @@
1
+ module Jirify
2
+ class CLI < Thor
3
+ desc "setup", "A guided setup for jirify"
4
+ def setup
5
+ say "Welcome! This will guide you through the configuration of the jirify CLI tool."
6
+
7
+ if Config.initialized?
8
+ puts
9
+ reconfigure = yes? "You seem to have already configured jirify.\n" \
10
+ "Do you want to continue and overwrite the current configuration? [Y/N]"
11
+ exit(0) unless reconfigure
12
+ end
13
+
14
+ username = ask "Enter username:"
15
+ token = ask "Enter token (generate from https://id.atlassian.com):"
16
+ site = ask "Enter JIRA url:"
17
+ project = ask "Enter JIRA Project key:"
18
+ filter_labels = ask "Enter a comma-separated list of labels to filter by every time (optional):"
19
+
20
+ labels = filter_labels.split ', ' if filter_labels
21
+
22
+ options = {
23
+ 'options' => {
24
+ 'username' => username,
25
+ 'token' => token,
26
+ 'site' => site,
27
+ 'project' => project,
28
+ }
29
+ }
30
+
31
+ options['options']['filter_by_labels'] = labels unless labels.empty?
32
+
33
+ Config.write(options)
34
+ end
35
+ end
36
+ end
37
+
@@ -0,0 +1,10 @@
1
+ module Jirify
2
+ class CLI < Thor
3
+ desc "sprint", "Show the current sprint table"
4
+ method_option :mine, type: :boolean, aliases: '-m', desc: "Show only issues assigned to me"
5
+ method_option :all_columns, type: :boolean, aliases: '-a', desc: "Show all columns"
6
+ def sprint
7
+ Jirify::Sprint.current(options[:verbose], options[:columns], options[:mine])
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,45 @@
1
+ require 'yaml'
2
+
3
+ module Jirify
4
+ class Config
5
+ class << self
6
+ def initialized?
7
+ File.exists? config_file
8
+ end
9
+
10
+ def write(config)
11
+ puts "Writing config:"
12
+ puts config.to_yaml
13
+
14
+ File.write(config_file, config.to_yaml)
15
+ end
16
+
17
+ def config_file
18
+ @config_file ||= "#{Dir.home}/.jirify"
19
+ end
20
+
21
+ def options
22
+ raise StandardError unless initialized?
23
+ @options ||= YAML.load_file(config_file)['options']
24
+ end
25
+
26
+ def atlassian_url
27
+ options['site']
28
+ end
29
+
30
+ def issue_browse_url
31
+ "#{atlassian_url}/browse/"
32
+ end
33
+
34
+ def client_options
35
+ {
36
+ :username => options['username'],
37
+ :password => options['token'],
38
+ :site => atlassian_url,
39
+ :context_path => '',
40
+ :auth_type => :basic,
41
+ }
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,13 @@
1
+ module Jirify
2
+ class Base
3
+ class << self
4
+ def client
5
+ @client ||= JIRA::Client.new(Config.client_options)
6
+ end
7
+
8
+ def project
9
+ @project ||= Config.options['project']
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,34 @@
1
+ require 'colorize'
2
+
3
+ module Jirify
4
+ class Issues < Base
5
+ class << self
6
+ def mine(verbose, statuses = [], all = false)
7
+ all_clause = "AND sprint in openSprints() " unless all
8
+ my_issues = client.Issue.jql("project='#{project}' #{all_clause}AND assignee='#{Config.options["username"]}'")
9
+
10
+ my_issues.sort_by! { |issue| issue.status.name }
11
+ my_issues.each do |issue|
12
+ status = issue.status.name
13
+
14
+ next if statuses.any? && !statuses.include?(status)
15
+
16
+ status_justified = "(#{status})".rjust(14)
17
+ status_colorized = case status
18
+ when "Done" then status_justified.green
19
+ when "In Progress" then status_justified.blue
20
+ when "In Review" then status_justified.yellow
21
+ when "Closed" then status_justified.black
22
+ else status_justified
23
+ end
24
+
25
+ if verbose
26
+ print "#{status_colorized} #{issue.key.ljust(7)}: #{issue.summary} (#{Config.issue_browse_url}#{issue.key})\n"
27
+ else
28
+ print "#{issue.key.ljust(7)}: (#{Config.issue_browse_url}#{issue.key})\n"
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,47 @@
1
+ require 'colorize'
2
+ require 'terminal-table'
3
+ require 'json'
4
+
5
+ module Jirify
6
+ class Sprint < Base
7
+ class << self
8
+ def current(verbose = false, all_columns = false, only_mine = false)
9
+ labels = Config.options['filter_by_labels']
10
+ labels = labels.join(", ") if labels
11
+
12
+ labels_clause = "AND labels in (#{labels})" if labels
13
+ mine_clause = "AND assignee='#{Config.options["username"]}'" if only_mine
14
+
15
+ issues = client.Issue.jql("project='#{project}' AND sprint in openSprints() #{labels_clause} #{mine_clause}", { max_results: 200 })
16
+
17
+ if all_columns
18
+ grouped_issues = issues.group_by { |issue| issue.status.name }
19
+ else
20
+ grouped_issues = issues.group_by { |issue| issue.status.statusCategory['name'] }
21
+ end
22
+
23
+ all_groups = grouped_issues.values
24
+
25
+ l = all_groups.map(&:length).max
26
+ transposed = all_groups.map{ |e| e.values_at(0...l) }.transpose
27
+
28
+ transposed = transposed.map do |row|
29
+ row.map do |issue|
30
+ if issue
31
+ key = issue.key.ljust(7)
32
+ url = "(#{Config.issue_browse_url}/#{issue.key})".blue
33
+ summary = "#{issue.summary[0, 35]}...\n" if verbose
34
+ "#{key}: #{summary}#{url}"
35
+ else
36
+ ""
37
+ end
38
+ end
39
+ end
40
+
41
+ table = Terminal::Table.new headings: grouped_issues.keys, rows: transposed
42
+
43
+ puts table unless transposed.empty?
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,3 @@
1
+ module Jirify
2
+ VERSION = "0.1.0"
3
+ end
data/lib/jirify.rb ADDED
@@ -0,0 +1,16 @@
1
+ require 'thor'
2
+ require 'jira-ruby'
3
+
4
+ require 'jirify/config'
5
+ require 'jirify/cli/setup'
6
+ require 'jirify/cli/sprint'
7
+ require 'jirify/cli/issue'
8
+ require 'jirify/models/base'
9
+ require 'jirify/models/issues'
10
+ require 'jirify/models/sprint'
11
+
12
+ module Jirify
13
+ class CLI < Thor
14
+ class_option :verbose, type: :boolean, aliases: '-v', desc: "Show more verbose information"
15
+ end
16
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jirify
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Georgi Gardev
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-07-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jira-ruby
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: colorize
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.8'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: terminal-table
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.8'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.8'
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.20'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.20'
69
+ description: JIRA for your terminal
70
+ email: georgi@gardev.com
71
+ executables:
72
+ - jira
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - README.md
77
+ - bin/jira
78
+ - lib/jirify.rb
79
+ - lib/jirify/cli/issue.rb
80
+ - lib/jirify/cli/setup.rb
81
+ - lib/jirify/cli/sprint.rb
82
+ - lib/jirify/config.rb
83
+ - lib/jirify/models/base.rb
84
+ - lib/jirify/models/issues.rb
85
+ - lib/jirify/models/sprint.rb
86
+ - lib/jirify/version.rb
87
+ homepage: https://github.com/GeorgeSG/jira-cli
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.6.14
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: JIRA CLI
111
+ test_files: []