mongoid_oslc 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -81,6 +81,18 @@ module Mongoid
81
81
  end
82
82
  end
83
83
 
84
+ class NilValue < GrammarNode
85
+ def to_mongo_query
86
+ nil
87
+ end
88
+ end
89
+
90
+ class EmptyValue < GrammarNode
91
+ def to_mongo_query
92
+ []
93
+ end
94
+ end
95
+
84
96
  class DecimalValue < GrammarNode
85
97
  def to_mongo_query
86
98
  text_value.to_f
@@ -20,6 +20,11 @@
20
20
  # string_esc ::= /* a string enclosed in double quotes, with certain characters escaped. See below. */
21
21
  # LANGTAG ::= /* see "SPARQL Query Language for RDF", http://www.w3.org/TR/rdf-sparql-query/#rLANGTAG */
22
22
 
23
+ # Extension
24
+ # literal_value ::= | nil_value | empty_value
25
+ # nil_value ::= "nil"
26
+ # empty_value ::= "empty"
27
+
23
28
  grammar Grammar
24
29
 
25
30
  rule decision
@@ -71,13 +76,21 @@ grammar Grammar
71
76
  end
72
77
 
73
78
  rule literal_value
74
- boolean / decimal / string_esc
79
+ boolean / decimal / string_esc / nil_value / empty_value
75
80
  end
76
81
 
77
82
  rule boolean
78
83
  'true' <Mongoid::Oslc::Grammar::BooleanValue> / 'false' <Mongoid::Oslc::Grammar::BooleanValue>
79
84
  end
80
85
 
86
+ rule nil_value
87
+ 'nil' <Mongoid::Oslc::Grammar::NilValue>
88
+ end
89
+
90
+ rule empty_value
91
+ 'empty' <Mongoid::Oslc::Grammar::EmptyValue>
92
+ end
93
+
81
94
  rule decimal
82
95
  [\+\-]? [\d\.]+ <Mongoid::Oslc::Grammar::DecimalValue>
83
96
  end
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module Oslc
3
- VERSION = '0.0.8'
3
+ VERSION = '0.0.9'
4
4
  end
5
5
  end
@@ -32,6 +32,14 @@ describe Mongoid::Oslc::Strategy do
32
32
  parse_query('dcterms:title!="First"').should eql({"title"=> {"$ne" => "First"}})
33
33
  end
34
34
 
35
+ it "should parse query with nil value" do
36
+ parse_query('dcterms:title=nil').should eql({"title"=> nil})
37
+ end
38
+
39
+ it "should parse query with empty value" do
40
+ parse_query('dcterms:title=empty').should eql({"title"=> []})
41
+ end
42
+
35
43
  it "should parse query with decimal value" do
36
44
  parse_query('dcterms:title=+5').should eql({"title"=> 5.0})
37
45
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_oslc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-24 00:00:00.000000000 Z
12
+ date: 2012-11-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -135,7 +135,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
135
135
  version: '0'
136
136
  segments:
137
137
  - 0
138
- hash: 3546982122950071674
138
+ hash: 2215901431613586552
139
139
  required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  none: false
141
141
  requirements:
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
144
  version: '0'
145
145
  segments:
146
146
  - 0
147
- hash: 3546982122950071674
147
+ hash: 2215901431613586552
148
148
  requirements: []
149
149
  rubyforge_project:
150
150
  rubygems_version: 1.8.24