dwc-archive 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -129,6 +129,9 @@ Then /^I can read its content into memory$/ do
129
129
  core_data.class.should == Array
130
130
  core_data.size.should == 584
131
131
  core_errors.size.should == 3
132
+ core_data, core_errors = @dwc.core.read(5)
133
+ core_data.size.should == 5
134
+ core_errors.size.should == 0
132
135
  end
133
136
 
134
137
  Then /^I can read extensions content into memory$/ do
@@ -2,7 +2,8 @@ class DarwinCore
2
2
  module Ingester
3
3
  attr_reader :data, :properties, :encoding, :fields_separator
4
4
  attr_reader :file_path, :fields, :line_separator, :quote_character, :ignore_headers
5
- def read(batch_size = 10000)
5
+
6
+ def read(batch_size = nil)
6
7
  res = []
7
8
  errors = []
8
9
  index_fix = 1
@@ -12,10 +13,14 @@ class DarwinCore
12
13
  CSV.open(@file_path, args).each_with_index do |r, i|
13
14
  index_fix = 0; next if @ignore_headers && i == 0
14
15
  min_size > r.size ? errors << r : process_csv_row(res, errors, r)
15
- if block_given? && (i + index_fix) % batch_size == 0
16
- yield [res, errors]
17
- res = []
18
- errors = []
16
+ if batch_size.to_i > 0 && (i + index_fix) % batch_size == 0
17
+ if block_given?
18
+ yield [res, errors]
19
+ res = []
20
+ errors = []
21
+ else
22
+ return [res, errors]
23
+ end
19
24
  end
20
25
  end
21
26
  [res, errors]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dwc-archive
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 0
10
- version: 0.3.0
9
+ - 1
10
+ version: 0.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dmitry Mozzherin
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-12 00:00:00 -04:00
18
+ date: 2010-08-11 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -132,6 +132,6 @@ signing_key:
132
132
  specification_version: 3
133
133
  summary: Handler of Darwin Core Archive files
134
134
  test_files:
135
- - spec/spec_helper.rb
136
- - spec/lib/ruby_extenstions_spec.rb
137
135
  - spec/lib/dwc-archive_spec.rb
136
+ - spec/lib/ruby_extenstions_spec.rb
137
+ - spec/spec_helper.rb