ooze-parser 0.1.7 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/ooz/base/field/select.rb +32 -0
- data/lib/ooz/base/model.rb +2 -2
- data/lib/ooz/model/ooze.rb +25 -2
- data/lib/ooz/version.rb +1 -1
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ac6c74a6c7335e7c002ef332684e510c03c569fdc254cdd5f334668513e67548
|
4
|
+
data.tar.gz: d63bc4cdf6bfb2dc97825b9446b31f2f862c04a4771de62d40b5556095b1237a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdd17d4a7b2f0fbe0fe0e10b71f0aff505ff63993e10b2ff72d0d4a3a66d051d6112fc441b513e47478b015fee5d5dc5b3547f4656157bf45cd53509f2ddc096
|
7
|
+
data.tar.gz: 69a53428143cb56b7f5be3be74f8f45040fa3e495a42d550ab18098ab312c2d9455ff237a8ecf5f9dc7328d4095c88cee8cb5beeafd2d735747aaf2e859019df
|
@@ -13,6 +13,38 @@ module Ooz
|
|
13
13
|
module Base
|
14
14
|
class Field
|
15
15
|
class Select
|
16
|
+
class << self
|
17
|
+
# Merges options in `more` into `master` options
|
18
|
+
# @param master [Ooz::Model::Field::Select]
|
19
|
+
# @param more [Ooz::Model::Field::Select, Array<Hash>]
|
20
|
+
# @note it prevents douplicated values
|
21
|
+
def merge_options(master, more, silent: false)
|
22
|
+
if !master.is_a?(Ooz::Model::Field::Select)
|
23
|
+
raise ArgumentError.new("Expecting 'master' to be Ooz::Model::Field::Select. Given: #{master.class}")
|
24
|
+
elsif !more.is_a?(Ooz::Model::Field::Select) && !more.is_a?(Array)
|
25
|
+
raise ArgumentError.new("Expecting 'more' to be Ooz::Model::Field::Select or Array<Hash>. Given: #{more.class}")
|
26
|
+
end
|
27
|
+
opts1 = master.doc["options"]
|
28
|
+
opts2 = more.is_a?(Array)? more : more.doc["options"]
|
29
|
+
|
30
|
+
to_add = opts2.reject do |opt|
|
31
|
+
opts1.any? {|o| o["value"] == opt["value"]}
|
32
|
+
end
|
33
|
+
|
34
|
+
# Some feedback
|
35
|
+
if !silent && more.is_a?(Ooz::Model::Field::Select) && !to_add.empty?
|
36
|
+
puts "Merging more options to the field '#{more.label}':\n"
|
37
|
+
str_opts = to_add.map do |opt|
|
38
|
+
"'#{opt["value"]}' => '#{opt["name"]}'"
|
39
|
+
end.join("\n • ")
|
40
|
+
|
41
|
+
puts " • " + str_opts + "\n"
|
42
|
+
end
|
43
|
+
|
44
|
+
opts1.push(*to_add)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
16
48
|
overridable_const :select_option, Base::Field::Select::Option
|
17
49
|
passthrough :multiple, :flat, :data_type, :other, :other_desc, to: :doc
|
18
50
|
passthrough_arr :options, to: :doc, klass: :select_option
|
data/lib/ooz/base/model.rb
CHANGED
data/lib/ooz/model/ooze.rb
CHANGED
@@ -6,6 +6,11 @@ module Ooz
|
|
6
6
|
overridable_const :field_factory_class, Model::FieldFactory
|
7
7
|
overridable_const :force_class, Model::Force
|
8
8
|
|
9
|
+
def tagged?(tag, search_on: :tags)
|
10
|
+
haystack = self.send(search_on)
|
11
|
+
haystack.include?(tag)
|
12
|
+
end
|
13
|
+
|
9
14
|
def stages?
|
10
15
|
evolution && evolution.stages&.length > 0
|
11
16
|
end
|
@@ -35,8 +40,26 @@ module Ooz
|
|
35
40
|
membranes
|
36
41
|
end
|
37
42
|
|
38
|
-
def fields_hash
|
39
|
-
|
43
|
+
def fields_hash(key: "_id", silent: true)
|
44
|
+
fields.group_by do |fld|
|
45
|
+
fld.send(key)
|
46
|
+
end.transform_values do |flds|
|
47
|
+
if flds.length == 1
|
48
|
+
flds.first
|
49
|
+
else
|
50
|
+
master = flds.first
|
51
|
+
next master unless master.is_a?(Ooz::Model::Field::Select)
|
52
|
+
rest = flds[1..-1]
|
53
|
+
rest.each do |fld|
|
54
|
+
if fld.is_a?(Ooz::Model::Field::Select)
|
55
|
+
master.other ||= fld.other
|
56
|
+
master.multiple ||= fld.multiple
|
57
|
+
Ooz::Base::Field::Select.merge_options(master, fld, silent: silent)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
master
|
61
|
+
end
|
62
|
+
end
|
40
63
|
end
|
41
64
|
|
42
65
|
def sections
|
data/lib/ooz/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ooze-parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oscar Segura
|
@@ -140,8 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: '0'
|
142
142
|
requirements: []
|
143
|
-
|
144
|
-
rubygems_version: 2.6.14.1
|
143
|
+
rubygems_version: 3.0.3
|
145
144
|
signing_key:
|
146
145
|
specification_version: 4
|
147
146
|
summary: ooze-parser to boost data integration and treatment
|