Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix count_rows_in_file for ruby 2.6.3 #38

Merged
merged 3 commits into from
Jul 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/job-iteration/csv_enumerator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,16 @@ def batches(batch_size:, cursor:)
private

def count_rows_in_file
# TODO: Remove rescue for NoMethodError when Ruby 2.6 is no longer supported.
begin
filepath = @csv.path
rescue NoMethodError
return
end

# Behaviour of CSV#path changed in Ruby 2.6.3 (returns nil instead of raising NoMethodError)
return unless filepath

count = %x(wc -l < #{filepath}).strip.to_i
count -= 1 if @csv.headers
count
Expand Down
2 changes: 1 addition & 1 deletion lib/job-iteration/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module JobIteration
VERSION = "1.1.1"
VERSION = "1.1.2"
end