metanorma-plugin-glossarist 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/liquid/drops/concepts_drop.rb +21 -3
- data/lib/metanorma/plugin/glossarist/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a70474bfd62145088fa8353c1680521c1bf09d5401182641b43490eaf2e26fd0
|
4
|
+
data.tar.gz: 2611ecbd803ffae2ebbc48bb566f8d0db55408001029b98d66fdf9ea6f4dac81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e0d7d6c140927fd8ca69ca74ed5fd91a8316a43ff73790b817712dcfb5594a45dc0f588ffffda53d01d1eb12ffc897b6b8bc3c073bfab0950494e499fb087bf
|
7
|
+
data.tar.gz: 3c150a94c4644ce6a516992f84276a2a064c0a9b5925bfca76efed7ac333b8a81e56f21d278663b9fb355ec855e4f5cba2536088484aa887abb287e6bb1fe63e
|
@@ -4,7 +4,7 @@ module Liquid
|
|
4
4
|
module Drops
|
5
5
|
class ConceptsDrop < Liquid::Drop
|
6
6
|
# rubocop:disable Lint/MissingSuper
|
7
|
-
NON_LANGUAGE_FIELDS = %w[term termid].freeze
|
7
|
+
NON_LANGUAGE_FIELDS = %w[term termid groups].freeze
|
8
8
|
|
9
9
|
def initialize(managed_concept_collection, filters = {})
|
10
10
|
@concepts_collection = managed_concept_collection
|
@@ -34,6 +34,7 @@ module Liquid
|
|
34
34
|
concept_filters = filters.dup
|
35
35
|
language_filter = concept_filters.delete('lang')
|
36
36
|
sort_filter = concept_filters.delete('sort_by')
|
37
|
+
group_filter = concept_filters.delete('group')
|
37
38
|
|
38
39
|
concepts = concepts_collection.to_h["managed_concepts"].map do |concept|
|
39
40
|
filtered_concept = concept.dup
|
@@ -47,8 +48,14 @@ module Liquid
|
|
47
48
|
|
48
49
|
concept_filters.each do |name, value|
|
49
50
|
fields = extract_nested_field_names(name)
|
50
|
-
|
51
|
-
|
51
|
+
if fields.last.start_with?("start_with")
|
52
|
+
value = fields.last.gsub(/start_with\(([^\)]*)\)/, '\1')
|
53
|
+
fields = fields[0..-2]
|
54
|
+
|
55
|
+
unless filtered_concept.dig(*fields).start_with?(value)
|
56
|
+
filtered_concept.delete(field)
|
57
|
+
end
|
58
|
+
elsif filtered_concept.dig(*fields) != value
|
52
59
|
filtered_concept.delete(field)
|
53
60
|
end
|
54
61
|
end
|
@@ -61,6 +68,7 @@ module Liquid
|
|
61
68
|
end
|
62
69
|
end.compact
|
63
70
|
|
71
|
+
apply_group_filter(concepts, group_filter)
|
64
72
|
apply_sort_filter(concepts, sort_filter)
|
65
73
|
end
|
66
74
|
|
@@ -70,6 +78,16 @@ module Liquid
|
|
70
78
|
concepts.sort_by { |concept| concept.dig(*extract_nested_field_names(sort_by)) }
|
71
79
|
end
|
72
80
|
|
81
|
+
def apply_group_filter(concepts, groups)
|
82
|
+
return concepts unless groups
|
83
|
+
|
84
|
+
concepts.select! do |concept|
|
85
|
+
groups.split(",").reduce(true) do |pre_result, group|
|
86
|
+
pre_result && concept["groups"].include?(group.strip)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
73
91
|
def extract_nested_field_names(name)
|
74
92
|
name.split(".").map do |field|
|
75
93
|
field_name = field.strip
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-plugin-glossarist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|