agnostic_backend 0.9.8 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +2 -0
- data/agnostic_backend.gemspec +2 -2
- data/lib/agnostic_backend/cloudsearch/index_field.rb +1 -0
- data/lib/agnostic_backend/cloudsearch/indexer.rb +2 -0
- data/lib/agnostic_backend/elasticsearch/index_field.rb +1 -0
- data/lib/agnostic_backend/elasticsearch/indexer.rb +2 -0
- data/lib/agnostic_backend/indexable/field_type.rb +1 -0
- data/lib/agnostic_backend/indexable/indexable.rb +1 -1
- data/lib/agnostic_backend/queryable/attribute.rb +4 -0
- data/lib/agnostic_backend/queryable/cloudsearch/visitor.rb +9 -1
- data/lib/agnostic_backend/queryable/criteria/binary.rb +3 -0
- data/lib/agnostic_backend/queryable/criteria_builder.rb +4 -0
- data/lib/agnostic_backend/queryable/elasticsearch/visitor.rb +1 -1
- data/lib/agnostic_backend/queryable/validator.rb +7 -2
- data/lib/agnostic_backend/queryable/value.rb +1 -0
- data/lib/agnostic_backend/queryable/visitor.rb +4 -0
- data/lib/agnostic_backend/utilities.rb +1 -1
- data/lib/agnostic_backend/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ed2f8294a4e610eb4603d376fb93a6e6d2e96e4
|
4
|
+
data.tar.gz: f6e47ceafa6f3777bbcddd2f019e514ebbd01330
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aad2c7bb9671be7eb720a4aabf1e067ed1ac51df44d7a86e4fee5ccfb75750891c878d6f184327a84337493b720f966a7b36cbe4ef746b4dd561c7118fabd005
|
7
|
+
data.tar.gz: 67837152d83201cc3c509826a00372123735885d72b7b17a441d61ad8544f2b45267f54215344a16acde1f1dfb7c8adc0f3f5ac37cae0c4b038d6e075af4c630
|
data/.rspec
CHANGED
data/agnostic_backend.gemspec
CHANGED
@@ -23,13 +23,13 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
spec.required_ruby_version = '>= 2.1.0' # for mandatory method keyword arguments
|
25
25
|
|
26
|
-
spec.add_runtime_dependency "activesupport"
|
26
|
+
spec.add_runtime_dependency "activesupport", "~>3"
|
27
27
|
spec.add_runtime_dependency "aws-sdk", "~> 2"
|
28
28
|
spec.add_runtime_dependency "faraday"
|
29
29
|
|
30
30
|
spec.add_development_dependency "bundler"
|
31
31
|
spec.add_development_dependency "rake", "~> 10"
|
32
|
-
spec.add_development_dependency "rspec", "~>
|
32
|
+
spec.add_development_dependency "rspec", "~> 3"
|
33
33
|
spec.add_development_dependency "simplecov"
|
34
34
|
spec.add_development_dependency "simplecov-html"
|
35
35
|
end
|
@@ -9,6 +9,7 @@ module AgnosticBackend
|
|
9
9
|
AgnosticBackend::Indexable::FieldType::STRING => "literal",
|
10
10
|
AgnosticBackend::Indexable::FieldType::STRING_ARRAY => "literal-array",
|
11
11
|
AgnosticBackend::Indexable::FieldType::DATE => "date",
|
12
|
+
AgnosticBackend::Indexable::FieldType::DATE_ARRAY=> "date-array",
|
12
13
|
AgnosticBackend::Indexable::FieldType::INTEGER => "int",
|
13
14
|
AgnosticBackend::Indexable::FieldType::DOUBLE => "double",
|
14
15
|
AgnosticBackend::Indexable::FieldType::BOOLEAN => "literal",
|
@@ -65,6 +65,8 @@ module AgnosticBackend
|
|
65
65
|
document.each do |k, v|
|
66
66
|
if v.is_a?(Time)
|
67
67
|
document[k] = v.utc.strftime("%Y-%m-%dT%H:%M:%SZ")
|
68
|
+
elsif v.is_a?(Array) && v.all?{|e| e.is_a?(Time)}
|
69
|
+
document[k] = v.map{|e| e.utc.strftime("%Y-%m-%dT%H:%M:%SZ")}
|
68
70
|
end
|
69
71
|
end
|
70
72
|
end
|
@@ -6,6 +6,7 @@ module AgnosticBackend
|
|
6
6
|
AgnosticBackend::Indexable::FieldType::STRING => "string",
|
7
7
|
AgnosticBackend::Indexable::FieldType::STRING_ARRAY => "string",
|
8
8
|
AgnosticBackend::Indexable::FieldType::DATE => "date",
|
9
|
+
AgnosticBackend::Indexable::FieldType::DATE_ARRAY => "date",
|
9
10
|
AgnosticBackend::Indexable::FieldType::INTEGER => "integer",
|
10
11
|
AgnosticBackend::Indexable::FieldType::DOUBLE => "double",
|
11
12
|
AgnosticBackend::Indexable::FieldType::BOOLEAN => "boolean",
|
@@ -45,6 +45,8 @@ module AgnosticBackend
|
|
45
45
|
document.each do |k, v|
|
46
46
|
if v.is_a?(Time)
|
47
47
|
document[k] = v.utc.strftime("%Y-%m-%dT%H:%M:%SZ")
|
48
|
+
elsif v.is_a?(Array) && v.all?{|e| e.is_a?(Time)}
|
49
|
+
document[k] = v.map{|e| e.utc.strftime("%Y-%m-%dT%H:%M:%SZ")}
|
48
50
|
end
|
49
51
|
end
|
50
52
|
end
|
@@ -11,7 +11,7 @@ module AgnosticBackend
|
|
11
11
|
|
12
12
|
def self.included(base)
|
13
13
|
@includers ||= []
|
14
|
-
@includers << base
|
14
|
+
@includers << base if @includers.none?{|klass| klass.name == base.name}
|
15
15
|
base.send :include, InstanceMethods
|
16
16
|
base.send :extend, ClassMethods
|
17
17
|
end
|
@@ -53,6 +53,14 @@ module AgnosticBackend
|
|
53
53
|
"(prefix field=#{visit(subject.attribute)} #{visit(subject.value)})"
|
54
54
|
end
|
55
55
|
|
56
|
+
def visit_criteria_free_text(subject)
|
57
|
+
if subject.attribute.any?
|
58
|
+
"(and #{visit(subject.value)})"
|
59
|
+
else
|
60
|
+
"(and #{visit(subject.attribute)}: #{visit(subject.value)})"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
56
64
|
def visit_operations_not(subject)
|
57
65
|
"(not #{visit(subject.operand)})"
|
58
66
|
end
|
@@ -109,7 +117,7 @@ module AgnosticBackend
|
|
109
117
|
case subject.type
|
110
118
|
when :integer
|
111
119
|
subject.value
|
112
|
-
when :date
|
120
|
+
when :date,:date_array
|
113
121
|
"'#{subject.value.utc.strftime("%Y-%m-%dT%H:%M:%SZ")}'"
|
114
122
|
when :double
|
115
123
|
subject.value
|
@@ -56,6 +56,10 @@ module AgnosticBackend
|
|
56
56
|
Criteria::Starts.new(attribute: attribute, value: value, context: context)
|
57
57
|
end
|
58
58
|
|
59
|
+
def free_text(attribute, value)
|
60
|
+
Criteria::FreeText.new(attribute: attribute, value: value, context: context)
|
61
|
+
end
|
62
|
+
|
59
63
|
def asc(attribute)
|
60
64
|
Operations::Ascending.new(attribute: attribute, context: context)
|
61
65
|
end
|
@@ -79,6 +79,11 @@ module AgnosticBackend
|
|
79
79
|
visit(subject.right_value)
|
80
80
|
end
|
81
81
|
|
82
|
+
def visit_criteria_free_text(subject)
|
83
|
+
visit(subject.attribute)
|
84
|
+
visit(subject.value)
|
85
|
+
end
|
86
|
+
|
82
87
|
def visit_operations_not(subject)
|
83
88
|
visit(subject.operand)
|
84
89
|
end
|
@@ -124,7 +129,7 @@ module AgnosticBackend
|
|
124
129
|
end
|
125
130
|
|
126
131
|
def visit_attribute(subject)
|
127
|
-
if value_for_key(subject.context.index.schema, subject.name).nil?
|
132
|
+
if value_for_key(subject.context.index.schema, subject.name).nil? && !subject.any?
|
128
133
|
subject.context.query.errors[subject.class.name] << attribute_error(subject)
|
129
134
|
@valid = false
|
130
135
|
end
|
@@ -147,7 +152,7 @@ module AgnosticBackend
|
|
147
152
|
subject.context.query.errors[subject.class.name] << value_error(subject)
|
148
153
|
@valid = false
|
149
154
|
end
|
150
|
-
when :date
|
155
|
+
when :date,:date_array
|
151
156
|
unless subject.value.is_a?(Time)
|
152
157
|
subject.context.query.errors[subject.class.name] << value_error(subject)
|
153
158
|
@valid = false
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: agnostic_backend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Iasonas Gavriilidis
|
@@ -10,22 +10,22 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-09-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- - "
|
19
|
+
- - "~>"
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
21
|
+
version: '3'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- - "
|
26
|
+
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: '
|
28
|
+
version: '3'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: aws-sdk
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -88,14 +88,14 @@ dependencies:
|
|
88
88
|
requirements:
|
89
89
|
- - "~>"
|
90
90
|
- !ruby/object:Gem::Version
|
91
|
-
version: '
|
91
|
+
version: '3'
|
92
92
|
type: :development
|
93
93
|
prerelease: false
|
94
94
|
version_requirements: !ruby/object:Gem::Requirement
|
95
95
|
requirements:
|
96
96
|
- - "~>"
|
97
97
|
- !ruby/object:Gem::Version
|
98
|
-
version: '
|
98
|
+
version: '3'
|
99
99
|
- !ruby/object:Gem::Dependency
|
100
100
|
name: simplecov
|
101
101
|
requirement: !ruby/object:Gem::Requirement
|