icersplicer 1.0.7 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/icersplicer +15 -15
- data/examples/keywords-ruby.ice +31 -9
- data/examples/keywords.ice +18 -8
- data/lib/icersplicer.rb +54 -48
- data/lib/version.rb +2 -2
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ed0550a22c725c9d54bf723d1f708844022d9bc
|
4
|
+
data.tar.gz: 8b295dd653c3d6eedcb2bcd741d97814ac7aeb3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ea2903a7adda3b0824898589d2545252c708bec1b3ca2d6221ee0ecd60bcac320b81a003e491bd07b5844808225ad5bcc1a5649953977fbfbe433c851ce86c8
|
7
|
+
data.tar.gz: 7511032048d26a6c8deea2f7598e875b08da4082c37ce74a61001258a6730b42ff28833567c0451fe0904489d1406b01e6d8e1aeccdc017fb5fe601a69d3d443
|
data/bin/icersplicer
CHANGED
@@ -95,18 +95,18 @@ opts.each do |opt, arg|
|
|
95
95
|
|
96
96
|
Features:
|
97
97
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
98
|
+
Syntax highlighting / On / Off
|
99
|
+
Head /Tail functionality
|
100
|
+
Tail follow like tail -f
|
101
|
+
Support for multiple input for files / wildcards
|
102
|
+
Ability to Skip lines and line ranges and blank lines
|
103
|
+
Quiet mode for exporting large files
|
104
|
+
Countlines in a file
|
105
|
+
Grep functionality
|
106
|
+
Search & Replace in a file
|
107
|
+
Turn off line numbers
|
108
|
+
Debugging mode
|
109
|
+
Turn off line numbers
|
110
110
|
|
111
111
|
Example:
|
112
112
|
|
@@ -278,13 +278,13 @@ begin
|
|
278
278
|
}
|
279
279
|
}
|
280
280
|
}
|
281
|
-
rescue
|
282
|
-
raise
|
281
|
+
rescue NoMethodError
|
282
|
+
raise LoadError, "Please specify a valid filename or wildcard file extension"
|
283
283
|
end
|
284
284
|
rescue Errno::EPIPE, IOError
|
285
285
|
raise IOError, "Closing session due to broken pipe"
|
286
286
|
end
|
287
|
-
ice.
|
287
|
+
ice.close
|
288
288
|
unless instance_variable_defined?("@nostats")
|
289
289
|
ice.filterlinestats(filterlines)
|
290
290
|
ice.stats(inputfile, outputfile)
|
data/examples/keywords-ruby.ice
CHANGED
@@ -20,12 +20,13 @@ include##colour=cyan
|
|
20
20
|
public##colour=cyan
|
21
21
|
private##colour=cyan
|
22
22
|
protected##colour=cyan
|
23
|
-
unless##colour=
|
24
|
-
|
25
|
-
|
23
|
+
unless##colour=magenta
|
24
|
+
while##colour=magenta
|
25
|
+
case##colour=magenta
|
26
|
+
when##colour=magenta
|
26
27
|
do##colour=yellow
|
27
|
-
if##colour=
|
28
|
-
else##colour=
|
28
|
+
if##colour=magenta
|
29
|
+
else##colour=magenta
|
29
30
|
puts##colour=blue
|
30
31
|
print##colour=blue
|
31
32
|
each##colour=green
|
@@ -34,7 +35,7 @@ gsub##colour=cyan
|
|
34
35
|
strip##colour=cyan
|
35
36
|
split##colour=cyan
|
36
37
|
rand##colour=yellow
|
37
|
-
and##colour=yellow
|
38
|
+
and ##colour=yellow
|
38
39
|
raise##colour=yellow
|
39
40
|
trap##colour=blue
|
40
41
|
new##colour=cyan
|
@@ -43,6 +44,9 @@ nil##colour=cyan
|
|
43
44
|
.write##colour=cyan
|
44
45
|
.close##colour=cyan
|
45
46
|
.update##colour=cyan
|
47
|
+
.glob##colour=cyan
|
48
|
+
.upto##colour=cyan
|
49
|
+
.downto##colour=cyan
|
46
50
|
::##colour=white
|
47
51
|
@##colour=yellow
|
48
52
|
||=##colour=white
|
@@ -50,6 +54,24 @@ nil##colour=cyan
|
|
50
54
|
-=##colour=white
|
51
55
|
+=##colour=white
|
52
56
|
=##colour=white
|
53
|
-
{##colour=
|
54
|
-
}##colour=
|
55
|
-
exit##colour=
|
57
|
+
{##colour=red
|
58
|
+
}##colour=red
|
59
|
+
exit##colour=magenta
|
60
|
+
INSERT##colour=green
|
61
|
+
INTO##colour=green
|
62
|
+
UPDATE##colour=green
|
63
|
+
DELETE##colour=green
|
64
|
+
FROM##colour=green
|
65
|
+
GROUP##colour=green
|
66
|
+
BY##colour=green
|
67
|
+
ORDER##colour=green
|
68
|
+
LIMIT##colour=green
|
69
|
+
OFFSET##colour=green
|
70
|
+
SELECT##colour=green
|
71
|
+
FROM##colour=green
|
72
|
+
WHERE##colour=green
|
73
|
+
VALUES##colour=green
|
74
|
+
AND##colour=green
|
75
|
+
OR##colour=green
|
76
|
+
NOT##colour=green
|
77
|
+
IN##colour=green
|
data/examples/keywords.ice
CHANGED
@@ -1,11 +1,26 @@
|
|
1
|
-
INSERT##colour=
|
2
|
-
INTO##colour=
|
3
|
-
VALUES##colour=
|
1
|
+
INSERT##colour=magenta
|
2
|
+
INTO##colour=magenta
|
3
|
+
VALUES##colour=magenta
|
4
4
|
CREATE TABLE##colour=red
|
5
5
|
CREATE SCHEMA##colour=red
|
6
|
+
ALTER SEQUENCE##colour=red
|
7
|
+
CREATE SEQUENCE##colour=red
|
8
|
+
CREATE USER##colour=red
|
9
|
+
ALTER USER##colour=red
|
10
|
+
COPY##colour=magenta
|
6
11
|
SET SCHEMA##colour=yellow
|
7
12
|
DROP TABLE##colour=red
|
8
13
|
DROP SCHEMA##colour=red
|
14
|
+
IGNORE##colour=red
|
15
|
+
IF##colour=red
|
16
|
+
EXISTS##colour=red
|
17
|
+
CONSTRAINT##colour=magenta
|
18
|
+
PRIMARY KEY##colour=magenta
|
19
|
+
FOREIGN KEY##colour=magenta
|
20
|
+
ALTER TABLE##colour=red
|
21
|
+
REFERENCES##colour=magenta
|
22
|
+
ADD##colour=red
|
23
|
+
COMMIT##colour=cyan
|
9
24
|
char
|
10
25
|
integer
|
11
26
|
varchar
|
@@ -13,8 +28,3 @@ date
|
|
13
28
|
boolean
|
14
29
|
NOT NULL##colour=white
|
15
30
|
NULL##colour=white
|
16
|
-
(##colour=cyan
|
17
|
-
)##colour=cyan
|
18
|
-
);##colour=cyan
|
19
|
-
true##colour=blue
|
20
|
-
false##colour=yellow
|
data/lib/icersplicer.rb
CHANGED
@@ -9,7 +9,40 @@
|
|
9
9
|
#
|
10
10
|
########################################################################
|
11
11
|
require 'file-tail'
|
12
|
+
require 'rainbow'
|
12
13
|
|
14
|
+
module OutputFile
|
15
|
+
|
16
|
+
@@fileopen = 0
|
17
|
+
|
18
|
+
def open(outputfile)
|
19
|
+
begin
|
20
|
+
puts "Openfile: #{outputfile}" if @debug >= 1
|
21
|
+
@export = File.open("#{outputfile}", 'w')
|
22
|
+
rescue Errno::EACCES
|
23
|
+
raise IOError, "Can't create file please check file / directory permissions"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def write(data)
|
28
|
+
@export.write(data)
|
29
|
+
end
|
30
|
+
|
31
|
+
def close
|
32
|
+
begin
|
33
|
+
@export.close
|
34
|
+
puts "Closing file"
|
35
|
+
rescue NoMethodError
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def processdata(data, outputfile, quietmode)
|
40
|
+
open(outputfile) if @@fileopen == 0
|
41
|
+
write(data)
|
42
|
+
@@fileopen += 1
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
13
46
|
|
14
47
|
module Icersplicer
|
15
48
|
|
@@ -17,17 +50,18 @@ module Icersplicer
|
|
17
50
|
|
18
51
|
attr_writer :nohighlighter, :skip_lines, :keywordsfile, :debug, :nolinenumbers
|
19
52
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
53
|
+
include OutputFile
|
54
|
+
|
55
|
+
COLOURS = {0 => "black",
|
56
|
+
1 => "red",
|
57
|
+
2 => "green",
|
58
|
+
3 => "yellow",
|
59
|
+
4 => "blue",
|
60
|
+
5 => "purple",
|
61
|
+
6 => "cyan",
|
62
|
+
7 => "white"}
|
28
63
|
|
29
64
|
def initialize
|
30
|
-
@fileopen = 0
|
31
65
|
@keywordsfile = "keywords.ice"
|
32
66
|
@debug = 0
|
33
67
|
@nolinenumbers = false
|
@@ -83,23 +117,22 @@ module Icersplicer
|
|
83
117
|
keys ||= load_keywords("#{@keywordsfile}")
|
84
118
|
unless keys.class == Hash
|
85
119
|
keys = {0 => "Ln:",
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
120
|
+
1 => "SELECT",
|
121
|
+
2 => "CREATE TABLE",
|
122
|
+
3 => "UPDATE",
|
123
|
+
4 => "DELETE",
|
124
|
+
5 => "INSERT"}
|
91
125
|
end
|
92
126
|
cpicker = [2,3,4,1,7,5,6] # Just a selection of colours
|
93
127
|
keys.each {|n|
|
94
128
|
if n[1].split("##")[1] == nil
|
95
|
-
|
129
|
+
name = COLOURS[rand(COLOURS.size - 1)]
|
130
|
+
text.gsub!("#{n[1]}", Rainbow.new.wrap("#{n[1]}").send(name.to_sym))
|
96
131
|
else
|
97
|
-
name = n[1].split("##")[1].split("=")[1]; puts "Name: #{name}" if @debug >= 3
|
98
|
-
cnum = COLOURS[name].to_i; puts "Colour Number: #{cnum}" if @debug >= 3
|
99
132
|
nval = n[1].split("##")[0]; puts "Value: #{nval}" if @debug >= 3
|
100
|
-
|
133
|
+
name = n[1].split("##")[1].split("=")[1]; puts "Value: #{name}" if @debug >= 3
|
134
|
+
text.gsub!("#{nval}", Rainbow.new.wrap("#{nval}").send(name.to_sym))
|
101
135
|
end
|
102
|
-
text.gsub!(" \e[0;32m", "\e[0;32m")
|
103
136
|
}
|
104
137
|
return text
|
105
138
|
end
|
@@ -157,39 +190,12 @@ module Icersplicer
|
|
157
190
|
end
|
158
191
|
|
159
192
|
def print_to_screen(linenum, text, quiet)
|
160
|
-
unless @nolinenumbers == true
|
161
|
-
print "
|
193
|
+
unless @nolinenumbers == true or quiet == true
|
194
|
+
print Rainbow.new.wrap("Ln: #{linenum}:").yellow
|
162
195
|
end
|
163
196
|
print "#{text}" unless quiet == true
|
164
197
|
end
|
165
198
|
|
166
|
-
def openfile(outputfile)
|
167
|
-
begin
|
168
|
-
puts "Openfile: #{outputfile}" if @debug >= 1
|
169
|
-
@export = File.open("#{outputfile}", 'w')
|
170
|
-
rescue Errno::EACCES
|
171
|
-
raise IOError, "Can't create file please check file / directory permissions"
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
def writefile(data)
|
176
|
-
@export.write(data)
|
177
|
-
end
|
178
|
-
|
179
|
-
def closefile
|
180
|
-
begin
|
181
|
-
@export.close
|
182
|
-
puts "Closing file"
|
183
|
-
rescue NoMethodError
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
def processdata(data, outputfile, quietmode)
|
188
|
-
openfile(outputfile) if @fileopen == 0
|
189
|
-
writefile(data)
|
190
|
-
@fileopen += 1
|
191
|
-
end
|
192
|
-
|
193
199
|
def stats(inputfile, outputfile)
|
194
200
|
puts "Skip Lines #{@skip_lines}" if @debug >= 1
|
195
201
|
print "Inputfile lines: "
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: icersplicer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Hood
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: walltime
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 1.1.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rainbow
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.1.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.1.0
|
41
55
|
description: Text file manipulation similar to UNIX tools like cat / head / tail
|
42
56
|
email: brianh6854@googlemail.com
|
43
57
|
executables:
|