cdmbl 0.11.1 → 0.12.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: c35f23365189a85dd22882bc8fb7c4c07bf41e08
4
- data.tar.gz: d80ba997c1cb74b63e40dbed80466407ed41d275
3
+ metadata.gz: 43e5cf62c413f7fc69f95751f5beccea22da21c6
4
+ data.tar.gz: 6c9d1fa56a87cfd5f48ff21dd5a91f5cfaff0fb7
5
5
  SHA512:
6
- metadata.gz: 8fd6c40c05f25c803ce6d2e26500e4d9082c0006b9f835b92710208b0a3c3fa8369987ea02052cf5fc9a451038b3da1a9411328d12df60b28230bef628312fce
7
- data.tar.gz: 2217bee7f887ea291b3b6fdfc842f0db063ff058340e4ff8af654708f4330ff64a32cb2e650a8793bb4e33cb03aed119a8c22947a68f8a9d3d3a3360f2a2acc8
6
+ metadata.gz: b147ab7d388f3f06c1ac47b66825fee6216c24972eff496440e576946d1946d23b9707d1dd419b8c2c4bbfb76ed7ae099c9f5d60accdb46d91ff307134583f1d
7
+ data.tar.gz: 7ae01db4bc7d3e3fbd8593f9cfb0f6e4f13ed09d98bad66741a89b555de68f4c22900a55a6ac17e296b92e117f77d8f04009ef0bfd28925e12892672e28ece3a
@@ -0,0 +1,19 @@
1
+ module CDMBL
2
+ # Search an OAI ListSets field using a regular expression
3
+ class RegexFilterCallback
4
+ attr_reader :field, :pattern, :inclusive
5
+ def initialize(field: 'setName', pattern: /.*/, inclusive: true)
6
+ @field = field
7
+ @pattern = pattern
8
+ @inclusive = inclusive
9
+ end
10
+
11
+ def valid?(set: {})
12
+ inclusive ? matches?(set) : !matches?(set)
13
+ end
14
+
15
+ def matches?(set)
16
+ pattern.match?(set[field])
17
+ end
18
+ end
19
+ end
@@ -30,20 +30,17 @@ namespace :cdmbl do
30
30
  :inclusive,
31
31
  :batch_size
32
32
  ] do |t, args|
33
- # Required args
34
33
  oai_endpoint = args.fetch(:oai_endpoint)
35
- solr_url = args.fetch(:solr_url)
36
- cdm_endpoint = args.fetch(:cdm_endpoint)
37
34
  # Optional args
38
- pattern = args.fetch(:set_spec_pattern, false)
39
- inclusive = args.fetch(:inclusive, true)
40
- batch_size = args.fetch(:batch_size, 5)
41
-
35
+ pattern = args.fetch(:set_spec_pattern, false)
36
+ inclusive = args.fetch(:inclusive, 'true') == 'true'
42
37
  # Define your own callback if you want to use other set related fields
43
- # Use the SetSpecFilterCallback as an example of how to build your own filter
38
+ # Use the RegexFilterCallback as an example of how to build your own filter
44
39
  set_specs =
45
40
  if pattern
46
- filter = CDMBL::SetSpecFilterCallback.new(pattern: Regexp.new(pattern))
41
+ filter = CDMBL::RegexFilterCallback.new(field: 'setName',
42
+ pattern: Regexp.new(pattern),
43
+ inclusive: inclusive)
47
44
  CDMBL::FilteredSetSpecs.new(oai_base_url: oai_endpoint,
48
45
  callback: filter).set_specs
49
46
  else
@@ -56,7 +53,7 @@ namespace :cdmbl do
56
53
  solr_config: { url: args.fetch(:solr_url) },
57
54
  oai_endpoint: args.fetch(:oai_endpoint),
58
55
  cdm_endpoint: args.fetch(:cdm_endpoint),
59
- batch_size: args.fetch(:batch_size, 10),
56
+ batch_size: args.fetch(:batch_size, 5),
60
57
  max_compounds: args.fetch(:max_compounds, 10)
61
58
  }
62
59
 
data/lib/cdmbl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module CDMBL
2
- VERSION = "0.11.1"
2
+ VERSION = "0.12.0"
3
3
  end
data/lib/cdmbl.rb CHANGED
@@ -28,4 +28,4 @@ require 'cdmbl/load_worker'
28
28
  require 'cdmbl/transform_worker'
29
29
  require 'cdmbl/filtered_set_specs'
30
30
  require 'cdmbl/etl_by_set_specs'
31
- require 'cdmbl/set_spec_filter_callback'
31
+ require 'cdmbl/regex_filter_callback'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cdmbl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.1
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - chadfennell
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-23 00:00:00.000000000 Z
11
+ date: 2018-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hash_at_path
@@ -238,7 +238,7 @@ files:
238
238
  - lib/cdmbl/oai_set_lookup.rb
239
239
  - lib/cdmbl/rake_task.rb
240
240
  - lib/cdmbl/record_transformer.rb
241
- - lib/cdmbl/set_spec_filter_callback.rb
241
+ - lib/cdmbl/regex_filter_callback.rb
242
242
  - lib/cdmbl/tasks/delete.rake
243
243
  - lib/cdmbl/tasks/etl.rake
244
244
  - lib/cdmbl/transform_worker.rb
@@ -1,17 +0,0 @@
1
- module CDMBL
2
- class SetSpecFilterCallback
3
- attr_reader :pattern, :inclusive
4
- def initialize(pattern: /.*/, inclusive: true)
5
- @pattern = pattern
6
- @inclusive = inclusive
7
- end
8
-
9
- def valid?(set: {})
10
- (inclusive) ? matches?(set) : !matches?(set)
11
- end
12
-
13
- def matches?(set)
14
- pattern.match?(set['setSpec'])
15
- end
16
- end
17
- end