pcut 0.0.1 → 0.0.2
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.
- data/.README.rdoc.swp +0 -0
- data/Manifest.txt +1 -0
- data/PostInstall.txt +1 -5
- data/README.rdoc +62 -2
- data/Rakefile +1 -1
- data/lib/pcut.rb +1 -1
- data/lib/pcut/cli.rb +5 -3
- data/lib/pcut/query.rb +4 -0
- data/lib/pcut/range_index.rb +8 -0
- data/spec/lib/pcut/query_spec.rb +4 -1
- data/spec/lib/pcut/range_index_spec.rb +5 -1
- metadata +10 -7
data/.README.rdoc.swp
ADDED
Binary file
|
data/Manifest.txt
CHANGED
data/PostInstall.txt
CHANGED
data/README.rdoc
CHANGED
@@ -5,12 +5,72 @@
|
|
5
5
|
== DESCRIPTION:
|
6
6
|
|
7
7
|
Yet another cutting tool.
|
8
|
+
pcut adds some features to cut command.
|
9
|
+
|
10
|
+
=== append field number, vertical print
|
11
|
+
|
12
|
+
Check field number before cutting.
|
13
|
+
when you have log line like this:
|
14
|
+
|
15
|
+
$ cat test
|
16
|
+
127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326 "http://www.example.com/start.html" "Mozilla/4.08 [en] (Win98; I ;Nav)"
|
17
|
+
|
18
|
+
You can cut line and get field number with --preview(-p).
|
19
|
+
It helps you to specify field number with -f option.
|
20
|
+
|
21
|
+
$ cat test | pcut -d " " --preview
|
22
|
+
[1]127.0.0.1 [2]- [3]frank [4][10/Oct/2000:13:55:36 [5]-0700] [6]"GET [7]/apache_pb.gif [8]HTTP/1.0" [9]200 [10]2326 [11]"http://www.example.com/start.html" [12]"Mozilla/4.08 [13][en] [14](Win98; [15]I [16];Nav)"
|
23
|
+
|
24
|
+
With --vertical(-v), cut results are joined by LF.
|
25
|
+
|
26
|
+
$ cat test | pcut -d " " --preview --vertical
|
27
|
+
[1]127.0.0.1
|
28
|
+
[2]-
|
29
|
+
[3]frank
|
30
|
+
[4][10/Oct/2000:13:55:36
|
31
|
+
[5]-0700]
|
32
|
+
[6]"GET
|
33
|
+
[7]/apache_pb.gif
|
34
|
+
[8]HTTP/1.0"
|
35
|
+
[9]200
|
36
|
+
[10]2326
|
37
|
+
[11]"http://www.example.com/start.html"
|
38
|
+
[12]"Mozilla/4.08
|
39
|
+
[13][en]
|
40
|
+
[14](Win98;
|
41
|
+
[15]I
|
42
|
+
[16];Nav)"
|
43
|
+
|
44
|
+
=== quoting
|
45
|
+
|
46
|
+
With -q option, pcut keep quoted strings as one field.
|
47
|
+
This function is usefull on logs like apache access log. Those logs
|
48
|
+
are likely to contain free text (path, user agent) and it may contains
|
49
|
+
cut delimiter.
|
50
|
+
|
51
|
+
-q specified quoting chars.
|
52
|
+
|
53
|
+
$ cat test | pcut -d " " --preview --vertical -q "DS["
|
54
|
+
[1]127.0.0.1
|
55
|
+
[2]-[3]frank
|
56
|
+
[4]10/Oct/2000:13:55:36 -0700
|
57
|
+
[5]GET /apache_pb.gif HTTP/1.0
|
58
|
+
[6]200[7]2326
|
59
|
+
[8]http://www.example.com/start.html
|
60
|
+
[9]Mozilla/4.08 [en] (Win98; I ;Nav)
|
61
|
+
|
62
|
+
D="dounble quote", S="single quote", [="[]", (="()"
|
63
|
+
You can set multiple chars to quote.
|
64
|
+
|
65
|
+
=== sub queries
|
66
|
+
|
67
|
+
|
68
|
+
|
8
69
|
|
9
|
-
== FEATURES/PROBLEMS:
|
10
70
|
|
11
71
|
== SYNOPSIS:
|
12
72
|
|
13
|
-
|
73
|
+
see pcut --help
|
14
74
|
|
15
75
|
== REQUIREMENTS:
|
16
76
|
|
data/Rakefile
CHANGED
@@ -12,7 +12,7 @@ Hoe.plugin :newgem
|
|
12
12
|
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
13
13
|
$hoe = Hoe.spec 'pcut' do
|
14
14
|
self.developer 'Nakano Kyohei (bonar)', 'bonar@me.com'
|
15
|
-
|
15
|
+
self.post_install_message = 'PostInstall.txt'
|
16
16
|
self.rubyforge_name = self.name # TODO this is default value
|
17
17
|
self.extra_deps = [
|
18
18
|
['term-ansicolor','>= 1.0.7']
|
data/lib/pcut.rb
CHANGED
data/lib/pcut/cli.rb
CHANGED
@@ -117,7 +117,7 @@ module Pcut
|
|
117
117
|
value.split(query.delimiter), query.index)
|
118
118
|
value = sliced.join(query.delimiter)
|
119
119
|
end
|
120
|
-
buff << query_label(index.index, queries
|
120
|
+
buff << query_label(index.index, queries) + (value || "")
|
121
121
|
end
|
122
122
|
end
|
123
123
|
# no @fields is "all the fields"
|
@@ -140,11 +140,13 @@ module Pcut
|
|
140
140
|
(@color ? red : '') + "]" + (@color ? reset : '')
|
141
141
|
end
|
142
142
|
|
143
|
-
def query_label(index,
|
143
|
+
def query_label(index, queries)
|
144
144
|
return "" unless @preview
|
145
|
+
query_str = queries.each { |q| q.to_s }.join(".")
|
146
|
+
|
145
147
|
(@color ? red : '') + "[" +
|
146
148
|
(@color ? yellow : '' ) + "#{index}" +
|
147
|
-
(@color ? green : '' ) + "
|
149
|
+
(@color ? green : '' ) + ".#{query_str}" +
|
148
150
|
(@color ? red : '') + "]" + (@color ? reset : '')
|
149
151
|
end
|
150
152
|
|
data/lib/pcut/query.rb
CHANGED
data/lib/pcut/range_index.rb
CHANGED
data/spec/lib/pcut/query_spec.rb
CHANGED
@@ -41,5 +41,8 @@ describe Pcut::Query do
|
|
41
41
|
should raise_error(ArgumentError, %r/zero/)
|
42
42
|
end
|
43
43
|
|
44
|
-
it 'implements to_s'
|
44
|
+
it 'implements to_s' do
|
45
|
+
Pcut::Query.parse(%q|[/K/, -89]|).to_s.should == "[/K/,-89]"
|
46
|
+
Pcut::Query.parse(%q|[/_/, 23-]|).to_s.should == "[/_/,23-]"
|
47
|
+
end
|
45
48
|
end
|
@@ -71,6 +71,10 @@ describe Pcut::RangeIndex do
|
|
71
71
|
should raise_error(ArgumentError, %r/invalid range index expression/)
|
72
72
|
end
|
73
73
|
|
74
|
-
it 'implements to_s'
|
74
|
+
it 'implements to_s' do
|
75
|
+
Pcut::RangeIndex.new(2, false, false).to_s.should == "2"
|
76
|
+
Pcut::RangeIndex.new(4, true, false).to_s.should == "-4"
|
77
|
+
Pcut::RangeIndex.new(6, false, true).to_s.should == "6-"
|
78
|
+
end
|
75
79
|
|
76
80
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pcut
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Nakano Kyohei (bonar)
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-04-
|
18
|
+
date: 2012-04-15 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: term-ansicolor
|
@@ -79,7 +79,9 @@ dependencies:
|
|
79
79
|
version: "3.0"
|
80
80
|
type: :development
|
81
81
|
version_requirements: *id004
|
82
|
-
description:
|
82
|
+
description: |-
|
83
|
+
Yet another cutting tool.
|
84
|
+
pcut adds some features to cut command.
|
83
85
|
email:
|
84
86
|
- bonar@me.com
|
85
87
|
executables:
|
@@ -92,6 +94,7 @@ extra_rdoc_files:
|
|
92
94
|
- PostInstall.txt
|
93
95
|
- README.rdoc
|
94
96
|
files:
|
97
|
+
- .README.rdoc.swp
|
95
98
|
- History.txt
|
96
99
|
- Manifest.txt
|
97
100
|
- PostInstall.txt
|
@@ -120,7 +123,7 @@ files:
|
|
120
123
|
homepage: http://github.com/bonar/pcut
|
121
124
|
licenses: []
|
122
125
|
|
123
|
-
post_install_message:
|
126
|
+
post_install_message: PostInstall.txt
|
124
127
|
rdoc_options:
|
125
128
|
- --main
|
126
129
|
- README.rdoc
|
@@ -150,6 +153,6 @@ rubyforge_project: pcut
|
|
150
153
|
rubygems_version: 1.8.21
|
151
154
|
signing_key:
|
152
155
|
specification_version: 3
|
153
|
-
summary: Yet another cutting tool
|
156
|
+
summary: Yet another cutting tool
|
154
157
|
test_files: []
|
155
158
|
|