msfl 0.0.1.pre.rc2 → 0.0.1.pre.rc3

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: daafbe97f5c20cfcd8c01f85f037d2ce541f79ea
4
- data.tar.gz: 5dc889069b814f410425cd899a195affb0d5033e
3
+ metadata.gz: b6c56cf3880a84eafff98a45f46931bf957e2f09
4
+ data.tar.gz: 23afd30b810244488d9307059faad6ddfae6ba48
5
5
  SHA512:
6
- metadata.gz: 82a657a00b0dfa31b645d4a23bf587768510dd03dbeaa659543e11570af810688e29dad84475c4632ef1dc0c7f9f1b2c3115af9f6579f764b9d99be54268c8e5
7
- data.tar.gz: be3361401722d576c5a9cb66dd1f4c4883f1d9abdf9328fe52f7dce1966deb09ffe7b16cebe4d21496847b23cf9642465c3f018196da031439c4726c1c63258d
6
+ metadata.gz: c3ac65b1be870a46fa7495c3510fb78290b93b9ff28ec49fe5fdd5860bd1c8a51a625df4ec067e0f30da9a93f90b3a6ae7e11bef6ef0b1aededbf53015e23771
7
+ data.tar.gz: a2c081a4776ab4f93eddeca6c219c4238c3cb3f0e60c383ce560172fd1ba556a4590b7eaed030f05831ca7b45561034190be91bebabb6b358acd8749c3827471
@@ -8,7 +8,9 @@ module MSFL
8
8
  # @param json [String] the string to parse
9
9
  # @return [Object] the Ruby encoded MSFL, which may be a Hash, MSFL::Types::Set, or any number of scalar types
10
10
  def self.parse(json)
11
- obj = ::JSON.parse(json)
11
+ json_to_parse = json
12
+ json_to_parse = '{}' if json_to_parse.nil? || json_to_parse == "" || json_to_parse == "null"
13
+ obj = ::JSON.parse(json_to_parse)
12
14
  obj = arrays_to_sets obj
13
15
  obj
14
16
  end
data/lib/msfl/sinatra.rb CHANGED
@@ -14,7 +14,7 @@ module MSFL
14
14
  # @return [Object] the Ruby-ified MSFL filter
15
15
  def parse_filter_from(params)
16
16
  filter = params[:filter]
17
- MSFL::Parsers::JSON.parse filter.to_json unless filter.nil?
17
+ MSFL::Parsers::JSON.parse filter.to_json
18
18
  end
19
19
 
20
20
  # Extracts the dataset name from the Sinatra params. It then returns a new instance of the specified
data/msfl.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'msfl'
3
- s.version = '0.0.1-rc2'
3
+ s.version = '0.0.1-rc3'
4
4
  s.date = '2015-03-05'
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."
@@ -9,6 +9,17 @@ describe "MSFL::Parsers::JSON" do
9
9
 
10
10
  let(:test_json) { '{"total_funding": 5000000}' }
11
11
 
12
+ context "when parsing an empty json string" do
13
+
14
+ let(:test_json) { '' }
15
+
16
+ let(:expected) { MSFL::Parsers::JSON.parse '{}' }
17
+
18
+ it "is parsed as an empty json hash" do
19
+ expect(mut).to eq expected
20
+ end
21
+ end
22
+
12
23
  context "when parsing a json hash" do
13
24
 
14
25
  it "is an equivalent Ruby Hash" do
@@ -2,6 +2,24 @@ shared_examples_for "an invocation of MSFL::Sinatra.validate" do
2
2
 
3
3
  let(:params) { { dataset: dataset, filter: filter } }
4
4
 
5
+ context "when params[:filter] is nil" do
6
+
7
+ let(:filter) { nil }
8
+
9
+ let(:dataset) { nil }
10
+
11
+ it { is_expected.to be true }
12
+ end
13
+
14
+ context "when params[:filter] is an empty hash" do
15
+
16
+ let(:filter) { {} }
17
+
18
+ let(:dataset) { nil }
19
+
20
+ it { is_expected.to be true }
21
+ end
22
+
5
23
  context "when params[:dataset] is :movies" do
6
24
 
7
25
  let(:dataset) { :movies }
@@ -69,13 +69,6 @@ describe "MSFL::Sinatra::Helpers" do
69
69
  end
70
70
  end
71
71
 
72
- context "when params[:filter] is nil" do
73
-
74
- it "raises an ArgumentError" do
75
- expect { mut }.to raise_error ArgumentError
76
- end
77
- end
78
-
79
72
  context "when params[:dataset] is a valid Dataset" do
80
73
 
81
74
  let(:dataset) { :cars }
@@ -40,6 +40,23 @@ describe "MSFL::Validators::Semantic" do
40
40
 
41
41
  end
42
42
 
43
+ describe "#validate" do
44
+
45
+ subject(:mut) { test_instance.validate hash, errors, options }
46
+
47
+ let(:test_instance) { MSFL::Validators::Semantic.new }
48
+
49
+ let(:hash) { {} }
50
+
51
+ let(:errors) { [] }
52
+
53
+ let(:options) { {} }
54
+
55
+ context "when the filter is empty" do
56
+ it { is_expected.to be true }
57
+ end
58
+ end
59
+
43
60
  describe "#validate_set" do
44
61
 
45
62
  subject(:mut) { test_instance.validate_set set, errors, options }
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: 0.0.1.pre.rc2
4
+ version: 0.0.1.pre.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Courtland Caldwell