efo_nelfo 1.3.2 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/efo_nelfo/post_head_type.rb +0 -1
- data/lib/efo_nelfo/reader/csv.rb +9 -12
- data/lib/efo_nelfo/version.rb +1 -1
- data/spec/efo_nelfo_spec.rb +4 -5
- data/spec/parsing/bh_spec.rb +0 -5
- 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: 7cd36136a8426da58c3b6c2ce3c4bf4c877d8909
|
4
|
+
data.tar.gz: a4d291f32bd8dcf424ee8838210c4630fa2f6d03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4058a0deb87c886511770d283a52117bac37400d939b5cb93b9a3e26c98fe1904f183b785e64b14ceba37facfea22f5ef7dbe543e2413979d5ba22c6cdc8d2ce
|
7
|
+
data.tar.gz: 94e3115db5dece52aa977f7b9338dc78f4e52fdefcdba0fcd411af77287177d6f6a5b27747e870f9ca579a1af18c068f4a18a4b79a2c9eab93955c3165b523ea
|
data/lib/efo_nelfo/reader/csv.rb
CHANGED
@@ -27,12 +27,8 @@ module EfoNelfo
|
|
27
27
|
@csv = ::CSV.new @data, CSV_OPTIONS
|
28
28
|
end
|
29
29
|
|
30
|
+
# Parses the data and returns an EfoNelfo object of some kind
|
30
31
|
def parse
|
31
|
-
# Create the head object based on the first row
|
32
|
-
head = parse_head first
|
33
|
-
head.source = @data
|
34
|
-
|
35
|
-
# Read rest of the file and add them to the head
|
36
32
|
csv.each do |row|
|
37
33
|
# Find the correct posttype module for given posttype and version
|
38
34
|
klass = EfoNelfo::PostType.for row[0], head.version
|
@@ -46,15 +42,16 @@ module EfoNelfo
|
|
46
42
|
|
47
43
|
# Returns the first row of the csv file
|
48
44
|
def first
|
49
|
-
|
45
|
+
return @first if @first
|
46
|
+
csv.rewind
|
47
|
+
@first = csv.first
|
50
48
|
end
|
51
49
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
klass.new row
|
50
|
+
def head
|
51
|
+
return @head if @head
|
52
|
+
klass = EfoNelfo::PostType.for first[0], first[2]
|
53
|
+
raise EfoNelfo::UnsupportedPostType.new("Don't know how to handle v#{first[2]} of #{first[0]}") if klass.nil?
|
54
|
+
@head = klass.new first
|
58
55
|
end
|
59
56
|
|
60
57
|
end
|
data/lib/efo_nelfo/version.rb
CHANGED
data/spec/efo_nelfo_spec.rb
CHANGED
@@ -84,11 +84,10 @@ describe EfoNelfo do
|
|
84
84
|
|
85
85
|
|
86
86
|
describe ".parse" do
|
87
|
-
it "
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
parsed.source.must_equal loaded.source
|
87
|
+
it "uses the CSV reader to parse the input" do
|
88
|
+
input = File.read csv('B650517.032.csv')
|
89
|
+
result = EfoNelfo.parse(input)
|
90
|
+
result.must_be_instance_of EfoNelfo::V40::BH
|
92
91
|
end
|
93
92
|
end
|
94
93
|
|
data/spec/parsing/bh_spec.rb
CHANGED
@@ -46,9 +46,4 @@ describe "parsing a BH.csv file" do
|
|
46
46
|
order.lines.first.text.first.to_s.must_equal "Her er litt fritekst"
|
47
47
|
end
|
48
48
|
|
49
|
-
it "stores the contents file in the Order object" do
|
50
|
-
filename = csv('B650517.032.csv')
|
51
|
-
order = EfoNelfo.load(filename)
|
52
|
-
order.source.must_equal File.read(filename)
|
53
|
-
end
|
54
49
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: efo_nelfo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gudleik Rasch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|