traject_plus 0.0.3 → 0.1.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
  SHA1:
3
- metadata.gz: c8a834e5438fea87e70c76613829687057f7b79c
4
- data.tar.gz: 9246f088e53b02c1ddbbccf9ee1b15ca43859bba
3
+ metadata.gz: 531ac9e2b209eb0206963fa1807c700df3b161a6
4
+ data.tar.gz: 0bc34504ec992107ec04777e01d3d91f06e88c12
5
5
  SHA512:
6
- metadata.gz: 2ed41666055b98d3e5726435396bba301c4f0df8f3472aa5cdd51c016355d8a3a2a54dc2527cc42db2eea375bbf8955b76a024da44a3cb1872696e927df035a0
7
- data.tar.gz: 43c7d9686789f1b2382a5bbbbdc6a6c2d408a8e849d17bace9f93313a066bba983f2311032313c9d3fee6efb2e5948bf920b0113828af72ab84b6e8a90ba7732
6
+ metadata.gz: 7696256342e7ceb99d3b1afb595b8aed58e52cc87e65cd3380400b848bd4443cd66aad85afdecce7830b9bd897217d8093194370d9a6145b11f8ab8f442072e0
7
+ data.tar.gz: b922f870fd7db6569e1a04c037e48eff8a77e75150b34e02afcb82880da0d879ffaf2670a0a9d59ce19fdf3754f6c5ea90561b6bc6c3dd4a1838889f3b130d39
@@ -1,8 +1,8 @@
1
1
  module TrajectPlus
2
2
  module Indexer
3
3
  class ToFieldStep < Traject::Indexer::ToFieldStep
4
- def initialize(fieldname, lambda, block, source_location, single: false)
5
- super(fieldname, lambda, block, source_location)
4
+ def initialize(fieldname, procs, block, source_location, single: false)
5
+ super(fieldname, procs, block, source_location)
6
6
 
7
7
  @single = single
8
8
  end
@@ -24,13 +24,16 @@ module TrajectPlus
24
24
  accumulator.compact! unless context.settings[ALLOW_NIL_VALUES]
25
25
  return if accumulator.empty? and not (context.settings[ALLOW_EMPTY_FIELDS])
26
26
 
27
- if field.single?
28
- context.output_hash[field_name] = accumulator.first if accumulator.length > 0
29
- else
30
- context.output_hash[field_name] ||= []
27
+ # field_name can actually be an array of field names
28
+ Array(field_name).each do |a_field_name|
29
+ if field.single?
30
+ context.output_hash[a_field_name] = accumulator.first if accumulator.length > 0
31
+ else
32
+ context.output_hash[a_field_name] ||= []
31
33
 
32
- existing_accumulator = context.output_hash[field_name].concat(accumulator)
33
- existing_accumulator.uniq! unless context.settings[ALLOW_DUPLICATE_VALUES]
34
+ existing_accumulator = context.output_hash[a_field_name].concat(accumulator)
35
+ existing_accumulator.uniq! unless context.settings[ALLOW_DUPLICATE_VALUES]
36
+ end
34
37
  end
35
38
  end
36
39
  end
@@ -38,18 +41,20 @@ module TrajectPlus
38
41
  class ComposeStep < ToFieldStep
39
42
  attr_reader :indexer
40
43
 
41
- def initialize(fieldname, lambda, block, source_location, indexer)
44
+ def initialize(fieldname, procs, block, source_location, indexer)
42
45
  @indexer = indexer
43
- self.field_name = fieldname
44
- self.lambda = lambda
45
- self.block = block
46
- self.source_location = source_location
46
+ @field_name = fieldname
47
+ @procs = procs
48
+ @block = block
49
+ @source_location = source_location
47
50
  end
48
51
 
49
52
  def execute(context)
50
53
  accumulator = []
51
- if lambda
52
- lambda.call(context.source_record, accumulator, context)
54
+ source_record = context.source_record
55
+
56
+ if procs
57
+ procs.call(context.source_record, accumulator, context)
53
58
  else
54
59
  accumulator << context.source_record
55
60
  end
@@ -1,3 +1,3 @@
1
1
  module TrajectPlus
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
data/traject_plus.gemspec CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_dependency 'activesupport'
24
24
  spec.add_dependency 'jsonpath'
25
- spec.add_dependency 'traject', '~> 2.3', '>= 2.3.4'
25
+ spec.add_dependency 'traject', '~> 3.0'
26
26
 
27
27
  spec.add_development_dependency "bundler", "~> 1.15"
28
28
  spec.add_development_dependency "rake", "~> 10.0"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: traject_plus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2018-06-26 00:00:00.000000000 Z
14
+ date: 2018-10-17 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport
@@ -47,20 +47,14 @@ dependencies:
47
47
  requirements:
48
48
  - - "~>"
49
49
  - !ruby/object:Gem::Version
50
- version: '2.3'
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: 2.3.4
50
+ version: '3.0'
54
51
  type: :runtime
55
52
  prerelease: false
56
53
  version_requirements: !ruby/object:Gem::Requirement
57
54
  requirements:
58
55
  - - "~>"
59
56
  - !ruby/object:Gem::Version
60
- version: '2.3'
61
- - - ">="
62
- - !ruby/object:Gem::Version
63
- version: 2.3.4
57
+ version: '3.0'
64
58
  - !ruby/object:Gem::Dependency
65
59
  name: bundler
66
60
  requirement: !ruby/object:Gem::Requirement