glark 1.10.4 → 1.10.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/glark/app/info/options.rb +1 -1
- data/lib/glark/io/file/zip_file.rb +38 -13
- data/lib/glark/match/re.rb +1 -1
- data/lib/glark/util/highlight.rb +9 -26
- data/test/glark/app/highlight_test.rb +19 -0
- metadata +34 -19
- checksums.yaml +0 -7
@@ -12,22 +12,11 @@ module Glark
|
|
12
12
|
def initialize fname, range, &blk
|
13
13
|
super fname, range
|
14
14
|
|
15
|
-
|
16
|
-
# installed with other package managers. So the require is down here, used
|
17
|
-
# only if needed.
|
18
|
-
|
19
|
-
begin
|
20
|
-
require 'zip/zip'
|
21
|
-
rescue LoadError => e
|
22
|
-
msg = "error loading zip gem: #{e}\n"
|
23
|
-
msg << "to install this dependency, run 'gem install rubyzip'"
|
24
|
-
info "msg: #{msg}".color(:red)
|
25
|
-
raise msg
|
26
|
-
end
|
15
|
+
check_rubyzip
|
27
16
|
end
|
28
17
|
|
29
18
|
def get_reader
|
30
|
-
@zipfile = Zip::
|
19
|
+
@zipfile = Zip::File.new @fname
|
31
20
|
end
|
32
21
|
|
33
22
|
def read entry
|
@@ -37,5 +26,41 @@ module Glark
|
|
37
26
|
def entry_name entry
|
38
27
|
entry.name
|
39
28
|
end
|
29
|
+
|
30
|
+
def check_rubyzip
|
31
|
+
check_rubyzip_exists
|
32
|
+
check_rubyzip_version
|
33
|
+
end
|
34
|
+
|
35
|
+
def check_rubyzip_exists
|
36
|
+
# Given that this is a gem, I'm not sure if it is installed with other
|
37
|
+
# package managers. So the require is down here, used only if needed.
|
38
|
+
begin
|
39
|
+
require 'zip'
|
40
|
+
rescue LoadError => e
|
41
|
+
msg = "error loading zip gem: #{e}\n"
|
42
|
+
msg << "to install this dependency, run 'gem install rubyzip'"
|
43
|
+
info Rainbow::Presenter.new("msg: #{msg}").color(:red)
|
44
|
+
raise msg
|
45
|
+
end
|
46
|
+
check_rubyzip_version
|
47
|
+
end
|
48
|
+
|
49
|
+
def check_rubyzip_version
|
50
|
+
require 'zip/version'
|
51
|
+
reqver = '1.1.4'
|
52
|
+
reqnum = version_to_number reqver
|
53
|
+
currnum = version_to_number Zip::VERSION
|
54
|
+
if currnum < reqnum
|
55
|
+
msg = "error: support for zip files requires rubyzip version >= #{reqver}; current version is #{Zip::VERSION}"
|
56
|
+
info Rainbow::Presenter.new("msg: #{msg}").color(:red)
|
57
|
+
raise msg
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def version_to_number ver
|
62
|
+
vernums = ver.split('.')
|
63
|
+
num = vernums.inject(0) { |s, n| 1000 * s + n.to_i }
|
64
|
+
end
|
40
65
|
end
|
41
66
|
end
|
data/lib/glark/match/re.rb
CHANGED
data/lib/glark/util/highlight.rb
CHANGED
@@ -13,23 +13,6 @@ module Highlight
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
module Sickill
|
17
|
-
module Rainbow
|
18
|
-
class AnsiColor
|
19
|
-
$-w = false
|
20
|
-
# includes the aberrant color name in the error message.
|
21
|
-
def validate_color_name #:nodoc:
|
22
|
-
color_names = TERM_COLORS.keys
|
23
|
-
|
24
|
-
unless color_names.include?(@color)
|
25
|
-
raise ArgumentError.new "Unknown color name: '#{@color}'; valid names: #{color_names.join(', ')}"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
$-w = true
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
16
|
class RainbowHighlighter
|
34
17
|
include Singleton
|
35
18
|
|
@@ -49,25 +32,25 @@ class RainbowHighlighter
|
|
49
32
|
def get_code color, type
|
50
33
|
case color
|
51
34
|
when 'bold', 'bright'
|
52
|
-
|
35
|
+
Rainbow::Presenter::TERM_EFFECTS[:bright]
|
53
36
|
when 'reverse', 'negative', 'inverse'
|
54
|
-
|
37
|
+
Rainbow::Presenter::TERM_EFFECTS[:inverse]
|
55
38
|
when 'underline'
|
56
|
-
|
39
|
+
Rainbow::Presenter::TERM_EFFECTS[:underline]
|
57
40
|
when 'blink'
|
58
|
-
|
41
|
+
Rainbow::Presenter::TERM_EFFECTS[:blink]
|
59
42
|
when %r{^[\dA-Fa-f]{6}$}
|
60
|
-
ac =
|
61
|
-
ac.
|
43
|
+
ac = Rainbow::Color.build type, [ color ]
|
44
|
+
ac.codes.join(';')
|
62
45
|
else
|
63
|
-
ac =
|
64
|
-
ac.
|
46
|
+
ac = Rainbow::Color.build type, [ color.to_sym ]
|
47
|
+
ac.codes.join(';')
|
65
48
|
end
|
66
49
|
end
|
67
50
|
|
68
51
|
def to_codes color
|
69
52
|
codes = ""
|
70
|
-
return codes unless
|
53
|
+
return codes unless Rainbow.enabled
|
71
54
|
color.scan(COLORS_RE).collect do |md|
|
72
55
|
color, type = md[0] ? [ md[0], :background ] : [ md[1], :foreground ]
|
73
56
|
code = get_code color, type
|
@@ -43,6 +43,25 @@ module Glark
|
|
43
43
|
run_app_test expected, [ '--file-color', 'yellow', 'The.?M.*Tale' ], *files
|
44
44
|
end
|
45
45
|
|
46
|
+
def test_rgb
|
47
|
+
files = [ '/proj/org/incava/glark/test/resources/textfile.txt', '/proj/org/incava/glark/test/resources/filelist.txt' ]
|
48
|
+
expected = [
|
49
|
+
"[38;5;152m/proj/org/incava/glark/test/resources/textfile.txt[0m",
|
50
|
+
" 3 -rw-r--r-- 1 jpace jpace 45450 2010-12-04 15:24 02-[38;5;207mTheMillersTale[0m.txt",
|
51
|
+
" 6 -rw-r--r-- 1 jpace jpace 63290 2010-12-04 15:24 05-[38;5;207mTheManOfLawsTale[0m.txt",
|
52
|
+
" 11 -rw-r--r-- 1 jpace jpace 65852 2010-12-04 15:24 10-[38;5;207mTheMerchantsTale[0m.txt",
|
53
|
+
" 20 -rw-r--r-- 1 jpace jpace 49747 2010-12-04 15:24 19-[38;5;207mTheMonksTale[0m.txt",
|
54
|
+
" 24 -rw-r--r-- 1 jpace jpace 21141 2010-12-04 15:24 23-[38;5;207mTheManciplesTale[0m.txt",
|
55
|
+
"[38;5;152m/proj/org/incava/glark/test/resources/filelist.txt[0m",
|
56
|
+
" 3 02-[38;5;207mThe_Millers_Tale[0m.txt",
|
57
|
+
" 6 05-[38;5;207mThe_Man_Of_Laws_Tale[0m.txt",
|
58
|
+
" 11 10-[38;5;207mThe_Merchants_Tale[0m.txt",
|
59
|
+
" 20 19-[38;5;207mThe_Monks_Tale[0m.txt",
|
60
|
+
" 24 23-[38;5;207mThe_Manciples_Tale[0m.txt",
|
61
|
+
]
|
62
|
+
run_app_test expected, [ '--file-color', '#aabbcc', '--text-color', '#f03dda', 'The.?M.*Tale' ], *files
|
63
|
+
end
|
64
|
+
|
46
65
|
def test_highlight_multi
|
47
66
|
fname = '/proj/org/incava/glark/test/resources/04-TheCooksTale.txt'
|
48
67
|
expected = [
|
metadata
CHANGED
@@ -1,76 +1,90 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glark
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.10.
|
4
|
+
version: 1.10.5
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Jeff Pace
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2014-06-18 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: riel
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
|
-
- - '>='
|
19
|
+
- - ! '>='
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: 1.2.0
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
|
-
- - '>='
|
27
|
+
- - ! '>='
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: 1.2.0
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: logue
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
|
-
- - '>='
|
35
|
+
- - ! '>='
|
32
36
|
- !ruby/object:Gem::Version
|
33
37
|
version: 1.0.0
|
34
38
|
type: :runtime
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
|
-
- - '>='
|
43
|
+
- - ! '>='
|
39
44
|
- !ruby/object:Gem::Version
|
40
45
|
version: 1.0.0
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: rainbow
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
|
-
- - '>='
|
51
|
+
- - ! '>='
|
46
52
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
53
|
+
version: 2.0.0
|
48
54
|
type: :runtime
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
|
-
- - '>='
|
59
|
+
- - ! '>='
|
53
60
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
61
|
+
version: 2.0.0
|
55
62
|
- !ruby/object:Gem::Dependency
|
56
63
|
name: ragol
|
57
64
|
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
58
66
|
requirements:
|
59
|
-
- - '>='
|
67
|
+
- - ! '>='
|
60
68
|
- !ruby/object:Gem::Version
|
61
69
|
version: 1.0.0
|
62
70
|
type: :runtime
|
63
71
|
prerelease: false
|
64
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
65
74
|
requirements:
|
66
|
-
- - '>='
|
75
|
+
- - ! '>='
|
67
76
|
- !ruby/object:Gem::Version
|
68
77
|
version: 1.0.0
|
69
|
-
description:
|
70
|
-
|
78
|
+
description: ! 'Glark searches files for regular expressions, extending grep by matching
|
79
|
+
complex
|
80
|
+
|
71
81
|
expressions ("and", "or", and "xor"), extracting and searching within compressed
|
82
|
+
|
72
83
|
files, and excluding .svn and .git subdirectories by default. Different projects
|
84
|
+
|
73
85
|
can have their own Glark configuration.
|
86
|
+
|
87
|
+
'
|
74
88
|
email: jeugenepace@gmail.com
|
75
89
|
executables:
|
76
90
|
- glark
|
@@ -194,26 +208,27 @@ files:
|
|
194
208
|
- test/resources/greet.rb
|
195
209
|
homepage: http://www.incava.org/projects/glark
|
196
210
|
licenses: []
|
197
|
-
metadata: {}
|
198
211
|
post_install_message:
|
199
212
|
rdoc_options: []
|
200
213
|
require_paths:
|
201
214
|
- lib
|
202
215
|
required_ruby_version: !ruby/object:Gem::Requirement
|
216
|
+
none: false
|
203
217
|
requirements:
|
204
|
-
- - '>='
|
218
|
+
- - ! '>='
|
205
219
|
- !ruby/object:Gem::Version
|
206
220
|
version: '0'
|
207
221
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
222
|
+
none: false
|
208
223
|
requirements:
|
209
|
-
- - '>='
|
224
|
+
- - ! '>='
|
210
225
|
- !ruby/object:Gem::Version
|
211
226
|
version: '0'
|
212
227
|
requirements: []
|
213
228
|
rubyforge_project:
|
214
|
-
rubygems_version:
|
229
|
+
rubygems_version: 1.8.23
|
215
230
|
signing_key:
|
216
|
-
specification_version:
|
231
|
+
specification_version: 3
|
217
232
|
summary: Extended searching of text files.
|
218
233
|
test_files:
|
219
234
|
- test/glark/app/and_test.rb
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: dfdc6d9ef40b4b5c09b5a7c5957b39b6b35d33e7
|
4
|
-
data.tar.gz: 91b8ef68d27dbfbc99285023675d083df7208148
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: af2c59dfac30ecba8c342938d319edaa58424066e25ae27ec1492367195708586b46b3a97bf6f93edeb6ef58c154eee9fd26a5aa4b9be8e95c5020992627a9c8
|
7
|
-
data.tar.gz: 0bf5f92f6018b2663ffdf7496443c32d9560c49c7a1e932f920debd6e603cfc5e73a90e0ec5f45e57ac718d343115d9c6a289771a88ece7df9891e7a93557793
|