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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 78ab950b02b7049200da1e0e5de3b2e652dafd54
4
- data.tar.gz: 179c82aa18e4812ac7850cdcf368bad9dfa66b43
3
+ metadata.gz: 7cd36136a8426da58c3b6c2ce3c4bf4c877d8909
4
+ data.tar.gz: a4d291f32bd8dcf424ee8838210c4630fa2f6d03
5
5
  SHA512:
6
- metadata.gz: a0d8371775eed749b0f1ee7351f4cdb03fffa79d4d9bc806394e034e9f7b623d980aa535b37c55aa21472743915b73e34b65c14023d94f3518de6d0699b40f31
7
- data.tar.gz: d18f93c56c3b188942a84ee39a6b5b7269f38fe732c53f799f0c00c2fe6463d8bc828e646afa30fe4a5241bf05c6b42a2f3dab6d5b1d4d2b8a96b520025d8487
6
+ metadata.gz: 4058a0deb87c886511770d283a52117bac37400d939b5cb93b9a3e26c98fe1904f183b785e64b14ceba37facfea22f5ef7dbe543e2413979d5ba22c6cdc8d2ce
7
+ data.tar.gz: 94e3115db5dece52aa977f7b9338dc78f4e52fdefcdba0fcd411af77287177d6f6a5b27747e870f9ca579a1af18c068f4a18a4b79a2c9eab93955c3165b523ea
@@ -1,6 +1,5 @@
1
1
  module EfoNelfo
2
2
  module PostHeadType
3
- attr_accessor :source
4
3
 
5
4
  def self.included(base)
6
5
  base.send :property, :post_type, alias: :PostType, limit: 2, default: base.post_type
@@ -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
- csv.first
45
+ return @first if @first
46
+ csv.rewind
47
+ @first = csv.first
50
48
  end
51
49
 
52
- private
53
-
54
- def parse_head(row)
55
- klass = EfoNelfo::PostType.for row[0], row[2]
56
- raise EfoNelfo::UnsupportedPostType.new("Don't know how to handle v#{row[2]} of #{row[0]}") if klass.nil?
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
@@ -1,3 +1,3 @@
1
1
  module EfoNelfo
2
- VERSION = "1.3.2"
2
+ VERSION = "1.4.0"
3
3
  end
@@ -84,11 +84,10 @@ describe EfoNelfo do
84
84
 
85
85
 
86
86
  describe ".parse" do
87
- it "does the same as .load" do
88
- filename = csv('B650517.032.csv')
89
- parsed = EfoNelfo.parse File.read(filename)
90
- loaded = EfoNelfo.load filename
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
 
@@ -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.3.2
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-09 00:00:00.000000000 Z
11
+ date: 2013-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler