traject_plus 1.0.0 → 1.1.0

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
2
  SHA256:
3
- metadata.gz: 586e90e7cb12df2dce7019884f218d1438a0493f4a982da874b0a566f163fb15
4
- data.tar.gz: 1a54f1a1f29fba7669f746266861687836678d376348f796d8442799ec2f8e0f
3
+ metadata.gz: 9e88950f9930b74cc29eaf7d62b55c255e3f29e471f73abfcdbd7c2456e604bc
4
+ data.tar.gz: bb058742cce2434abc341dc72cd76928cf856afc149fc681122819fdc9022897
5
5
  SHA512:
6
- metadata.gz: a72f9d3fab511ca29b2f01995bfca990953c2b28ba3bc9d33a09bc56c2c769c7f665c95776720c51c38278fc781d1beefeba00f21e35009ca442fb7f3e79e44e
7
- data.tar.gz: ca6c5f9ab9e060c9883c66f75d061877279cc13288b4832faed6779cf36b107e96e537a36c6a7bafd2f57a605ce3395af49087102487cde446ad56cc2d95e22d
6
+ metadata.gz: 942616c2a50191ee8a1f30d10fbfb718bade0c99adc9d5181aca0d8087b6fea2f264f36434f0e1341cd03da871cf33cc14e172320d2ba877230cfcab75b352f7
7
+ data.tar.gz: f5063714eac2c658c34d99ce8a7ce22d8ed45bef54ffe16945305f794034963e411b8e9c6f046867a8e90c3f9e4fffac900d32bab4dc67669cbaac7d4da9b732
@@ -4,6 +4,7 @@ require 'active_support/core_ext/object/blank'
4
4
  require 'deprecation'
5
5
 
6
6
  module TrajectPlus
7
+ # @deprecated because Traject 3 can do this for us.
7
8
  module Extraction
8
9
  def self.apply_extraction_options(result, options = {})
9
10
  TransformPipeline.new(options).transform(result)
@@ -10,6 +10,9 @@ module TrajectPlus
10
10
  lambda do |row, accumulator, _context|
11
11
  return if row[header_or_index].to_s.empty?
12
12
  result = Array(row[header_or_index].to_s)
13
+ unless options.empty?
14
+ Deprecation.warn(self, "passing options to column is deprecated and will be removed in the next major release. Use the Traject 3 pipeline instead")
15
+ end
13
16
  result = TrajectPlus::Extraction.apply_extraction_options(result, options)
14
17
  accumulator.concat(result)
15
18
  end
@@ -12,6 +12,9 @@ module TrajectPlus
12
12
  lambda do |json, accumulator, _context|
13
13
  result = Array(JsonPath.on(json, path))
14
14
  result = TrajectPlus::Extraction.apply_extraction_options(result, options)
15
+ unless options.empty?
16
+ Deprecation.warn(self, "passing options to extract_json is deprecated and will be removed in the next major release. Use the Traject 3 pipeline instead")
17
+ end
15
18
  accumulator.concat(result)
16
19
  end
17
20
  end
@@ -10,6 +10,9 @@ module TrajectPlus
10
10
  def extract_xml(xpath, namespaces, options = {})
11
11
  lambda do |xml, accumulator, _context|
12
12
  result = xml.xpath(xpath, namespaces).map(&:text)
13
+ unless options.empty?
14
+ Deprecation.warn(self, "passing options to extract_xml is deprecated and will be removed in the next major release. Use the Traject 3 pipeline instead")
15
+ end
13
16
  result = TrajectPlus::Extraction.apply_extraction_options(result, options)
14
17
  accumulator.concat(result)
15
18
  end
@@ -1,6 +1,11 @@
1
1
  # frozen_string_literal: true
2
+
3
+ require 'deprecation'
4
+
2
5
  module TrajectPlus
3
6
  module Macros
7
+ extend Deprecation
8
+
4
9
  # construct a structured hash using values extracted using traject
5
10
  def transform_values(context, hash)
6
11
  hash.transform_values do |lambdas|
@@ -51,10 +56,9 @@ module TrajectPlus
51
56
  end
52
57
 
53
58
  def transform(options = {})
54
- lambda do |record, accumulator, context|
55
- results = TrajectPlus::Extraction.apply_extraction_options(accumulator, options)
56
- accumulator.replace(results)
57
- end
59
+ return deprecated_transform(options) unless block_given?
60
+
61
+ super() # These empty parens are meaningful, otherwise it'll pass options.
58
62
  end
59
63
 
60
64
  # apply the same mapping to multiple fields
@@ -63,6 +67,9 @@ module TrajectPlus
63
67
  end
64
68
 
65
69
  def to_field(field_name, *procs, extract: nil, transform: nil, **namedArgs, &block)
70
+ if transform || extract
71
+ Deprecation.warn(self, "Passing extract or transform arguments to to_field is deprecated. Use the Traject 3 pipeline instead.")
72
+ end
66
73
  procs = [extract, transform] if procs.empty?
67
74
  @index_steps << TrajectPlus::Indexer::ToFieldStep.new(field_name, procs, block, Traject::Util.extract_caller_location(caller.first), **namedArgs)
68
75
  end
@@ -78,5 +85,15 @@ module TrajectPlus
78
85
 
79
86
  @index_steps << TrajectPlus::Indexer::ComposeStep.new(fieldname, extract || aLambda, transform, Traject::Util.extract_caller_location(caller.first), indexer)
80
87
  end
88
+
89
+ private
90
+
91
+ def deprecated_transform(options)
92
+ Deprecation.warn(self, "transform is deprecated and will be removed in the next major release. Use the Traject 3 pipeline instead")
93
+ lambda do |record, accumulator, context|
94
+ results = TrajectPlus::Extraction.apply_extraction_options(accumulator, options)
95
+ accumulator.replace(results)
96
+ end
97
+ end
81
98
  end
82
99
  end
@@ -1,3 +1,3 @@
1
1
  module TrajectPlus
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0".freeze
3
3
  end
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: 1.0.0
4
+ version: 1.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: 2019-02-26 00:00:00.000000000 Z
14
+ date: 2019-03-04 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport