Skip to content

Commit

Permalink
faraday_middleware gemを削除 (#1897)
Browse files Browse the repository at this point in the history
* remove faraday_middleware gem

* use Faraday::FilePart

* add faraday-multipart gem
  • Loading branch information
nabeta authored Aug 18, 2024
1 parent ecde85c commit c8c52e2
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 112 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ gem 'jquery-rails'
gem 'addressable'
gem 'progress_bar'
gem 'rails_autolink'
gem 'faraday_middleware'
gem 'kramdown'
gem 'solid_queue'
gem 'mission_control-jobs'
Expand All @@ -113,6 +112,7 @@ gem 'oai'
gem 'active_storage_validations'
gem 'sprockets', '~> 3.7'
gem 'webpacker', '~> 5.0'
gem 'faraday-multipart'

group :development, :test do
gem 'annotate'
Expand Down
34 changes: 9 additions & 25 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -163,33 +163,15 @@ GEM
factory_bot_rails (6.4.3)
factory_bot (~> 6.4)
railties (>= 5.0.0)
faraday (1.10.3)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0)
faraday-multipart (~> 1.0)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.0)
faraday-patron (~> 1.0)
faraday-rack (~> 1.0)
faraday-retry (~> 1.0)
ruby2_keywords (>= 0.0.4)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday (2.10.1)
faraday-net_http (>= 2.0, < 3.2)
logger
faraday-follow_redirects (0.3.0)
faraday (>= 1, < 3)
faraday-httpclient (1.0.1)
faraday-multipart (1.0.4)
multipart-post (~> 2)
faraday-net_http (1.0.2)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
faraday_middleware (1.2.0)
faraday (~> 1.0)
faraday-net_http (3.1.1)
net-http
ffi (1.17.0-x86_64-linux-gnu)
friendly_id (5.5.1)
activerecord (>= 4.0.0)
Expand Down Expand Up @@ -284,6 +266,8 @@ GEM
msgpack (1.7.2)
multipart-post (2.4.1)
mutex_m (0.2.0)
net-http (0.4.1)
uri
net-imap (0.4.14)
date
net-protocol
Expand Down Expand Up @@ -430,7 +414,6 @@ GEM
ruby-vips (2.2.2)
ffi (~> 1.12)
logger
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
sassc (2.4.0)
ffi (~> 1.9)
Expand Down Expand Up @@ -500,6 +483,7 @@ GEM
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-types (1.9.0)
uri (0.13.0)
vcr (6.2.0)
warden (1.2.9)
rack (>= 2.0.9)
Expand Down Expand Up @@ -553,7 +537,7 @@ DEPENDENCIES
devise
dotenv-rails
factory_bot_rails (~> 6.4.0)
faraday_middleware
faraday-multipart
friendly_id
geocoder
globalize
Expand Down
4 changes: 1 addition & 3 deletions app/models/concerns/enju_nii/enju_manifestation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ def return_rdf(isbn: nil, ncid: nil)

if rss.items.first
conn = Faraday.new("#{rss.items.first.link}.rdf") do |faraday|
faraday.use FaradayMiddleware::FollowRedirects
faraday.adapter :net_http
end
Nokogiri::XML(conn.get.body)
Expand Down Expand Up @@ -165,7 +164,7 @@ def cinii_normalize_isbn(isbn)
def get_cinii_creator(doc)
doc.xpath("//foaf:maker/foaf:Person").map{|e|
{
full_name: e.at("./foaf:name").content,
full_name: e.at("./foaf:name").content&.strip,
full_name_transcription: e.xpath("./foaf:name[@xml:lang]").map{|n| n.content}.join("\n"),
patron_identifier: e.attributes["about"].try(:content)
}
Expand Down Expand Up @@ -207,7 +206,6 @@ def create_cinii_series_statements(doc, manifestation)
ptbl = series["dc:title"]
rdf_url = "#{URI.parse(parent_url.gsub(/\#\w+\Z/, '')).to_s}"
conn = Faraday.new("#{rdf_url}.rdf") do |faraday|
faraday.use FaradayMiddleware::FollowRedirects
faraday.adapter :net_http
end
parent_doc = Nokogiri::XML(conn.get.body)
Expand Down
2 changes: 1 addition & 1 deletion app/models/manifestation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def extract_text
response = client.put('/tika/text') do |req|
req.headers['Content-Type'] = attachment.content_type
req.headers['Content-Length'] = attachment.byte_size.to_s
req.body = Faraday::UploadIO.new(StringIO.new(attachment.download), attachment.content_type)
req.body = Faraday::FilePart.new(StringIO.new(attachment.download), attachment.content_type)
end

payload = JSON.parse(response.body)['X-TIKA:content'].strip.tr("\t", " ").gsub(/\r?\n/, "")
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

19 changes: 10 additions & 9 deletions spec/cassette_library/CiniiBook/should_search_with_ncid.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion spec/models/cinii_book_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
fixtures :all

it "should search bibliographic records", vcr: true do
CiniiBook.search("library system")[:total_entries].should eq 3837
CiniiBook.search("library system")[:total_entries].should eq 3924
end

it "should search with ncid", vcr: true do
Expand Down

0 comments on commit c8c52e2

Please sign in to comment.