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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4d52907dcd0715f3a20a5777a99929543e0a08fd
4
- data.tar.gz: ccd312355b0ef53e9d2e4055daacb52500cec7af
3
+ metadata.gz: ec86e090c75136ef7d6ae7c98ca05f943aded079
4
+ data.tar.gz: 703958a133df34d7379e855bc0ca69011bf583e4
5
5
  SHA512:
6
- metadata.gz: f036f88b92b9ab1c7fa226f07f7479c37eab34a177e0a0bcc0084e6322e25d0f1b49791c7df2c6de4312702b272a03a0f53219380650ba0de98640a723904815
7
- data.tar.gz: c80fb9f59d9c85b4b3db3a000fb411a874ebf3af28a3dbade0f326cb60ad7b018091fb04a81861dea1928825dd9fffa23a75bc8bff2d9123d2ccb2f9037720d7
6
+ metadata.gz: 298dcc7dc510ff9acee3356c796cec7283842c724763250a2c780467a3bb8ca83fe078d3225d081b855a5332f7d6a3894bdcd5e97c18401daa2b046035287238
7
+ data.tar.gz: bd582b45420ad6510449ec11f0a7e9afa6ff8a52b675ee8b0467be47cdfa9cb81908bff3374656789dd4486a4945c2db93c9710b92b730f1af0624857078d58d
@@ -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
- input.scan(%r{
43
- \s*
44
- (?:
45
- ["'/](.*?)["'/] # quoted string, or regexp argument
46
- |
47
- ([\w:]+ (?:\[.+\])?) # bare words, or Type::Name, or Type::Name[args..]
48
- )
49
- \s*
50
- (?:,|$) # match to end of comma-separated arg, or the last arg
51
- }mx).flatten.compact
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
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
2
  module Kafo
3
3
  PARSER_CACHE_VERSION = 1
4
- VERSION = "2.0.0"
4
+ VERSION = "2.0.1"
5
5
  end
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.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-03-24 00:00:00.000000000 Z
11
+ date: 2017-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler