gotime-slither 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +0 -4
- data/gotime-slither.gemspec +0 -0
- data/lib/slither/parser.rb +4 -8
- data/lib/slither/section.rb +1 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 142e44b4e22d9c2dd08254e8642e46d577d28872
|
4
|
+
data.tar.gz: d47a87c897ce9036e854c421afb8931500c375a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdbdadf5f6a73deb182ac70c4dd40243973b18940ae8e54bbed0c6dfd7605c2c7c4cb66a597fd92c47542df503143ef3445e69c79aa2a2ff96a602150ca2fcc7
|
7
|
+
data.tar.gz: 77bec72b2ccdc699d64622b94a7e2b65b5195a9d04aacaf117f16a7d4e558de2c8dc618cc5c8665b16ec95e53858d3d4ad4ec1b60feafc90d4de16713be2294b
|
data/README.rdoc
CHANGED
@@ -26,14 +26,11 @@ A simple, clean DSL for describing, writing, and parsing fixed-width text files.
|
|
26
26
|
|
27
27
|
# Create a header section
|
28
28
|
d.header :align => :left do |header|
|
29
|
-
# The trap tells Slither which lines should fall into this section
|
30
|
-
header.trap { |line| line[0,4] == 'HEAD' }
|
31
29
|
# Use the boundary template for the columns
|
32
30
|
header.template :boundary
|
33
31
|
end
|
34
32
|
|
35
33
|
d.body do |body|
|
36
|
-
body.trap { |line| line[0,4] =~ /[^(HEAD|FOOT)]/ }
|
37
34
|
body.column :id, 10, :type => :integer
|
38
35
|
body.column :name, 10, :align => :left
|
39
36
|
body.spacer 3
|
@@ -41,7 +38,6 @@ A simple, clean DSL for describing, writing, and parsing fixed-width text files.
|
|
41
38
|
end
|
42
39
|
|
43
40
|
d.footer do |footer|
|
44
|
-
footer.trap { |line| line[0,4] == 'FOOT' }
|
45
41
|
footer.template :boundary
|
46
42
|
footer.column :record_count, 10
|
47
43
|
end
|
data/gotime-slither.gemspec
CHANGED
Binary file
|
data/lib/slither/parser.rb
CHANGED
@@ -10,13 +10,11 @@ class Slither
|
|
10
10
|
|
11
11
|
def parse
|
12
12
|
@file.each_line do |line|
|
13
|
-
line.chomp!
|
13
|
+
line.chomp!
|
14
14
|
next if line.empty?
|
15
15
|
@definition.sections.each do |section|
|
16
|
-
if
|
17
|
-
|
18
|
-
yield section.parse(line)
|
19
|
-
end
|
16
|
+
validate_length(line, section) if @definition.options[:validate_length]
|
17
|
+
yield section.parse(line)
|
20
18
|
end
|
21
19
|
end
|
22
20
|
end
|
@@ -37,9 +35,7 @@ class Slither
|
|
37
35
|
record.force_encoding @file.external_encoding
|
38
36
|
|
39
37
|
@definition.sections.each do |section|
|
40
|
-
|
41
|
-
yield section.parse(record)
|
42
|
-
end
|
38
|
+
yield section.parse(record)
|
43
39
|
end
|
44
40
|
end
|
45
41
|
end
|
data/lib/slither/section.rb
CHANGED
@@ -9,7 +9,6 @@ class Slither
|
|
9
9
|
@name = name
|
10
10
|
@options = options
|
11
11
|
@columns = []
|
12
|
-
@trap = options[:trap]
|
13
12
|
@optional = options[:optional] || false
|
14
13
|
@length = 0
|
15
14
|
end
|
@@ -28,10 +27,6 @@ class Slither
|
|
28
27
|
column(:spacer, length)
|
29
28
|
end
|
30
29
|
|
31
|
-
def trap(&block)
|
32
|
-
@trap = block
|
33
|
-
end
|
34
|
-
|
35
30
|
def template(name)
|
36
31
|
template = @definition.templates[name]
|
37
32
|
raise ArgumentError, "Template #{name} not found as a known template." unless template
|
@@ -76,7 +71,7 @@ class Slither
|
|
76
71
|
end
|
77
72
|
|
78
73
|
def match(raw_line)
|
79
|
-
raw_line.nil?
|
74
|
+
!raw_line.nil?
|
80
75
|
end
|
81
76
|
|
82
77
|
def method_missing(method, *args)
|