koine-csv 0.2.0 → 0.2.1

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: 61750f55f1fbec9a7047d25dbf2501dae41ae5c5
4
- data.tar.gz: 00a991aa589665470d1bb0d19d1bf2494d53419c
3
+ metadata.gz: c2ab5d5e472cd27ad9319466797742a81361e3dc
4
+ data.tar.gz: 6307658fe8e2b9ce33eba48bc662e95d8fad9f6a
5
5
  SHA512:
6
- metadata.gz: 3b38bf2bb5a637b24ef2ebff7e8fc911291b26ea4ac3df76f2fe70a40fea2c12c72ff61a0c71dcff7ddb2defb45cf99994f3f9dd400fe8276a0b6793c6381f92
7
- data.tar.gz: da11db9c6c6e33daf5ca58c80ac4705149520e5932ad0ea7e43ed976eade7b956b0563e4537363f9c11195449cc5919a5db0a6ed7ab6263e89db95c21b3adc3a
6
+ metadata.gz: 775e17bab5ae215eaf8225200320bc2465a39a554d5b0fb42654456897dfb908402f75570af133db37982ae5658fae769927a0860c98b73c96845ad77beaf86a
7
+ data.tar.gz: 8a3dcfca5becb95f5782fe8149f3e86da7d4073af3d0b6bea9d9641ba3887b6663014e871b4283d04b40d805a420b7b574524095325babda5b4ae78b6e0f86d9
@@ -1,20 +1,23 @@
1
- require "csv"
1
+ require 'csv'
2
2
 
3
3
  module Koine
4
4
  module Csv
5
5
  class NamedColumnsParser < CsvParser
6
6
  def parse(contents, &block)
7
- contents = contents.split("\n")
8
- titles = contents.shift
9
- column_names = CSV.parse(titles, col_sep: column_separator).first
7
+ csv = CSV.parse(contents, headers: true, col_sep: column_separator)
8
+ column_names = csv.headers
9
+ collection = []
10
10
 
11
- options = {
12
- column_names: column_names,
13
- column_separator: column_separator
14
- }
11
+ csv.each do |line|
12
+ element = {}
13
+ column_names.each do |name|
14
+ element[name] = line[name]
15
+ end
16
+ collection << element
17
+ end
15
18
 
16
- contents = contents.join("\n")
17
- MappedColumnsParser.new(options).parse(contents, &block)
19
+ return collection.each(&block) if block
20
+ collection
18
21
  end
19
22
  end
20
23
  end
@@ -1,5 +1,5 @@
1
1
  module Koine
2
2
  module Csv
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: koine-csv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcelo Jacobus
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-14 00:00:00.000000000 Z
11
+ date: 2017-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
137
  version: '0'
138
138
  requirements: []
139
139
  rubyforge_project:
140
- rubygems_version: 2.6.11
140
+ rubygems_version: 2.6.8
141
141
  signing_key:
142
142
  specification_version: 4
143
143
  summary: Csv parsing classes