traject 3.8.3 → 3.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c4434e6a85dc5176d84dfb2c6e42c0882937cdffa37c24e5f5f06844ad0e542d
4
- data.tar.gz: fd2da1d197ace61ab86e2308298e77ed64866ef0f1ffc49b88b344578900f76e
3
+ metadata.gz: 9e73d6d38cf8601c13b83efcbafd739f6f387b00d8982ee1eca95230d2361b37
4
+ data.tar.gz: c9a516522aa1f17e612ea4fbff0f9e3e99d80ae841bc0b43e3320038311cac3e
5
5
  SHA512:
6
- metadata.gz: 3aad25487edbb9489a30f6d8a9c6c2fdb467683c6cd6a96199d7de10538f861fd92c2f25ec8213b5a753ef85bc7440c1d27ee48d65fc05d2f36e735a15a7b6a6
7
- data.tar.gz: 7641b36d876e01d3b8188add71a4121a768116a8bd2462c1fcfb0e2652af7ddebfc9a17d03dd24c68fa56b8810e2b7cd865eea53ff905a53fb5f7675c5dc99e4
6
+ metadata.gz: 23a439be2faf8245af5eaf2d653cb61b7bc5a66e43a251df793c34b69276ef2dc3c672bb3e9b23ea3a02e2c2512c1fd759844018bac15da19656a19614dd88fd
7
+ data.tar.gz: 257fe8d4015d16d96d1beabde4c784e849f97d519dee68a59391c562b6e1f7a4d058b4c14f31b05b61bcf2f39349bf6e36057ef86f6d96ce5e5827a6b540dec9
@@ -19,8 +19,9 @@ jobs:
19
19
  - '3.2'
20
20
  - '3.3'
21
21
  - '3.4'
22
- - 'jruby-9.3'
23
- - 'jruby-9.4'
22
+ - '4.0'
23
+ - 'jruby-10.0'
24
+ - 'jruby-10.1'
24
25
  name: Ruby ${{ matrix.ruby }}
25
26
  steps:
26
27
  - uses: actions/checkout@v2
data/CHANGES.md CHANGED
@@ -1,26 +1,47 @@
1
1
  # Changes
2
2
 
3
- ## 3.8.3 Compatibility release for ruby 3.4
3
+ ## Next
4
+
5
+ Work will continue to lessen dependence on `http-client` (which is
6
+ unsupported) while making sure to not break anything or lose
7
+ important characteristics like keepAlive and multi threading.
8
+
9
+ ##
10
+
11
+ ## 3.9.0
12
+
13
+ * add SolrJsonWriter2 using httpx client instead of httpclient [@jrochkind] https://github.com/traject/traject/pull/307
14
+ * Eliminate frozen string literal warnings in latest rubies. [@jrochkind]
15
+ * Update marc language and geographic maps from LOC [@maxkadel]
16
+ * Support http gem 6.x [@cbeer]
17
+ * Replace CGI.* methods removed from ruby 4.0 with URI.* methods [@jrochkind]
18
+
19
+ ## 3.8.3
20
+
21
+ Compatibility release for ruby 3.4
22
+
23
+ [Incorporates work from @jrochkind and @jcoyne]
4
24
 
5
25
  Note that some gems, `ruby-marc` in particular, will throw zillions of
6
- warnings about literal strings being frozen in future versions of ruby.
26
+ warnings about literal strings being frozen in future versions of ruby
27
+ when running under ruby 3.4.
7
28
 
8
29
  - Update CI testing matrix
9
30
  - removed MRI ruby 2.4, 2.5, 2.6, and jruby-9.2
10
31
  - added MRI ruby 3.4
11
- - Add gem dependencies for `csv` and `mutex_m`, both of which were
32
+ - Add gem dependencies for `csv` and `mutex_m`, both of which were
12
33
  part of the standard library prior to ruby 3.4
13
34
 
14
35
 
15
36
  ## 3.8.2
16
37
 
17
- Bug fix for the `#filing_version` logic, which was incorrectly assuming the
38
+ Bug fix for the `#filing_version` logic, which was incorrectly assuming the
18
39
  first subfield in a field would hold content (e.g., `$a`) and thus failed
19
40
  when it held a pointer to a linking field (e.g., `$6 245-01`)
20
41
 
21
42
  ## 3.8.1
22
43
 
23
- Ugh. Forgot about Jruby 9.1 problem with bundler 2. Changing the requirement back.
44
+ Ugh. Forgot about Jruby 9.1 problem with bundler 2. Changing the requirement back.
24
45
 
25
46
  ## 3.8.0
26
47
 
@@ -30,7 +51,7 @@ HTTPClient, for whatever reason, prefers its own packaged certs, which are now y
30
51
  and don't work with Let's Encrypt.
31
52
 
32
53
  This changes the code to prefer the OS certs, which can be overridden by setting
33
- `solr_json_writer.use_packaged_certs` to `true` or `"true"`.
54
+ `solr_json_writer.use_packaged_certs` to `true` or `"true"`.
34
55
 
35
56
  ## 3.7.0
36
57
 
data/README.md CHANGED
@@ -49,6 +49,7 @@ You can keep your settings and indexing rules in one config file, or split them
49
49
 
50
50
  There are two main categories of directives in your configuration files: _Settings_, and _Indexing Rules_.
51
51
 
52
+
52
53
  ## Settings
53
54
 
54
55
  Settings are a flat list of key/value pairs, where the keys are always strings and the values usually are too. They look like this in a config file:
@@ -86,6 +87,11 @@ You can also use `store` if you want to force-set: last set wins.
86
87
  See, docs page on [Settings](./doc/settings.md) for list
87
88
  of all standardized settings.
88
89
 
90
+ ## Note: New writer coming
91
+
92
+ The default writer, `Traject::SolrJsonWriter` uses the [http gem](https://github.com/httprb/http) for HTTP. We will be in the future switching to use [httpx](https://github.com/HoneyryderChuck/httpx) for the default writer.
93
+
94
+ To opt into the new httpx-based writer now, either set the shell ENV variable `TRAJECT_DEFAULT_WRITER=SolrJsonHttpxWriter`, or set configuration `provide "writer_class_name", "Traject::SolrJsonHttpxWriter"`
89
95
 
90
96
  ## Indexing rules: 'to_field'
91
97
 
@@ -12,14 +12,13 @@ namespace :load_maps do
12
12
  task :marc_geographic do |task|
13
13
  require_nokogiri(task)
14
14
 
15
- source_url = "http://www.loc.gov/marc/geoareas/gacs_code.html"
15
+ source_url = "https://www.loc.gov/marc/geoareas/gacs_code.html"
16
16
 
17
17
  filename = ENV["OUTPUT_TO"] || File.expand_path("../../translation_maps/marc_geographic.yaml", __FILE__)
18
18
  file = File.open( filename, "w:utf-8" )
19
19
 
20
20
  $stderr.puts "Writing to `#{filename}` ..."
21
-
22
- html = Nokogiri::HTML(open(source_url).read)
21
+ html = Nokogiri::HTML(Net::HTTP.get(URI.parse(source_url)))
23
22
 
24
23
  file.puts "# Translation map for marc geographic codes constructed by `rake load_maps:marc_geographic` task"
25
24
  file.puts "# Scraped from #{source_url} at #{Time.now}"
@@ -51,6 +50,7 @@ namespace :load_maps do
51
50
  file.puts("# Map Language Codes (in 008[35-37], 041) to User Friendly Term\r")
52
51
 
53
52
  marc_language_source_url = 'https://www.loc.gov/standards/codelists/languages.xml'
53
+ file.puts "# Scraped from #{marc_language_source_url} at #{Time.now}"
54
54
  doc = Nokogiri::XML(URI.parse(marc_language_source_url).open)
55
55
  marc_language_hash = doc.xpath('//codelist:language', codelist: CODELIST_NS)
56
56
  .to_h do |node|
@@ -5,7 +5,6 @@ require 'csv'
5
5
  # Use DelimitedWriter for non-CSV lines (e.g., tab-delimited)
6
6
  #
7
7
  #
8
-
9
8
  class Traject::CSVWriter < Traject::DelimitedWriter
10
9
 
11
10
  def initialize(*args)
@@ -26,6 +25,11 @@ class Traject::CSVWriter < Traject::DelimitedWriter
26
25
  # Let CSV take care of the comma escaping
27
26
  def escape(x)
28
27
  x = x.to_s
28
+
29
+ if x.frozen?
30
+ x = x.dup
31
+ end
32
+
29
33
  x.gsub! internal_delimiter, @eidelim
30
34
  x
31
35
  end
@@ -20,7 +20,7 @@ require 'traject/line_writer'
20
20
  # escape delimiters/internal_delimiters in the following way:
21
21
  # * If the delimiter is a tab, replace tabs in values with a single space
22
22
  # * If the delimiter is anything else, prefix it with a backslash
23
-
23
+ #
24
24
  class Traject::DelimitedWriter < Traject::LineWriter
25
25
 
26
26
  attr_reader :delimiter, :internal_delimiter, :edelim, :eidelim
@@ -83,6 +83,11 @@ class Traject::DelimitedWriter < Traject::LineWriter
83
83
  # Escape the delimiters in whatever way has been defined
84
84
  def escape(x)
85
85
  x = x.to_s
86
+
87
+ if x.frozen?
88
+ x = x.dup
89
+ end
90
+
86
91
  x.gsub! @delimiter, @edelim if @delimiter
87
92
  x.gsub! @internal_delimiter, @eidelim
88
93
  x
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Traject
2
4
  # An EXPERIMENTAL HALF-FINISHED implementation of a streaming/pull reader using Nokogiri.
3
5
  # Not ready for use, not stable API, could go away.
@@ -134,7 +136,7 @@ module Traject
134
136
  @inverted_namespaces = namespaces.invert
135
137
  @clipboard = clipboard
136
138
  # We're guessing using a string will be more efficient than an array
137
- @current_path = ""
139
+ @current_path = +""
138
140
  @floating = false
139
141
 
140
142
  @path_spec, @floating = parse_path(str_spec)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Represents the context of a specific record being indexed, passed
2
4
  # to indexing logic blocks
3
5
  #
@@ -57,7 +59,7 @@ class Traject::Indexer
57
59
  # a string label that can be used to refer to a particular record in log messages and
58
60
  # exceptions. Includes various parts depending on what we got.
59
61
  def record_inspect
60
- str = "<"
62
+ str = +"<"
61
63
 
62
64
  str << "record ##{position}" if position
63
65
 
@@ -10,6 +10,7 @@ require 'traject/indexer/step'
10
10
  require 'traject/marc_reader'
11
11
  require 'traject/json_writer'
12
12
  require 'traject/solr_json_writer'
13
+ require 'traject/solr_json_httpx_writer'
13
14
  require 'traject/debug_writer'
14
15
  require 'traject/array_writer'
15
16
 
@@ -282,7 +283,7 @@ class Traject::Indexer
282
283
  def self.default_settings
283
284
  @default_settings ||= {
284
285
  # Writer defaults
285
- "writer_class_name" => "Traject::SolrJsonWriter",
286
+ "writer_class_name" => ENV['TRAJECT_DEFAULT_WRITER'] == 'SolrJsonHttpxWriter' ? "Traject::SolrJsonHttpxWriter" : "Traject::SolrJsonWriter2",
286
287
  "solr_writer.batch_size" => 100,
287
288
  "solr_writer.thread_pool" => 1,
288
289
 
@@ -1,4 +1,5 @@
1
1
  # Encoding: UTF-8
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'traject/marc_extractor'
4
5
 
@@ -570,7 +571,7 @@ module Traject::Macros
570
571
  # associated with the content of subfield $v, $x, $y, and $z."
571
572
  # http://www.loc.gov/marc/bibliographic/bd600.html
572
573
  def self.assemble_lcsh(marc_field, subd_separator = " — ", other_separator = " ")
573
- str = ""
574
+ str = +""
574
575
  subd_prefix_codes = %w{v x y z}
575
576
 
576
577
 
@@ -1,5 +1,4 @@
1
1
  require 'uri'
2
- require 'cgi'
3
2
  require 'http'
4
3
 
5
4
  module Traject
@@ -54,7 +53,7 @@ module Traject
54
53
  end
55
54
 
56
55
  def start_url_verb
57
- @start_url_verb ||= (array = CGI.parse(URI.parse(start_url).query)["verb"]) && array.first
56
+ @start_url_verb ||= URI.decode_www_form(URI.parse(start_url).query).to_h["verb"]
58
57
  end
59
58
 
60
59
  def extra_xpath_hooks
@@ -94,7 +93,7 @@ module Traject
94
93
  # resumption URL is just original verb with resumption token, that seems to be
95
94
  # the oai-pmh spec.
96
95
  parsed_uri = URI.parse(start_url)
97
- parsed_uri.query = "verb=#{CGI.escape start_url_verb}&resumptionToken=#{CGI.escape resumption_token}"
96
+ parsed_uri.query = "verb=#{URI.encode_www_form_component start_url_verb}&resumptionToken=#{URI.encode_www_form_component resumption_token}"
98
97
  parsed_uri.to_s
99
98
  end
100
99