Skip to content

Commit

Permalink
Fixes some deprecation warnings, and allows import of CSV's with blan…
Browse files Browse the repository at this point in the history
…k lines (#124)

* Deprecation &  helper update

* conditionally load coveralls
* fix deprecation warnings for riiif & sqlite

* Updates to allow the csv parser to ignore blank lines

Co-authored-by: McClain Looney <[email protected]>
  • Loading branch information
mlooney and McClain Looney authored Sep 15, 2021
1 parent b30afb5 commit c3f42d3
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/zizia/parsers/csv_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def records
file.rewind

CSV.parse(file.read, headers: true).each do |row|
yield InputRecord.from(metadata: row)
yield InputRecord.from(metadata: row) if row.detect { |x| !x.last.nil? }
end
rescue CSV::MalformedCSVError => e
Rails.logger.error "[zizia] The file #{file} could not be parsed as CSV: #{e}"
Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/config/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
require_relative 'application'

# Initialize the Rails application.
Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true
Rails.application.initialize!

2 changes: 1 addition & 1 deletion spec/dummy/config/initializers/riiif.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Riiif::Image.file_resolver = Riiif::HTTPFileResolver.new
Riiif::Image.file_resolver = Riiif::HttpFileResolver.new
Riiif::Image.info_service = lambda do |id, _file|
# id will look like a path to a pcdm:file
# (e.g. rv042t299%2Ffiles%2F6d71677a-4f80-42f1-ae58-ed1063fd79c7)
Expand Down
6 changes: 4 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true
require 'coveralls'
Coveralls.wear!('rails')
unless ENV['NOCOV']
require 'coveralls'
Coveralls.wear!('rails')
end
require 'pry' unless ENV['CI']

ENV['environment'] ||= 'test'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# frozen_string_literal: true
require 'spec_helper'
require 'rails_helper'

RSpec.describe "zizia/importer_documentation/guide.html.erb", type: :view do
before do
view.stub(:render_guide).and_return('<h1 id="title">Title</h1>')
allow(view).to receive(:render_guide).and_return('<h1 id="title">Title</h1>')
end

it 'renders as html' do
Expand Down
1 change: 1 addition & 0 deletions spec/zizia/csv_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<<-EOS
title,description,date created
The Moomins and the Great Flood,"The Moomins and the Great Flood (Swedish: Småtrollen och den stora översvämningen, literally The Little Trolls and the Great Flood) is a book written by Finnish author Tove Jansson in 1945, during the end of World War II. It was the first book to star the Moomins, but is often seen as a prelude to the main Moomin books, as most of the main characters are introduced in the next book.",1945
Comet in Moominland,"Comet in Moominland is the second in Tove Jansson's series of Moomin books. Published in 1946, it marks the first appearance of several main characters, like Snufkin and the Snork Maiden.",1946
EOS
end
Expand Down

0 comments on commit c3f42d3

Please sign in to comment.