Commit da7ed78
Changed files (2)
lib
scim
kit
v2
spec
scim
kit
lib/scim/kit/v2/parser.rb
@@ -26,14 +26,11 @@ module Scim
logical_expression |
(not_op >> lparen >> value_filter >> rparen)
end
- rule(:tmp) do
- attribute_expression | logical_expression
- end
# attrExp = (attrPath SP "pr") / (attrPath SP compareOp SP compValue)
rule(:attribute_expression) do
(attribute_path >> space >> presence) |
- (attribute_path >> space >> comparison_operator >> space >> quote >> comparison_value >> quote)
+ (attribute_path >> space >> comparison_operator >> space >> comparison_value)
end
# logExp = FILTER SP ("and" / "or") SP FILTER
@@ -43,7 +40,7 @@ module Scim
# compValue = false / null / true / number / string ; rules from JSON (RFC 7159)
rule(:comparison_value) do
- (falsey | null | truthy | number | string).repeat(1)
+ falsey | null | truthy | number | string
end
# compareOp = "eq" / "ne" / "co" / "sw" / "ew" / "gt" / "lt" / "ge" / "le"
@@ -103,13 +100,14 @@ module Scim
rule(:less_than) { str('lt') }
rule(:greater_than_equals) { str('ge') }
rule(:less_than_equals) { str('le') }
- rule(:string) { (alpha | single_quote | at | dot | hyphen | colon | digit).repeat(1) }
+ rule(:string) do
+ quote >> (str('\\') >> any | str('"').absent? >> any).repeat >> quote
+ end
rule(:lparen) { str('(') }
rule(:rparen) { str(')') }
rule(:lbracket) { str('[') >> space? }
rule(:rbracket) { str(']') >> space? }
rule(:digit) { match('\d') }
- rule(:at) { str('@') }
rule(:quote) { str('"') }
rule(:single_quote) { str("'") }
rule(:space) { match('\s') }
spec/scim/kit/v2/parser_spec.rb
@@ -47,9 +47,9 @@ RSpec.describe Scim::Kit::V2::Parser do
[
#'firstName eq "Tsuyoshi" and lastName eq "Garret"',
- #'type eq "work" and value co "@example.com"',
- 'firstName eq "Tsuyoshi"',
- 'firstName pr',
+ 'type eq "work" and value co "@example.com"',
+ #'firstName eq "Tsuyoshi"',
+ #'firstName pr',
].each do |x|
specify { expect(subject.value_filter).to parse(x) }
end
@@ -70,7 +70,7 @@ RSpec.describe Scim::Kit::V2::Parser do
specify { expect(subject.logical_expression).to parse(x) }
end
- ['false', 'null', 'true', '1', 'hello', 'urn:ietf:params:scim:schemas:extension:enterprise:2.0:User', 'Garrett'].each do |x|
+ ['false', 'null', 'true', '1', '"hello"', '"urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"', '"Garrett"'].each do |x|
specify { expect(subject.comparison_value).to parse(x) }
end
@@ -138,9 +138,9 @@ RSpec.describe Scim::Kit::V2::Parser do
end
[
- 'Tsuyoshi',
- 'hello@example.org',
- '2011-05-13T04:42:34Z'
+ '"Tsuyoshi"',
+ '"hello@example.org"',
+ '"2011-05-13T04:42:34Z"'
].each do |x|
specify { expect(subject.string).to parse(x) }
end