traject 2.3.3-java → 2.3.4-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 203a69835854bde2665c53aafaea20ceb731f431
4
- data.tar.gz: 38579221ab60f0db3a05bec41e367ff6e06c4153
2
+ SHA256:
3
+ metadata.gz: df62db1f1ace291c7dd827e312cd166ce41ec2c4368dd0dfde794b1e7b54c1f1
4
+ data.tar.gz: 0b9efb45341e5420f545d57ecf993e185da1db030b8b7b00c05b56ced483ba7e
5
5
  SHA512:
6
- metadata.gz: 26969d8a05a35dbf5fd2d59391f4701353af387c14641a99e43beb32d9ee07de8ed6b0a1709091f03cc1db474ac4a24203969fc2a114d11edacc7e2f0e91963e
7
- data.tar.gz: 6129937d2a7b6958368487ed38174458740d476c9513cc7f497b81f882aca9f6b61e36034ddbe59bfa9dacef5575bf7b5123702dc1f5c22072255eeba65afad2
6
+ metadata.gz: cb66e7a9f88375d7c8a8f2cfb0bbc009293bf5c2543de98bbc8eea9ef4c0aa75dadf8683b44f57e53045c279f74a2e467d18e93052d358343126882ecb474aac
7
+ data.tar.gz: 17bef76f4018541e6b5560df53e8fea2f8fe1c53a7b84d9fd2c2288fe04ce77373206c5b12c682d5f2619d9bf04f67794bae1c5008abc5f1619b2c1076866771
data/.travis.yml CHANGED
@@ -5,12 +5,8 @@ rvm:
5
5
  - jruby-19mode
6
6
  - jruby-9.0.4.0
7
7
  - 1.9
8
- - 2.2
9
- - 2.3.3
10
- - 2.4.0
11
- before_install:
12
- - gem update --system
13
- - gem uninstall bundler
14
- - gem update bundler
8
+ - 2.2.8
9
+ - 2.3.5
10
+ - 2.4.2
15
11
  jdk:
16
12
  - oraclejdk8
data/CHANGES.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changes
2
2
 
3
+ ## 2.3.4
4
+ * Totally internal change to provide easier hooks into indexing process
5
+
3
6
  ## 2.3.3
4
7
  * Further squash use of capture-variabels ('$1', etc.)
5
8
  to try to work around the non-thread-safety of
@@ -184,7 +184,7 @@ class Traject::Indexer
184
184
  @after_processing_steps = []
185
185
  end
186
186
 
187
- # Pass a string file path, or a File object, for
187
+ # Pass a string file path, a Pathname, or a File object, for
188
188
  # a config file to load into indexer.
189
189
  #
190
190
  # Can raise:
@@ -195,9 +195,9 @@ class Traject::Indexer
195
195
  def load_config_file(file_path)
196
196
  File.open(file_path) do |file|
197
197
  begin
198
- self.instance_eval(file.read, file_path)
198
+ self.instance_eval(file.read, file_path.to_s)
199
199
  rescue ScriptError, StandardError => e
200
- raise ConfigLoadError.new(file_path, e)
200
+ raise ConfigLoadError.new(file_path.to_s, e)
201
201
  end
202
202
  end
203
203
  end
@@ -342,12 +342,10 @@ class Traject::Indexer
342
342
 
343
343
  # Set the index step for error reporting
344
344
  context.index_step = index_step
345
- accumulator = log_mapping_errors(context, index_step) do
345
+ log_mapping_errors(context, index_step) do
346
346
  index_step.execute(context) # will always return [] for an each_record step
347
347
  end
348
348
 
349
- add_accumulator_to_context!(accumulator, context) if index_step.to_field_step?
350
-
351
349
  # And unset the index step now that we're finished
352
350
  context.index_step = nil
353
351
  end
@@ -355,37 +353,6 @@ class Traject::Indexer
355
353
  return context
356
354
  end
357
355
 
358
-
359
- # Add the accumulator to the context with the correct field name
360
- # Do post-processing on the accumulator (remove nil values, allow empty
361
- # fields, etc)
362
- #
363
- # Only get here if we've got a to_field step; otherwise the
364
- # call to get a field_name will throw an error
365
-
366
- ALLOW_NIL_VALUES = "allow_nil_values".freeze
367
- ALLOW_EMPTY_FIELDS = "allow_empty_fields".freeze
368
- ALLOW_DUPLICATE_VALUES = "allow_duplicate_values".freeze
369
-
370
- def add_accumulator_to_context!(accumulator, context)
371
-
372
- accumulator.compact! unless settings[ALLOW_NIL_VALUES]
373
- return if accumulator.empty? and not (settings[ALLOW_EMPTY_FIELDS])
374
-
375
- field_name = context.index_step.field_name
376
- context.output_hash[field_name] ||= []
377
-
378
- existing_accumulator = context.output_hash[field_name].concat(accumulator)
379
- existing_accumulator.uniq! unless settings[ALLOW_DUPLICATE_VALUES]
380
-
381
- rescue NameError => e
382
- msg = "Tried to call add_accumulator_to_context with a non-to_field step"
383
- msg += context.index_step.inspect
384
- logger.error msg
385
- raise ArgumentError.new(msg)
386
- end
387
-
388
-
389
356
  # just a wrapper that captures and records any unexpected
390
357
  # errors raised in mapping, along with contextual information
391
358
  # on record and location in source file of mapping rule.
@@ -414,7 +381,6 @@ class Traject::Indexer
414
381
  end
415
382
  end
416
383
 
417
-
418
384
  # Processes a stream of records, reading from the configured Reader,
419
385
  # mapping according to configured mapping rules, and then writing
420
386
  # to configured Writer.
@@ -150,9 +150,26 @@ class Traject::Indexer
150
150
  end
151
151
 
152
152
 
153
+ add_accumulator_to_context!(accumulator, context)
153
154
  return accumulator
154
155
  end
155
156
 
157
+ # Add the accumulator to the context with the correct field name
158
+ # Do post-processing on the accumulator (remove nil values, allow empty
159
+ # fields, etc)
160
+ ALLOW_NIL_VALUES = "allow_nil_values".freeze
161
+ ALLOW_EMPTY_FIELDS = "allow_empty_fields".freeze
162
+ ALLOW_DUPLICATE_VALUES = "allow_duplicate_values".freeze
163
+
164
+ def add_accumulator_to_context!(accumulator, context)
165
+ accumulator.compact! unless context.settings[ALLOW_NIL_VALUES]
166
+ return if accumulator.empty? and not (context.settings[ALLOW_EMPTY_FIELDS])
167
+
168
+ context.output_hash[field_name] ||= []
169
+
170
+ existing_accumulator = context.output_hash[field_name].concat(accumulator)
171
+ existing_accumulator.uniq! unless context.settings[ALLOW_DUPLICATE_VALUES]
172
+ end
156
173
  end
157
174
 
158
175
  # A class representing a block of logic called after
@@ -1,3 +1,3 @@
1
1
  module Traject
2
- VERSION = "2.3.3"
2
+ VERSION = "2.3.4"
3
3
  end
@@ -20,7 +20,7 @@ describe "Traject::Indexer#load_config_path" do
20
20
  end
21
21
  end
22
22
 
23
- describe "with good config" do
23
+ describe "with good config provided" do
24
24
  before do
25
25
  @config_file = tmp_config_file_with(%Q{
26
26
  settings do
@@ -32,11 +32,19 @@ describe "Traject::Indexer#load_config_path" do
32
32
  after do
33
33
  @config_file.unlink
34
34
  end
35
- it "loads config file by path" do
35
+
36
+
37
+ it "loads config file by path (as a String)" do
36
38
  @indexer.load_config_file(@config_file.path)
37
39
 
38
40
  assert_equal "our_value", @indexer.settings["our_key"]
39
41
  end
42
+
43
+ it "loads config file by path (as a Pathname)" do
44
+ @indexer.load_config_file(Pathname.new(@config_file.path))
45
+
46
+ assert_equal "our_value", @indexer.settings["our_key"]
47
+ end
40
48
  end
41
49
 
42
50
  describe "with error in config" do
@@ -60,7 +68,7 @@ describe "Traject::Indexer#load_config_path" do
60
68
  assert_equal 4, e.config_file_lineno
61
69
  end
62
70
 
63
- it "raises good error on StandardError type" do
71
+ it "raises good error on StandardError type (when passing String)" do
64
72
  @config_file = tmp_config_file_with(%Q{
65
73
  # Intentional non-syntax error, bad extract_marc spec
66
74
  to_field "foo", extract_marc("#%^%^%^")
@@ -74,6 +82,20 @@ describe "Traject::Indexer#load_config_path" do
74
82
  assert_equal @config_file.path, e.config_file
75
83
  assert_equal 3, e.config_file_lineno
76
84
  end
85
+
86
+ it "raises good error on StandardError type (when passing Pathname)" do
87
+ @config_file = tmp_config_file_with(%Q{
88
+ # Intentional non-syntax error, bad extract_marc spec
89
+ to_field "foo", extract_marc("#%^%^%^")
90
+ })
91
+
92
+ e = assert_raises(Traject::Indexer::ConfigLoadError) do
93
+ @indexer.load_config_file(Pathname.new(@config_file.path))
94
+ end
95
+
96
+ assert_kind_of StandardError, e.original
97
+ assert_equal @config_file.path, e.config_file
98
+ end
77
99
  end
78
100
 
79
101
 
@@ -84,6 +106,4 @@ describe "Traject::Indexer#load_config_path" do
84
106
 
85
107
  return file
86
108
  end
87
-
88
-
89
- end
109
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: traject
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.3
4
+ version: 2.3.4
5
5
  platform: java
6
6
  authors:
7
7
  - Jonathan Rochkind
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-01-25 00:00:00.000000000 Z
12
+ date: 2018-08-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  requirement: !ruby/object:Gem::Requirement
@@ -345,7 +345,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
345
345
  version: '0'
346
346
  requirements: []
347
347
  rubyforge_project:
348
- rubygems_version: 2.6.8
348
+ rubygems_version: 2.7.6
349
349
  signing_key:
350
350
  specification_version: 4
351
351
  summary: Index MARC to Solr; or generally process source records to hash-like structures