jirify 0.1.7 → 0.1.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb5f0f6dfffdfe5bf7ba883f13791a579a5defaaa5887cb210bb2c8d4022dbe6
4
- data.tar.gz: 44f3bff0804ebe0a796d94417d690a3babb17fab8b3d3403a7882195defe8b67
3
+ metadata.gz: 6fa6f6e12d2dc9625fc0d7feff7a43bc6317bdfa3e65399183520fc1abaaf79a
4
+ data.tar.gz: e1b7cad8d84ca28e4c4a2f08eabbb37a14fbc519ca6c715e0b4aa075ad24b07b
5
5
  SHA512:
6
- metadata.gz: 6d5069a25d999001f6e63a273d2ea32a3bd89b96b8586f77562cd4c16cd87806a892953a17e8656f460ed3b15c53ff58621a60120d95c689891f1eeecf83b85a
7
- data.tar.gz: d4a806b94ab345ba3d89feb15f551ff8f3801a4713004331fc143b36b5abbd80ab24f1225b25561e7962c9eef8b72850413191898dd4a908e3c2b885688184a6
6
+ metadata.gz: 315d6b7ad7ec9d2a32f3b25ffb02836d80cb49fdbef0013715e63468bad235b371907ca7ba94bd4bd79f37c53820a32cdd98aa61d4f8ab27fb86e1b31046f4a0
7
+ data.tar.gz: 743c5029ad03b45ecb4d36a24035db2ba6e34d9163a8983e5db1dd62b37887a99257789e6d0ebea39488c2ea8ddae7c1efba7a42aed6470302242d41358bec42
@@ -55,7 +55,7 @@ module Jirify
55
55
  if issue.assignee.nil?
56
56
  say 'Unassigned'.yellow
57
57
  else
58
- say issue.assignee.name
58
+ say issue.assignee.displayName
59
59
  end
60
60
  end
61
61
 
@@ -5,7 +5,13 @@ module Jirify
5
5
 
6
6
  desc 'list', 'List all projects'
7
7
  def list
8
- Models::Project.all.map(&:name).each { |name| say name }
8
+ projects = Models::ProjectList.all
9
+ longest_key = projects.keys.map(&:size).max
10
+
11
+ projects.each do |project|
12
+ key = "#{project.key}:".ljust(longest_key + 1)
13
+ say "#{key} #{project.name}"
14
+ end
9
15
  end
10
16
  end
11
17
  end
@@ -2,12 +2,21 @@ module Jirify
2
2
  class CLI < Thor
3
3
  desc 'sprint', 'Show the current sprint table'
4
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'
5
+ method_option :all_columns, type: :boolean, aliases: '-c', default: true, desc: 'Show all columns'
6
+ method_option :assignee, type: :boolean, aliases: '-a', desc: 'Show issue assignee'
7
+ method_option :summary, type: :boolean, aliases: '-s', desc: 'Show issue summary'
8
+ method_option :url, type: :boolean, aliases: '-u', desc: 'Show issue url'
6
9
  def sprint
7
10
  verbose = Config.always_verbose || options[:verbose]
8
11
  issues = Models::Sprint.issues_in_current_sprint(options[:mine])
9
12
 
10
- say UI::SprintTable.new(issues).to_table(options[:all_columns], verbose)
13
+ duplicate_options = options.dup
14
+ if verbose
15
+ duplicate_options[:assignee] = true
16
+ duplicate_options[:url] = true
17
+ duplicate_options[:summary] = true
18
+ end
19
+ say UI::SprintTable.new(issues).to_table(duplicate_options)
11
20
  rescue UI::WindowTooNarrow
12
21
  say 'ERROR: Your terminal window is too narrow to print the sprint table!'.red
13
22
  end
@@ -0,0 +1,13 @@
1
+ module Jirify
2
+ module Models
3
+ class BaseList < Base
4
+ include Enumerable
5
+
6
+ attr_reader :list
7
+
8
+ def each(&block)
9
+ list.each(&block)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -53,12 +53,13 @@ module Jirify
53
53
  end
54
54
 
55
55
  def to_s(verbose)
56
- url = "#{Config.issue_browse_url}#{key}".blue
56
+ url = ColorizedString["#{Config.issue_browse_url}#{key}"].blue.underline
57
+ bold_key = ColorizedString["#{key.ljust(7)}:"].bold
57
58
 
58
59
  if verbose
59
- "#{status.pretty_name} #{key.ljust(7)}: #{summary} (#{url})"
60
+ "#{status.pretty_name} #{bold_key} #{summary} (#{url})"
60
61
  else
61
- "#{key.ljust(7)}: (#{url})"
62
+ "#{bold_key} #{url}"
62
63
  end
63
64
  end
64
65
 
@@ -1,11 +1,6 @@
1
1
  module Jirify
2
2
  module Models
3
3
  class Project < Base
4
- class << self
5
- def all
6
- client.Project.all.map { |project| Project.new project }
7
- end
8
- end
9
4
  end
10
5
  end
11
6
  end
@@ -0,0 +1,27 @@
1
+ module Jirify
2
+ module Models
3
+ class ProjectList < BaseList
4
+ def initialize(list)
5
+ @list = list.map { |project| Project.new project }
6
+ end
7
+
8
+ def find_by_name(name)
9
+ find { |project| project.name == name }
10
+ end
11
+
12
+ def keys
13
+ map(&:key)
14
+ end
15
+
16
+ def names
17
+ map(&:name)
18
+ end
19
+
20
+ class << self
21
+ def all
22
+ ProjectList.new client.Project.all
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,6 @@
1
+ module Jirify
2
+ module Models
3
+ class Transition < Base
4
+ end
5
+ end
6
+ end
@@ -1,18 +1,16 @@
1
1
  module Jirify
2
2
  module Models
3
- class TransitionList < Base
4
- attr_accessor :list
5
-
3
+ class TransitionList < BaseList
6
4
  def initialize(list)
7
- @list = list
5
+ @list = list.map { |transition| Transition.new transition }
8
6
  end
9
7
 
10
8
  def find_by_name(name)
11
- @list.find { |transition| transition.name == name }
9
+ find { |transition| transition.name == name }
12
10
  end
13
11
 
14
12
  def names
15
- @list.map(&:name)
13
+ map(&:name)
16
14
  end
17
15
 
18
16
  Config.transitions.keys.each do |transition_name|
@@ -10,6 +10,18 @@ module Jirify
10
10
  @max_cell_length = max_cell_length
11
11
  end
12
12
 
13
+ def to_s(options)
14
+ raise UI::WindowTooNarrow, 'The terminal window is too narrow.' if max_cell_length <= key.size
15
+
16
+ row = ''
17
+ row << key_and_summary_lines(options, max_cell_length)
18
+ row << "\n#{ColorizedString[url].blue.underline}" if display_url?(options)
19
+ row << assignee_line(max_cell_length) if show_assignee?(options)
20
+ row
21
+ end
22
+
23
+ protected
24
+
13
25
  def key
14
26
  issue.key
15
27
  end
@@ -18,45 +30,58 @@ module Jirify
18
30
  issue.summary
19
31
  end
20
32
 
33
+ def show_assignee?(options)
34
+ options[:assignee] && !options[:mine]
35
+ end
36
+
37
+ def assignee
38
+ if issue.assignee.nil?
39
+ 'Unassigned'
40
+ else
41
+ issue.assignee.displayName
42
+ end
43
+ end
44
+
21
45
  def url
22
46
  "#{Config.issue_browse_url}#{issue.key}"
23
47
  end
24
48
 
25
- def to_s(verbose)
26
- raise UI::WindowTooNarrow, 'The terminal window is too narrow.' if max_cell_length <= key.size
27
-
28
- verbose ? to_verbose_cell : to_short_cell
49
+ def display_url?(options)
50
+ url.size <= max_cell_length && options[:url]
29
51
  end
30
52
 
31
- protected
53
+ def wrap(string, columns, character = "\n")
54
+ start_pos = columns
55
+ while start_pos < string.length
56
+ space = string.rindex(' ', start_pos)
57
+ string.slice!(space)
58
+ string.insert(space, character)
59
+ start_pos = space + columns + 1
60
+ end
32
61
 
33
- def display_url?
34
- url.size <= max_cell_length
62
+ string
35
63
  end
36
64
 
37
- def to_verbose_cell
38
- key_and_summary = "#{key}: #{summary}"
65
+ def key_and_summary_lines(options, max_cell_length)
66
+ bold_key = ColorizedString[key].bold
67
+ return bold_key unless options[:summary]
68
+
69
+ key_and_summary = "#{bold_key}: #{summary}"
39
70
 
40
71
  if key_and_summary.size <= max_cell_length
41
- row = key_and_summary
72
+ key_and_summary
42
73
  else
43
- row = "#{key}\n#{summary[0...max_cell_length - 3]}..."
74
+ row = "#{bold_key}\n"
75
+ row << wrap(summary.strip, max_cell_length)
76
+ row
44
77
  end
45
-
46
- row << "\n#{url.blue}" if display_url?
47
- row
48
78
  end
49
79
 
50
- def to_short_cell
51
- return key unless display_url?
52
-
53
- single_row = "#{key}: #{url}"
80
+ def assignee_line(max_cell_length)
81
+ assignee_line = assignee
82
+ assignee_line = "#{assignee[0...max_cell_length - 3]}..." if assignee_line.size >= max_cell_length
54
83
 
55
- if single_row.size <= max_cell_length
56
- "#{key}: #{url.blue}"
57
- else
58
- "#{key}\n#{url.blue}"
59
- end
84
+ "\n#{assignee_line.magenta}"
60
85
  end
61
86
  end
62
87
  end
@@ -9,12 +9,12 @@ module Jirify
9
9
  @issues = issues
10
10
  end
11
11
 
12
- def to_table(all_columns, verbose)
12
+ def to_table(options)
13
13
  grouped_issues = issues.group_by do |issue|
14
- all_columns ? issue.status.name : issue.status.statusCategory['name']
14
+ options[:all_columns] ? issue.status.name : issue.status.statusCategory['name']
15
15
  end
16
16
 
17
- grouped_issues_as_table(grouped_issues, verbose)
17
+ grouped_issues_as_table(grouped_issues, options)
18
18
  end
19
19
 
20
20
  protected
@@ -28,7 +28,7 @@ module Jirify
28
28
  end
29
29
 
30
30
  def headings(grouped_issues)
31
- grouped_issues.keys.sort_by do |name|
31
+ sorted_headings = grouped_issues.keys.sort_by do |name|
32
32
  status_index = Models::Status.status_order.index(name)
33
33
  if status_index.nil?
34
34
  grouped_issues.keys.length
@@ -36,10 +36,21 @@ module Jirify
36
36
  status_index
37
37
  end
38
38
  end
39
+
40
+ sorted_headings.map! do |name|
41
+ case name
42
+ when Config.statuses['todo'] then ColorizedString[name].white.on_black.bold
43
+ when Config.statuses['in_progress'] then ColorizedString[name].white.on_blue.bold
44
+ when Config.statuses['in_review'] then ColorizedString[name].white.on_yellow.bold
45
+ when Config.statuses['blocked'] then ColorizedString[name].white.on_red.bold
46
+ when Config.statuses['done'] then ColorizedString[name].white.on_green.bold
47
+ else ColorizedString[name].white.on_green.bold
48
+ end
49
+ end
39
50
  end
40
51
 
41
- def grouped_issues_as_table(grouped_issues, verbose)
42
- transposed = transpose(grouped_issues.values, verbose)
52
+ def grouped_issues_as_table(grouped_issues, options)
53
+ transposed = transpose(grouped_issues.values, options)
43
54
  return nil if transposed.empty?
44
55
 
45
56
  Terminal::Table.new(
@@ -49,7 +60,7 @@ module Jirify
49
60
  )
50
61
  end
51
62
 
52
- def transpose(grouped_issues, verbose)
63
+ def transpose(grouped_issues, options)
53
64
  col_padding_per_row = grouped_issues.size * 4
54
65
  max_cell_length = (terminal_width - col_padding_per_row) / grouped_issues.size
55
66
 
@@ -67,7 +78,7 @@ module Jirify
67
78
  transposed.map! do |row|
68
79
  row.map do |issue|
69
80
  next if issue.nil?
70
- SprintCell.new(issue, max_cell_length).to_s(verbose)
81
+ SprintCell.new(issue, max_cell_length).to_s(options)
71
82
  end
72
83
  end
73
84
 
@@ -1,3 +1,3 @@
1
1
  module Jirify
2
- VERSION = '0.1.7'.freeze
2
+ VERSION = '0.1.8'.freeze
3
3
  end
data/lib/jirify.rb CHANGED
@@ -1,17 +1,21 @@
1
1
  require 'jira-ruby'
2
2
  require 'thor'
3
3
  require 'colorize'
4
+ require 'colorized_string'
4
5
 
5
6
  require 'jirify/version'
6
7
  require 'jirify/config'
7
8
  require 'jirify/monkey_patches/jira_issue'
8
9
 
9
10
  require 'jirify/models/base'
11
+ require 'jirify/models/base_list'
10
12
  require 'jirify/models/status'
13
+ require 'jirify/models/transition'
11
14
  require 'jirify/models/transition_list'
12
15
  require 'jirify/models/issue'
13
16
  require 'jirify/models/sprint'
14
17
  require 'jirify/models/project'
18
+ require 'jirify/models/project_list'
15
19
 
16
20
  require 'jirify/ui/sprint_cell'
17
21
  require 'jirify/ui/sprint_table'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jirify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Georgi Gardev
@@ -271,10 +271,13 @@ files:
271
271
  - lib/jirify/cli/sprint.rb
272
272
  - lib/jirify/config.rb
273
273
  - lib/jirify/models/base.rb
274
+ - lib/jirify/models/base_list.rb
274
275
  - lib/jirify/models/issue.rb
275
276
  - lib/jirify/models/project.rb
277
+ - lib/jirify/models/project_list.rb
276
278
  - lib/jirify/models/sprint.rb
277
279
  - lib/jirify/models/status.rb
280
+ - lib/jirify/models/transition.rb
278
281
  - lib/jirify/models/transition_list.rb
279
282
  - lib/jirify/monkey_patches/jira_issue.rb
280
283
  - lib/jirify/ui/sprint_cell.rb