gpr 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/gpr +4 -0
- data/gpr.gemspec +5 -5
- data/lib/gpr/api_helper.rb +3 -0
- data/lib/gpr/cli.rb +10 -2
- data/lib/gpr/version.rb +1 -1
- data/lib/gpr.rb +0 -13
- data/lib/graph_drawer/data.rb +3 -1
- data/lib/table_builder/column.rb +3 -1
- data/lib/table_builder/table.rb +3 -1
- metadata +32 -8
- data/lib/colorize.rb +0 -43
- data/lib/interactive_filter/input.rb +0 -27
- data/lib/interactive_filter/interface.rb +0 -126
- data/lib/interactive_filter.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95117424561ceb8c9d644bc5e205aa19839d016e
|
4
|
+
data.tar.gz: ed65b1a5812176da694c3bd9b8c09f2e607c5621
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 297f2d0dba68cef4fa1ff32ab7375e106cc4af93e2251fcc72e4d9a51c69dc310abf5706d77712d09d0d9ab4978afb70c751f83c8e9aa1a50bf234c78900f1ba
|
7
|
+
data.tar.gz: 4d814901a9a4bf82c63231557351810e73b14b3227d85365464ce6fcb3ebc4fc7af9bb48f8d87b0c54c5acc9e6426db7c44d0385d74c2942a87e766f5ffa59d4
|
data/bin/gpr
CHANGED
data/gpr.gemspec
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
1
|
+
$LOAD_PATH << File.expand_path('../lib', __FILE__)
|
4
2
|
require 'gpr/version'
|
5
3
|
|
6
4
|
Gem::Specification.new do |spec|
|
@@ -8,8 +6,8 @@ Gem::Specification.new do |spec|
|
|
8
6
|
spec.version = Gpr::VERSION
|
9
7
|
spec.authors = ['kaihar4']
|
10
8
|
spec.email = ['kaihar4@gmail.com']
|
11
|
-
spec.summary = '
|
12
|
-
spec.description =
|
9
|
+
spec.summary = 'Gitkeeper.'
|
10
|
+
spec.description = spec.summary
|
13
11
|
spec.homepage = 'https://github.com/kaihar4/gpr'
|
14
12
|
spec.license = 'MIT'
|
15
13
|
|
@@ -21,6 +19,8 @@ Gem::Specification.new do |spec|
|
|
21
19
|
spec.add_dependency 'thor'
|
22
20
|
spec.add_dependency 'rroonga'
|
23
21
|
spec.add_dependency 'curses'
|
22
|
+
spec.add_dependency 'safe_colorize'
|
23
|
+
spec.add_dependency 'ifilter'
|
24
24
|
|
25
25
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
26
26
|
spec.add_development_dependency 'rake'
|
data/lib/gpr/api_helper.rb
CHANGED
data/lib/gpr/cli.rb
CHANGED
@@ -1,6 +1,14 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'groonga'
|
3
|
+
require 'safe_colorize'
|
4
|
+
require 'ifilter'
|
5
|
+
|
6
|
+
require 'table_builder'
|
7
|
+
require 'graph_drawer'
|
8
|
+
|
1
9
|
module Gpr
|
2
10
|
class CLI < Thor
|
3
|
-
using
|
11
|
+
using SafeColorize
|
4
12
|
include TableBuilder
|
5
13
|
include GraphDrawer
|
6
14
|
|
@@ -64,7 +72,7 @@ module Gpr
|
|
64
72
|
desc 'select', 'Select a repository using the interactive interface'
|
65
73
|
def select
|
66
74
|
repositories = get_repositories
|
67
|
-
puts
|
75
|
+
puts Ifilter.filtering(repositories)
|
68
76
|
end
|
69
77
|
|
70
78
|
desc 'contrib', 'Show your contributions of registered repositories'
|
data/lib/gpr/version.rb
CHANGED
data/lib/gpr.rb
CHANGED
@@ -1,16 +1,3 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
require 'net/https'
|
3
|
-
require 'json'
|
4
|
-
require 'find'
|
5
|
-
|
6
|
-
require 'thor'
|
7
|
-
require 'groonga'
|
8
|
-
require 'curses'
|
9
|
-
|
10
|
-
require 'colorize'
|
11
|
-
require 'table_builder'
|
12
|
-
require 'graph_drawer'
|
13
|
-
require 'interactive_filter'
|
14
1
|
require 'gpr/version'
|
15
2
|
require 'gpr/api_helper'
|
16
3
|
require 'gpr/git_helper'
|
data/lib/graph_drawer/data.rb
CHANGED
data/lib/table_builder/column.rb
CHANGED
data/lib/table_builder/table.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gpr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kaihar4
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -52,6 +52,34 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: safe_colorize
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: ifilter
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: bundler
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,7 +136,7 @@ dependencies:
|
|
108
136
|
- - ">="
|
109
137
|
- !ruby/object:Gem::Version
|
110
138
|
version: '0'
|
111
|
-
description:
|
139
|
+
description: Gitkeeper.
|
112
140
|
email:
|
113
141
|
- kaihar4@gmail.com
|
114
142
|
executables:
|
@@ -123,7 +151,6 @@ files:
|
|
123
151
|
- Rakefile
|
124
152
|
- bin/gpr
|
125
153
|
- gpr.gemspec
|
126
|
-
- lib/colorize.rb
|
127
154
|
- lib/gpr.rb
|
128
155
|
- lib/gpr/api_helper.rb
|
129
156
|
- lib/gpr/cli.rb
|
@@ -132,9 +159,6 @@ files:
|
|
132
159
|
- lib/graph_drawer.rb
|
133
160
|
- lib/graph_drawer/data.rb
|
134
161
|
- lib/graph_drawer/graph.rb
|
135
|
-
- lib/interactive_filter.rb
|
136
|
-
- lib/interactive_filter/input.rb
|
137
|
-
- lib/interactive_filter/interface.rb
|
138
162
|
- lib/table_builder.rb
|
139
163
|
- lib/table_builder/column.rb
|
140
164
|
- lib/table_builder/column_validator.rb
|
@@ -164,5 +188,5 @@ rubyforge_project:
|
|
164
188
|
rubygems_version: 2.2.2
|
165
189
|
signing_key:
|
166
190
|
specification_version: 4
|
167
|
-
summary:
|
191
|
+
summary: Gitkeeper.
|
168
192
|
test_files: []
|
data/lib/colorize.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
module Colorize
|
2
|
-
refine String do
|
3
|
-
COLORS = {
|
4
|
-
black: 0,
|
5
|
-
red: 1,
|
6
|
-
green: 2,
|
7
|
-
yellow: 3,
|
8
|
-
blue: 4,
|
9
|
-
magenta: 5,
|
10
|
-
cyan: 6,
|
11
|
-
white: 7
|
12
|
-
}
|
13
|
-
|
14
|
-
STYLES = {
|
15
|
-
reset: 0,
|
16
|
-
bold: 1,
|
17
|
-
underscore: 4,
|
18
|
-
blink: 5,
|
19
|
-
reverse: 6,
|
20
|
-
concealed: 7
|
21
|
-
}
|
22
|
-
|
23
|
-
def color(color)
|
24
|
-
to_ansi("3#{COLORS[color]}")
|
25
|
-
end
|
26
|
-
|
27
|
-
def bg_color(color)
|
28
|
-
to_ansi("4#{COLORS[color]}")
|
29
|
-
end
|
30
|
-
|
31
|
-
def style(style)
|
32
|
-
to_ansi(STYLES[style])
|
33
|
-
end
|
34
|
-
|
35
|
-
def to_ansi(code)
|
36
|
-
"\e[#{code.to_i}m#{self}\e[0m"
|
37
|
-
end
|
38
|
-
|
39
|
-
def to_pure
|
40
|
-
gsub(/\x1B\[[0-9]{1,3}[mK]/, '')
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module InteractiveFilter
|
2
|
-
class Input
|
3
|
-
attr_accessor :text
|
4
|
-
|
5
|
-
def initialize(text = '')
|
6
|
-
@text = text
|
7
|
-
end
|
8
|
-
|
9
|
-
def <<(text)
|
10
|
-
@text << text
|
11
|
-
end
|
12
|
-
|
13
|
-
def backspace!
|
14
|
-
@text.chop!
|
15
|
-
end
|
16
|
-
|
17
|
-
def to_s
|
18
|
-
@text
|
19
|
-
end
|
20
|
-
|
21
|
-
def to_regex
|
22
|
-
/#{@text}/
|
23
|
-
rescue
|
24
|
-
nil
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,126 +0,0 @@
|
|
1
|
-
module InteractiveFilter
|
2
|
-
class Interface
|
3
|
-
def initialize(name, array)
|
4
|
-
@prompt = "#{name}> "
|
5
|
-
@targets = array
|
6
|
-
|
7
|
-
@input = Input.new
|
8
|
-
@outputs = []
|
9
|
-
@cursor_position = 1
|
10
|
-
|
11
|
-
Curses.init_screen
|
12
|
-
Curses.crmode
|
13
|
-
Curses.noecho
|
14
|
-
@window = Curses::Window.new(Curses.lines, Curses.cols, 0, 0)
|
15
|
-
@window.keypad(true)
|
16
|
-
end
|
17
|
-
|
18
|
-
def grep
|
19
|
-
output_line(@prompt)
|
20
|
-
output_choises
|
21
|
-
reset_cursor_position
|
22
|
-
|
23
|
-
loop do
|
24
|
-
key = @window.getch
|
25
|
-
keycode = get_keycode(key)
|
26
|
-
|
27
|
-
if key.class == String
|
28
|
-
@input << key
|
29
|
-
|
30
|
-
# <BS>
|
31
|
-
elsif key == 127
|
32
|
-
@input.backspace!
|
33
|
-
|
34
|
-
# <CR>
|
35
|
-
elsif keycode == :KEY_CTRL_J
|
36
|
-
if @outputs.size >= @cursor_position && @cursor_position >= 1
|
37
|
-
break
|
38
|
-
else
|
39
|
-
next
|
40
|
-
end
|
41
|
-
|
42
|
-
elsif keycode == :KEY_DOWN
|
43
|
-
down_cursor_position
|
44
|
-
next
|
45
|
-
|
46
|
-
elsif keycode == :KEY_UP
|
47
|
-
up_cursor_position
|
48
|
-
next
|
49
|
-
|
50
|
-
# Ignore other keys
|
51
|
-
else
|
52
|
-
next
|
53
|
-
end
|
54
|
-
|
55
|
-
# Initialize a window
|
56
|
-
@outputs = []
|
57
|
-
@window.clear
|
58
|
-
reset_cursor_position
|
59
|
-
|
60
|
-
output_line(@prompt + @input.to_s)
|
61
|
-
output_choises
|
62
|
-
reset_cursor_position
|
63
|
-
end
|
64
|
-
|
65
|
-
Curses.close_screen
|
66
|
-
return @outputs[@cursor_position - 1]
|
67
|
-
|
68
|
-
# <C-c>
|
69
|
-
rescue Interrupt
|
70
|
-
Curses.close_screen
|
71
|
-
end
|
72
|
-
|
73
|
-
private
|
74
|
-
|
75
|
-
def get_keycode(key)
|
76
|
-
Curses.constants.select do |name|
|
77
|
-
/^KEY/ =~ name && Curses.const_get(name) == key
|
78
|
-
end.first
|
79
|
-
end
|
80
|
-
|
81
|
-
def output_choises
|
82
|
-
# Filtering
|
83
|
-
@targets.each do |target|
|
84
|
-
regex = @input.to_regex
|
85
|
-
|
86
|
-
if !regex.nil? && regex =~ target
|
87
|
-
@outputs << target
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
@outputs.each { |output| output_line(output) }
|
92
|
-
end
|
93
|
-
|
94
|
-
def output_line(word)
|
95
|
-
@window.setpos(@cursor_position - 1, 0)
|
96
|
-
@cursor_position += 1
|
97
|
-
|
98
|
-
@window << word
|
99
|
-
end
|
100
|
-
|
101
|
-
def up_cursor_position
|
102
|
-
if @cursor_position == 1
|
103
|
-
@window.setpos(@outputs.size, 0)
|
104
|
-
@cursor_position = @outputs.size
|
105
|
-
else
|
106
|
-
@window.setpos(@cursor_position - 1, 0)
|
107
|
-
@cursor_position -= 1
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
def down_cursor_position
|
112
|
-
if @cursor_position == @outputs.size
|
113
|
-
@window.setpos(1, 0)
|
114
|
-
@cursor_position = 1
|
115
|
-
else
|
116
|
-
@window.setpos(@cursor_position + 1, 0)
|
117
|
-
@cursor_position += 1
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
def reset_cursor_position
|
122
|
-
@window.setpos(1, 0)
|
123
|
-
@cursor_position = 1
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
data/lib/interactive_filter.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'interactive_filter/input'
|
2
|
-
require 'interactive_filter/interface'
|
3
|
-
|
4
|
-
module InteractiveFilter
|
5
|
-
def self.filtering(repositories)
|
6
|
-
name = caller.last.match(/.+\/(.+?)(:|\.)/)[1].capitalize
|
7
|
-
|
8
|
-
isatty = STDOUT.isatty
|
9
|
-
|
10
|
-
unless isatty
|
11
|
-
stdout_old = STDOUT.dup
|
12
|
-
STDOUT.reopen('/dev/tty')
|
13
|
-
end
|
14
|
-
|
15
|
-
ifilter = Interface.new(name, repositories)
|
16
|
-
result = ifilter.grep
|
17
|
-
|
18
|
-
unless isatty
|
19
|
-
STDOUT.flush
|
20
|
-
STDOUT.reopen(stdout_old)
|
21
|
-
end
|
22
|
-
|
23
|
-
result
|
24
|
-
end
|
25
|
-
end
|