rxraw-lineparser 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/rxraw-lineparser.rb +12 -12
  2. metadata +2 -2
@@ -23,6 +23,7 @@ module Enumerable
23
23
  end
24
24
 
25
25
  class RXRawLineParser
26
+
26
27
 
27
28
  def initialize(format_mask)
28
29
  @format_mask = format_mask
@@ -33,6 +34,8 @@ class RXRawLineParser
33
34
  field_names = @format_mask.to_s.scan(/\[!(\w+)\]/).flatten.map(&:to_sym)
34
35
 
35
36
  patterns = possible_patterns(@format_mask)
37
+ patterns.each{|x| puts x.inspect }
38
+
36
39
  pattern = patterns.detect {|x| line.match(/#{x.join}/)}.join
37
40
  field_values = line.match(/#{pattern}/).captures
38
41
 
@@ -66,19 +69,25 @@ class RXRawLineParser
66
69
  r2 = r
67
70
  end
68
71
 
72
+ #puts 'r2'
73
+ #r2.each{|x| puts x.inspect}
74
+
69
75
  rr = r2.map do |x|
70
76
  x.each_with_index.map do |item, i|
77
+
71
78
  d = a[i]
72
79
  case item
73
80
  when 1
74
81
  i > 0 ? d + qpattern : qpattern
75
82
  when 0
76
83
  s = "([^%s]+)" % d
77
- i > 0 ? d + s : s
84
+ i > 0 ? a[i-1] + s : s
78
85
  end
79
86
  end
80
87
  end
81
88
 
89
+ rr.each{|x| puts x.inspect}
90
+
82
91
  count = 2**main_fields
83
92
  rr2 = rr.take(count+1).map {|x| x + [a[-1] + '(.*)']}
84
93
  wild_r = rr2.slice!(-1)
@@ -99,17 +108,8 @@ class RXRawLineParser
99
108
  end
100
109
 
101
110
  def fmask_delimiters(f)
102
- a = f.split(/(?=\[!\w+\])/)[0..-2].map do |x|
103
-
104
- aa = x.split(/(?=[^\]]+$)/)
105
-
106
- if aa.length == 2 and aa.first[/\[!\w+\]/] then
107
- field, delimiter = *aa
108
- delimiter ||= '$'
109
- d = delimiter[0]
110
- d
111
- end
112
- end
111
+ a = f.split(/(?=\[!\w+\])/)[0..-2].map {|x| x[/\](.*)/,1] }
113
112
  end
114
113
 
114
+
115
115
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rxraw-lineparser
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.1
5
+ version: 0.1.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - James Robertson
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-04-19 00:00:00 +01:00
13
+ date: 2012-04-25 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies: []
16
16