forked from Nuix/Worker-Side-Script-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWSS_ExcludeByExtension.rb
48 lines (38 loc) · 1.58 KB
/
WSS_ExcludeByExtension.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
=begin
Copyright 2019 Nuix
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Visit GitHub for more examples: https://github.com/Nuix/Worker-Side-Script-Examples
If an item's name contains an extension we don't want to process
we will tell the worker not to process that item. Note since we are using
the item's name, this only really effectively filters data for which the item's
name in Nuix contains the item's extension.
=end
# List of extensions we don't want to process. Provide then extension
# without period, map call will convert it into regex for .ext anchored to end
# of input ($).
$excluded_extensions = [
"plist",
"cab",
].map{|e|/\.#{e}$/i}
# Define our worker item callback
def nuix_worker_item_callback(worker_item)
# Get the associated SourceItem
source_item = worker_item.getSourceItem
# Get the item's name
item_name = source_item.getName
# Does the item name match our exclusion test?
if $excluded_extensions.any?{|e|item_name =~ e}
# It does, exclude it from processing
worker_item.setProcessItem(false)
# This will be written to worker log
puts "Excluding item with name: #{item_name}"
end
end