msfl 1.2.1.dev1 → 1.2.1.dev2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/msfl/converters/operator.rb +4 -0
- data/lib/msfl/validators/definitions/hash_key.rb +9 -4
- data/msfl.gemspec +1 -1
- data/spec/msfl/converters/operator_spec.rb +17 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad99df360e8e32175605e12ccc3abf9fc47700fd
|
4
|
+
data.tar.gz: b06896540e73eb488a6ee6dc4abb723f50388923
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1b504c5cb7780c17a59cccdbd5b519705bf97e96e707b30dde921015761933d5ffffe4b9c76bbee63d0429adaa3591a8085e62b9c5fefdd5b0f827bea1286e3
|
7
|
+
data.tar.gz: 4960d6ffad371bff60692c149f06284448b0cabc183f8e4e5824e08e2556f2321520ba92a6ff44e1aa3ea9d25b4c54ff6609b62dfe519d497c29b26724b11624
|
@@ -102,6 +102,7 @@ module MSFL
|
|
102
102
|
#
|
103
103
|
# @param obj [Object] the Hash that is an implicit and
|
104
104
|
# @return [Hash] the resulting explicit hash
|
105
|
+
# @todo clean up the if elsif train
|
105
106
|
def implicit_and_to_explicit_recursively(obj, parent_key = nil)
|
106
107
|
if obj.is_a? Hash
|
107
108
|
first_key = obj.keys.first
|
@@ -112,6 +113,9 @@ module MSFL
|
|
112
113
|
elsif first_key == :partial
|
113
114
|
result = { partial: { given: implicit_and_to_explicit_recursively(obj[:partial][:given]),
|
114
115
|
filter: implicit_and_to_explicit_recursively(obj[:partial][:filter]) } }
|
116
|
+
elsif first_key == :foreign
|
117
|
+
result = { foreign: { dataset: implicit_and_to_explicit_recursively(obj[:foreign][:dataset]),
|
118
|
+
filter: implicit_and_to_explicit_recursively(obj[:foreign][:filter]) } }
|
115
119
|
else
|
116
120
|
# the first key is not an operator
|
117
121
|
# if there is only one key just assign the result of calling this method recursively on the value to the result for the key
|
@@ -13,7 +13,7 @@ module MSFL
|
|
13
13
|
|
14
14
|
# Operators still needing parsing: ellipsis2, tilda
|
15
15
|
def hash_key_operators
|
16
|
-
binary_operators.concat(logical_operators).concat(partial_operators)
|
16
|
+
binary_operators.concat(logical_operators).concat(partial_operators).concat(foreign_operators)
|
17
17
|
end
|
18
18
|
|
19
19
|
def binary_operators
|
@@ -30,9 +30,6 @@ module MSFL
|
|
30
30
|
:gt, # >
|
31
31
|
:gte, # >=
|
32
32
|
:neg, # logical negation
|
33
|
-
:foreign, # Defines a filter on a related item
|
34
|
-
:dataset, # A foreign dataset
|
35
|
-
:filter, # an explicit filter
|
36
33
|
]
|
37
34
|
end
|
38
35
|
|
@@ -44,6 +41,14 @@ module MSFL
|
|
44
41
|
]
|
45
42
|
end
|
46
43
|
|
44
|
+
def foreign_operators
|
45
|
+
[
|
46
|
+
:foreign, # Defines a filter on a related item
|
47
|
+
:dataset, # A foreign dataset
|
48
|
+
:filter, # an explicit filter
|
49
|
+
]
|
50
|
+
end
|
51
|
+
|
47
52
|
def logical_operators
|
48
53
|
[:and, :or]
|
49
54
|
end
|
data/msfl.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'msfl'
|
3
|
-
s.version = '1.2.1.
|
3
|
+
s.version = '1.2.1.dev2'
|
4
4
|
s.date = '2015-05-20'
|
5
5
|
s.summary = "MSFL in Ruby"
|
6
6
|
s.description = "Serializers, validators, and other tasty goodness for the Mattermark Semantic Filter Language in Ruby."
|
@@ -574,16 +574,28 @@ describe MSFL::Converters::Operator do
|
|
574
574
|
end
|
575
575
|
end
|
576
576
|
|
577
|
-
|
577
|
+
context "when running conversions on a msfl filter containing a specific type of filter" do
|
578
|
+
|
579
|
+
let(:converter) { described_class.new }
|
578
580
|
|
579
581
|
subject { converter.run_conversions msfl }
|
580
582
|
|
581
|
-
|
583
|
+
describe "running conversions on a normal msfl filter containing a partial" do
|
582
584
|
|
583
|
-
|
585
|
+
let(:msfl) { { partial: { given: { make: "Toyota" }, filter: { avg_age: 10 } } } }
|
584
586
|
|
585
|
-
|
586
|
-
|
587
|
+
it "is unchanged" do
|
588
|
+
expect(subject).to eq msfl
|
589
|
+
end
|
590
|
+
end
|
591
|
+
|
592
|
+
describe "running conversion on a normal msfl filter containing a foreign" do
|
593
|
+
|
594
|
+
let(:msfl) { { foreign: { dataset: :person, filter: { age: 10 } } } }
|
595
|
+
|
596
|
+
it "is unchanged" do
|
597
|
+
expect(subject).to eq msfl
|
598
|
+
end
|
587
599
|
end
|
588
600
|
end
|
589
601
|
end
|