kafo 2.0.0 → 2.0.1
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/lib/kafo/data_type.rb +38 -10
- data/lib/kafo/puppet_log_parser.rb +11 -0
- data/lib/kafo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec86e090c75136ef7d6ae7c98ca05f943aded079
|
4
|
+
data.tar.gz: 703958a133df34d7379e855bc0ca69011bf583e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 298dcc7dc510ff9acee3356c796cec7283842c724763250a2c780467a3bb8ca83fe078d3225d081b855a5332f7d6a3894bdcd5e97c18401daa2b046035287238
|
7
|
+
data.tar.gz: bd582b45420ad6510449ec11f0a7e9afa6ff8a52b675ee8b0467be47cdfa9cb81908bff3374656789dd4486a4945c2db93c9710b92b730f1af0624857078d58d
|
data/lib/kafo/data_type.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'strscan'
|
2
|
+
|
1
3
|
module Kafo
|
2
4
|
class DataType
|
3
5
|
def self.new_from_string(str)
|
@@ -39,16 +41,42 @@ module Kafo
|
|
39
41
|
end
|
40
42
|
|
41
43
|
def self.split_arguments(input)
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
44
|
+
scanner = StringScanner.new(input)
|
45
|
+
args = []
|
46
|
+
|
47
|
+
until scanner.eos?
|
48
|
+
scanner.skip(/\s*/)
|
49
|
+
|
50
|
+
if %w(' " /).include?(quote = scanner.peek(1)) # quoted string, or regexp argument
|
51
|
+
scanner.getch # skip first quote
|
52
|
+
quoted = scanner.scan_until(/(?:^|[^\\])#{quote}/) or raise ConfigurationException, "missing end quote in argument #{args.count + 1} in data type #{input}"
|
53
|
+
args << quoted[0..-2] # store unquoted value
|
54
|
+
|
55
|
+
else # bare words, or Type::Name, or Type::Name[args..]
|
56
|
+
type = scanner.scan(/[\w:-]+/) or raise ConfigurationException, "missing argument #{args.count + 1} to data type #{input}"#
|
57
|
+
|
58
|
+
# store inner arguments as a continuation of the type string
|
59
|
+
if scanner.peek(1) == '['
|
60
|
+
type << scanner.getch
|
61
|
+
bracket_count = 1
|
62
|
+
until bracket_count.zero?
|
63
|
+
next_bracket = scanner.scan_until(/[\[\]]/) or raise ConfigurationException, "missing close bracket in argument #{args.count + 1} in data type #{input}"
|
64
|
+
case next_bracket[-1..-1]
|
65
|
+
when '['
|
66
|
+
bracket_count += 1
|
67
|
+
when ']'
|
68
|
+
bracket_count -= 1
|
69
|
+
end
|
70
|
+
type << next_bracket
|
71
|
+
end
|
72
|
+
end
|
73
|
+
args << type
|
74
|
+
end
|
75
|
+
|
76
|
+
scanner.skip(/\s*,?/)
|
77
|
+
end
|
78
|
+
|
79
|
+
args
|
52
80
|
end
|
53
81
|
|
54
82
|
def self.parse_hash(input)
|
@@ -5,6 +5,7 @@ module Kafo
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def parse(line)
|
8
|
+
line = normalize_encoding(line)
|
8
9
|
method, message = case
|
9
10
|
when line =~ /^Error:(.*)/i || line =~ /^Err:(.*)/i
|
10
11
|
[:error, $1]
|
@@ -21,5 +22,15 @@ module Kafo
|
|
21
22
|
@last_level = method
|
22
23
|
return [method, message.chomp]
|
23
24
|
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def normalize_encoding(line)
|
29
|
+
if line.respond_to?(:encode) && line.respond_to?(:valid_encoding?)
|
30
|
+
line.valid_encoding? ? line : line.encode('UTF-16be', :invalid => :replace, :replace => '?').encode('UTF-8')
|
31
|
+
else # Ruby 1.8.7, doesn't worry about invalid encodings
|
32
|
+
line
|
33
|
+
end
|
34
|
+
end
|
24
35
|
end
|
25
36
|
end
|
data/lib/kafo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kafo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marek Hulan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|