Skip to content

Commit

Permalink
Merge pull request #38 from Shopify/fix-count-rows-in-file-for-ruby-26
Browse files Browse the repository at this point in the history
Fix count_rows_in_file for ruby 2.6.3
  • Loading branch information
peterzhu2118 authored Jul 24, 2019
2 parents 99159f2 + 1c4b185 commit 1cadfd0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
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

0 comments on commit 1cadfd0

Please sign in to comment.