Skip to content

Commit

Permalink
Merge pull request #163 from tulibraries/DEVO-654-ruby-upgrade
Browse files Browse the repository at this point in the history
Update ingest command
  • Loading branch information
dkinzer authored Dec 15, 2022
2 parents baba026 + 68be411 commit e6b56c3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions exe/cob_web_index
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ class App
end

if options["use-fixtures"]
CobWebIndex::CLI.ingest_fixtures(opts)
CobWebIndex::CLI.ingest_fixtures(**opts)
elsif args.empty?
CobWebIndex::CLI.pull(opts)
CobWebIndex::CLI.pull(**opts)
else
CobWebIndex::CLI.ingest(opts.merge(ingest_path: args[0], delete_collection: true))
opts.merge!(ingest_path: args[0], delete_collection: true)
CobWebIndex::CLI.ingest(**opts)
end
end
end
Expand Down
4 changes: 3 additions & 1 deletion lib/cob_web_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def self.ingest(ingest_path: nil, ingest_string: "", **opts)
if ingest_path
logger.info "Ingesting #{ingest_path}"
ingest_string = CobWebIndex::CLI.open_read(ingest_path)

data = JSON.parse(ingest_string).fetch("data")

# Protect against trying to ingest nil data
Expand Down Expand Up @@ -60,7 +61,8 @@ def self.open_read(url)
options = { http_basic_authentication: [ENV["WEB_CONTENT_BASIC_AUTH_USER"], ENV["WEB_CONTENT_BASIC_AUTH_PASSWORD"]] }
end
options[:read_timeout] = ENV["WEB_CONTENT_READ_TIMEOUT"].to_i if ENV["WEB_CONTENT_READ_TIMEOUT"]
URI.open(url, options).read
file = options.empty? ? URI.open(url) : URI.open(url, options)
file.read
end

def self.ingest_fixtures(opts = {})
Expand Down
2 changes: 1 addition & 1 deletion spec/cob_web_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
}

it "receives no options" do
expect(URI).to receive(:open).with(uri, {})
expect(URI).to receive(:open).with(uri)
CobWebIndex::CLI.open_read(uri)
end

Expand Down

0 comments on commit e6b56c3

Please sign in to comment.