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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a58464b8656e2798472a29b29e094aad2a3ad371
4
- data.tar.gz: b719bf7b58574861ea9237a32db5b788e1813a1c
3
+ metadata.gz: 8ed2f8294a4e610eb4603d376fb93a6e6d2e96e4
4
+ data.tar.gz: f6e47ceafa6f3777bbcddd2f019e514ebbd01330
5
5
  SHA512:
6
- metadata.gz: b4f4431dd6d69edd313476822b7a76cbf1f271969bb7c4a72ecc78f93143f7558c78243919598a9fbd821b1b608fb8334f5d1c2c472846bc32e5740d407c69a2
7
- data.tar.gz: 19ef97db6ecb648f1b4ca63d4902bd5c51f1e084601e7f7c9560385656a1e454fa803c7e16e88d791ed44ab2d4d44e56e2c3098f6ee5b17c0a29e27ff6e545a3
6
+ metadata.gz: aad2c7bb9671be7eb720a4aabf1e067ed1ac51df44d7a86e4fee5ccfb75750891c878d6f184327a84337493b720f966a7b36cbe4ef746b4dd561c7118fabd005
7
+ data.tar.gz: 67837152d83201cc3c509826a00372123735885d72b7b17a441d61ad8544f2b45267f54215344a16acde1f1dfb7c8adc0f3f5ac37cae0c4b038d6e075af4c630
data/.rspec CHANGED
@@ -1 +1,3 @@
1
1
  --color
2
+ --order rand
3
+ --format documentation
@@ -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", "~> 2"
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
@@ -8,6 +8,7 @@ module AgnosticBackend
8
8
  TEXT = :text
9
9
  TEXT_ARRAY = :text_array
10
10
  DATE = :date # datetime
11
+ DATE_ARRAY = :date_array # datetime
11
12
  BOOLEAN = :boolean
12
13
  STRUCT = :struct # a nested structure containing other values
13
14
 
@@ -11,7 +11,7 @@ module AgnosticBackend
11
11
 
12
12
  def self.included(base)
13
13
  @includers ||= []
14
- @includers << base unless @includers.include? 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
@@ -17,6 +17,10 @@ module AgnosticBackend
17
17
  def type
18
18
  value_for_key(context.index.schema, name).try(:type)
19
19
  end
20
+
21
+ def any?
22
+ @name == '*'
23
+ end
20
24
  end
21
25
  end
22
26
  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
@@ -42,6 +42,9 @@ module AgnosticBackend
42
42
 
43
43
  class Starts < Relational;
44
44
  end
45
+
46
+ class FreeText < Relational;
47
+ end
45
48
  end
46
49
  end
47
50
  end
@@ -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
@@ -177,7 +177,7 @@ module AgnosticBackend
177
177
  case subject.type
178
178
  when :integer
179
179
  subject.value
180
- when :date
180
+ when :date,:date_array
181
181
  "#{subject.value.utc.strftime("%Y-%m-%dT%H:%M:%SZ")}"
182
182
  when :double
183
183
  subject.value
@@ -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
@@ -19,6 +19,7 @@ module AgnosticBackend
19
19
  end
20
20
 
21
21
  def type
22
+ return :text if associated_attribute.try(:any?)
22
23
  associated_attribute.type if associated_attribute.present?
23
24
  end
24
25
  end
@@ -56,6 +56,10 @@ module AgnosticBackend
56
56
  raise NotImplementedError
57
57
  end
58
58
 
59
+ def visit_criteria_free_text(subject)
60
+ raise NotImplementedError
61
+ end
62
+
59
63
  def visit_operations_not(subject)
60
64
  raise NotImplementedError
61
65
  end
@@ -142,7 +142,7 @@ module AgnosticBackend
142
142
  else
143
143
  value
144
144
  end
145
- when :date
145
+ when :date, :date_array
146
146
  if value.is_a?(Time)
147
147
  value
148
148
  elsif is_date?(value)
@@ -1,3 +1,3 @@
1
1
  module AgnosticBackend
2
- VERSION = "0.9.8"
2
+ VERSION = "0.9.9"
3
3
  end
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.8
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-06-22 00:00:00.000000000 Z
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: '0'
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: '0'
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: '2'
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: '2'
98
+ version: '3'
99
99
  - !ruby/object:Gem::Dependency
100
100
  name: simplecov
101
101
  requirement: !ruby/object:Gem::Requirement