pra 1.1.0 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f854d2dbd12cfe0df0d280e0b4c48cf5389acc1c
4
- data.tar.gz: 95a6f5c7dce502ab33aeacee0957a22c00425e22
3
+ metadata.gz: 5d8d6958b72e8f36437ec53d445f6f2ebf534109
4
+ data.tar.gz: aa381045ea18651af3ebc0bec87e0c6257bc92bf
5
5
  SHA512:
6
- metadata.gz: f35294303b1581e0e51c34ffac26dc70c255ed5a76b253e393f890ab57d8b26074529a41f6174cb12434f5f6ed90302d9061fc8b224c8a5783a59402b400c68e
7
- data.tar.gz: ec7edb303f591bc50e2884906aa3b95b371d3266df854ef213e4158eb5480b4eafd78e9d31477f088cf61a2188c0da9fd97314c1d19868c7de4cdfd23912ffa6
6
+ metadata.gz: 0b0848e6357f350b38a3d7f48472f339d6a004020aa01f45697014d5a6e2387d172b654f6fbb14d49796b748fe9cdff431f5aa9d0af28a67ce1b0f33f8860d67
7
+ data.tar.gz: 11cd8fd6da709723581b2e1e3137f278a9e1b0a5f5c5b2ce7d7123653d9edae27cc9b6e016df3ae65d041ef485a5f875607a2bbf27d64d67f02008ea5f8e8900
data/ChangeLog.md CHANGED
@@ -6,6 +6,12 @@ versions as well as provide a rough history.
6
6
 
7
7
  #### Next Release
8
8
 
9
+ #### v1.2.0
10
+
11
+ * Added Assignee blacklisting so that when you have a group user that
12
+ represents a team assignment it can be blacklisted so that it doesn't show
13
+ up as assigned.
14
+
9
15
  #### v1.1.0
10
16
 
11
17
  * Added "Assignee" column so that users can see which pull requests have
data/README.md CHANGED
@@ -21,6 +21,11 @@ directory. The following is an example config that can be used as a starter.
21
21
  **your.stash.server**, and the **repositories** sections of each of the pull
22
22
  sources.
23
23
 
24
+ #### Assignee Blacklist
25
+
26
+ Reduces noise to more easily determine which pull requests are unassigned. Names
27
+ added will not appear in the assignee column.
28
+
24
29
  {
25
30
  "pull_sources": [
26
31
  {
@@ -49,6 +54,10 @@ sources.
49
54
  ]
50
55
  }
51
56
  }
57
+ ],
58
+ "assignee_blacklist": [
59
+ "IPT-Capture",
60
+ "IPT-Core Services"
52
61
  ]
53
62
  }
54
63
 
data/lib/pra/config.rb CHANGED
@@ -40,5 +40,9 @@ module Pra
40
40
  def pull_sources
41
41
  @initial_config["pull_sources"]
42
42
  end
43
+
44
+ def assignee_blacklist
45
+ @initial_config["assignee_blacklist"]
46
+ end
43
47
  end
44
48
  end
@@ -0,0 +1,53 @@
1
+ require 'pra/config'
2
+
3
+ module Pra
4
+ class CursesPullRequestPresenter
5
+ def initialize(pull_request)
6
+ @pull_request = pull_request
7
+ end
8
+
9
+ def repository
10
+ force_length(@pull_request.repository, 15)
11
+ end
12
+
13
+ def title
14
+ force_length(@pull_request.title, 20)
15
+ end
16
+
17
+ def from_reference
18
+ force_length(@pull_request.from_reference, 20)
19
+ end
20
+
21
+ def to_reference
22
+ force_length(@pull_request.to_reference, 20)
23
+ end
24
+
25
+ def author
26
+ force_length(@pull_request.author, 20)
27
+ end
28
+
29
+ def assignee
30
+ return force_length('', 20) if @pull_request.assignee.nil? || blacklisted?(@pull_request.assignee)
31
+ force_length(@pull_request.assignee, 20)
32
+ end
33
+
34
+ def service_id
35
+ force_length(@pull_request.service_id, 10)
36
+ end
37
+
38
+ def assignee_blacklist
39
+ config = Pra::Config.load_config
40
+ config.assignee_blacklist
41
+ end
42
+
43
+ private
44
+
45
+ def force_length(string, length)
46
+ string.ljust(length)[0..length - 1]
47
+ end
48
+
49
+ def blacklisted?(assignee)
50
+ assignee_blacklist.include?(assignee)
51
+ end
52
+ end
53
+ end
@@ -1,4 +1,5 @@
1
1
  require 'pra/window_system'
2
+ require 'pra/curses_pull_request_presenter'
2
3
  require 'pra/config'
3
4
  require 'launchy'
4
5
  require 'curses'
@@ -71,7 +72,7 @@ module Pra
71
72
  Curses.curs_set(0)
72
73
  Curses.init_pair(1, Curses::COLOR_CYAN, Curses::COLOR_BLACK)
73
74
  end
74
-
75
+
75
76
  def output_string(row, col, str)
76
77
  Curses.setpos(row, col)
77
78
  Curses.clrtoeol
@@ -114,7 +115,7 @@ module Pra
114
115
  output_string(3, 0, "#{@current_pull_requests.length} Pull Requests")
115
116
  output_string(HEADER_LINE, 0, "repository title from_reference to_reference author assignee service")
116
117
  output_string(HEADER_LINE + 1, 0, "-----------------------------------------------------------------------------------------------------------------------------------------------")
117
-
118
+
118
119
  (LIST_START_LINE...LIST_START_LINE+@previous_number_of_pull_requests).each do |i|
119
120
  Curses.setpos(i,0)
120
121
  Curses.clrtoeol
@@ -122,10 +123,11 @@ module Pra
122
123
  end
123
124
 
124
125
  @current_pull_requests.each_with_index do |pull_request, index|
126
+ pull_request_presenter = Pra::CursesPullRequestPresenter.new(pull_request)
125
127
  if index == @selected_pull_request_index
126
- output_highlighted_string(LIST_START_LINE + index, 0, "#{pull_request.repository.ljust(15)[0..14]}\t#{pull_request.title.ljust(20)[0..19]}\t#{pull_request.from_reference.ljust(20)[0..19]}\t#{pull_request.to_reference.ljust(20)[0..19]}\t#{pull_request.author.ljust(20)[0..19]}\t#{pull_request.assignee.ljust(20)[0..19]}\t#{pull_request.service_id.ljust(10)[0..9]}")
128
+ output_highlighted_string(LIST_START_LINE + index, 0, "#{pull_request_presenter.repository}\t#{pull_request_presenter.title}\t#{pull_request_presenter.from_reference}\t#{pull_request_presenter.to_reference}\t#{pull_request_presenter.author}\t#{pull_request_presenter.assignee}\t#{pull_request_presenter.service_id}")
127
129
  else
128
- output_string(LIST_START_LINE + index, 0, "#{pull_request.repository.ljust(15)[0..14]}\t#{pull_request.title.ljust(20)[0..19]}\t#{pull_request.from_reference.ljust(20)[0..19]}\t#{pull_request.to_reference.ljust(20)[0..19]}\t#{pull_request.author.ljust(20)[0..19]}\t#{pull_request.assignee.ljust(20)[0..19]}\t#{pull_request.service_id.ljust(10)[0..9]}")
130
+ output_string(LIST_START_LINE + index, 0, "#{pull_request_presenter.repository}\t#{pull_request_presenter.title}\t#{pull_request_presenter.from_reference}\t#{pull_request_presenter.to_reference}\t#{pull_request_presenter.author}\t#{pull_request_presenter.assignee}\t#{pull_request_presenter.service_id}")
129
131
  end
130
132
  end
131
133
  }
@@ -1,3 +1,5 @@
1
+ require 'pra/config'
2
+
1
3
  module Pra
2
4
  class PullRequest
3
5
  attr_accessor :title, :from_reference, :to_reference, :author, :assignee, :link, :service_id, :repository
@@ -12,9 +14,5 @@ module Pra
12
14
  @service_id = attributes[:service_id]
13
15
  @repository = attributes[:repository]
14
16
  end
15
-
16
- def assignee
17
- @assignee || ""
18
- end
19
17
  end
20
18
  end
data/lib/pra/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pra
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -134,4 +134,12 @@ describe Pra::Config do
134
134
  subject.pull_sources.should eq(pull_source_configs)
135
135
  end
136
136
  end
137
+
138
+ describe "#assignee_blacklist" do
139
+ it "returns the assignee blacklist value out of the config" do
140
+ assignee_blacklist_configs = double('assignee blacklist configs')
141
+ subject.instance_variable_set(:@initial_config, { "assignee_blacklist" => assignee_blacklist_configs })
142
+ subject.assignee_blacklist.should eq(assignee_blacklist_configs)
143
+ end
144
+ end
137
145
  end
@@ -0,0 +1,136 @@
1
+ require_relative '../../../lib/pra/curses_pull_request_presenter'
2
+
3
+ describe Pra::CursesPullRequestPresenter do
4
+ describe '.new' do
5
+ it 'construct given pull request' do
6
+ pull_request = double('pull request')
7
+ Pra::CursesPullRequestPresenter.new(pull_request)
8
+ end
9
+
10
+ it 'assigns pull request to an instance variable' do
11
+ pull_request = double('pull request')
12
+ curses_pull_request = Pra::CursesPullRequestPresenter.new(pull_request)
13
+ expect(curses_pull_request.instance_variable_get(:@pull_request)).to eq pull_request
14
+ end
15
+ end
16
+
17
+ describe '#force_length' do
18
+ it 'right pads the given string up to the specified length' do
19
+ pull_request = double
20
+ curses_pull_request = Pra::CursesPullRequestPresenter.new(pull_request)
21
+ expect(curses_pull_request.send(:force_length, 'capture_api', 15)).to eq 'capture_api '
22
+ end
23
+
24
+ it 'truncates the given string down to the specified length' do
25
+ pull_request = double
26
+ curses_pull_request = Pra::CursesPullRequestPresenter.new(pull_request)
27
+ expect(curses_pull_request.send(:force_length, 'capture_api_012345678912345', 15)).to eq 'capture_api_012'
28
+ end
29
+ end
30
+
31
+ describe '#repository' do
32
+ it 'forces the repository length to 15' do
33
+ repository = double
34
+ curses_pull_request = Pra::CursesPullRequestPresenter.new(double('pull request', repository: repository))
35
+ expect(curses_pull_request).to receive(:force_length).with(repository, 15)
36
+ curses_pull_request.repository
37
+ end
38
+ end
39
+
40
+ describe '#title' do
41
+ it 'forces the title length to 20' do
42
+ title = double
43
+ curses_pull_request = Pra::CursesPullRequestPresenter.new(double('pull request', title: title))
44
+ expect(curses_pull_request).to receive(:force_length).with(title, 20)
45
+ curses_pull_request.title
46
+ end
47
+ end
48
+
49
+ describe '#from_reference' do
50
+ it 'forces the from_reference length to 20' do
51
+ from_reference = double
52
+ curses_pull_request = Pra::CursesPullRequestPresenter.new(double('pull request', from_reference: from_reference))
53
+ expect(curses_pull_request).to receive(:force_length).with(from_reference, 20)
54
+ curses_pull_request.from_reference
55
+ end
56
+ end
57
+
58
+ describe '#to_reference' do
59
+ it 'forces the to_reference length to 20' do
60
+ to_reference = double
61
+ curses_pull_request = Pra::CursesPullRequestPresenter.new(double('pull request', to_reference: to_reference))
62
+ expect(curses_pull_request).to receive(:force_length).with(to_reference, 20)
63
+ curses_pull_request.to_reference
64
+ end
65
+ end
66
+
67
+ describe '#author' do
68
+ it 'forces the author length to 20' do
69
+ author = double
70
+ curses_pull_request = Pra::CursesPullRequestPresenter.new(double('pull request', author: author))
71
+ expect(curses_pull_request).to receive(:force_length).with(author, 20)
72
+ curses_pull_request.author
73
+ end
74
+ end
75
+
76
+ describe '#assignee' do
77
+ context 'when assignee is nil' do
78
+ it 'returns an empty string with length of 20' do
79
+ curses_pull_request = Pra::CursesPullRequestPresenter.new(double('pull_request', assignee: nil))
80
+ expect(curses_pull_request.assignee).to eq(' '*20)
81
+ end
82
+ end
83
+
84
+ context 'when assignee is NOT nil' do
85
+ context 'when assignee is blacklisted' do
86
+ it 'returns an empty string with length of 20' do
87
+ curses_pull_request = Pra::CursesPullRequestPresenter.new(double('pull_request', assignee: nil))
88
+ expect(curses_pull_request.assignee).to eq(' '*20)
89
+ end
90
+ end
91
+ end
92
+
93
+ context 'when assignee is NOT blacklisted' do
94
+ it 'returns assignee with a length of 20' do
95
+ curses_pull_request = Pra::CursesPullRequestPresenter.new(double('pull_request', assignee: 'IPT-Capture'))
96
+ allow(curses_pull_request).to receive(:assignee_blacklist).and_return(['IPT'])
97
+ expect(curses_pull_request.assignee).to eq('IPT-Capture ')
98
+ end
99
+ end
100
+
101
+ context 'when assignee IS blacklisted' do
102
+ it 'returns an empty string with length of 20' do
103
+ curses_pull_request = Pra::CursesPullRequestPresenter.new(double('pull_request', assignee: 'IPT-Capture'))
104
+ allow(curses_pull_request).to receive(:assignee_blacklist).and_return(['IPT-Capture'])
105
+ expect(curses_pull_request.assignee).to eq(' '*20)
106
+ end
107
+ end
108
+ end
109
+
110
+ describe '#service_id' do
111
+ it 'forces the service_id length to 20' do
112
+ service_id = double
113
+ curses_pull_request = Pra::CursesPullRequestPresenter.new(double('pull request', service_id: service_id))
114
+ expect(curses_pull_request).to receive(:force_length).with(service_id, 10)
115
+ curses_pull_request.service_id
116
+ end
117
+ end
118
+
119
+ describe '#blacklisted?' do
120
+ context 'when assignee IS blacklisted' do
121
+ it 'returns true' do
122
+ curses_pull_request = Pra::CursesPullRequestPresenter.new(double('pull request', assignee: 'IPT-Capture'))
123
+ allow(curses_pull_request).to receive(:assignee_blacklist).and_return(['IPT-Capture'])
124
+ expect(curses_pull_request.send(:blacklisted?, 'IPT-Capture')).to eq true
125
+ end
126
+ end
127
+
128
+ context 'when assignee IS not blacklisted' do
129
+ it 'returns false' do
130
+ curses_pull_request = Pra::CursesPullRequestPresenter.new(double('pull request', assignee: 'IPT-Capture'))
131
+ allow(curses_pull_request).to receive(:assignee_blacklist).and_return(['IPT'])
132
+ expect(curses_pull_request.send(:blacklisted?, 'IPT-Capture')).to eq false
133
+ end
134
+ end
135
+ end
136
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pra
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew De Ponte
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-19 00:00:00.000000000 Z
11
+ date: 2013-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -101,6 +101,7 @@ files:
101
101
  - lib/pra.rb
102
102
  - lib/pra/app.rb
103
103
  - lib/pra/config.rb
104
+ - lib/pra/curses_pull_request_presenter.rb
104
105
  - lib/pra/curses_window_system.rb
105
106
  - lib/pra/error_log.rb
106
107
  - lib/pra/github_pull_source.rb
@@ -116,6 +117,7 @@ files:
116
117
  - pra.gemspec
117
118
  - spec/lib/pra/app_spec.rb
118
119
  - spec/lib/pra/config_spec.rb
120
+ - spec/lib/pra/curses_pull_request_presenter_spec.rb
119
121
  - spec/lib/pra/curses_window_system_spec.rb
120
122
  - spec/lib/pra/error_log_spec.rb
121
123
  - spec/lib/pra/github_pull_source_spec.rb
@@ -155,6 +157,7 @@ summary: CLI tool that shows open pull-requests across systems.
155
157
  test_files:
156
158
  - spec/lib/pra/app_spec.rb
157
159
  - spec/lib/pra/config_spec.rb
160
+ - spec/lib/pra/curses_pull_request_presenter_spec.rb
158
161
  - spec/lib/pra/curses_window_system_spec.rb
159
162
  - spec/lib/pra/error_log_spec.rb
160
163
  - spec/lib/pra/github_pull_source_spec.rb