CloudSesame 0.7.10 → 0.7.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/cloud_sesame.gemspec +1 -1
- data/coverage/.last_run.json +1 -1
- data/coverage/.resultset.json +407 -390
- data/lib/cloud_sesame/query/ast/abstract/value.rb +5 -0
- data/lib/cloud_sesame/query/ast/date_value.rb +14 -6
- data/lib/cloud_sesame/query/ast/range_value.rb +1 -1
- data/lib/cloud_sesame/query/ast/value.rb +5 -1
- metadata +1 -1
@@ -11,6 +11,7 @@ module CloudSesame
|
|
11
11
|
RANGE_FORMAT = Regexp.new(/\A(\[|{)(.*),(.*)(\}|\])\z/).freeze
|
12
12
|
DIGIT_FORMAT = Regexp.new(/\A\d+(.\d+)?\z/).freeze
|
13
13
|
DATETIME_FORMAT = Regexp.new(/\d+{4}-\d+{2}-\d+{2}T\d+{2}:\d+{2}:\d+{2}/).freeze
|
14
|
+
TIME_FORMAT = Regexp.new(/\d+{4}-\d+{2}-\d+{2} \d+{2}:\d+{2}:\d+{2}/).freeze
|
14
15
|
DATE_FORMAT = Regexp.new(/\d+{4}-\d+{2}-\d+{2}/).freeze
|
15
16
|
|
16
17
|
attr_reader :value, :changed, :compiled
|
@@ -42,6 +43,10 @@ module CloudSesame
|
|
42
43
|
value.is_a?(String) && DATETIME_FORMAT =~ value
|
43
44
|
end
|
44
45
|
|
46
|
+
def self.string_time?(value)
|
47
|
+
value.is_a?(String) && TIME_FORMAT =~ value
|
48
|
+
end
|
49
|
+
|
45
50
|
def self.string_date?(value)
|
46
51
|
value.is_a?(String) && DATE_FORMAT =~ value
|
47
52
|
end
|
@@ -5,15 +5,19 @@ module CloudSesame
|
|
5
5
|
|
6
6
|
COMPILE_FORMAT = '%FT%TZ'.freeze
|
7
7
|
DATETIME_FORMAT = '%FT%T'.freeze
|
8
|
+
TIME_FORMAT = '%F %T %z'.freeze
|
8
9
|
DATE_FORMAT = '%F'.freeze
|
9
10
|
|
10
11
|
def self.parse(value)
|
11
12
|
return value.parse self if value.kind_of?(RangeValue)
|
13
|
+
range?(value) || string_range?(value) ? RangeValue.new(value, self) : new(value)
|
14
|
+
end
|
12
15
|
|
13
|
-
|
14
|
-
string_datetime?(value) ?
|
15
|
-
|
16
|
-
|
16
|
+
def initialize(value, type = nil)
|
17
|
+
value = Value.string_datetime?(value) ? parse_datetime(value) :
|
18
|
+
Value.string_time?(value) ? parse_time(value) :
|
19
|
+
Value.string_date?(value) ? parse_date(value) : value
|
20
|
+
super(value, type)
|
17
21
|
end
|
18
22
|
|
19
23
|
def to_s
|
@@ -22,11 +26,15 @@ module CloudSesame
|
|
22
26
|
|
23
27
|
private
|
24
28
|
|
25
|
-
def
|
29
|
+
def parse_datetime(string)
|
26
30
|
DateTime.strptime(string, DATETIME_FORMAT)
|
27
31
|
end
|
28
32
|
|
29
|
-
def
|
33
|
+
def parse_time(string)
|
34
|
+
DateTime.strptime(string, TIME_FORMAT)
|
35
|
+
end
|
36
|
+
|
37
|
+
def parse_date(string)
|
30
38
|
Date.strptime(string, DATE_FORMAT)
|
31
39
|
end
|
32
40
|
|
@@ -86,7 +86,7 @@ module CloudSesame
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def build_from_string(string)
|
89
|
-
matches = RANGE_FORMAT.match(strip
|
89
|
+
matches = RANGE_FORMAT.match(string.strip).captures
|
90
90
|
matches[1,2] = matches[1,2].map { |i| i unless i.empty? }
|
91
91
|
initialize_value(*matches)
|
92
92
|
end
|
@@ -18,7 +18,7 @@ module CloudSesame
|
|
18
18
|
(
|
19
19
|
range_value?(value) ? RangeValue :
|
20
20
|
numeric_value?(value) ? NumericValue :
|
21
|
-
|
21
|
+
datetime_value?(value) ? DateValue : StringValue
|
22
22
|
).new(value, self)
|
23
23
|
end
|
24
24
|
|
@@ -30,6 +30,10 @@ module CloudSesame
|
|
30
30
|
numeric?(value) || string_numeric?(value)
|
31
31
|
end
|
32
32
|
|
33
|
+
def self.datetime_value?(value)
|
34
|
+
datetime?(value) || string_datetime?(value) || string_time?(value)
|
35
|
+
end
|
36
|
+
|
33
37
|
end
|
34
38
|
end
|
35
39
|
end
|