cortex-plugins-core 2.0.1 → 2.1.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/app/models/asset_field_type.rb +4 -4
- data/app/models/author_field_type.rb +6 -6
- data/app/models/boolean_field_type.rb +5 -5
- data/app/models/content_item_field_type.rb +6 -6
- data/app/models/date_time_field_type.rb +4 -4
- data/app/models/float_field_type.rb +7 -7
- data/app/models/integer_field_type.rb +8 -8
- data/app/models/tag_field_type.rb +11 -8
- data/app/models/text_field_type.rb +16 -6
- data/app/models/tree_field_type.rb +5 -5
- data/app/models/user_field_type.rb +6 -6
- data/lib/cortex/plugins/core/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94cebb14cba585c69240da175861cf9f988b3ef5
|
4
|
+
data.tar.gz: c08ca77752ae8d36768e3f292287b38a067fe53c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 737c74d7227248643d50daf8465392d863d1ef490e8b1346a56115549dcdfa28b066a350e4cc8afaabbcf4f33832751ac185eb14248955073c53f2b7d2af0c62
|
7
|
+
data.tar.gz: d28804c3678c07474bcc2e4a792c73b6e3f5602343e6115df22756e7d686860b4811da38d3e89dbc5f43d9486448124ff3555383d1edcf504509abd0cd513b8c
|
@@ -9,6 +9,10 @@ class AssetFieldType < FieldType
|
|
9
9
|
validate :asset_presence, if: :validate_presence?
|
10
10
|
validate :asset_errors
|
11
11
|
|
12
|
+
def elasticsearch_mapping
|
13
|
+
{ name: mapping_field_name, type: :string, analyzer: :keyword }
|
14
|
+
end
|
15
|
+
|
12
16
|
def data=(data_hash)
|
13
17
|
assign data_hash['asset'] if data_hash['asset']
|
14
18
|
@asset = attacher.get
|
@@ -32,10 +36,6 @@ class AssetFieldType < FieldType
|
|
32
36
|
json
|
33
37
|
end
|
34
38
|
|
35
|
-
def mapping
|
36
|
-
{ name: mapping_field_name, type: :string, analyzer: :keyword }
|
37
|
-
end
|
38
|
-
|
39
39
|
private
|
40
40
|
|
41
41
|
def image?
|
@@ -4,9 +4,13 @@ class AuthorFieldType < FieldType
|
|
4
4
|
|
5
5
|
validates :author_name, presence: true, if: :validate_presence?
|
6
6
|
|
7
|
+
def elasticsearch_mapping
|
8
|
+
{ name: mapping_field_name, type: :string, analyzer: :keyword }
|
9
|
+
end
|
10
|
+
|
7
11
|
def data=(data_hash)
|
8
|
-
data_hash[:author_name] = data_hash[:default_author_name] if data_hash
|
9
|
-
@author_name = data_hash
|
12
|
+
data_hash[:author_name] = data_hash[:default_author_name] if data_hash['author_name'].blank?
|
13
|
+
@author_name = data_hash['author_name']
|
10
14
|
end
|
11
15
|
|
12
16
|
def field_item_as_indexed_json_for_field_type(field_item, options = {})
|
@@ -15,10 +19,6 @@ class AuthorFieldType < FieldType
|
|
15
19
|
json
|
16
20
|
end
|
17
21
|
|
18
|
-
def mapping
|
19
|
-
{ name: mapping_field_name, type: :string, analyzer: :snowball }
|
20
|
-
end
|
21
|
-
|
22
22
|
private
|
23
23
|
|
24
24
|
def mapping_field_name
|
@@ -1,8 +1,12 @@
|
|
1
1
|
class BooleanFieldType < FieldType
|
2
2
|
attr_accessor :value
|
3
3
|
|
4
|
+
def elasticsearch_mapping
|
5
|
+
{ name: mapping_field_name, type: :boolean }
|
6
|
+
end
|
7
|
+
|
4
8
|
def data=(data_hash)
|
5
|
-
@value = data_hash
|
9
|
+
@value = data_hash['value']
|
6
10
|
end
|
7
11
|
|
8
12
|
def field_item_as_indexed_json_for_field_type(field_item, options = {})
|
@@ -11,10 +15,6 @@ class BooleanFieldType < FieldType
|
|
11
15
|
json
|
12
16
|
end
|
13
17
|
|
14
|
-
def mapping
|
15
|
-
{ name: mapping_field_name, type: :string, analyzer: :snowball }
|
16
|
-
end
|
17
|
-
|
18
18
|
private
|
19
19
|
|
20
20
|
def mapping_field_name
|
@@ -1,8 +1,12 @@
|
|
1
1
|
class ContentItemFieldType < FieldType
|
2
2
|
attr_accessor :content_item_id
|
3
3
|
|
4
|
+
def elasticsearch_mapping
|
5
|
+
{ name: mapping_field_name, type: :keyword, index: :not_analyzed }
|
6
|
+
end
|
7
|
+
|
4
8
|
def data=(data_hash)
|
5
|
-
@content_item_id = data_hash
|
9
|
+
@content_item_id = data_hash['content_item_id']
|
6
10
|
end
|
7
11
|
|
8
12
|
def field_item_as_indexed_json_for_field_type(field_item, options = {})
|
@@ -11,13 +15,9 @@ class ContentItemFieldType < FieldType
|
|
11
15
|
json
|
12
16
|
end
|
13
17
|
|
14
|
-
def mapping
|
15
|
-
{ name: mapping_field_name, type: :string, analyzer: :snowball }
|
16
|
-
end
|
17
|
-
|
18
18
|
private
|
19
19
|
|
20
20
|
def mapping_field_name
|
21
|
-
"#{field_name.parameterize(separator: '_')}
|
21
|
+
"#{field_name.parameterize(separator: '_')}_content_item_id"
|
22
22
|
end
|
23
23
|
end
|
@@ -4,6 +4,10 @@ class DateTimeFieldType < FieldType
|
|
4
4
|
validates :timestamp, presence: true, if: :validate_presence?
|
5
5
|
validate :timestamp_is_valid?, if: :validate_presence?
|
6
6
|
|
7
|
+
def elasticsearch_mapping
|
8
|
+
{ name: mapping_field_name, type: :string, analyzer: :snowball }
|
9
|
+
end
|
10
|
+
|
7
11
|
def data=(data_hash)
|
8
12
|
@timestamp = data_hash.deep_symbolize_keys[:timestamp]
|
9
13
|
end
|
@@ -14,10 +18,6 @@ class DateTimeFieldType < FieldType
|
|
14
18
|
json
|
15
19
|
end
|
16
20
|
|
17
|
-
def mapping
|
18
|
-
{name: mapping_field_name, type: :string, analyzer: :snowball}
|
19
|
-
end
|
20
|
-
|
21
21
|
private
|
22
22
|
|
23
23
|
def mapping_field_name
|
@@ -6,8 +6,12 @@ class FloatFieldType < FieldType
|
|
6
6
|
validate :less_than, if: Proc.new { |float| validate_key(:max) }
|
7
7
|
validate :greater_than, if: Proc.new { |float| validate_key(:min) }
|
8
8
|
|
9
|
+
def elasticsearch_mapping
|
10
|
+
{ name: mapping_field_name, type: :float }
|
11
|
+
end
|
12
|
+
|
9
13
|
def data=(data_hash)
|
10
|
-
@float = data_hash
|
14
|
+
@float = data_hash['float']
|
11
15
|
end
|
12
16
|
|
13
17
|
def field_item_as_indexed_json_for_field_type(field_item, options = {})
|
@@ -16,10 +20,6 @@ class FloatFieldType < FieldType
|
|
16
20
|
json
|
17
21
|
end
|
18
22
|
|
19
|
-
def mapping
|
20
|
-
{name: mapping_field_name, type: :float}
|
21
|
-
end
|
22
|
-
|
23
23
|
private
|
24
24
|
|
25
25
|
def mapping_field_name
|
@@ -31,10 +31,10 @@ class FloatFieldType < FieldType
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def less_than
|
34
|
-
|
34
|
+
errors.add(:float, "must be less_than #{validations[:max]}") if :float <= validations[:max]
|
35
35
|
end
|
36
36
|
|
37
37
|
def greater_than
|
38
|
-
|
38
|
+
errors.add(:float, "must be greater_than #{validations[:min]}") if :float >= validations[:min]
|
39
39
|
end
|
40
40
|
end
|
@@ -4,10 +4,14 @@ class IntegerFieldType < FieldType
|
|
4
4
|
validates :integer, presence: true, if: Proc.new { |int| validate_key(:presence) }
|
5
5
|
validates_numericality_of :integer, unless: "integer.nil?"
|
6
6
|
validate :less_than, if: Proc.new { |int| validate_key(:max) }
|
7
|
-
validate :greater_than, if:
|
7
|
+
validate :greater_than, if: Proc.new { |int| validate_key(:min) }
|
8
|
+
|
9
|
+
def elasticsearch_mapping
|
10
|
+
{ name: mapping_field_name, type: :integer }
|
11
|
+
end
|
8
12
|
|
9
13
|
def data=(data_hash)
|
10
|
-
@integer = data_hash
|
14
|
+
@integer = data_hash['integer']
|
11
15
|
end
|
12
16
|
|
13
17
|
def field_item_as_indexed_json_for_field_type(field_item, options = {})
|
@@ -16,10 +20,6 @@ class IntegerFieldType < FieldType
|
|
16
20
|
json
|
17
21
|
end
|
18
22
|
|
19
|
-
def mapping
|
20
|
-
{name: mapping_field_name, type: :integer}
|
21
|
-
end
|
22
|
-
|
23
23
|
private
|
24
24
|
|
25
25
|
def mapping_field_name
|
@@ -31,10 +31,10 @@ class IntegerFieldType < FieldType
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def less_than
|
34
|
-
|
34
|
+
errors.add(:integer, "must be less_than #{validations[:max]}") if :integer <= validations[:max]
|
35
35
|
end
|
36
36
|
|
37
37
|
def greater_than
|
38
|
-
|
38
|
+
errors.add(:integer, "must be greater_than #{validations[:min]}") if :integer >= validations[:min]
|
39
39
|
end
|
40
40
|
end
|
@@ -3,28 +3,31 @@ class TagFieldType < FieldType
|
|
3
3
|
|
4
4
|
validates :tag_list, presence: true, if: :validate_presence?
|
5
5
|
|
6
|
+
def elasticsearch_mapping
|
7
|
+
{ name: mapping_field_name, analyzer: :keyword }
|
8
|
+
end
|
9
|
+
|
6
10
|
def data=(data_hash)
|
7
|
-
@tag_list = data_hash
|
8
|
-
@tag_list.nil? ? nil : (@tag_list = @tag_list.split(","))
|
11
|
+
@tag_list = tag_list_to_a data_hash['tag_list']
|
9
12
|
end
|
10
13
|
|
11
14
|
def field_item_as_indexed_json_for_field_type(field_item, options = {})
|
12
15
|
json = {}
|
13
|
-
json[mapping_field_name] = field_item.data['tag_list']
|
16
|
+
json[mapping_field_name] = tag_list_to_a field_item.data['tag_list']
|
14
17
|
json
|
15
18
|
end
|
16
19
|
|
17
|
-
def mapping
|
18
|
-
{name: mapping_field_name, type: :string, analyzer: :snowball}
|
19
|
-
end
|
20
|
-
|
21
20
|
private
|
22
21
|
|
23
22
|
def mapping_field_name
|
24
|
-
"#{field_name.parameterize(separator: '_')}
|
23
|
+
"#{field_name.parameterize(separator: '_')}_tags"
|
25
24
|
end
|
26
25
|
|
27
26
|
def validate_presence?
|
28
27
|
validations.key? :presence
|
29
28
|
end
|
29
|
+
|
30
|
+
def tag_list_to_a(string)
|
31
|
+
string&.split(',')&.map(&:strip)
|
32
|
+
end
|
30
33
|
end
|
@@ -1,4 +1,6 @@
|
|
1
1
|
class TextFieldType < FieldType
|
2
|
+
PRIMARY_DATA_KEY = 'text'.freeze
|
3
|
+
|
2
4
|
attr_accessor :text
|
3
5
|
jsonb_accessor :data, text: :string
|
4
6
|
|
@@ -6,20 +8,28 @@ class TextFieldType < FieldType
|
|
6
8
|
validate :text_length, if: :validate_length?
|
7
9
|
validate :text_unique, if: :validate_uniqueness?
|
8
10
|
|
11
|
+
def elasticsearch_mapping
|
12
|
+
{ name: mapping_field_name, type: :string, analyzer: :snowball }
|
13
|
+
end
|
14
|
+
|
15
|
+
def graphql_value
|
16
|
+
text
|
17
|
+
end
|
18
|
+
|
19
|
+
def graphql_type
|
20
|
+
types.String
|
21
|
+
end
|
22
|
+
|
9
23
|
def data=(data_hash)
|
10
|
-
@text = data_hash
|
24
|
+
@text = data_hash[PRIMARY_DATA_KEY]
|
11
25
|
end
|
12
26
|
|
13
27
|
def field_item_as_indexed_json_for_field_type(field_item, options = {})
|
14
28
|
json = {}
|
15
|
-
json[mapping_field_name] = field_item.data[
|
29
|
+
json[mapping_field_name] = field_item.data[PRIMARY_DATA_KEY]
|
16
30
|
json
|
17
31
|
end
|
18
32
|
|
19
|
-
def mapping
|
20
|
-
{name: mapping_field_name, type: :string, analyzer: :snowball}
|
21
|
-
end
|
22
|
-
|
23
33
|
private
|
24
34
|
|
25
35
|
def mapping_field_name
|
@@ -5,12 +5,16 @@ class TreeFieldType < FieldType
|
|
5
5
|
validate :minimum, if: :validate_minimum?
|
6
6
|
validate :maximum, if: :validate_maximum?
|
7
7
|
|
8
|
+
def elasticsearch_mapping
|
9
|
+
{ name: mapping_field_name, type: :string, analyzer: :snowball }
|
10
|
+
end
|
11
|
+
|
8
12
|
def data
|
9
13
|
@values
|
10
14
|
end
|
11
15
|
|
12
16
|
def data=(data_hash)
|
13
|
-
values = data_hash
|
17
|
+
values = data_hash['values']
|
14
18
|
|
15
19
|
if values.is_a?(Hash)
|
16
20
|
@values = { values: values.keys }
|
@@ -25,10 +29,6 @@ class TreeFieldType < FieldType
|
|
25
29
|
json
|
26
30
|
end
|
27
31
|
|
28
|
-
def mapping
|
29
|
-
{ name: mapping_field_name, type: :string, analyzer: :snowball }
|
30
|
-
end
|
31
|
-
|
32
32
|
private
|
33
33
|
|
34
34
|
def mapping_field_name
|
@@ -4,8 +4,12 @@ class UserFieldType < FieldType
|
|
4
4
|
validates :user_id, presence: true, if: :validate_presence?
|
5
5
|
validate :valid_user_id?
|
6
6
|
|
7
|
+
def elasticsearch_mapping
|
8
|
+
{ name: mapping_field_name, type: :keyword, index: :not_analyzed }
|
9
|
+
end
|
10
|
+
|
7
11
|
def data=(data_hash)
|
8
|
-
@user_id = data_hash
|
12
|
+
@user_id = data_hash['user_id']
|
9
13
|
end
|
10
14
|
|
11
15
|
def field_item_as_indexed_json_for_field_type(field_item, options = {})
|
@@ -14,14 +18,10 @@ class UserFieldType < FieldType
|
|
14
18
|
json
|
15
19
|
end
|
16
20
|
|
17
|
-
def mapping
|
18
|
-
{name: mapping_field_name, type: :string, analyzer: :snowball}
|
19
|
-
end
|
20
|
-
|
21
21
|
private
|
22
22
|
|
23
23
|
def mapping_field_name
|
24
|
-
"#{field_name.parameterize(separator: '_')}
|
24
|
+
"#{field_name.parameterize(separator: '_')}_user_id"
|
25
25
|
end
|
26
26
|
|
27
27
|
def valid_user_id?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cortex-plugins-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CareerBuilder Employer Site & Content Products
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|