traject_plus 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/traject_plus/indexer/step.rb +20 -15
- data/lib/traject_plus/version.rb +1 -1
- data/traject_plus.gemspec +1 -1
- metadata +4 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 531ac9e2b209eb0206963fa1807c700df3b161a6
|
4
|
+
data.tar.gz: 0bc34504ec992107ec04777e01d3d91f06e88c12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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,
|
5
|
-
super(fieldname,
|
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
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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
|
-
|
33
|
-
|
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,
|
44
|
+
def initialize(fieldname, procs, block, source_location, indexer)
|
42
45
|
@indexer = indexer
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
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
|
-
|
52
|
-
|
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
|
data/lib/traject_plus/version.rb
CHANGED
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', '~>
|
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
|
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-
|
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: '
|
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: '
|
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
|