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 +4 -4
- data/lib/cdmbl/regex_filter_callback.rb +19 -0
- data/lib/cdmbl/tasks/etl.rake +7 -10
- data/lib/cdmbl/version.rb +1 -1
- data/lib/cdmbl.rb +1 -1
- metadata +3 -3
- data/lib/cdmbl/set_spec_filter_callback.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43e5cf62c413f7fc69f95751f5beccea22da21c6
|
4
|
+
data.tar.gz: 6c9d1fa56a87cfd5f48ff21dd5a91f5cfaff0fb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/cdmbl/tasks/etl.rake
CHANGED
@@ -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
|
39
|
-
inclusive
|
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
|
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::
|
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,
|
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
data/lib/cdmbl.rb
CHANGED
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.
|
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-
|
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/
|
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
|