create_custom_attributes 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +12 -0
- data/Rakefile +35 -0
- data/lib/custom_attributes.rb +64 -0
- data/lib/custom_attributes/acts_as/acts_as_custom_field.rb +167 -0
- data/lib/custom_attributes/acts_as/acts_as_custom_value.rb +53 -0
- data/lib/custom_attributes/acts_as/acts_as_customizable.rb +216 -0
- data/lib/custom_attributes/api/custom_attributes_controller_helper.rb +32 -0
- data/lib/custom_attributes/concerns/searchable.rb +64 -0
- data/lib/custom_attributes/custom_attributes_api_helper.rb +6 -0
- data/lib/custom_attributes/custom_field_value.rb +54 -0
- data/lib/custom_attributes/field_type.rb +153 -0
- data/lib/custom_attributes/field_types/bool_field_type.rb +40 -0
- data/lib/custom_attributes/field_types/date_field_type.rb +28 -0
- data/lib/custom_attributes/field_types/float_field_type.rb +19 -0
- data/lib/custom_attributes/field_types/int_field_type.rb +19 -0
- data/lib/custom_attributes/field_types/list.rb +57 -0
- data/lib/custom_attributes/field_types/list_field_type.rb +36 -0
- data/lib/custom_attributes/field_types/numeric.rb +5 -0
- data/lib/custom_attributes/field_types/string_field_type.rb +5 -0
- data/lib/custom_attributes/field_types/text_field_type.rb +10 -0
- data/lib/custom_attributes/field_types/unbounded.rb +16 -0
- data/lib/custom_attributes/fluent_search_query.rb +168 -0
- data/lib/custom_attributes/search_query.rb +229 -0
- data/lib/custom_attributes/search_query_field.rb +48 -0
- data/lib/custom_attributes/version.rb +3 -0
- data/lib/tasks/custom_attributes_tasks.rake +4 -0
- data/lib/tasks/elasticsearch_tasks.rake +1 -0
- metadata +144 -0
@@ -0,0 +1,48 @@
|
|
1
|
+
module CustomAttributes
|
2
|
+
class SearchQueryField
|
3
|
+
attr_reader :query, :fuzziness, :operator
|
4
|
+
|
5
|
+
def initialize(field, defaults)
|
6
|
+
@defaults = defaults
|
7
|
+
@field = field
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_query_hash
|
11
|
+
query_hash = {}
|
12
|
+
|
13
|
+
return query_hash if query == '*'
|
14
|
+
|
15
|
+
query_hash = query_hash.merge({query: query}) unless query.nil?
|
16
|
+
query_hash = query_hash.merge({fuzziness: fuzziness}) unless fuzziness.nil? || fuzziness.zero?
|
17
|
+
query_hash = query_hash.merge({operator: operator}) unless operator.nil?
|
18
|
+
|
19
|
+
query_hash
|
20
|
+
end
|
21
|
+
|
22
|
+
def query
|
23
|
+
field_or_default(:query)
|
24
|
+
end
|
25
|
+
|
26
|
+
def fuzziness
|
27
|
+
field_or_default(:fuzziness)
|
28
|
+
end
|
29
|
+
|
30
|
+
def operator
|
31
|
+
field_or_default(:operator)
|
32
|
+
end
|
33
|
+
|
34
|
+
def field
|
35
|
+
@field ||= {}
|
36
|
+
end
|
37
|
+
|
38
|
+
def defaults
|
39
|
+
@defaults ||= { query: '*' }
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def field_or_default(attribute)
|
45
|
+
field[attribute].nil? ? defaults[attribute] : field[attribute]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'elasticsearch/rails/tasks/import'
|
metadata
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: create_custom_attributes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel Grützmacher
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-11-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.2.3
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.2.3
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: elasticsearch
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: elasticsearch-model
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: elasticsearch-rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sqlite3
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Adds capabilities to manage custom fields and values of various types
|
84
|
+
to database models. Also includes ElasticSearch integration.
|
85
|
+
email:
|
86
|
+
- dg@create.at
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- MIT-LICENSE
|
92
|
+
- README.md
|
93
|
+
- Rakefile
|
94
|
+
- lib/custom_attributes.rb
|
95
|
+
- lib/custom_attributes/acts_as/acts_as_custom_field.rb
|
96
|
+
- lib/custom_attributes/acts_as/acts_as_custom_value.rb
|
97
|
+
- lib/custom_attributes/acts_as/acts_as_customizable.rb
|
98
|
+
- lib/custom_attributes/api/custom_attributes_controller_helper.rb
|
99
|
+
- lib/custom_attributes/concerns/searchable.rb
|
100
|
+
- lib/custom_attributes/custom_attributes_api_helper.rb
|
101
|
+
- lib/custom_attributes/custom_field_value.rb
|
102
|
+
- lib/custom_attributes/field_type.rb
|
103
|
+
- lib/custom_attributes/field_types/bool_field_type.rb
|
104
|
+
- lib/custom_attributes/field_types/date_field_type.rb
|
105
|
+
- lib/custom_attributes/field_types/float_field_type.rb
|
106
|
+
- lib/custom_attributes/field_types/int_field_type.rb
|
107
|
+
- lib/custom_attributes/field_types/list.rb
|
108
|
+
- lib/custom_attributes/field_types/list_field_type.rb
|
109
|
+
- lib/custom_attributes/field_types/numeric.rb
|
110
|
+
- lib/custom_attributes/field_types/string_field_type.rb
|
111
|
+
- lib/custom_attributes/field_types/text_field_type.rb
|
112
|
+
- lib/custom_attributes/field_types/unbounded.rb
|
113
|
+
- lib/custom_attributes/fluent_search_query.rb
|
114
|
+
- lib/custom_attributes/search_query.rb
|
115
|
+
- lib/custom_attributes/search_query_field.rb
|
116
|
+
- lib/custom_attributes/version.rb
|
117
|
+
- lib/tasks/custom_attributes_tasks.rake
|
118
|
+
- lib/tasks/elasticsearch_tasks.rake
|
119
|
+
homepage: http://www.create.at
|
120
|
+
licenses:
|
121
|
+
- MIT
|
122
|
+
metadata: {}
|
123
|
+
post_install_message:
|
124
|
+
rdoc_options: []
|
125
|
+
require_paths:
|
126
|
+
- lib
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
requirements: []
|
138
|
+
rubyforge_project:
|
139
|
+
rubygems_version: 2.6.14
|
140
|
+
signing_key:
|
141
|
+
specification_version: 4
|
142
|
+
summary: Manage and Search Custom Attributes, Fields and Value for any ActiveRecord
|
143
|
+
Model.
|
144
|
+
test_files: []
|