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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 99ab6bb56013c690a945d6621bfba1a39beb78a3
4
- data.tar.gz: 8195f0c7272a6b8988d8ecf502a47aaa67ce7d6e
3
+ metadata.gz: 142e44b4e22d9c2dd08254e8642e46d577d28872
4
+ data.tar.gz: d47a87c897ce9036e854c421afb8931500c375a7
5
5
  SHA512:
6
- metadata.gz: fc74901e7d3c703c87c0a37716f906a4f33ca6bec64407c424e2d233d4c04296237cfc3de4ca87d8eb1f5f17ec80017e2ea4118c7ced1927676c21d515823753
7
- data.tar.gz: b9159e5c9d546abcb62a22469e765781558770fad136bbc76f1e9daea891e79bae14f7ab4cd193658e95f3a244c085cf06b0514ef297da34c6f7c5260403a734
6
+ metadata.gz: fdbdadf5f6a73deb182ac70c4dd40243973b18940ae8e54bbed0c6dfd7605c2c7c4cb66a597fd92c47542df503143ef3445e69c79aa2a2ff96a602150ca2fcc7
7
+ data.tar.gz: 77bec72b2ccdc699d64622b94a7e2b65b5195a9d04aacaf117f16a7d4e558de2c8dc618cc5c8665b16ec95e53858d3d4ad4ec1b60feafc90d4de16713be2294b
@@ -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
Binary file
@@ -10,13 +10,11 @@ class Slither
10
10
 
11
11
  def parse
12
12
  @file.each_line do |line|
13
- line.chomp! if line
13
+ line.chomp!
14
14
  next if line.empty?
15
15
  @definition.sections.each do |section|
16
- if section.match(line)
17
- validate_length(line, section) if @definition.options[:validate_length]
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
- if section.match(record)
41
- yield section.parse(record)
42
- end
38
+ yield section.parse(record)
43
39
  end
44
40
  end
45
41
  end
@@ -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? ? false : @trap.call(raw_line)
74
+ !raw_line.nil?
80
75
  end
81
76
 
82
77
  def method_missing(method, *args)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gotime-slither
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Wood