openpull 0.0.3 → 0.0.4

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: b4be083cf16d42a2a0a87676af1d910ace880cd1
4
- data.tar.gz: 4fcb96cfc828411d7601f3079b006a662c2c9c4e
3
+ metadata.gz: 4d9f4bdf1fa1c21ed9f640511a7f34c0f781d56e
4
+ data.tar.gz: d5e88c87bdacef6d50b91c793a1ab75b6bf2aa36
5
5
  SHA512:
6
- metadata.gz: 3dfe1646a104bf3f3603d21c68ecc62ec602b458a095172d33d2c46294f66d792adde9cd305881dcc399a798e3ca7a2a2733b94c00efffa2e0f261f3774a35b3
7
- data.tar.gz: 44b6f4cb27c8efae9bf737ab62f81cf701e40691a1809607f07d471b212af3203f778b3c2b38e6d2d937c9b94c49bc9ef826f19484fc8953be95c186c8b06dc7
6
+ metadata.gz: d66eb8c9a83010b6b6c6a18d1cfe0eb91870c31f78f4e1363ca377c81d65e807a2a7224e8eb266f027415b4d2cd6fa56909a4035fa9ff71947882a153232b3fb
7
+ data.tar.gz: 96efa30ce9638de93d486910734c705ab83e617c923a775cc97011bae72671bbd9dae225c4a2f93fc4787cb44b9530cc3f4189b3816849f059669b31d0f86ed5
data/bin/openpull CHANGED
@@ -2,53 +2,4 @@
2
2
  require 'optparse'
3
3
  require 'openpull'
4
4
 
5
- options = {}
6
- op = OptionParser.new do |opts|
7
- opts.banner = 'Usage: openpull [options]'
8
-
9
- opts.separator ''
10
- opts.separator 'Organisation and username can also be set in the ' \
11
- 'environment as GITHUB_ORGANISATION and GITHUB_USERNAME.'
12
- opts.separator ''
13
-
14
- opts.separator "Options:"
15
-
16
- opts.on_tail('-h', '--help', 'Show this message') do
17
- puts opts
18
- exit
19
- end
20
-
21
- opts.on_tail("--version", "Show version") do
22
- puts OpenPull::VERSION
23
- exit
24
- end
25
-
26
- options[:organisation] = ENV['GITHUB_ORGANISATION']
27
- opts.on('-o', '--organisation [ORG]', String, 'The Github organisation') do |o|
28
- options[:organisation] = o
29
- end
30
-
31
- options[:username] = ENV['GITHUB_USERNAME']
32
- opts.on('-u', '--username [USER]', String, 'Your Github username') do |u|
33
- options[:username] = u
34
- end
35
- end
36
-
37
- op.parse!
38
-
39
- options[:access_token] = ENV['GITHUB_ACCESS_TOKEN']
40
-
41
- if options[:access_token].nil?
42
- puts 'You need to set the GitHub access token in your environment. ' \
43
- '(GITHUB_ACCESS_TOKEN)'
44
- exit
45
- elsif options[:organisation].nil?
46
- puts 'You need to either pass GitHub organisation or set it in your ' \
47
- 'environment. (GITHUB_ORGANISATION)'
48
- puts "\n#{op}"
49
- exit
50
- end
51
-
52
- puts OpenPull::Client.new(options[:access_token],
53
- options[:organisation],
54
- options[:username]).show_table
5
+ OpenPull::Runner.new(ARGV).run
data/lib/openpull.rb CHANGED
@@ -4,6 +4,7 @@ require 'colorize'
4
4
  require 'terminal-table'
5
5
  require 'delegate'
6
6
 
7
+ require 'openpull/runner'
7
8
  require 'openpull/client'
8
9
  require 'openpull/pull_request_decorator'
9
10
  require 'openpull/pull_request_fetcher'
@@ -22,14 +22,18 @@ module OpenPull
22
22
  pull_requests = client.pull_requests(repository.id, state: 'open')
23
23
  return [] if pull_requests.empty?
24
24
 
25
- header = ["#{repository.name} (#{pull_requests.size})".blue.bold]
26
- header += [''] * (OpenPull::Table::HEADINGS.size - 1)
25
+ headers = ["#{repository.name} (#{pull_requests.size})"]
26
+ headers << (repository.private ? 'private' : 'public')
27
+ headers += [''] * 3
28
+ headers << repository.html_url
29
+ headers << ''
30
+ headers.map! { |h| h.blue.bold }
27
31
 
28
32
  results = pull_requests.map do |pr|
29
33
  Thread.new { row(pr) }
30
34
  end.map(&:value)
31
35
 
32
- [header] + results
36
+ [headers] + results
33
37
  end
34
38
 
35
39
  def row(pr)
@@ -43,7 +47,7 @@ module OpenPull
43
47
  deco_pr.labels,
44
48
  deco_pr.status,
45
49
  deco_pr.mergeable,
46
- deco_pr.html_url,
50
+ deco_pr.html_url.underline,
47
51
  deco_pr.updated_at
48
52
  ]
49
53
  end
@@ -0,0 +1,76 @@
1
+ require 'optparse'
2
+
3
+ module OpenPull
4
+ class Runner
5
+ attr_reader :argv
6
+ attr_accessor :options
7
+
8
+ def initialize(argv)
9
+ @argv = argv
10
+ @options = {}
11
+ end
12
+
13
+ def run
14
+ op = option_parser
15
+ op.parse!
16
+ exit unless check_options(op)
17
+
18
+ puts OpenPull::Client.new(@options[:access_token],
19
+ @options[:organisation],
20
+ @options[:username]).show_table
21
+
22
+ end
23
+
24
+ private
25
+
26
+ def option_parser
27
+ OptionParser.new do |opts|
28
+ opts.banner = 'Usage: openpull [options]'
29
+
30
+ opts.separator ''
31
+ opts.separator 'Organisation and username can also be set in the ' \
32
+ 'environment as GITHUB_ORGANISATION and GITHUB_USERNAME.'
33
+ opts.separator ''
34
+
35
+ opts.separator 'Options:'
36
+
37
+ opts.on_tail('-h', '--help', 'Show this message') do
38
+ puts opts
39
+ exit
40
+ end
41
+
42
+ opts.on_tail('--version', 'Show version') do
43
+ puts OpenPull::VERSION
44
+ exit
45
+ end
46
+
47
+ @options[:organisation] = ENV['GITHUB_ORGANISATION']
48
+ opts.on('-o', '--organisation [ORG]', String, 'The Github organisation') do |o|
49
+ @options[:organisation] = o
50
+ end
51
+
52
+ @options[:username] = ENV['GITHUB_USERNAME']
53
+ opts.on('-u', '--username [USER]', String, 'Your Github username') do |u|
54
+ @options[:username] = u
55
+ end
56
+ end
57
+ end
58
+
59
+ def check_options(op)
60
+ @options[:access_token] = ENV['GITHUB_ACCESS_TOKEN']
61
+
62
+ if @options[:access_token].nil?
63
+ puts 'You need to set the GitHub access token in your environment. ' \
64
+ '(GITHUB_ACCESS_TOKEN)'
65
+ return false
66
+ elsif @options[:organisation].nil?
67
+ puts 'You need to either pass GitHub organisation or set it in your ' \
68
+ 'environment. (GITHUB_ORGANISATION)'
69
+ puts "\n#{op}"
70
+ return false
71
+ end
72
+
73
+ return true
74
+ end
75
+ end
76
+ end
@@ -1,3 +1,3 @@
1
1
  module OpenPull
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openpull
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mads Ohm Larsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-17 00:00:00.000000000 Z
11
+ date: 2015-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit
@@ -78,6 +78,7 @@ files:
78
78
  - lib/openpull/client.rb
79
79
  - lib/openpull/pull_request_decorator.rb
80
80
  - lib/openpull/pull_request_fetcher.rb
81
+ - lib/openpull/runner.rb
81
82
  - lib/openpull/table.rb
82
83
  - lib/openpull/version.rb
83
84
  homepage: http://ohm.sh/
@@ -100,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
101
  version: '0'
101
102
  requirements: []
102
103
  rubyforge_project:
103
- rubygems_version: 2.2.2
104
+ rubygems_version: 2.4.5
104
105
  signing_key:
105
106
  specification_version: 4
106
107
  summary: Fetches Open Pull-Requests from Github