msfl 1.2.1.dev1 → 1.2.1.dev2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06a5c190ca1f28269f35a382637758327bb4d601
4
- data.tar.gz: f0bfb4e6be47d3d69b6b4a568bf70247f30a9fcd
3
+ metadata.gz: ad99df360e8e32175605e12ccc3abf9fc47700fd
4
+ data.tar.gz: b06896540e73eb488a6ee6dc4abb723f50388923
5
5
  SHA512:
6
- metadata.gz: f55554e68871ad1faf1421d380881229f3ef9092c4d2d37776cb1873e523291cf0915a9a0998b592820738433710f1c8f50fe7a34fa066b597a11575bbc8a6c0
7
- data.tar.gz: b9c507c62f4dab0cd1312971b7bddc77632c94738e3b0428b36e79fd945d075274360c57bbd75087ca534f9321983ab870943a1b280fa2822173ea2481c5a3b9
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.dev1'
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
- describe "running conversions on a normal msfl filter containing a partial" do
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
- let(:converter) { described_class.new }
583
+ describe "running conversions on a normal msfl filter containing a partial" do
582
584
 
583
- let(:msfl) { { partial: { given: { make: "Toyota" }, filter: { avg_age: 10 } } } }
585
+ let(:msfl) { { partial: { given: { make: "Toyota" }, filter: { avg_age: 10 } } } }
584
586
 
585
- it "is unchanged" do
586
- expect(subject).to eq msfl
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: msfl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1.dev1
4
+ version: 1.2.1.dev2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Courtland Caldwell