jls-grok 0.4.1 → 0.4.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/grok.gemspec +1 -1
- data/lib/grok/match.rb +11 -12
- data/test/general/captures_test.rb +5 -0
- metadata +63 -67
data/grok.gemspec
CHANGED
@@ -38,7 +38,7 @@ Gem::Specification.new do |spec|
|
|
38
38
|
|
39
39
|
#svnrev = %x{svn info}.split("\n").grep(/Revision:/).first.split(" ").last.to_i
|
40
40
|
spec.name = "jls-grok"
|
41
|
-
spec.version = "0.4.
|
41
|
+
spec.version = "0.4.2"
|
42
42
|
|
43
43
|
spec.summary = "grok bindings for ruby"
|
44
44
|
spec.description = "Grok ruby bindings - pattern match/extraction tool"
|
data/lib/grok/match.rb
CHANGED
@@ -28,8 +28,8 @@ class Grok::Match < FFI::Struct
|
|
28
28
|
@captures = nil
|
29
29
|
end
|
30
30
|
|
31
|
-
|
32
|
-
def
|
31
|
+
public
|
32
|
+
def each_capture
|
33
33
|
@captures = Hash.new { |h, k| h[k] = Array.new }
|
34
34
|
grok_match_walk_init(self)
|
35
35
|
name_ptr = FFI::MemoryPointer.new(:pointer)
|
@@ -41,16 +41,21 @@ class Grok::Match < FFI::Struct
|
|
41
41
|
name = name_ptr.get_pointer(0).get_string(0, namelen)
|
42
42
|
datalen = datalen_ptr.read_int
|
43
43
|
data = data_ptr.get_pointer(0).get_string(0, datalen)
|
44
|
-
|
44
|
+
yield name, data
|
45
45
|
end
|
46
46
|
grok_match_walk_end(self)
|
47
|
-
end
|
47
|
+
end # def each_capture
|
48
48
|
|
49
49
|
public
|
50
50
|
def captures
|
51
|
-
|
51
|
+
if @captures.nil?
|
52
|
+
@captures = Hash.new { |h,k| h[k] = [] }
|
53
|
+
each_capture do |key, val|
|
54
|
+
@captures[key] << val
|
55
|
+
end
|
56
|
+
end
|
52
57
|
return @captures
|
53
|
-
end
|
58
|
+
end # def captures
|
54
59
|
|
55
60
|
public
|
56
61
|
def start
|
@@ -66,10 +71,4 @@ class Grok::Match < FFI::Struct
|
|
66
71
|
def subject
|
67
72
|
return self[:subject]
|
68
73
|
end
|
69
|
-
|
70
|
-
public
|
71
|
-
def each_capture
|
72
|
-
_get_captures if @captures.nil?
|
73
|
-
@captures.each { |k, v| yield([k, v]) }
|
74
|
-
end
|
75
74
|
end # Grok::Match
|
@@ -32,6 +32,11 @@ class GrokPatternCapturingTests < Test::Unit::TestCase
|
|
32
32
|
assert_kind_of(String, match.captures["foo"][0])
|
33
33
|
assert_equal(input, match.captures["foo"][0])
|
34
34
|
|
35
|
+
match.each_capture do |key, val|
|
36
|
+
assert(key.is_a?(String), "Grok::Match::each_capture should yield string,string, got #{key.class.name} as first argument.")
|
37
|
+
assert(val.is_a?(String), "Grok::Match::each_capture should yield string,string, got #{key.class.name} as first argument.")
|
38
|
+
end
|
39
|
+
|
35
40
|
assert_kind_of(Fixnum, match.start)
|
36
41
|
assert_kind_of(Fixnum, match.end)
|
37
42
|
assert_kind_of(String, match.subject)
|
metadata
CHANGED
@@ -1,44 +1,42 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jls-grok
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
4
|
+
prerelease: false
|
6
5
|
segments:
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
version: 0.4.
|
6
|
+
- 0
|
7
|
+
- 4
|
8
|
+
- 2
|
9
|
+
version: 0.4.2
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
|
-
- Jordan Sissel
|
14
|
-
- Pete Fritchman
|
12
|
+
- Jordan Sissel
|
13
|
+
- Pete Fritchman
|
15
14
|
autorequire:
|
16
15
|
bindir: bin
|
17
16
|
cert_chain: []
|
18
17
|
|
19
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-20 00:00:00 -08:00
|
20
19
|
default_executable:
|
21
20
|
dependencies:
|
22
|
-
- !ruby/object:Gem::Dependency
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
version_requirements: *id001
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: ffi
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
- 6
|
32
|
+
- 3
|
33
|
+
version: 0.6.3
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
38
36
|
description: Grok ruby bindings - pattern match/extraction tool
|
39
37
|
email:
|
40
|
-
- jls@semicomplete.com
|
41
|
-
- petef@databits.net
|
38
|
+
- jls@semicomplete.com
|
39
|
+
- petef@databits.net
|
42
40
|
executables: []
|
43
41
|
|
44
42
|
extensions: []
|
@@ -46,32 +44,32 @@ extensions: []
|
|
46
44
|
extra_rdoc_files: []
|
47
45
|
|
48
46
|
files:
|
49
|
-
- INSTALL
|
50
|
-
- Rakefile
|
51
|
-
- examples/grok-web.rb
|
52
|
-
- examples/pattern-discovery.rb
|
53
|
-
- examples/test.rb
|
54
|
-
- grok.gemspec
|
55
|
-
- lib/grok.rb
|
56
|
-
- lib/grok/match.rb
|
57
|
-
- lib/grok/pile.rb
|
58
|
-
- test/Makefile
|
59
|
-
- test/alltests.rb
|
60
|
-
- test/general/basic_test.rb
|
61
|
-
- test/general/captures_test.rb
|
62
|
-
- test/patterns/day.rb
|
63
|
-
- test/patterns/host.rb
|
64
|
-
- test/patterns/ip.input
|
65
|
-
- test/patterns/ip.rb
|
66
|
-
- test/patterns/iso8601.rb
|
67
|
-
- test/patterns/month.rb
|
68
|
-
- test/patterns/number.rb
|
69
|
-
- test/patterns/path.rb
|
70
|
-
- test/patterns/prog.rb
|
71
|
-
- test/patterns/quotedstring.rb
|
72
|
-
- test/patterns/uri.rb
|
73
|
-
- test/run.sh
|
74
|
-
- test/speedtest.rb
|
47
|
+
- INSTALL
|
48
|
+
- Rakefile
|
49
|
+
- examples/grok-web.rb
|
50
|
+
- examples/pattern-discovery.rb
|
51
|
+
- examples/test.rb
|
52
|
+
- grok.gemspec
|
53
|
+
- lib/grok.rb
|
54
|
+
- lib/grok/match.rb
|
55
|
+
- lib/grok/pile.rb
|
56
|
+
- test/Makefile
|
57
|
+
- test/alltests.rb
|
58
|
+
- test/general/basic_test.rb
|
59
|
+
- test/general/captures_test.rb
|
60
|
+
- test/patterns/day.rb
|
61
|
+
- test/patterns/host.rb
|
62
|
+
- test/patterns/ip.input
|
63
|
+
- test/patterns/ip.rb
|
64
|
+
- test/patterns/iso8601.rb
|
65
|
+
- test/patterns/month.rb
|
66
|
+
- test/patterns/number.rb
|
67
|
+
- test/patterns/path.rb
|
68
|
+
- test/patterns/prog.rb
|
69
|
+
- test/patterns/quotedstring.rb
|
70
|
+
- test/patterns/uri.rb
|
71
|
+
- test/run.sh
|
72
|
+
- test/speedtest.rb
|
75
73
|
has_rdoc: true
|
76
74
|
homepage: http://code.google.com/p/semicomplete/wiki/Grok
|
77
75
|
licenses: []
|
@@ -80,29 +78,27 @@ post_install_message:
|
|
80
78
|
rdoc_options: []
|
81
79
|
|
82
80
|
require_paths:
|
83
|
-
- lib
|
81
|
+
- lib
|
84
82
|
required_ruby_version: !ruby/object:Gem::Requirement
|
85
83
|
none: false
|
86
84
|
requirements:
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
version: "0"
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
segments:
|
88
|
+
- 0
|
89
|
+
version: "0"
|
93
90
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
91
|
none: false
|
95
92
|
requirements:
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
version: "0"
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
segments:
|
96
|
+
- 0
|
97
|
+
version: "0"
|
102
98
|
requirements: []
|
103
99
|
|
104
100
|
rubyforge_project:
|
105
|
-
rubygems_version: 1.
|
101
|
+
rubygems_version: 1.3.7
|
106
102
|
signing_key:
|
107
103
|
specification_version: 3
|
108
104
|
summary: grok bindings for ruby
|