icersplicer 0.6.8 → 0.7.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 +4 -4
- data/bin/icersplicer +26 -7
- data/lib/icersplicer.rb +18 -5
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b230d59ba3efeebb5a3ebaadde17f54a77ea235
|
4
|
+
data.tar.gz: 2b7e2bd69ce17fd94352006e5414a2c280f2b707
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6aedfb1f769f17d80c46f905c9be428fe57626305929e1929070ccfefe766d3c4f8eac98d8563775cee7d66f981170f2ce095150ef9077f79e6c9c6007acbdf
|
7
|
+
data.tar.gz: 8da23292ddff84de317c1729224bb707d9e6f805627672c35c10fd9d82d169eaf32284bd8dd7c256560627339a9e475d231c4fcafcf58e1d82efda581cbf379e
|
data/bin/icersplicer
CHANGED
@@ -22,6 +22,16 @@ require File.expand_path(File.join(
|
|
22
22
|
|
23
23
|
include Icersplicer
|
24
24
|
|
25
|
+
def reset_screen
|
26
|
+
puts "\e[0m\ "
|
27
|
+
end
|
28
|
+
|
29
|
+
trap("INT") {
|
30
|
+
puts "Goodbye see you soon!"
|
31
|
+
reset_screen
|
32
|
+
exit
|
33
|
+
}
|
34
|
+
|
25
35
|
VERSION = Icersplicer::VERSION::STRING
|
26
36
|
|
27
37
|
ARGV[0] = "--help" if ARGV[0] == nil
|
@@ -32,6 +42,7 @@ opts = GetoptLong.new(
|
|
32
42
|
[ '--linelimit', '-n', GetoptLong::REQUIRED_ARGUMENT],
|
33
43
|
[ '--head', '-3', GetoptLong::REQUIRED_ARGUMENT],
|
34
44
|
[ '--tail', '-4', GetoptLong::REQUIRED_ARGUMENT],
|
45
|
+
[ '--followtail', '-5', GetoptLong::REQUIRED_ARGUMENT],
|
35
46
|
[ '--incrementlimit', '-i', GetoptLong::OPTIONAL_ARGUMENT],
|
36
47
|
[ '--inputfile', '-f', GetoptLong::REQUIRED_ARGUMENT],
|
37
48
|
[ '--skiplines', '-s', GetoptLong::OPTIONAL_ARGUMENT],
|
@@ -57,6 +68,7 @@ opts.each do |opt, arg|
|
|
57
68
|
--linelimit '-n' INTEGER
|
58
69
|
--head '-3' INTEGER
|
59
70
|
--tail '-4' INTEGER
|
71
|
+
--followtail '-5' INTEGER
|
60
72
|
--inputfile '-f' filename
|
61
73
|
--skiplines '-s' LINE NUMBERS 3,5,6
|
62
74
|
--skipblank '-b' NO ARGUMENTS ( Ommit blank lines )
|
@@ -92,6 +104,9 @@ Written by Brian Hood
|
|
92
104
|
end
|
93
105
|
when /^--linelimit|^--head/
|
94
106
|
@line_limit = arg.to_i
|
107
|
+
when '--followtail'
|
108
|
+
@followtail = arg.to_i
|
109
|
+
puts "Tail lines: #{@followtail}"
|
95
110
|
when '--incrementlimit'
|
96
111
|
@increment_limit = arg.to_i
|
97
112
|
when '--inputfile'
|
@@ -119,6 +134,15 @@ Written by Brian Hood
|
|
119
134
|
end
|
120
135
|
end
|
121
136
|
|
137
|
+
inputfile = @inputfile
|
138
|
+
outputfile = @outputfile
|
139
|
+
grep = @grep
|
140
|
+
|
141
|
+
if instance_variable_defined?("@followtail")
|
142
|
+
lines = @followtail
|
143
|
+
followtail(inputfile, lines)
|
144
|
+
end
|
145
|
+
|
122
146
|
if instance_variable_defined?("@search")
|
123
147
|
search = @search
|
124
148
|
if instance_variable_defined?("@replace")
|
@@ -130,7 +154,6 @@ if instance_variable_defined?("@search")
|
|
130
154
|
end
|
131
155
|
end
|
132
156
|
|
133
|
-
|
134
157
|
unless instance_variable_defined?("@line_offset")
|
135
158
|
lineoffset = 0
|
136
159
|
else
|
@@ -152,10 +175,6 @@ end
|
|
152
175
|
linecounter = 0
|
153
176
|
quietmode = false | @quiet_mode
|
154
177
|
|
155
|
-
inputfile = @inputfile
|
156
|
-
outputfile = @outputfile
|
157
|
-
grep = @grep
|
158
|
-
|
159
178
|
if @countlines == true
|
160
179
|
countlines(inputfile)
|
161
180
|
exit
|
@@ -208,8 +227,8 @@ begin
|
|
208
227
|
rescue Errno::EPIPE
|
209
228
|
puts "Closing session due to broken pipe"
|
210
229
|
end
|
211
|
-
closefile
|
230
|
+
closefile
|
212
231
|
stats(inputfile, outputfile)
|
213
232
|
timer.watch('stop')
|
214
233
|
timer.print_stats
|
215
|
-
|
234
|
+
reset_screen
|
data/lib/icersplicer.rb
CHANGED
@@ -8,13 +8,14 @@
|
|
8
8
|
#
|
9
9
|
#
|
10
10
|
########################################################################
|
11
|
+
require 'file-tail'
|
11
12
|
|
12
13
|
module Icersplicer
|
13
14
|
|
14
15
|
module VERSION #:nodoc:
|
15
16
|
MAJOR = 0
|
16
|
-
MINOR =
|
17
|
-
TINY =
|
17
|
+
MINOR = 7
|
18
|
+
TINY = 0
|
18
19
|
CODENAME = "Ice Climber !"
|
19
20
|
STRING = [MAJOR, MINOR, TINY].join('.')
|
20
21
|
end
|
@@ -32,7 +33,16 @@ module Icersplicer
|
|
32
33
|
"purple" => 5,
|
33
34
|
"cyan" => 6,
|
34
35
|
"white" => 7}
|
35
|
-
|
36
|
+
|
37
|
+
def followtail(filename, number)
|
38
|
+
File::Tail::Logfile.open(filename) do |log|
|
39
|
+
log.interval = 3
|
40
|
+
log.backward(10)
|
41
|
+
log.backward(number).tail { |line| puts line }
|
42
|
+
end
|
43
|
+
exit
|
44
|
+
end
|
45
|
+
|
36
46
|
def load_keywords(file)
|
37
47
|
keys = Hash.new
|
38
48
|
linenum = 0
|
@@ -157,8 +167,11 @@ module Icersplicer
|
|
157
167
|
end
|
158
168
|
|
159
169
|
def closefile
|
160
|
-
|
161
|
-
|
170
|
+
begin
|
171
|
+
@@exp.close
|
172
|
+
puts "Closing file"
|
173
|
+
rescue NoMethodError
|
174
|
+
end
|
162
175
|
end
|
163
176
|
|
164
177
|
def processdata(data, outputfile, quietmode)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: icersplicer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Hood
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.0.5
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: file-tail
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.1.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.1.0
|
27
41
|
description: Text file manipulation similar to UNIX tools like cat / head / tail
|
28
42
|
email: brianh6854@googlemail.com
|
29
43
|
executables:
|