Improvement
and revert back to support draft 04 (but using custom variable, allow the user to follow draft 05 spec)
This commit is contained in:
@@ -0,0 +1,52 @@
|
|||||||
|
note
|
||||||
|
description: "[
|
||||||
|
Summary description for {URI_TEMPLATE_CONSTANTS}.
|
||||||
|
|
||||||
|
see http://tools.ietf.org/html/draft-gregorio-uritemplate-05
|
||||||
|
]"
|
||||||
|
author: ""
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
class
|
||||||
|
URI_TEMPLATE_CONSTANTS
|
||||||
|
|
||||||
|
feature -- Operator
|
||||||
|
|
||||||
|
Reserved_operator: CHARACTER = '+'
|
||||||
|
|
||||||
|
Form_style_query_operator: CHARACTER = '?'
|
||||||
|
|
||||||
|
Path_style_parameters_operator: CHARACTER = ';'
|
||||||
|
|
||||||
|
Path_segment_operator: CHARACTER = '/'
|
||||||
|
|
||||||
|
Label_operator: CHARACTER = '.'
|
||||||
|
|
||||||
|
feature -- Separator
|
||||||
|
|
||||||
|
Default_delimiter: CHARACTER = '|' --| Draft 05
|
||||||
|
|
||||||
|
feature -- Explode
|
||||||
|
|
||||||
|
Explode_plus: CHARACTER = '+'
|
||||||
|
|
||||||
|
Explode_star: CHARACTER = '*'
|
||||||
|
|
||||||
|
feature -- Modified
|
||||||
|
|
||||||
|
Modifier_substring: CHARACTER = ':'
|
||||||
|
|
||||||
|
Modifier_remainder: CHARACTER = '^'
|
||||||
|
|
||||||
|
note
|
||||||
|
copyright: "2011-2011, Eiffel Software and others"
|
||||||
|
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||||
|
source: "[
|
||||||
|
Eiffel Software
|
||||||
|
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||||
|
Telephone 805-685-1006, Fax 805-685-6869
|
||||||
|
Website http://www.eiffel.com
|
||||||
|
Customer support http://support.eiffel.com
|
||||||
|
]"
|
||||||
|
end
|
||||||
@@ -2,7 +2,9 @@ note
|
|||||||
description: "[
|
description: "[
|
||||||
Summary description for {URI_TEMPLATE}.
|
Summary description for {URI_TEMPLATE}.
|
||||||
|
|
||||||
See http://tools.ietf.org/html/draft-gregorio-uritemplate-05
|
See http://tools.ietf.org/html/draft-gregorio-uritemplate-04
|
||||||
|
|
||||||
|
note for draft 05, check {URI_TEMPLATE_CONSTANTS}.Default_delimiter
|
||||||
|
|
||||||
]"
|
]"
|
||||||
legal: "See notice at end of class."
|
legal: "See notice at end of class."
|
||||||
@@ -52,17 +54,18 @@ feature -- Access
|
|||||||
feature -- Structures
|
feature -- Structures
|
||||||
|
|
||||||
variable_names: LIST [STRING]
|
variable_names: LIST [STRING]
|
||||||
|
-- All variable names
|
||||||
do
|
do
|
||||||
analyze (Void)
|
analyze
|
||||||
if attached expansion_parts as l_x_parts then
|
if attached expressions as l_expressions then
|
||||||
create {ARRAYED_LIST [STRING]} Result.make (l_x_parts.count)
|
create {ARRAYED_LIST [STRING]} Result.make (l_expressions.count)
|
||||||
from
|
from
|
||||||
l_x_parts.start
|
l_expressions.start
|
||||||
until
|
until
|
||||||
l_x_parts.after
|
l_expressions.after
|
||||||
loop
|
loop
|
||||||
Result.append (l_x_parts.item.variable_names)
|
Result.append (l_expressions.item.variable_names)
|
||||||
l_x_parts.forth
|
l_expressions.forth
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
create {ARRAYED_LIST [STRING]} Result.make (0)
|
create {ARRAYED_LIST [STRING]} Result.make (0)
|
||||||
@@ -70,19 +73,20 @@ feature -- Structures
|
|||||||
end
|
end
|
||||||
|
|
||||||
path_variable_names: LIST [STRING]
|
path_variable_names: LIST [STRING]
|
||||||
|
-- All variable names part of the path
|
||||||
do
|
do
|
||||||
analyze (Void)
|
analyze
|
||||||
if attached expansion_parts as l_x_parts then
|
if attached expressions as l_expressions then
|
||||||
create {ARRAYED_LIST [STRING]} Result.make (l_x_parts.count)
|
create {ARRAYED_LIST [STRING]} Result.make (l_expressions.count)
|
||||||
from
|
from
|
||||||
l_x_parts.start
|
l_expressions.start
|
||||||
until
|
until
|
||||||
l_x_parts.after
|
l_expressions.after
|
||||||
loop
|
loop
|
||||||
if not l_x_parts.item.is_query then
|
if not l_expressions.item.is_query then
|
||||||
Result.append (l_x_parts.item.variable_names)
|
Result.append (l_expressions.item.variable_names)
|
||||||
end
|
end
|
||||||
l_x_parts.forth
|
l_expressions.forth
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
create {ARRAYED_LIST [STRING]} Result.make (0)
|
create {ARRAYED_LIST [STRING]} Result.make (0)
|
||||||
@@ -90,19 +94,20 @@ feature -- Structures
|
|||||||
end
|
end
|
||||||
|
|
||||||
query_variable_names: LIST [STRING]
|
query_variable_names: LIST [STRING]
|
||||||
|
-- All variable names part of the query (i.e after '?')
|
||||||
do
|
do
|
||||||
analyze (Void)
|
analyze
|
||||||
if attached expansion_parts as l_x_parts then
|
if attached expressions as l_expressions then
|
||||||
create {ARRAYED_LIST [STRING]} Result.make (l_x_parts.count)
|
create {ARRAYED_LIST [STRING]} Result.make (l_expressions.count)
|
||||||
from
|
from
|
||||||
l_x_parts.start
|
l_expressions.start
|
||||||
until
|
until
|
||||||
l_x_parts.after
|
l_expressions.after
|
||||||
loop
|
loop
|
||||||
if l_x_parts.item.is_query then
|
if l_expressions.item.is_query then
|
||||||
Result.append (l_x_parts.item.variable_names)
|
Result.append (l_expressions.item.variable_names)
|
||||||
end
|
end
|
||||||
l_x_parts.forth
|
l_expressions.forth
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
create {ARRAYED_LIST [STRING]} Result.make (0)
|
create {ARRAYED_LIST [STRING]} Result.make (0)
|
||||||
@@ -111,33 +116,33 @@ feature -- Structures
|
|||||||
|
|
||||||
feature -- Builder
|
feature -- Builder
|
||||||
|
|
||||||
string (a_ht: HASH_TABLE [detachable ANY, STRING]): STRING
|
expanded_string (a_ht: HASH_TABLE [detachable ANY, STRING]): STRING
|
||||||
-- Expanded template using variable from `a_ht'
|
-- Expanded template using variable from `a_ht'
|
||||||
local
|
local
|
||||||
tpl: like template
|
tpl: like template
|
||||||
exp: URI_TEMPLATE_EXPRESSION
|
exp: URI_TEMPLATE_EXPRESSION
|
||||||
p,q: INTEGER
|
p,q: INTEGER
|
||||||
do
|
do
|
||||||
analyze (Void)
|
analyze
|
||||||
tpl := template
|
tpl := template
|
||||||
if attached expansion_parts as l_x_parts then
|
if attached expressions as l_expressions then
|
||||||
create Result.make (tpl.count)
|
create Result.make (tpl.count)
|
||||||
from
|
from
|
||||||
l_x_parts.start
|
l_expressions.start
|
||||||
p := 1
|
p := 1
|
||||||
until
|
until
|
||||||
l_x_parts.after
|
l_expressions.after
|
||||||
loop
|
loop
|
||||||
q := l_x_parts.item.position
|
q := l_expressions.item.position
|
||||||
--| Added inter variable text
|
--| Added inter variable text
|
||||||
Result.append (tpl.substring (p, q - 1))
|
Result.append (tpl.substring (p, q - 1))
|
||||||
--| Expand variables ...
|
--| Expand variables ...
|
||||||
exp := l_x_parts.item
|
exp := l_expressions.item
|
||||||
exp.append_to_string (a_ht, Result)
|
exp.append_expanded_to_string (a_ht, Result)
|
||||||
|
|
||||||
p := q + l_x_parts.item.expression.count + 2
|
p := q + l_expressions.item.expression.count + 2
|
||||||
|
|
||||||
l_x_parts.forth
|
l_expressions.forth
|
||||||
end
|
end
|
||||||
Result.append (tpl.substring (p, tpl.count))
|
Result.append (tpl.substring (p, tpl.count))
|
||||||
else
|
else
|
||||||
@@ -160,33 +165,37 @@ feature -- Match
|
|||||||
l_uri_count: INTEGER
|
l_uri_count: INTEGER
|
||||||
do
|
do
|
||||||
--| Extract expansion parts "\\{([^\\}]*)\\}"
|
--| Extract expansion parts "\\{([^\\}]*)\\}"
|
||||||
analyze (Void)
|
analyze
|
||||||
if attached expansion_parts as l_x_parts then
|
if attached expressions as l_expressions then
|
||||||
create l_path_vars.make (l_x_parts.count)
|
create l_path_vars.make (l_expressions.count)
|
||||||
create l_query_vars.make (l_x_parts.count)
|
create l_query_vars.make (l_expressions.count)
|
||||||
l_vars := l_path_vars
|
l_vars := l_path_vars
|
||||||
b := True
|
b := True
|
||||||
l_uri_count := a_uri.count
|
l_uri_count := a_uri.count
|
||||||
tpl := template
|
tpl := template
|
||||||
if l_x_parts.is_empty then
|
if l_expressions.is_empty then
|
||||||
b := a_uri.substring (1, tpl.count).same_string (tpl)
|
b := a_uri.substring (1, tpl.count).same_string (tpl)
|
||||||
else
|
else
|
||||||
from
|
from
|
||||||
l_x_parts.start
|
l_expressions.start
|
||||||
p := 1
|
p := 1
|
||||||
l_offset := 0
|
l_offset := 0
|
||||||
until
|
until
|
||||||
l_x_parts.after or not b
|
l_expressions.after or not b
|
||||||
loop
|
loop
|
||||||
exp := l_x_parts.item
|
exp := l_expressions.item
|
||||||
vn := exp.expression
|
vn := exp.expression
|
||||||
q := exp.position
|
q := exp.position
|
||||||
--| Check text between vars
|
--| Check text between vars
|
||||||
|
--| FIXME jfiat [2011/07/22] : check this ...
|
||||||
|
--| There should be at least one literal between two expression
|
||||||
|
--| {var}{foobar} is ambigous for matching ...
|
||||||
|
b := False
|
||||||
if q > p then
|
if q > p then
|
||||||
t := tpl.substring (p, q - 1)
|
t := tpl.substring (p, q - 1)
|
||||||
s := a_uri.substring (p + l_offset, q + l_offset - 1)
|
s := a_uri.substring (p + l_offset, q + l_offset - 1)
|
||||||
b := s.same_string (t)
|
b := s.same_string (t)
|
||||||
p := q + vn.count + 2
|
p := exp.end_position
|
||||||
end
|
end
|
||||||
--| Check related variable
|
--| Check related variable
|
||||||
if b and then not vn.is_empty then
|
if b and then not vn.is_empty then
|
||||||
@@ -210,7 +219,7 @@ feature -- Match
|
|||||||
b := exp.is_query --| query are optional
|
b := exp.is_query --| query are optional
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
l_x_parts.forth
|
l_expressions.forth
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if b then
|
if b then
|
||||||
@@ -221,14 +230,14 @@ feature -- Match
|
|||||||
|
|
||||||
feature {NONE} -- Internal Access
|
feature {NONE} -- Internal Access
|
||||||
|
|
||||||
expansion_parts: detachable LIST [URI_TEMPLATE_EXPRESSION]
|
expressions: detachable LIST [URI_TEMPLATE_EXPRESSION]
|
||||||
-- Expansion parts
|
-- Expansion parts
|
||||||
|
|
||||||
feature {NONE} -- Implementation
|
feature {NONE} -- Implementation
|
||||||
|
|
||||||
analyze (a_handler: detachable URI_TEMPLATE_HANDLER)
|
analyze
|
||||||
local
|
local
|
||||||
l_x_parts: like expansion_parts
|
l_expressions: like expressions
|
||||||
c: CHARACTER
|
c: CHARACTER
|
||||||
i,p,n: INTEGER
|
i,p,n: INTEGER
|
||||||
tpl: like template
|
tpl: like template
|
||||||
@@ -237,12 +246,12 @@ feature {NONE} -- Implementation
|
|||||||
x: STRING
|
x: STRING
|
||||||
exp: URI_TEMPLATE_EXPRESSION
|
exp: URI_TEMPLATE_EXPRESSION
|
||||||
do
|
do
|
||||||
l_x_parts := expansion_parts
|
l_expressions := expressions
|
||||||
if l_x_parts = Void then
|
if l_expressions = Void then
|
||||||
tpl := template
|
tpl := template
|
||||||
|
|
||||||
--| Extract expansion parts "\\{([^\\}]*)\\}"
|
--| Extract expansion parts "\\{([^\\}]*)\\}"
|
||||||
create {ARRAYED_LIST [like expansion_parts.item]} l_x_parts.make (tpl.occurrences ('{'))
|
create {ARRAYED_LIST [like expressions.item]} l_expressions.make (tpl.occurrences ('{'))
|
||||||
from
|
from
|
||||||
i := 1
|
i := 1
|
||||||
n := tpl.count
|
n := tpl.count
|
||||||
@@ -254,7 +263,7 @@ feature {NONE} -- Implementation
|
|||||||
if in_x then
|
if in_x then
|
||||||
if c = '}' then
|
if c = '}' then
|
||||||
create exp.make (p, x.twin, in_query)
|
create exp.make (p, x.twin, in_query)
|
||||||
l_x_parts.force (exp)
|
l_expressions.force (exp)
|
||||||
x.wipe_out
|
x.wipe_out
|
||||||
in_x := False
|
in_x := False
|
||||||
else
|
else
|
||||||
@@ -276,7 +285,7 @@ feature {NONE} -- Implementation
|
|||||||
end
|
end
|
||||||
i := i + 1
|
i := i + 1
|
||||||
end
|
end
|
||||||
expansion_parts := l_x_parts
|
expressions := l_expressions
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -355,11 +364,6 @@ feature {NONE} -- Implementation
|
|||||||
Result := a_uri.substring (a_index, p)
|
Result := a_uri.substring (a_index, p)
|
||||||
end
|
end
|
||||||
|
|
||||||
url_encoder: URL_ENCODER
|
|
||||||
once
|
|
||||||
create Result
|
|
||||||
end
|
|
||||||
|
|
||||||
note
|
note
|
||||||
copyright: "2011-2011, Eiffel Software and others"
|
copyright: "2011-2011, Eiffel Software and others"
|
||||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||||
|
|||||||
52
library/protocol/uri_template/src/uri_template_constants.e
Normal file
52
library/protocol/uri_template/src/uri_template_constants.e
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
note
|
||||||
|
description: "[
|
||||||
|
Summary description for {URI_TEMPLATE_CONSTANTS}.
|
||||||
|
|
||||||
|
see http://tools.ietf.org/html/draft-gregorio-uritemplate-04
|
||||||
|
]"
|
||||||
|
author: ""
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
class
|
||||||
|
URI_TEMPLATE_CONSTANTS
|
||||||
|
|
||||||
|
feature -- Operator
|
||||||
|
|
||||||
|
Reserved_operator: CHARACTER = '+'
|
||||||
|
|
||||||
|
Form_style_query_operator: CHARACTER = '?'
|
||||||
|
|
||||||
|
Path_style_parameters_operator: CHARACTER = ';'
|
||||||
|
|
||||||
|
Path_segment_operator: CHARACTER = '/'
|
||||||
|
|
||||||
|
Label_operator: CHARACTER = '.'
|
||||||
|
|
||||||
|
feature -- Separator
|
||||||
|
|
||||||
|
Default_delimiter: CHARACTER = '=' --| Draft 0.4 , change to '|' for Draft 0.5
|
||||||
|
|
||||||
|
feature -- Explode
|
||||||
|
|
||||||
|
Explode_plus: CHARACTER = '+'
|
||||||
|
|
||||||
|
Explode_star: CHARACTER = '*'
|
||||||
|
|
||||||
|
feature -- Modified
|
||||||
|
|
||||||
|
Modifier_substring: CHARACTER = ':'
|
||||||
|
|
||||||
|
Modifier_remainder: CHARACTER = '^'
|
||||||
|
|
||||||
|
note
|
||||||
|
copyright: "2011-2011, Eiffel Software and others"
|
||||||
|
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||||
|
source: "[
|
||||||
|
Eiffel Software
|
||||||
|
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||||
|
Telephone 805-685-1006, Fax 805-685-6869
|
||||||
|
Website http://www.eiffel.com
|
||||||
|
Customer support http://support.eiffel.com
|
||||||
|
]"
|
||||||
|
end
|
||||||
@@ -8,8 +8,13 @@ class
|
|||||||
URI_TEMPLATE_EXPRESSION
|
URI_TEMPLATE_EXPRESSION
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
ANY
|
||||||
|
|
||||||
DEBUG_OUTPUT
|
DEBUG_OUTPUT
|
||||||
|
|
||||||
|
URI_TEMPLATE_CONSTANTS
|
||||||
|
export {NONE} all end
|
||||||
|
|
||||||
create
|
create
|
||||||
make
|
make
|
||||||
|
|
||||||
@@ -42,22 +47,27 @@ feature -- Processing
|
|||||||
op_prefix := '%U'
|
op_prefix := '%U'
|
||||||
op_delimiter := ','
|
op_delimiter := ','
|
||||||
inspect exp[1]
|
inspect exp[1]
|
||||||
when '+' then
|
when Reserved_operator then
|
||||||
|
--| '+'
|
||||||
reserved := True
|
reserved := True
|
||||||
operator := '+'
|
operator := '+'
|
||||||
when '.' then
|
when Label_operator then
|
||||||
|
--| '.'
|
||||||
operator := '.'
|
operator := '.'
|
||||||
op_prefix := '.'
|
op_prefix := '.'
|
||||||
op_delimiter := '.'
|
op_delimiter := '.'
|
||||||
when '/' then
|
when Path_segment_operator then
|
||||||
|
--| '/'
|
||||||
operator := '/'
|
operator := '/'
|
||||||
op_prefix := '/'
|
op_prefix := '/'
|
||||||
op_delimiter := '/'
|
op_delimiter := '/'
|
||||||
when ';' then
|
when Path_style_parameters_operator then
|
||||||
|
--| ';'
|
||||||
operator := ';'
|
operator := ';'
|
||||||
op_prefix := ';'
|
op_prefix := ';'
|
||||||
op_delimiter := ';'
|
op_delimiter := ';'
|
||||||
when '?' then
|
when Form_style_query_operator then
|
||||||
|
--| '?'
|
||||||
operator := '?'
|
operator := '?'
|
||||||
op_prefix := '?'
|
op_prefix := '?'
|
||||||
op_delimiter := '&'
|
op_delimiter := '&'
|
||||||
@@ -81,7 +91,7 @@ feature -- Processing
|
|||||||
loop
|
loop
|
||||||
s := lst.item
|
s := lst.item
|
||||||
vmodifier := Void
|
vmodifier := Void
|
||||||
p := s.index_of ('|', 1)
|
p := s.index_of (Default_delimiter, 1)
|
||||||
if p > 0 then
|
if p > 0 then
|
||||||
vn := s.substring (1, p - 1)
|
vn := s.substring (1, p - 1)
|
||||||
s := s.substring (p + 1, s.count)
|
s := s.substring (p + 1, s.count)
|
||||||
@@ -97,7 +107,7 @@ feature -- Processing
|
|||||||
i > n
|
i > n
|
||||||
loop
|
loop
|
||||||
inspect vn[i]
|
inspect vn[i]
|
||||||
when '*', '+', ':', '^' then
|
when Explode_plus, Explode_star, Modifier_substring, Modifier_remainder then
|
||||||
vmodifier := vn.substring (i, n)
|
vmodifier := vn.substring (i, n)
|
||||||
vn := vn.substring (1, i - 1)
|
vn := vn.substring (1, i - 1)
|
||||||
i := n + 1 --| exit
|
i := n + 1 --| exit
|
||||||
@@ -105,7 +115,7 @@ feature -- Processing
|
|||||||
i := i + 1
|
i := i + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
vars.force (create {URI_TEMPLATE_EXPRESSION_VARIABLE}.make (operator, vn, s, vmodifier))
|
vars.force (create {URI_TEMPLATE_EXPRESSION_VARIABLE}.make (Current, vn, s, vmodifier))
|
||||||
lst.forth
|
lst.forth
|
||||||
end
|
end
|
||||||
variables := vars
|
variables := vars
|
||||||
@@ -117,32 +127,39 @@ feature -- Processing
|
|||||||
feature -- Access
|
feature -- Access
|
||||||
|
|
||||||
position: INTEGER
|
position: INTEGER
|
||||||
|
-- Character position on Current in the template
|
||||||
|
|
||||||
|
end_position: INTEGER
|
||||||
|
do
|
||||||
|
Result := position + expression.count + 2 --| '{' + `expression' + '}'
|
||||||
|
end
|
||||||
|
|
||||||
expression: STRING
|
expression: STRING
|
||||||
|
-- Operator? + VariableName + modifier
|
||||||
|
|
||||||
is_query: BOOLEAN
|
is_query: BOOLEAN
|
||||||
|
-- Is in the query part (i.e: after '?' ?)
|
||||||
|
|
||||||
feature -- Status
|
feature -- Status
|
||||||
|
|
||||||
operator: CHARACTER
|
operator: CHARACTER
|
||||||
|
-- First character of `expression' if among
|
||||||
has_operator: BOOLEAN
|
|
||||||
do
|
|
||||||
Result := operator /= '%U'
|
|
||||||
end
|
|
||||||
|
|
||||||
reserved: BOOLEAN
|
reserved: BOOLEAN
|
||||||
|
-- Is reserved
|
||||||
has_op_prefix: BOOLEAN
|
-- i.e: do not url-encode the reserved character
|
||||||
do
|
|
||||||
Result := op_prefix /= '%U'
|
|
||||||
end
|
|
||||||
|
|
||||||
op_prefix: CHARACTER
|
op_prefix: CHARACTER
|
||||||
|
-- When expanding list of table, first character to use
|
||||||
|
--| ex: '?' for {?var}
|
||||||
|
|
||||||
op_delimiter: CHARACTER
|
op_delimiter: CHARACTER
|
||||||
|
-- When expanding list of table, delimiter character to use
|
||||||
|
--| ex: ',' for {?var}
|
||||||
|
|
||||||
variables: detachable LIST [URI_TEMPLATE_EXPRESSION_VARIABLE]
|
variables: detachable LIST [URI_TEMPLATE_EXPRESSION_VARIABLE]
|
||||||
|
-- List of variables declared in `expression'
|
||||||
|
--| ex: "foo", "bar" for {?foo,bar}
|
||||||
|
|
||||||
variable_names: LIST [STRING]
|
variable_names: LIST [STRING]
|
||||||
do
|
do
|
||||||
@@ -168,46 +185,16 @@ feature -- Status report
|
|||||||
|
|
||||||
feature -- Report
|
feature -- Report
|
||||||
|
|
||||||
append_to_string (a_ht: HASH_TABLE [detachable ANY, STRING]; a_buffer: STRING)
|
append_expanded_to_string (a_ht: HASH_TABLE [detachable ANY, STRING]; a_buffer: STRING)
|
||||||
do
|
do
|
||||||
analyze
|
analyze
|
||||||
if attached variables as vars then
|
if attached variables as vars then
|
||||||
append_custom_variables_to_string (a_ht, vars, op_prefix, op_delimiter, True, a_buffer)
|
append_custom_variables_to_string (a_ht, vars, op_prefix, op_delimiter, True, a_buffer)
|
||||||
-- inspect operator
|
|
||||||
-- when '?' then
|
|
||||||
-- append_custom_variables_to_string (a_ht, vars, '?', '&', True, a_buffer)
|
|
||||||
-- when ';' then
|
|
||||||
-- append_custom_variables_to_string (a_ht, vars, ';', ';', False, a_buffer)
|
|
||||||
-- when '.' then
|
|
||||||
-- append_custom_variables_to_string (a_ht, vars, '.', ',', True, a_buffer)
|
|
||||||
-- when '/' then
|
|
||||||
-- append_custom_variables_to_string (a_ht, vars, '/', '/', True, a_buffer)
|
|
||||||
-- else
|
|
||||||
-- append_custom_variables_to_string (a_ht, vars, '%U', ',', False, a_buffer)
|
|
||||||
-- end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
feature {NONE} -- Implementation
|
feature {NONE} -- Implementation
|
||||||
|
|
||||||
url_encoded_string (s: READABLE_STRING_GENERAL; a_encoded: BOOLEAN): STRING
|
|
||||||
do
|
|
||||||
if a_encoded then
|
|
||||||
Result := url_encoder.encoded_string (s.as_string_32)
|
|
||||||
else
|
|
||||||
Result := url_encoder.partial_encoded_string (s.as_string_32, <<
|
|
||||||
':', ',',
|
|
||||||
'+', '.', '/', ';', '?',
|
|
||||||
'|', '!', '@'
|
|
||||||
>>)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
url_encoder: URL_ENCODER
|
|
||||||
once
|
|
||||||
create Result
|
|
||||||
end
|
|
||||||
|
|
||||||
append_custom_variables_to_string (a_ht: HASH_TABLE [detachable ANY, STRING]; vars: like variables; prefix_char, delimiter_char: CHARACTER; a_include_name: BOOLEAN; a_buffer: STRING)
|
append_custom_variables_to_string (a_ht: HASH_TABLE [detachable ANY, STRING]; vars: like variables; prefix_char, delimiter_char: CHARACTER; a_include_name: BOOLEAN; a_buffer: STRING)
|
||||||
-- If `first_char' is '%U' do not print any first character
|
-- If `first_char' is '%U' do not print any first character
|
||||||
local
|
local
|
||||||
@@ -228,8 +215,8 @@ feature {NONE} -- Implementation
|
|||||||
vdata := a_ht.item (vi.name)
|
vdata := a_ht.item (vi.name)
|
||||||
vstr := Void
|
vstr := Void
|
||||||
if vdata /= Void then
|
if vdata /= Void then
|
||||||
vstr := vi.string (vdata)
|
vstr := vi.expanded_string (vdata)
|
||||||
if vstr = Void and vi.has_explode_modifier then
|
if vstr = Void and vi.has_explode then
|
||||||
--| Missing or list empty
|
--| Missing or list empty
|
||||||
vstr := vi.default_value
|
vstr := vi.default_value
|
||||||
l_use_default := True
|
l_use_default := True
|
||||||
@@ -250,9 +237,9 @@ feature {NONE} -- Implementation
|
|||||||
else
|
else
|
||||||
a_buffer.append_character (delimiter_char)
|
a_buffer.append_character (delimiter_char)
|
||||||
end
|
end
|
||||||
if l_use_default and (operator = '?') and not vi.has_explode_modifier_star then
|
if l_use_default and (operator = Form_style_query_operator) and not vi.has_explode_star then
|
||||||
a_buffer.append (vi.name)
|
a_buffer.append (vi.name)
|
||||||
if vi.has_explode_modifier_plus then
|
if vi.has_explode_plus then
|
||||||
a_buffer.append_character ('.')
|
a_buffer.append_character ('.')
|
||||||
else
|
else
|
||||||
a_buffer.append_character ('=')
|
a_buffer.append_character ('=')
|
||||||
|
|||||||
@@ -7,133 +7,172 @@ note
|
|||||||
class
|
class
|
||||||
URI_TEMPLATE_EXPRESSION_VARIABLE
|
URI_TEMPLATE_EXPRESSION_VARIABLE
|
||||||
|
|
||||||
|
inherit
|
||||||
|
ANY
|
||||||
|
|
||||||
|
URI_TEMPLATE_CONSTANTS
|
||||||
|
export {NONE} all end
|
||||||
|
|
||||||
create
|
create
|
||||||
make
|
make
|
||||||
|
|
||||||
feature {NONE} -- Initialization
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make (op: like operator; n: like name; d: like default_value; m: like modifier)
|
make (exp: like expression; n: like name; d: like default_value; em: detachable STRING)
|
||||||
|
-- Create based on expression `exp', variable name `n', default value `d' if any
|
||||||
|
-- and explode or modifier string `em'
|
||||||
do
|
do
|
||||||
operator := op
|
expression := exp
|
||||||
|
operator := exp.operator
|
||||||
name := n
|
name := n
|
||||||
default_value := d
|
default_value := d
|
||||||
modifier := m
|
if em /= Void and then em.count > 0 then
|
||||||
|
inspect em[1]
|
||||||
|
when Explode_star, Explode_plus then
|
||||||
|
explode := em[1]
|
||||||
|
when Modifier_substring, Modifier_remainder then
|
||||||
|
modifier := em
|
||||||
|
else
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
op_prefix := '%U'
|
op_prefix := '%U'
|
||||||
op_separator := ','
|
op_separator := ','
|
||||||
|
|
||||||
inspect op
|
inspect operator
|
||||||
when '+' then
|
when Reserved_operator then --| '+'
|
||||||
reserved := True
|
reserved := True
|
||||||
when '?' then
|
when Form_style_query_operator then --| '?'
|
||||||
op_prefix := '?'
|
op_prefix := '?'
|
||||||
op_separator := '&'
|
op_separator := '&'
|
||||||
when ';' then
|
when Path_style_parameters_operator then --| ';'
|
||||||
op_prefix := ';'
|
op_prefix := ';'
|
||||||
op_separator := ';'
|
op_separator := ';'
|
||||||
when '/' then
|
when Path_segment_operator then --| '/'
|
||||||
op_prefix := '/'
|
op_prefix := '/'
|
||||||
op_separator := '/'
|
op_separator := '/'
|
||||||
when '.' then
|
when Label_operator then --| '.'
|
||||||
op_prefix := '.'
|
op_prefix := '.'
|
||||||
op_separator := '.'
|
op_separator := '.'
|
||||||
else
|
else
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Access
|
feature -- Access
|
||||||
|
|
||||||
|
expression: URI_TEMPLATE_EXPRESSION
|
||||||
|
-- Parent expression
|
||||||
|
|
||||||
operator: CHARACTER
|
operator: CHARACTER
|
||||||
|
-- First character of related `expression'
|
||||||
|
|
||||||
name: STRING
|
name: STRING
|
||||||
|
-- variable name
|
||||||
|
|
||||||
default_value: detachable STRING
|
default_value: detachable STRING
|
||||||
|
-- default value if any
|
||||||
|
|
||||||
reserved: BOOLEAN
|
reserved: BOOLEAN
|
||||||
|
-- Is reserved?
|
||||||
|
-- i.e: do not url-encode the reserved character
|
||||||
|
|
||||||
op_prefix: CHARACTER
|
op_prefix: CHARACTER
|
||||||
|
-- When expanding list of table, first character to use
|
||||||
|
--| ex: '?' for {?var}
|
||||||
|
|
||||||
op_separator: CHARACTER
|
op_separator: CHARACTER
|
||||||
|
-- When expanding list of table, delimiter character to use
|
||||||
|
--| ex: ',' for {?var}
|
||||||
|
|
||||||
|
explode: CHARACTER
|
||||||
|
-- Explode character , '*' or '+'
|
||||||
|
|
||||||
modifier: detachable STRING
|
modifier: detachable STRING
|
||||||
|
-- Modifier expression, starting by ':' or '^'
|
||||||
|
--| ":3" , "-3", "^4", ...
|
||||||
|
|
||||||
has_modifier: BOOLEAN
|
modified_string (s: READABLE_STRING_GENERAL): READABLE_STRING_GENERAL
|
||||||
do
|
|
||||||
Result := modifier /= Void
|
|
||||||
end
|
|
||||||
|
|
||||||
modified (s: READABLE_STRING_GENERAL): READABLE_STRING_GENERAL
|
|
||||||
local
|
local
|
||||||
t: STRING
|
t: STRING
|
||||||
i,n: INTEGER
|
i,n: INTEGER
|
||||||
do
|
do
|
||||||
Result := s
|
Result := s
|
||||||
if attached modifier as m and then m.count > 1 and then m[1] = ':' then
|
if attached modifier as m and then m.count > 1 then
|
||||||
n := s.count
|
n := s.count
|
||||||
t := m.substring (2, m.count)
|
t := m.substring (2, m.count)
|
||||||
if t.is_integer then
|
if t.is_integer then
|
||||||
i := t.to_integer
|
i := t.to_integer
|
||||||
if i > 0 then
|
inspect m[1]
|
||||||
if i < n then
|
when Modifier_substring then
|
||||||
Result := s.substring (1, i)
|
if i > 0 then
|
||||||
|
if i < n then
|
||||||
|
Result := s.substring (1, i)
|
||||||
|
end
|
||||||
|
elseif i < 0 then
|
||||||
|
Result := s.substring (n - i, n)
|
||||||
end
|
end
|
||||||
elseif i < 0 then
|
when Modifier_remainder then
|
||||||
Result := s.substring (n - i, n)
|
if i > 0 then
|
||||||
|
if i < n then
|
||||||
|
Result := s.substring (i + 1, n)
|
||||||
|
end
|
||||||
|
elseif i < 0 then
|
||||||
|
Result := s.substring (1, n + i) --| n + i = n - (-i)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
check Known_modified: False end
|
||||||
|
-- Unchanged
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
has_explode_modifier: BOOLEAN
|
has_explode: BOOLEAN
|
||||||
do
|
do
|
||||||
Result := attached modifier as m and then m.count = 1 and then (
|
Result := explode = Explode_plus or explode = Explode_star
|
||||||
m[1] = '+' or m[1] = '*'
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
has_explode_modifier_plus: BOOLEAN
|
has_explode_plus: BOOLEAN
|
||||||
do
|
do
|
||||||
Result := attached modifier as m and then m.count = 1 and then
|
Result := explode = Explode_plus
|
||||||
m[1] = '+'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
has_explode_modifier_star: BOOLEAN
|
has_explode_star: BOOLEAN
|
||||||
do
|
do
|
||||||
Result := attached modifier as m and then m.count = 1 and then
|
Result := explode = Explode_star
|
||||||
m[1] = '*'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Report
|
feature -- Report
|
||||||
|
|
||||||
string (d: detachable ANY): detachable STRING
|
expanded_string (d: detachable ANY): detachable STRING
|
||||||
local
|
local
|
||||||
l_delimiter: CHARACTER
|
l_delimiter: CHARACTER
|
||||||
v_enc: detachable STRING
|
v_enc: detachable STRING
|
||||||
k_enc: STRING
|
k_enc: STRING
|
||||||
l_obj: detachable ANY
|
l_obj: detachable ANY
|
||||||
i,n: INTEGER
|
i,n: INTEGER
|
||||||
modifier_is_plus: BOOLEAN
|
explode_is_plus: BOOLEAN
|
||||||
modifier_is_star: BOOLEAN
|
explode_is_star: BOOLEAN
|
||||||
modifier_has_explode: BOOLEAN
|
l_has_explode: BOOLEAN
|
||||||
dft: detachable ANY
|
dft: detachable ANY
|
||||||
has_list_op: BOOLEAN
|
has_list_op: BOOLEAN
|
||||||
|
op: like operator
|
||||||
do
|
do
|
||||||
modifier_has_explode := has_explode_modifier
|
l_has_explode := has_explode
|
||||||
if modifier_has_explode then
|
if l_has_explode then
|
||||||
modifier_is_plus := has_explode_modifier_plus
|
explode_is_plus := has_explode_plus
|
||||||
modifier_is_star := has_explode_modifier_star
|
explode_is_star := has_explode_star
|
||||||
end
|
end
|
||||||
has_list_op := operator /= '%U' and operator /= '+'
|
op := operator
|
||||||
|
has_list_op := op /= '%U' and op /= Reserved_operator
|
||||||
dft := default_value
|
dft := default_value
|
||||||
create Result.make (20)
|
create Result.make (20)
|
||||||
if attached {READABLE_STRING_GENERAL} d as l_string then
|
if attached {READABLE_STRING_GENERAL} d as l_string then
|
||||||
v_enc := url_encoded_string (modified (l_string), not reserved)
|
v_enc := url_encoded_string (modified_string (l_string), not reserved)
|
||||||
if operator = '?' then
|
if op = Form_style_query_operator then
|
||||||
Result.append (name)
|
Result.append (name)
|
||||||
Result.append_character ('=')
|
Result.append_character ('=')
|
||||||
elseif operator = ';' then
|
elseif op = Path_style_parameters_operator then
|
||||||
Result.append (name)
|
Result.append (name)
|
||||||
if not v_enc.is_empty then
|
if not v_enc.is_empty then
|
||||||
Result.append_character ('=')
|
Result.append_character ('=')
|
||||||
@@ -143,29 +182,29 @@ feature -- Report
|
|||||||
elseif attached {ARRAY [detachable ANY]} d as l_array then
|
elseif attached {ARRAY [detachable ANY]} d as l_array then
|
||||||
if l_array.is_empty then
|
if l_array.is_empty then
|
||||||
if dft /= Void then
|
if dft /= Void then
|
||||||
inspect operator
|
inspect op
|
||||||
when '?',';' then
|
when Form_style_query_operator, Path_style_parameters_operator then
|
||||||
if not modifier_has_explode then
|
if not l_has_explode then
|
||||||
Result.append (name)
|
Result.append (name)
|
||||||
Result.append_character ('=')
|
Result.append_character ('=')
|
||||||
Result.append (dft.out)
|
Result.append (dft.out)
|
||||||
else
|
else
|
||||||
if modifier_is_plus then
|
if explode_is_plus then
|
||||||
Result.append (name)
|
Result.append (name)
|
||||||
Result.append_character ('.')
|
Result.append_character ('.')
|
||||||
end
|
end
|
||||||
Result.append (dft.out)
|
Result.append (dft.out)
|
||||||
end
|
end
|
||||||
when '/' then
|
when Path_segment_operator then
|
||||||
if modifier_is_plus then
|
if explode_is_plus then
|
||||||
Result.append (name)
|
Result.append (name)
|
||||||
Result.append_character ('.')
|
Result.append_character ('.')
|
||||||
end
|
end
|
||||||
Result.append (dft.out)
|
Result.append (dft.out)
|
||||||
when '.' then
|
when Label_operator then
|
||||||
else
|
else
|
||||||
if modifier_has_explode then
|
if l_has_explode then
|
||||||
if modifier_is_plus then
|
if explode_is_plus then
|
||||||
Result.append (name)
|
Result.append (name)
|
||||||
Result.append_character ('.')
|
Result.append_character ('.')
|
||||||
end
|
end
|
||||||
@@ -176,17 +215,14 @@ feature -- Report
|
|||||||
-- nothing ...
|
-- nothing ...
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if modifier_has_explode then
|
if l_has_explode then
|
||||||
l_delimiter := op_separator
|
l_delimiter := op_separator
|
||||||
else
|
else
|
||||||
l_delimiter := ','
|
l_delimiter := ','
|
||||||
inspect operator
|
inspect op
|
||||||
when '?' then
|
when Form_style_query_operator then
|
||||||
Result.append (name)
|
Result.append (name)
|
||||||
Result.append_character ('=')
|
Result.append_character ('=')
|
||||||
when ';' then
|
|
||||||
when '/' then
|
|
||||||
-- Result.append_character ('/')
|
|
||||||
else
|
else
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -203,10 +239,10 @@ feature -- Report
|
|||||||
else
|
else
|
||||||
v_enc := ""
|
v_enc := ""
|
||||||
end
|
end
|
||||||
if modifier_is_plus then
|
if explode_is_plus then
|
||||||
if
|
if
|
||||||
(operator = '?' and modifier_is_plus) or
|
(op = Form_style_query_operator and explode_is_plus) or
|
||||||
(operator = ';' and modifier_has_explode)
|
(op = Path_style_parameters_operator and l_has_explode)
|
||||||
then
|
then
|
||||||
Result.append (name)
|
Result.append (name)
|
||||||
Result.append_character ('=')
|
Result.append_character ('=')
|
||||||
@@ -214,7 +250,7 @@ feature -- Report
|
|||||||
Result.append (name)
|
Result.append (name)
|
||||||
Result.append_character ('.')
|
Result.append_character ('.')
|
||||||
end
|
end
|
||||||
elseif modifier_is_star and operator = '?' then
|
elseif explode_is_star and op = Form_style_query_operator then
|
||||||
Result.append (name)
|
Result.append (name)
|
||||||
Result.append_character ('=')
|
Result.append_character ('=')
|
||||||
end
|
end
|
||||||
@@ -230,47 +266,31 @@ feature -- Report
|
|||||||
Result := Void
|
Result := Void
|
||||||
end
|
end
|
||||||
elseif attached {HASH_TABLE [detachable ANY, STRING]} d as l_table then
|
elseif attached {HASH_TABLE [detachable ANY, STRING]} d as l_table then
|
||||||
-- if operator = '?' and not modifier_has_explode and l_table.is_empty and dft = Void then
|
|
||||||
-- elseif operator = '?' and not modifier_has_explode then
|
|
||||||
-- Result.append (name)
|
|
||||||
-- Result.append_character ('=')
|
|
||||||
-- if l_table.is_empty and dft /= Void then
|
|
||||||
-- Result.append (dft.out)
|
|
||||||
-- end
|
|
||||||
-- elseif l_table.is_empty and dft /= Void then
|
|
||||||
-- if modifier_has_explode then
|
|
||||||
-- if modifier_is_plus then
|
|
||||||
-- Result.append (name)
|
|
||||||
-- Result.append_character ('.')
|
|
||||||
-- end
|
|
||||||
-- Result.append (dft.out)
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
if l_table.is_empty then
|
if l_table.is_empty then
|
||||||
if dft /= Void then
|
if dft /= Void then
|
||||||
inspect operator
|
inspect op
|
||||||
when '?',';' then
|
when Form_style_query_operator, Path_style_parameters_operator then
|
||||||
if not modifier_has_explode then
|
if not l_has_explode then
|
||||||
Result.append (name)
|
Result.append (name)
|
||||||
Result.append_character ('=')
|
Result.append_character ('=')
|
||||||
Result.append (dft.out)
|
Result.append (dft.out)
|
||||||
else
|
else
|
||||||
if modifier_is_plus then
|
if explode_is_plus then
|
||||||
Result.append (name)
|
Result.append (name)
|
||||||
Result.append_character ('.')
|
Result.append_character ('.')
|
||||||
end
|
end
|
||||||
Result.append (dft.out)
|
Result.append (dft.out)
|
||||||
end
|
end
|
||||||
when '/' then
|
when Path_segment_operator then
|
||||||
if modifier_is_plus then
|
if explode_is_plus then
|
||||||
Result.append (name)
|
Result.append (name)
|
||||||
Result.append_character ('.')
|
Result.append_character ('.')
|
||||||
end
|
end
|
||||||
Result.append (dft.out)
|
Result.append (dft.out)
|
||||||
when '.' then
|
when Label_operator then
|
||||||
else
|
else
|
||||||
if modifier_has_explode then
|
if l_has_explode then
|
||||||
if modifier_is_plus then
|
if explode_is_plus then
|
||||||
Result.append (name)
|
Result.append (name)
|
||||||
Result.append_character ('.')
|
Result.append_character ('.')
|
||||||
end
|
end
|
||||||
@@ -281,16 +301,14 @@ feature -- Report
|
|||||||
-- nothing ...
|
-- nothing ...
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if modifier_has_explode then
|
if l_has_explode then
|
||||||
l_delimiter := op_separator
|
l_delimiter := op_separator
|
||||||
else
|
else
|
||||||
l_delimiter := ','
|
l_delimiter := ','
|
||||||
inspect operator
|
inspect op
|
||||||
when '?' then
|
when Form_style_query_operator then
|
||||||
Result.append (name)
|
Result.append (name)
|
||||||
Result.append_character ('=')
|
Result.append_character ('=')
|
||||||
when ';' then
|
|
||||||
when '/' then
|
|
||||||
else
|
else
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -308,20 +326,12 @@ feature -- Report
|
|||||||
v_enc := ""
|
v_enc := ""
|
||||||
end
|
end
|
||||||
|
|
||||||
if modifier_is_plus then
|
if explode_is_plus then
|
||||||
Result.append (name)
|
Result.append (name)
|
||||||
Result.append_character ('.')
|
Result.append_character ('.')
|
||||||
end
|
end
|
||||||
if
|
if
|
||||||
modifier_has_explode and
|
l_has_explode
|
||||||
(
|
|
||||||
operator = '%U' or
|
|
||||||
operator = '+' or
|
|
||||||
operator = '?' or
|
|
||||||
operator = '.' or
|
|
||||||
operator = ';' or
|
|
||||||
operator = '/'
|
|
||||||
)
|
|
||||||
then
|
then
|
||||||
Result.append (k_enc)
|
Result.append (k_enc)
|
||||||
Result.append_character ('=')
|
Result.append_character ('=')
|
||||||
@@ -348,12 +358,12 @@ feature -- Report
|
|||||||
else
|
else
|
||||||
v_enc := default_value
|
v_enc := default_value
|
||||||
end
|
end
|
||||||
if operator = '?' then
|
if op = Form_style_query_operator then
|
||||||
Result.append (name)
|
Result.append (name)
|
||||||
if v_enc /= Void then
|
if v_enc /= Void then
|
||||||
Result.append_character ('=')
|
Result.append_character ('=')
|
||||||
end
|
end
|
||||||
elseif operator = ';' then
|
elseif op = Path_style_parameters_operator then
|
||||||
Result.append (name)
|
Result.append (name)
|
||||||
if v_enc /= Void and then not v_enc.is_empty then
|
if v_enc /= Void and then not v_enc.is_empty then
|
||||||
Result.append_character ('=')
|
Result.append_character ('=')
|
||||||
@@ -374,7 +384,11 @@ feature {NONE} -- Implementation
|
|||||||
else
|
else
|
||||||
Result := url_encoder.partial_encoded_string (s.as_string_32, <<
|
Result := url_encoder.partial_encoded_string (s.as_string_32, <<
|
||||||
':', ',',
|
':', ',',
|
||||||
'+', '.', '/', ';', '?',
|
Reserved_operator,
|
||||||
|
Label_operator,
|
||||||
|
Path_segment_operator,
|
||||||
|
Path_style_parameters_operator,
|
||||||
|
Form_style_query_operator,
|
||||||
'|', '!', '@'
|
'|', '!', '@'
|
||||||
>>)
|
>>)
|
||||||
end
|
end
|
||||||
|
|||||||
28
library/protocol/uri_template/test_uri_template-draft_05.ecf
Normal file
28
library/protocol/uri_template/test_uri_template-draft_05.ecf
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||||
|
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-8-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-8-0 http://www.eiffel.com/developers/xml/configuration-1-8-0.xsd" name="test_uri_template_draft_05" uuid="1B44EA8C-7D88-4823-B16A-C9FA8DA3ACFF" library_target="test_uri_template_draft_05">
|
||||||
|
<target name="test_uri_template_draft_05">
|
||||||
|
<root class="ANY" feature="default_create"/>
|
||||||
|
<file_rule>
|
||||||
|
<exclude>/.git$</exclude>
|
||||||
|
<exclude>/EIFGENs$</exclude>
|
||||||
|
<exclude>/.svn$</exclude>
|
||||||
|
</file_rule>
|
||||||
|
<file_rule>
|
||||||
|
<exclude>/.git$</exclude>
|
||||||
|
<exclude>/EIFGENs$</exclude>
|
||||||
|
<exclude>/.svn$</exclude>
|
||||||
|
</file_rule>
|
||||||
|
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all">
|
||||||
|
<assertions precondition="true"/>
|
||||||
|
</option>
|
||||||
|
<variable name="uri_template" value="draft_05"/>
|
||||||
|
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||||
|
<library name="testing" location="$ISE_LIBRARY\library\testing\testing-safe.ecf"/>
|
||||||
|
<library name="uri_template" location="uri_template-safe.ecf"/>
|
||||||
|
<tests name="tests" location=".\tests\" recursive="true">
|
||||||
|
<file_rule>
|
||||||
|
<exclude>/test_uri_template.e$</exclude>
|
||||||
|
</file_rule>
|
||||||
|
</tests>
|
||||||
|
</target>
|
||||||
|
</system>
|
||||||
@@ -0,0 +1,632 @@
|
|||||||
|
note
|
||||||
|
description: "[
|
||||||
|
Eiffel tests that can be executed by testing tool.
|
||||||
|
]"
|
||||||
|
author: "EiffelStudio test wizard"
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
testing: "type/manual"
|
||||||
|
|
||||||
|
class
|
||||||
|
TEST_URI_TEMPLATE_DRAFT_05
|
||||||
|
|
||||||
|
inherit
|
||||||
|
EQA_TEST_SET
|
||||||
|
|
||||||
|
feature -- Test routines
|
||||||
|
|
||||||
|
test_uri_template_parser
|
||||||
|
note
|
||||||
|
testing: "uri-template-05"
|
||||||
|
do
|
||||||
|
uri_template_parse ("api/foo/{foo_id}/{?id,extra}", <<"foo_id">>, <<"id", "extra">>)
|
||||||
|
uri_template_parse ("weather/{state}/{city}?forecast={day}", <<"state", "city">>, <<"day">>)
|
||||||
|
end
|
||||||
|
|
||||||
|
test_uri_template_matcher
|
||||||
|
note
|
||||||
|
testing: "uri-template-05"
|
||||||
|
local
|
||||||
|
tpl: URI_TEMPLATE
|
||||||
|
do
|
||||||
|
create tpl.make ("api/foo/{foo_id}/{?id,extra}")
|
||||||
|
uri_template_match (tpl, "api/foo/bar/", <<["foo_id", "bar"]>>, <<>>)
|
||||||
|
uri_template_match (tpl, "api/foo/bar/?id=123", <<["foo_id", "bar"]>>, <<["id", "123"]>>)
|
||||||
|
uri_template_match (tpl, "api/foo/bar/?id=123&extra=test", <<["foo_id", "bar"]>>, <<["id", "123"], ["extra", "test"]>>)
|
||||||
|
uri_template_match (tpl, "api/foo/bar/?id=123&extra=test&one=more", <<["foo_id", "bar"]>>, <<["id", "123"], ["extra", "test"]>>)
|
||||||
|
uri_template_mismatch (tpl, "")
|
||||||
|
uri_template_mismatch (tpl, "/")
|
||||||
|
uri_template_mismatch (tpl, "foo/bar/?id=123")
|
||||||
|
uri_template_mismatch (tpl, "/api/foo/bar/")
|
||||||
|
uri_template_mismatch (tpl, "api/foo/bar")
|
||||||
|
|
||||||
|
create tpl.make ("weather/{state}/{city}?forecast={day}")
|
||||||
|
uri_template_match (tpl, "weather/California/Goleta?forecast=today", <<["state", "California"], ["city", "Goleta"]>>, <<["day", "today"]>>)
|
||||||
|
end
|
||||||
|
|
||||||
|
uri_template_string_errors: detachable LIST [STRING]
|
||||||
|
|
||||||
|
test_uri_template_string_builder
|
||||||
|
note
|
||||||
|
testing: "uri-template-05"
|
||||||
|
local
|
||||||
|
ht: HASH_TABLE [detachable ANY, STRING]
|
||||||
|
empty_keys: HASH_TABLE [STRING, STRING]
|
||||||
|
empty_list: ARRAY [STRING]
|
||||||
|
favs: HASH_TABLE [detachable ANY, STRING]
|
||||||
|
keys: HASH_TABLE [STRING, STRING]
|
||||||
|
colors: ARRAY [STRING]
|
||||||
|
names: ARRAY [STRING]
|
||||||
|
semi_dot: HASH_TABLE [STRING, STRING]
|
||||||
|
vals: ARRAY [STRING]
|
||||||
|
do
|
||||||
|
create ht.make (3)
|
||||||
|
ht.force ("FooBar", "foo_id")
|
||||||
|
ht.force ("That's right!", "extra")
|
||||||
|
ht.force ("123", "id")
|
||||||
|
ht.force ("California", "state")
|
||||||
|
ht.force ("Goleta", "city")
|
||||||
|
ht.force ("today", "day")
|
||||||
|
|
||||||
|
ht.force ("value", "var")
|
||||||
|
ht.force ("Hello World!", "hello")
|
||||||
|
ht.force ("", "empty")
|
||||||
|
ht.force ("/foo/bar", "path")
|
||||||
|
ht.force ("1024", "x")
|
||||||
|
ht.force ("768", "y")
|
||||||
|
ht.force ("fred", "foo")
|
||||||
|
ht.force ("That's right!", "foo2")
|
||||||
|
ht.force ("http://example.com/home/", "base")
|
||||||
|
|
||||||
|
names := <<"Fred", "Wilma", "Pebbles">>
|
||||||
|
ht.force (names, "name")
|
||||||
|
create favs.make (2)
|
||||||
|
favs.force ("red", "color")
|
||||||
|
favs.force ("high", "volume")
|
||||||
|
ht.force (favs, "favs")
|
||||||
|
|
||||||
|
create empty_list.make_empty
|
||||||
|
ht.force (empty_list,"empty_list")
|
||||||
|
|
||||||
|
create empty_keys.make (0)
|
||||||
|
ht.force (empty_keys,"empty_keys")
|
||||||
|
|
||||||
|
vals := <<"val1", "val2", "val3">>
|
||||||
|
ht.force (vals, "list")
|
||||||
|
create keys.make (2)
|
||||||
|
keys.force ("val1", "key1")
|
||||||
|
keys.force ("val2", "key2")
|
||||||
|
ht.force (keys, "keys")
|
||||||
|
|
||||||
|
colors := <<"red", "green", "blue">>
|
||||||
|
create semi_dot.make (3)
|
||||||
|
semi_dot.force (";", "semi")
|
||||||
|
semi_dot.force (".", "dot")
|
||||||
|
semi_dot.force (",", "comma")
|
||||||
|
|
||||||
|
create {ARRAYED_LIST [STRING]} uri_template_string_errors.make (10)
|
||||||
|
|
||||||
|
|
||||||
|
--| Simple string expansion
|
||||||
|
uri_template_string (ht, "{var}", "value")
|
||||||
|
uri_template_string (ht, "{hello}", "Hello+World%%21")
|
||||||
|
uri_template_string (ht, "O{empty}X", "OX")
|
||||||
|
uri_template_string (ht, "O{undef}X", "OX")
|
||||||
|
|
||||||
|
--| String expansion with defaults
|
||||||
|
uri_template_string (ht, "{var|default}", "value")
|
||||||
|
uri_template_string (ht, "O{empty|default}X", "OX")
|
||||||
|
uri_template_string (ht, "O{undef|default}X", "OdefaultX")
|
||||||
|
|
||||||
|
--| Reserved expansion with defaults
|
||||||
|
uri_template_string (ht, "{+var}", "value")
|
||||||
|
uri_template_string (ht, "{+hello}", "Hello+World!")
|
||||||
|
uri_template_string (ht, "{+path}/here", "/foo/bar/here")
|
||||||
|
uri_template_string (ht, "here?ref={+path}", "here?ref=/foo/bar")
|
||||||
|
uri_template_string (ht, "up{+path}{x}/here", "up/foo/bar1024/here")
|
||||||
|
uri_template_string (ht, "up{+empty|/1}/here", "up/here")
|
||||||
|
uri_template_string (ht, "up{+undef|/1}/here", "up/1/here")
|
||||||
|
|
||||||
|
--| String expansion with multiple variables
|
||||||
|
uri_template_string (ht, "{x,y}", "1024,768")
|
||||||
|
uri_template_string (ht, "{x,hello,y}", "1024,Hello+World%%21,768")
|
||||||
|
uri_template_string (ht, "?{x,empty}", "?1024,")
|
||||||
|
uri_template_string (ht, "?{x,undef}", "?1024")
|
||||||
|
uri_template_string (ht, "?{undef,y}", "?768")
|
||||||
|
uri_template_string (ht, "?{x,undef|0}", "?1024,0")
|
||||||
|
|
||||||
|
--| Reserved expansion with multiple variables
|
||||||
|
uri_template_string (ht, "{+x,hello,y}", "1024,Hello+World!,768")
|
||||||
|
uri_template_string (ht, "{+path,x}/here", "/foo/bar,1024/here")
|
||||||
|
--| Label expansion, dot-prefixed
|
||||||
|
uri_template_string (ht, "X{.var}", "X.value")
|
||||||
|
uri_template_string (ht, "X{.empty}", "X.")
|
||||||
|
uri_template_string (ht, "X{.undef}", "X")
|
||||||
|
|
||||||
|
--| Path segments, slash-prefixed
|
||||||
|
uri_template_string (ht, "{/var}", "/value")
|
||||||
|
uri_template_string (ht, "{/var,empty}", "/value/")
|
||||||
|
uri_template_string (ht, "{/var,undef}", "/value")
|
||||||
|
|
||||||
|
--| Path-style parameters, semicolon-prefixed
|
||||||
|
uri_template_string (ht, "{;x,y}", ";x=1024;y=768")
|
||||||
|
uri_template_string (ht, "{;x,y,empty}", ";x=1024;y=768;empty")
|
||||||
|
uri_template_string (ht, "{;x,y,undef}", ";x=1024;y=768")
|
||||||
|
|
||||||
|
--| Form-style query, ampersand-separated
|
||||||
|
uri_template_string (ht, "{?x,y}", "?x=1024&y=768")
|
||||||
|
uri_template_string (ht, "{?x,y,empty}", "?x=1024&y=768&empty=")
|
||||||
|
uri_template_string (ht, "{?x,y,undef}", "?x=1024&y=768")
|
||||||
|
|
||||||
|
|
||||||
|
ht.force (colors, "list")
|
||||||
|
ht.force (semi_dot, "keys")
|
||||||
|
--| String expansion with value modifiers
|
||||||
|
uri_template_string (ht, "{var:3}", "val")
|
||||||
|
uri_template_string (ht, "{var:30}", "value")
|
||||||
|
uri_template_string (ht, "{var^3}", "ue")
|
||||||
|
uri_template_string (ht, "{var^-3}", "va")
|
||||||
|
|
||||||
|
uri_template_string (ht, "{list}", "red,green,blue")
|
||||||
|
uri_template_string (ht, "{list*}", "red,green,blue")
|
||||||
|
uri_template_string (ht, "{keys}", "semi,%%3B,dot,.,comma,%%2C")
|
||||||
|
uri_template_string (ht, "{keys*}", "semi=%%3B,dot=.,comma=%%2C")
|
||||||
|
--| Reserved expansion with value modifiers
|
||||||
|
uri_template_string (ht, "{+path:6}/here", "/foo/b/here")
|
||||||
|
uri_template_string (ht, "{+list}", "red,green,blue")
|
||||||
|
uri_template_string (ht, "{+list*}", "red,green,blue")
|
||||||
|
uri_template_string (ht, "{+keys}", "semi,;,dot,.,comma,,")
|
||||||
|
uri_template_string (ht, "{+keys*}", "semi=;,dot=.,comma=,")
|
||||||
|
--| Label expansion, dot-prefixed
|
||||||
|
uri_template_string (ht, "X{.var:3}", "X.val")
|
||||||
|
uri_template_string (ht, "X{.list}", "X.red,green,blue")
|
||||||
|
uri_template_string (ht, "X{.list*}", "X.red.green.blue")
|
||||||
|
uri_template_string (ht, "X{.keys}", "X.semi,%%3B,dot,.,comma,%%2C")
|
||||||
|
uri_template_string (ht, "X{.keys*}", "X.semi=%%3B.dot=..comma=%%2C")
|
||||||
|
|
||||||
|
--| Path segments, slash-prefixed
|
||||||
|
uri_template_string (ht, "{/var:1,var}", "/v/value")
|
||||||
|
uri_template_string (ht, "{/list}", "/red,green,blue")
|
||||||
|
uri_template_string (ht, "{/list*}", "/red/green/blue")
|
||||||
|
uri_template_string (ht, "{/list*,path:4}", "/red/green/blue/%%2Ffoo")
|
||||||
|
uri_template_string (ht, "{/keys}", "/semi,%%3B,dot,.,comma,%%2C")
|
||||||
|
uri_template_string (ht, "{/keys*}", "/semi=%%3B/dot=./comma=%%2C")
|
||||||
|
|
||||||
|
--| Path-style parameters, semicolon-prefixed
|
||||||
|
uri_template_string (ht, "{;hello:5}", ";hello=Hello")
|
||||||
|
uri_template_string (ht, "{;list}", ";red,green,blue")
|
||||||
|
uri_template_string (ht, "{;list*}", ";red;green;blue")
|
||||||
|
uri_template_string (ht, "{;keys}", ";semi,%%3B,dot,.,comma,%%2C")
|
||||||
|
uri_template_string (ht, "{;keys*}", ";semi=%%3B;dot=.;comma=%%2C")
|
||||||
|
|
||||||
|
--| Form-style query, ampersand-separated
|
||||||
|
uri_template_string (ht, "{?var:3}", "?var=val")
|
||||||
|
uri_template_string (ht, "{?list}", "?list=red,green,blue")
|
||||||
|
uri_template_string (ht, "{?list*}", "?list=red&list=green&list=blue")
|
||||||
|
uri_template_string (ht, "{?keys}", "?keys=semi,%%3B,dot,.,comma,%%2C")
|
||||||
|
uri_template_string (ht, "{?keys*}", "?semi=%%3B&dot=.&comma=%%2C")
|
||||||
|
|
||||||
|
assert ("all strings built", uri_template_string_errors = Void or (attached uri_template_string_errors as err and then err.is_empty))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
test_uri_template_string_builder_extra
|
||||||
|
note
|
||||||
|
testing: "uri-template-05"
|
||||||
|
local
|
||||||
|
ht: HASH_TABLE [detachable ANY, STRING]
|
||||||
|
empty_keys: HASH_TABLE [STRING, STRING]
|
||||||
|
empty_list: ARRAY [STRING]
|
||||||
|
favs: HASH_TABLE [detachable ANY, STRING]
|
||||||
|
keys: HASH_TABLE [STRING, STRING]
|
||||||
|
colors: ARRAY [STRING]
|
||||||
|
names: ARRAY [STRING]
|
||||||
|
semi_dot: HASH_TABLE [STRING, STRING]
|
||||||
|
vals: ARRAY [STRING]
|
||||||
|
do
|
||||||
|
create ht.make (3)
|
||||||
|
ht.force ("FooBar", "foo_id")
|
||||||
|
ht.force ("That's right!", "extra")
|
||||||
|
ht.force ("123", "id")
|
||||||
|
ht.force ("California", "state")
|
||||||
|
ht.force ("Goleta", "city")
|
||||||
|
ht.force ("today", "day")
|
||||||
|
|
||||||
|
ht.force ("value", "var")
|
||||||
|
ht.force ("Hello World!", "hello")
|
||||||
|
ht.force ("", "empty")
|
||||||
|
ht.force ("/foo/bar", "path")
|
||||||
|
ht.force ("1024", "x")
|
||||||
|
ht.force ("768", "y")
|
||||||
|
ht.force ("fred", "foo")
|
||||||
|
ht.force ("That's right!", "foo2")
|
||||||
|
ht.force ("http://example.com/home/", "base")
|
||||||
|
|
||||||
|
names := <<"Fred", "Wilma", "Pebbles">>
|
||||||
|
ht.force (names, "name")
|
||||||
|
create favs.make (2)
|
||||||
|
favs.force ("red", "color")
|
||||||
|
favs.force ("high", "volume")
|
||||||
|
ht.force (favs, "favs")
|
||||||
|
|
||||||
|
create empty_list.make_empty
|
||||||
|
ht.force (empty_list,"empty_list")
|
||||||
|
|
||||||
|
create empty_keys.make (0)
|
||||||
|
ht.force (empty_keys,"empty_keys")
|
||||||
|
|
||||||
|
vals := <<"val1", "val2", "val3">>
|
||||||
|
ht.force (vals, "list")
|
||||||
|
create keys.make (2)
|
||||||
|
keys.force ("val1", "key1")
|
||||||
|
keys.force ("val2", "key2")
|
||||||
|
ht.force (keys, "keys")
|
||||||
|
|
||||||
|
colors := <<"red", "green", "blue">>
|
||||||
|
create semi_dot.make (3)
|
||||||
|
semi_dot.force (";", "semi")
|
||||||
|
semi_dot.force (".", "dot")
|
||||||
|
semi_dot.force (",", "comma")
|
||||||
|
|
||||||
|
create {ARRAYED_LIST [STRING]} uri_template_string_errors.make (10)
|
||||||
|
|
||||||
|
--| Addition to the spec
|
||||||
|
uri_template_string (ht, "api/foo/{foo_id}/{?id,extra}",
|
||||||
|
"api/foo/FooBar/?id=123&extra=That%%27s+right%%21")
|
||||||
|
|
||||||
|
uri_template_string (ht, "api/foo/{foo_id}/{?id,empty,undef,extra}",
|
||||||
|
"api/foo/FooBar/?id=123&empty=&extra=That%%27s+right%%21")
|
||||||
|
|
||||||
|
uri_template_string (ht, "weather/{state}/{city}?forecast={day}",
|
||||||
|
"weather/California/Goleta?forecast=today")
|
||||||
|
|
||||||
|
|
||||||
|
uri_template_string (ht, "{var|default}", "value")
|
||||||
|
uri_template_string (ht, "{undef|default}", "default")
|
||||||
|
uri_template_string (ht, "{undef:3|default}", "default")
|
||||||
|
|
||||||
|
uri_template_string (ht, "x{empty}y", "xy")
|
||||||
|
uri_template_string (ht, "x{empty|_}y", "xy")
|
||||||
|
uri_template_string (ht, "x{undef}y", "xy")
|
||||||
|
uri_template_string (ht, "x{undef|_}y", "x_y")
|
||||||
|
|
||||||
|
uri_template_string (ht, "x{.name|none}", "x.Fred,Wilma,Pebbles")
|
||||||
|
uri_template_string (ht, "x{.name*|none}", "x.Fred.Wilma.Pebbles")
|
||||||
|
uri_template_string (ht, "x{.empty}", "x.")
|
||||||
|
uri_template_string (ht, "x{.empty|none}", "x.")
|
||||||
|
uri_template_string (ht, "x{.undef}", "x")
|
||||||
|
uri_template_string (ht, "x{.undef|none}", "x.none")
|
||||||
|
|
||||||
|
uri_template_string (ht, "x{/name|none}", "x/Fred,Wilma,Pebbles")
|
||||||
|
uri_template_string (ht, "x{/name*|none}", "x/Fred/Wilma/Pebbles")
|
||||||
|
uri_template_string (ht, "x{/undef}", "x")
|
||||||
|
uri_template_string (ht, "x{/undef|none}", "x/none")
|
||||||
|
uri_template_string (ht, "x{/empty}", "x/")
|
||||||
|
uri_template_string (ht, "x{/empty|none}", "x/")
|
||||||
|
uri_template_string (ht, "x{/empty_keys}", "x")
|
||||||
|
uri_template_string (ht, "x{/empty_keys|none}", "x/none")
|
||||||
|
uri_template_string (ht, "x{/empty_keys*}", "x")
|
||||||
|
uri_template_string (ht, "x{/empty_keys*|none}", "x/none")
|
||||||
|
|
||||||
|
uri_template_string (ht, "x{;name|none}", "x;name=Fred,Wilma,Pebbles")
|
||||||
|
uri_template_string (ht, "x{;favs|none}", "x;favs=color,red,volume,high")
|
||||||
|
uri_template_string (ht, "x{;favs*|none}", "x;color=red;volume=high")
|
||||||
|
uri_template_string (ht, "x{;empty}", "x;empty")
|
||||||
|
uri_template_string (ht, "x{;empty|none}", "x;empty")
|
||||||
|
|
||||||
|
uri_template_string (ht, "x{;undef}", "x")
|
||||||
|
uri_template_string (ht, "x{;undef|none}", "x;none")
|
||||||
|
uri_template_string (ht, "x{;undef|foo=y}", "x;foo=y")
|
||||||
|
|
||||||
|
uri_template_string (ht, "x{?var|none}", "x?var=value")
|
||||||
|
uri_template_string (ht, "x{?favs|none}", "x?favs=color,red,volume,high")
|
||||||
|
uri_template_string (ht, "x{?favs*|none}", "x?color=red&volume=high")
|
||||||
|
uri_template_string (ht, "x{?empty}", "x?empty=")
|
||||||
|
uri_template_string (ht, "x{?empty|foo=none}", "x?empty=")
|
||||||
|
uri_template_string (ht, "x{?undef}", "x")
|
||||||
|
uri_template_string (ht, "x{?undef|foo=none}", "x?foo=none")
|
||||||
|
uri_template_string (ht, "x{?empty_keys}", "x")
|
||||||
|
uri_template_string (ht, "x{?empty_keys|none}", "x?none")
|
||||||
|
uri_template_string (ht, "x{?empty_keys|y=z}", "x?y=z")
|
||||||
|
uri_template_string (ht, "x{?empty_keys*|y=z}", "x?y=z")
|
||||||
|
|
||||||
|
|
||||||
|
------
|
||||||
|
|
||||||
|
uri_template_string (ht, "x{empty_list}y", "xy")
|
||||||
|
uri_template_string (ht, "x{empty_list|_}y", "xy")
|
||||||
|
uri_template_string (ht, "x{empty_list*}y", "xy")
|
||||||
|
uri_template_string (ht, "x{empty_list*|_}y", "x_y")
|
||||||
|
uri_template_string (ht, "x{empty_list+}y", "xy")
|
||||||
|
uri_template_string (ht, "x{empty_list+|_}y", "xempty_list._y")
|
||||||
|
|
||||||
|
uri_template_string (ht, "x{empty_keys}y", "xy")
|
||||||
|
uri_template_string (ht, "x{empty_keys|_}y", "xy")
|
||||||
|
uri_template_string (ht, "x{empty_keys*}y", "xy")
|
||||||
|
uri_template_string (ht, "x{empty_keys*|_}y", "x_y")
|
||||||
|
uri_template_string (ht, "x{empty_keys+}y", "xy")
|
||||||
|
uri_template_string (ht, "x{empty_keys+|_}y", "xempty_keys._y")
|
||||||
|
|
||||||
|
uri_template_string (ht, "x{?name|none}", "x?name=Fred,Wilma,Pebbles")
|
||||||
|
uri_template_string (ht, "x{?favs|none}", "x?favs=color,red,volume,high")
|
||||||
|
uri_template_string (ht, "x{?favs*|none}", "x?color=red&volume=high")
|
||||||
|
uri_template_string (ht, "x{?favs+|none}", "x?favs.color=red&favs.volume=high")
|
||||||
|
|
||||||
|
uri_template_string (ht, "x{?undef}", "x")
|
||||||
|
uri_template_string (ht, "x{?undef|none}", "x?undef=none")
|
||||||
|
uri_template_string (ht, "x{?empty}", "x?empty=")
|
||||||
|
uri_template_string (ht, "x{?empty|none}", "x?empty=")
|
||||||
|
|
||||||
|
uri_template_string (ht, "x{?empty_list}", "x")
|
||||||
|
uri_template_string (ht, "x{?empty_list|none}", "x?empty_list=none")
|
||||||
|
uri_template_string (ht, "x{?empty_list*}", "x")
|
||||||
|
uri_template_string (ht, "x{?empty_list*|none}", "x?none")
|
||||||
|
uri_template_string (ht, "x{?empty_list+}", "x")
|
||||||
|
uri_template_string (ht, "x{?empty_list+|none}", "x?empty_list.none")
|
||||||
|
|
||||||
|
uri_template_string (ht, "x{?empty_keys}", "x")
|
||||||
|
uri_template_string (ht, "x{?empty_keys|none}", "x?empty_keys=none")
|
||||||
|
uri_template_string (ht, "x{?empty_keys*}", "x")
|
||||||
|
uri_template_string (ht, "x{?empty_keys*|none}", "x?none")
|
||||||
|
uri_template_string (ht, "x{?empty_keys+}", "x")
|
||||||
|
uri_template_string (ht, "x{?empty_keys+|none}", "x?empty_keys.none")
|
||||||
|
|
||||||
|
uri_template_string (ht, "x{;name|none}", "x;name=Fred,Wilma,Pebbles")
|
||||||
|
uri_template_string (ht, "x{;favs|none}", "x;favs=color,red,volume,high")
|
||||||
|
uri_template_string (ht, "x{;favs*|none}", "x;color=red;volume=high")
|
||||||
|
uri_template_string (ht, "x{;favs+|none}", "x;favs.color=red;favs.volume=high")
|
||||||
|
uri_template_string (ht, "x{;undef}", "x")
|
||||||
|
uri_template_string (ht, "x{;undef|none}", "x;undef=none")
|
||||||
|
uri_template_string (ht, "x{;undef|none}", "x;none")
|
||||||
|
uri_template_string (ht, "x{;empty}", "x;empty")
|
||||||
|
uri_template_string (ht, "x{;empty|none}", "x;empty")
|
||||||
|
|
||||||
|
uri_template_string (ht, "x{;empty_list}", "x")
|
||||||
|
uri_template_string (ht, "x{;empty_list|none}", "x;empty_list=none")
|
||||||
|
uri_template_string (ht, "x{;empty_list*}", "x")
|
||||||
|
uri_template_string (ht, "x{;empty_list*|none}", "x;none")
|
||||||
|
uri_template_string (ht, "x{;empty_list+}", "x")
|
||||||
|
uri_template_string (ht, "x{;empty_list+|none}", "x;empty_list.none")
|
||||||
|
|
||||||
|
uri_template_string (ht, "x{;empty_keys}", "x")
|
||||||
|
uri_template_string (ht, "x{;empty_keys|none}", "x;empty_keys=none")
|
||||||
|
uri_template_string (ht, "x{;empty_keys*}", "x")
|
||||||
|
uri_template_string (ht, "x{;empty_keys*|none}", "x;none")
|
||||||
|
uri_template_string (ht, "x{;empty_keys+}", "x")
|
||||||
|
uri_template_string (ht, "x{;empty_keys+|none}", "x;empty_keys.none")
|
||||||
|
|
||||||
|
uri_template_string (ht, "x{/name|none}", "x/Fred,Wilma,Pebbles")
|
||||||
|
uri_template_string (ht, "x{/name*|none}", "x/Fred/Wilma/Pebbles")
|
||||||
|
uri_template_string (ht, "x{/name+|none}", "x/name.Fred/name.Wilma/name.Pebbles")
|
||||||
|
uri_template_string (ht, "x{/favs|none}", "x/color,red,volume,high")
|
||||||
|
uri_template_string (ht, "x{/favs*|none}", "x/color/red/volume/high")
|
||||||
|
uri_template_string (ht, "x{/favs+|none}", "x/favs.color/red/favs.volume/high")
|
||||||
|
|
||||||
|
uri_template_string (ht, "x{/undef}", "x")
|
||||||
|
uri_template_string (ht, "x{/undef|none}", "x/none")
|
||||||
|
uri_template_string (ht, "x{/empty}", "x/")
|
||||||
|
uri_template_string (ht, "x{/empty|none}", "x/")
|
||||||
|
|
||||||
|
uri_template_string (ht, "x{/empty_list}", "x")
|
||||||
|
uri_template_string (ht, "x{/empty_list|none}", "x/none")
|
||||||
|
uri_template_string (ht, "x{/empty_list*}", "x")
|
||||||
|
uri_template_string (ht, "x{/empty_list*|none}", "x/none")
|
||||||
|
uri_template_string (ht, "x{/empty_list+}", "x")
|
||||||
|
uri_template_string (ht, "x{/empty_list+|none}", "x/empty_list.none")
|
||||||
|
|
||||||
|
uri_template_string (ht, "x{/empty_keys}", "x")
|
||||||
|
uri_template_string (ht, "x{/empty_keys|none}", "x/none")
|
||||||
|
uri_template_string (ht, "x{/empty_keys*}", "x")
|
||||||
|
uri_template_string (ht, "x{/empty_keys*|none}", "x/none")
|
||||||
|
uri_template_string (ht, "x{/empty_keys+}", "x")
|
||||||
|
uri_template_string (ht, "x{/empty_keys+|none}", "x/empty_keys.none")
|
||||||
|
|
||||||
|
--| Simple expansion with comma-separated values
|
||||||
|
uri_template_string (ht, "{var}", "value")
|
||||||
|
uri_template_string (ht, "{hello}", "Hello+World%%21")
|
||||||
|
uri_template_string (ht, "{path}/here", "%%2Ffoo%%2Fbar/here")
|
||||||
|
uri_template_string (ht, "{x,y}", "1024,768")
|
||||||
|
uri_template_string (ht, "{var|default}", "value")
|
||||||
|
uri_template_string (ht, "{undef|default}", "default")
|
||||||
|
uri_template_string (ht, "{list}", "val1,val2,val3")
|
||||||
|
uri_template_string (ht, "{list*}", "val1,val2,val3")
|
||||||
|
uri_template_string (ht, "{list+}", "list.val1,list.val2,list.val3")
|
||||||
|
uri_template_string (ht, "{keys}", "key1,val1,key2,val2")
|
||||||
|
uri_template_string (ht, "{keys*}", "key1,val1,key2,val2")
|
||||||
|
uri_template_string (ht, "{keys+}", "keys.key1,val1,keys.key2,val2")
|
||||||
|
|
||||||
|
--| Reserved expansion with comma-separated values
|
||||||
|
uri_template_string (ht, "{+var}", "value")
|
||||||
|
uri_template_string (ht, "{+hello}", "Hello+World!")
|
||||||
|
uri_template_string (ht, "{+path}/here", "/foo/bar/here")
|
||||||
|
uri_template_string (ht, "{+path,x}/here", "/foo/bar,1024/here")
|
||||||
|
uri_template_string (ht, "{+path}{x}/here", "/foo/bar1024/here")
|
||||||
|
uri_template_string (ht, "{+empty}/here", "/here")
|
||||||
|
uri_template_string (ht, "{+undef}/here", "/here")
|
||||||
|
uri_template_string (ht, "{+list}", "val1,val2,val3")
|
||||||
|
uri_template_string (ht, "{+list*}", "val1,val2,val3")
|
||||||
|
uri_template_string (ht, "{+list+}", "list.val1,list.val2,list.val3")
|
||||||
|
uri_template_string (ht, "{+keys}", "key1,val1,key2,val2")
|
||||||
|
uri_template_string (ht, "{+keys*}", "key1,val1,key2,val2")
|
||||||
|
uri_template_string (ht, "{+keys+}", "keys.key1,val1,keys.key2,val2")
|
||||||
|
|
||||||
|
--| Path-style parameters, semicolon-prefixed
|
||||||
|
uri_template_string (ht, "{;x,y}", ";x=1024;y=768")
|
||||||
|
uri_template_string (ht, "{;x,y,empty}", ";x=1024;y=768;empty")
|
||||||
|
uri_template_string (ht, "{;x,y,undef}", ";x=1024;y=768")
|
||||||
|
uri_template_string (ht, "{;list}", ";list=val1,val2,val3") -- DIFF
|
||||||
|
uri_template_string (ht, "{;list*}", ";val1;val2;val3")
|
||||||
|
uri_template_string (ht, "{;list+}", ";list=val1;list=val2;list=val3")
|
||||||
|
uri_template_string (ht, "{;keys}", ";key1,val1,key2,val2")
|
||||||
|
uri_template_string (ht, "{;keys*}", ";key1=val1;key2=val2")
|
||||||
|
uri_template_string (ht, "{;keys+}", ";keys.key1=val1;keys.key2=val2")
|
||||||
|
|
||||||
|
--| Form-style parameters, ampersand-separated
|
||||||
|
uri_template_string (ht, "{?x,y}", "?x=1024&y=768")
|
||||||
|
uri_template_string (ht, "{?x,y,empty}", "?x=1024&y=768&empty=")
|
||||||
|
uri_template_string (ht, "{?x,y,undef}", "?x=1024&y=768")
|
||||||
|
uri_template_string (ht, "{?list}", "?list=val1,val2,val3")
|
||||||
|
uri_template_string (ht, "{?list*}", "?val1&val2&val3")
|
||||||
|
uri_template_string (ht, "{?list+}", "?list=val1&list=val2&list=val3")
|
||||||
|
uri_template_string (ht, "{?keys}", "?keys=key1,val1,key2,val2")
|
||||||
|
uri_template_string (ht, "{?keys*}", "?key1=val1&key2=val2")
|
||||||
|
uri_template_string (ht, "{?keys+}", "?keys.key1=val1&keys.key2=val2")
|
||||||
|
|
||||||
|
--| Hierarchical path segments, slash-separated
|
||||||
|
uri_template_string (ht, "{/var}", "/value")
|
||||||
|
uri_template_string (ht, "{/var,empty}", "/value/")
|
||||||
|
uri_template_string (ht, "{/var,undef}", "/value")
|
||||||
|
uri_template_string (ht, "{/list}", "/val1,val2,val3")
|
||||||
|
uri_template_string (ht, "{/list*}", "/val1/val2/val3")
|
||||||
|
uri_template_string (ht, "{/list*,x}", "/val1/val2/val3/1024")
|
||||||
|
uri_template_string (ht, "{/list+}", "/list.val1/list.val2/list.val3")
|
||||||
|
uri_template_string (ht, "{/keys}", "/key1,val1,key2,val2")
|
||||||
|
uri_template_string (ht, "{/keys*}", "/key1/val1/key2/val2")
|
||||||
|
uri_template_string (ht, "{/keys+}", "/keys.key1/val1/keys.key2/val2")
|
||||||
|
|
||||||
|
--| Label expansion, dot-prefixed
|
||||||
|
uri_template_string (ht, "X{.var}", "X.value")
|
||||||
|
uri_template_string (ht, "X{.empty}", "X.")
|
||||||
|
uri_template_string (ht, "X{.undef}", "X")
|
||||||
|
uri_template_string (ht, "X{.list}", "X.val1,val2,val3")
|
||||||
|
uri_template_string (ht, "X{.list*}", "X.val1.val2.val3")
|
||||||
|
uri_template_string (ht, "X{.list*,x}", "X.val1.val2.val3.1024")
|
||||||
|
uri_template_string (ht, "X{.list+}", "X.list.val1.list.val2.list.val3")
|
||||||
|
uri_template_string (ht, "X{.keys}", "X.key1,val1,key2,val2")
|
||||||
|
uri_template_string (ht, "X{.keys*}", "X.key1.val1.key2.val2")
|
||||||
|
uri_template_string (ht, "X{.keys+}", "X.keys.key1.val1.keys.key2.val2")
|
||||||
|
|
||||||
|
--| Simple Expansion
|
||||||
|
uri_template_string (ht, "{foo}", "fred")
|
||||||
|
uri_template_string (ht, "{foo,foo}", "fred,fred")
|
||||||
|
uri_template_string (ht, "{bar,foo}", "fred")
|
||||||
|
uri_template_string (ht, "{bar|wilma}", "wilma")
|
||||||
|
|
||||||
|
--| Reserved Expansion
|
||||||
|
uri_template_string (ht, "{foo2}", "That%%27s+right%%21")
|
||||||
|
uri_template_string (ht, "{+foo2}", "That%%27s+right!")
|
||||||
|
uri_template_string (ht, "{base}index", "http%%3A%%2F%%2Fexample.com%%2Fhome%%2Findex")
|
||||||
|
uri_template_string (ht, "{+base}index", "http://example.com/home/index")
|
||||||
|
|
||||||
|
assert ("all strings built", uri_template_string_errors = Void or (attached uri_template_string_errors as err and then err.is_empty))
|
||||||
|
end
|
||||||
|
|
||||||
|
uri_template_string (a_ht: HASH_TABLE [detachable ANY, STRING]; a_expression: STRING; a_expected: STRING)
|
||||||
|
local
|
||||||
|
tpl: URI_TEMPLATE
|
||||||
|
s: STRING
|
||||||
|
m: STRING
|
||||||
|
do
|
||||||
|
create tpl.make (a_expression)
|
||||||
|
s := tpl.expanded_string (a_ht)
|
||||||
|
if not s.same_string (a_expected) then
|
||||||
|
m := "Expected string for %"" + a_expression + "%" expected=%""+ a_expected +"%" but got %"" + s + "%"%N"
|
||||||
|
if attached uri_template_string_errors as err then
|
||||||
|
print (m)
|
||||||
|
err.force (m)
|
||||||
|
else
|
||||||
|
assert (m, False)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
uri_template_parse (s: STRING_8; path_vars: ARRAY [STRING]; query_vars: ARRAY [STRING])
|
||||||
|
local
|
||||||
|
u: URI_TEMPLATE
|
||||||
|
matched: BOOLEAN
|
||||||
|
i: INTEGER
|
||||||
|
do
|
||||||
|
create u.make (s)
|
||||||
|
if attached u.path_variable_names as vars then
|
||||||
|
matched := vars.count = path_vars.count
|
||||||
|
from
|
||||||
|
i := path_vars.lower
|
||||||
|
vars.start
|
||||||
|
until
|
||||||
|
not matched or i > path_vars.upper
|
||||||
|
loop
|
||||||
|
matched := vars.item.same_string (path_vars[i])
|
||||||
|
vars.forth
|
||||||
|
i := i + 1
|
||||||
|
end
|
||||||
|
else
|
||||||
|
matched := path_vars.is_empty
|
||||||
|
end
|
||||||
|
assert ("path variables matched", matched)
|
||||||
|
|
||||||
|
if attached u.query_variable_names as vars then
|
||||||
|
matched := vars.count = query_vars.count
|
||||||
|
from
|
||||||
|
i := query_vars.lower
|
||||||
|
vars.start
|
||||||
|
until
|
||||||
|
not matched or i > query_vars.upper
|
||||||
|
loop
|
||||||
|
matched := vars.item.same_string (query_vars[i])
|
||||||
|
vars.forth
|
||||||
|
i := i + 1
|
||||||
|
end
|
||||||
|
else
|
||||||
|
matched := query_vars.is_empty
|
||||||
|
end
|
||||||
|
assert ("query variables matched", matched)
|
||||||
|
end
|
||||||
|
|
||||||
|
uri_template_mismatch (a_uri_template: URI_TEMPLATE; a_uri: STRING)
|
||||||
|
local
|
||||||
|
l_match: detachable URI_TEMPLATE_MATCH_RESULT
|
||||||
|
do
|
||||||
|
l_match := a_uri_template.match (a_uri)
|
||||||
|
assert ("uri %"" + a_uri + "%" does not match template %"" + a_uri_template.template + "%"", l_match = Void)
|
||||||
|
end
|
||||||
|
|
||||||
|
uri_template_match (a_uri_template: URI_TEMPLATE; a_uri: STRING; path_res: ARRAY [TUPLE [name: STRING; value: STRING]]; query_res: ARRAY [TUPLE [name: STRING; value: STRING]])
|
||||||
|
local
|
||||||
|
b: BOOLEAN
|
||||||
|
i: INTEGER
|
||||||
|
l_match: detachable URI_TEMPLATE_MATCH_RESULT
|
||||||
|
do
|
||||||
|
l_match := a_uri_template.match (a_uri)
|
||||||
|
if l_match /= Void then
|
||||||
|
if attached l_match.path_variables as path_ht then
|
||||||
|
b := path_ht.count = path_res.count
|
||||||
|
from
|
||||||
|
i := path_res.lower
|
||||||
|
until
|
||||||
|
not b or i > path_res.upper
|
||||||
|
loop
|
||||||
|
b := attached path_ht.item (path_res[i].name) as s and then s.same_string (path_res[i].value)
|
||||||
|
i := i + 1
|
||||||
|
end
|
||||||
|
assert ("uri matched path variables", b)
|
||||||
|
end
|
||||||
|
if attached l_match.query_variables as query_ht then
|
||||||
|
b := query_ht.count >= query_res.count
|
||||||
|
from
|
||||||
|
i := query_res.lower
|
||||||
|
until
|
||||||
|
not b or i > query_res.upper
|
||||||
|
loop
|
||||||
|
b := attached query_ht.item (query_res[i].name) as s and then s.same_string (query_res[i].value)
|
||||||
|
i := i + 1
|
||||||
|
end
|
||||||
|
assert ("uri matched query variables", b)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
assert ("uri matched", False)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
note
|
||||||
|
copyright: "2011-2011, Eiffel Software and others"
|
||||||
|
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||||
|
source: "[
|
||||||
|
Eiffel Software
|
||||||
|
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||||
|
Telephone 805-685-1006, Fax 805-685-6869
|
||||||
|
Website http://www.eiffel.com
|
||||||
|
Customer support http://support.eiffel.com
|
||||||
|
]"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -114,9 +114,9 @@ feature -- Test routines
|
|||||||
uri_template_string (ht, "O{undef}X", "OX")
|
uri_template_string (ht, "O{undef}X", "OX")
|
||||||
|
|
||||||
--| String expansion with defaults
|
--| String expansion with defaults
|
||||||
uri_template_string (ht, "{var|default}", "value")
|
uri_template_string (ht, "{var=default}", "value")
|
||||||
uri_template_string (ht, "O{empty|default}X", "OX")
|
uri_template_string (ht, "O{empty=default}X", "OX")
|
||||||
uri_template_string (ht, "O{undef|default}X", "OdefaultX")
|
uri_template_string (ht, "O{undef=default}X", "OdefaultX")
|
||||||
|
|
||||||
--| Reserved expansion with defaults
|
--| Reserved expansion with defaults
|
||||||
uri_template_string (ht, "{+var}", "value")
|
uri_template_string (ht, "{+var}", "value")
|
||||||
@@ -124,8 +124,8 @@ feature -- Test routines
|
|||||||
uri_template_string (ht, "{+path}/here", "/foo/bar/here")
|
uri_template_string (ht, "{+path}/here", "/foo/bar/here")
|
||||||
uri_template_string (ht, "here?ref={+path}", "here?ref=/foo/bar")
|
uri_template_string (ht, "here?ref={+path}", "here?ref=/foo/bar")
|
||||||
uri_template_string (ht, "up{+path}{x}/here", "up/foo/bar1024/here")
|
uri_template_string (ht, "up{+path}{x}/here", "up/foo/bar1024/here")
|
||||||
uri_template_string (ht, "up{+empty|/1}/here", "up/here")
|
uri_template_string (ht, "up{+empty=/1}/here", "up/here")
|
||||||
uri_template_string (ht, "up{+undef|/1}/here", "up/1/here")
|
uri_template_string (ht, "up{+undef=/1}/here", "up/1/here")
|
||||||
|
|
||||||
--| String expansion with multiple variables
|
--| String expansion with multiple variables
|
||||||
uri_template_string (ht, "{x,y}", "1024,768")
|
uri_template_string (ht, "{x,y}", "1024,768")
|
||||||
@@ -133,7 +133,7 @@ feature -- Test routines
|
|||||||
uri_template_string (ht, "?{x,empty}", "?1024,")
|
uri_template_string (ht, "?{x,empty}", "?1024,")
|
||||||
uri_template_string (ht, "?{x,undef}", "?1024")
|
uri_template_string (ht, "?{x,undef}", "?1024")
|
||||||
uri_template_string (ht, "?{undef,y}", "?768")
|
uri_template_string (ht, "?{undef,y}", "?768")
|
||||||
uri_template_string (ht, "?{x,undef|0}", "?1024,0")
|
uri_template_string (ht, "?{x,undef=0}", "?1024,0")
|
||||||
|
|
||||||
--| Reserved expansion with multiple variables
|
--| Reserved expansion with multiple variables
|
||||||
uri_template_string (ht, "{+x,hello,y}", "1024,Hello+World!,768")
|
uri_template_string (ht, "{+x,hello,y}", "1024,Hello+World!,768")
|
||||||
@@ -164,6 +164,9 @@ feature -- Test routines
|
|||||||
--| String expansion with value modifiers
|
--| String expansion with value modifiers
|
||||||
uri_template_string (ht, "{var:3}", "val")
|
uri_template_string (ht, "{var:3}", "val")
|
||||||
uri_template_string (ht, "{var:30}", "value")
|
uri_template_string (ht, "{var:30}", "value")
|
||||||
|
uri_template_string (ht, "{var^3}", "ue")
|
||||||
|
uri_template_string (ht, "{var^-3}", "va")
|
||||||
|
|
||||||
uri_template_string (ht, "{list}", "red,green,blue")
|
uri_template_string (ht, "{list}", "red,green,blue")
|
||||||
uri_template_string (ht, "{list*}", "red,green,blue")
|
uri_template_string (ht, "{list*}", "red,green,blue")
|
||||||
uri_template_string (ht, "{keys}", "semi,%%3B,dot,.,comma,%%2C")
|
uri_template_string (ht, "{keys}", "semi,%%3B,dot,.,comma,%%2C")
|
||||||
@@ -203,7 +206,6 @@ feature -- Test routines
|
|||||||
uri_template_string (ht, "{?keys}", "?keys=semi,%%3B,dot,.,comma,%%2C")
|
uri_template_string (ht, "{?keys}", "?keys=semi,%%3B,dot,.,comma,%%2C")
|
||||||
uri_template_string (ht, "{?keys*}", "?semi=%%3B&dot=.&comma=%%2C")
|
uri_template_string (ht, "{?keys*}", "?semi=%%3B&dot=.&comma=%%2C")
|
||||||
|
|
||||||
|
|
||||||
assert ("all strings built", uri_template_string_errors = Void or (attached uri_template_string_errors as err and then err.is_empty))
|
assert ("all strings built", uri_template_string_errors = Void or (attached uri_template_string_errors as err and then err.is_empty))
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -279,153 +281,153 @@ feature -- Test routines
|
|||||||
"weather/California/Goleta?forecast=today")
|
"weather/California/Goleta?forecast=today")
|
||||||
|
|
||||||
|
|
||||||
uri_template_string (ht, "{var|default}", "value")
|
uri_template_string (ht, "{var=default}", "value")
|
||||||
uri_template_string (ht, "{undef|default}", "default")
|
uri_template_string (ht, "{undef=default}", "default")
|
||||||
uri_template_string (ht, "{undef:3|default}", "default")
|
uri_template_string (ht, "{undef:3=default}", "default")
|
||||||
|
|
||||||
uri_template_string (ht, "x{empty}y", "xy")
|
uri_template_string (ht, "x{empty}y", "xy")
|
||||||
uri_template_string (ht, "x{empty|_}y", "xy")
|
uri_template_string (ht, "x{empty=_}y", "xy")
|
||||||
uri_template_string (ht, "x{undef}y", "xy")
|
uri_template_string (ht, "x{undef}y", "xy")
|
||||||
uri_template_string (ht, "x{undef|_}y", "x_y")
|
uri_template_string (ht, "x{undef=_}y", "x_y")
|
||||||
|
|
||||||
uri_template_string (ht, "x{.name|none}", "x.Fred,Wilma,Pebbles")
|
uri_template_string (ht, "x{.name=none}", "x.Fred,Wilma,Pebbles")
|
||||||
uri_template_string (ht, "x{.name*|none}", "x.Fred.Wilma.Pebbles")
|
uri_template_string (ht, "x{.name*=none}", "x.Fred.Wilma.Pebbles")
|
||||||
uri_template_string (ht, "x{.empty}", "x.")
|
uri_template_string (ht, "x{.empty}", "x.")
|
||||||
uri_template_string (ht, "x{.empty|none}", "x.")
|
uri_template_string (ht, "x{.empty=none}", "x.")
|
||||||
uri_template_string (ht, "x{.undef}", "x")
|
uri_template_string (ht, "x{.undef}", "x")
|
||||||
uri_template_string (ht, "x{.undef|none}", "x.none")
|
uri_template_string (ht, "x{.undef=none}", "x.none")
|
||||||
|
|
||||||
uri_template_string (ht, "x{/name|none}", "x/Fred,Wilma,Pebbles")
|
uri_template_string (ht, "x{/name=none}", "x/Fred,Wilma,Pebbles")
|
||||||
uri_template_string (ht, "x{/name*|none}", "x/Fred/Wilma/Pebbles")
|
uri_template_string (ht, "x{/name*=none}", "x/Fred/Wilma/Pebbles")
|
||||||
uri_template_string (ht, "x{/undef}", "x")
|
uri_template_string (ht, "x{/undef}", "x")
|
||||||
uri_template_string (ht, "x{/undef|none}", "x/none")
|
uri_template_string (ht, "x{/undef=none}", "x/none")
|
||||||
uri_template_string (ht, "x{/empty}", "x/")
|
uri_template_string (ht, "x{/empty}", "x/")
|
||||||
uri_template_string (ht, "x{/empty|none}", "x/")
|
uri_template_string (ht, "x{/empty=none}", "x/")
|
||||||
uri_template_string (ht, "x{/empty_keys}", "x")
|
uri_template_string (ht, "x{/empty_keys}", "x")
|
||||||
uri_template_string (ht, "x{/empty_keys|none}", "x/none")
|
uri_template_string (ht, "x{/empty_keys=none}", "x/none")
|
||||||
uri_template_string (ht, "x{/empty_keys*}", "x")
|
uri_template_string (ht, "x{/empty_keys*}", "x")
|
||||||
uri_template_string (ht, "x{/empty_keys*|none}", "x/none")
|
uri_template_string (ht, "x{/empty_keys*=none}", "x/none")
|
||||||
|
|
||||||
uri_template_string (ht, "x{;name|none}", "x;name=Fred,Wilma,Pebbles")
|
uri_template_string (ht, "x{;name=none}", "x;name=Fred,Wilma,Pebbles")
|
||||||
uri_template_string (ht, "x{;favs|none}", "x;favs=color,red,volume,high")
|
uri_template_string (ht, "x{;favs=none}", "x;favs=color,red,volume,high")
|
||||||
uri_template_string (ht, "x{;favs*|none}", "x;color=red;volume=high")
|
uri_template_string (ht, "x{;favs*=none}", "x;color=red;volume=high")
|
||||||
uri_template_string (ht, "x{;empty}", "x;empty")
|
uri_template_string (ht, "x{;empty}", "x;empty")
|
||||||
uri_template_string (ht, "x{;empty|none}", "x;empty")
|
uri_template_string (ht, "x{;empty=none}", "x;empty")
|
||||||
|
|
||||||
uri_template_string (ht, "x{;undef}", "x")
|
uri_template_string (ht, "x{;undef}", "x")
|
||||||
uri_template_string (ht, "x{;undef|none}", "x;none")
|
uri_template_string (ht, "x{;undef=none}", "x;none")
|
||||||
uri_template_string (ht, "x{;undef|foo=y}", "x;foo=y")
|
uri_template_string (ht, "x{;undef=foo=y}", "x;foo=y")
|
||||||
|
|
||||||
uri_template_string (ht, "x{?var|none}", "x?var=value")
|
uri_template_string (ht, "x{?var=none}", "x?var=value")
|
||||||
uri_template_string (ht, "x{?favs|none}", "x?favs=color,red,volume,high")
|
uri_template_string (ht, "x{?favs=none}", "x?favs=color,red,volume,high")
|
||||||
uri_template_string (ht, "x{?favs*|none}", "x?color=red&volume=high")
|
uri_template_string (ht, "x{?favs*=none}", "x?color=red&volume=high")
|
||||||
uri_template_string (ht, "x{?empty}", "x?empty=")
|
uri_template_string (ht, "x{?empty}", "x?empty=")
|
||||||
uri_template_string (ht, "x{?empty|foo=none}", "x?empty=")
|
uri_template_string (ht, "x{?empty=foo=none}", "x?empty=")
|
||||||
uri_template_string (ht, "x{?undef}", "x")
|
uri_template_string (ht, "x{?undef}", "x")
|
||||||
uri_template_string (ht, "x{?undef|foo=none}", "x?foo=none")
|
uri_template_string (ht, "x{?undef=foo=none}", "x?foo=none")
|
||||||
uri_template_string (ht, "x{?empty_keys}", "x")
|
uri_template_string (ht, "x{?empty_keys}", "x")
|
||||||
uri_template_string (ht, "x{?empty_keys|none}", "x?none")
|
uri_template_string (ht, "x{?empty_keys=none}", "x?none")
|
||||||
uri_template_string (ht, "x{?empty_keys|y=z}", "x?y=z")
|
uri_template_string (ht, "x{?empty_keys=y=z}", "x?y=z")
|
||||||
uri_template_string (ht, "x{?empty_keys*|y=z}", "x?y=z")
|
uri_template_string (ht, "x{?empty_keys*=y=z}", "x?y=z")
|
||||||
|
|
||||||
|
|
||||||
------
|
------
|
||||||
|
|
||||||
uri_template_string (ht, "x{empty_list}y", "xy")
|
uri_template_string (ht, "x{empty_list}y", "xy")
|
||||||
uri_template_string (ht, "x{empty_list|_}y", "xy")
|
uri_template_string (ht, "x{empty_list=_}y", "xy")
|
||||||
uri_template_string (ht, "x{empty_list*}y", "xy")
|
uri_template_string (ht, "x{empty_list*}y", "xy")
|
||||||
uri_template_string (ht, "x{empty_list*|_}y", "x_y")
|
uri_template_string (ht, "x{empty_list*=_}y", "x_y")
|
||||||
uri_template_string (ht, "x{empty_list+}y", "xy")
|
uri_template_string (ht, "x{empty_list+}y", "xy")
|
||||||
uri_template_string (ht, "x{empty_list+|_}y", "xempty_list._y")
|
uri_template_string (ht, "x{empty_list+=_}y", "xempty_list._y")
|
||||||
|
|
||||||
uri_template_string (ht, "x{empty_keys}y", "xy")
|
uri_template_string (ht, "x{empty_keys}y", "xy")
|
||||||
uri_template_string (ht, "x{empty_keys|_}y", "xy")
|
uri_template_string (ht, "x{empty_keys=_}y", "xy")
|
||||||
uri_template_string (ht, "x{empty_keys*}y", "xy")
|
uri_template_string (ht, "x{empty_keys*}y", "xy")
|
||||||
uri_template_string (ht, "x{empty_keys*|_}y", "x_y")
|
uri_template_string (ht, "x{empty_keys*=_}y", "x_y")
|
||||||
uri_template_string (ht, "x{empty_keys+}y", "xy")
|
uri_template_string (ht, "x{empty_keys+}y", "xy")
|
||||||
uri_template_string (ht, "x{empty_keys+|_}y", "xempty_keys._y")
|
uri_template_string (ht, "x{empty_keys+=_}y", "xempty_keys._y")
|
||||||
|
|
||||||
uri_template_string (ht, "x{?name|none}", "x?name=Fred,Wilma,Pebbles")
|
uri_template_string (ht, "x{?name=none}", "x?name=Fred,Wilma,Pebbles")
|
||||||
uri_template_string (ht, "x{?favs|none}", "x?favs=color,red,volume,high")
|
uri_template_string (ht, "x{?favs=none}", "x?favs=color,red,volume,high")
|
||||||
uri_template_string (ht, "x{?favs*|none}", "x?color=red&volume=high")
|
uri_template_string (ht, "x{?favs*=none}", "x?color=red&volume=high")
|
||||||
uri_template_string (ht, "x{?favs+|none}", "x?favs.color=red&favs.volume=high")
|
uri_template_string (ht, "x{?favs+=none}", "x?favs.color=red&favs.volume=high")
|
||||||
|
|
||||||
uri_template_string (ht, "x{?undef}", "x")
|
uri_template_string (ht, "x{?undef}", "x")
|
||||||
uri_template_string (ht, "x{?undef|none}", "x?undef=none")
|
uri_template_string (ht, "x{?undef=none}", "x?undef=none")
|
||||||
uri_template_string (ht, "x{?empty}", "x?empty=")
|
uri_template_string (ht, "x{?empty}", "x?empty=")
|
||||||
uri_template_string (ht, "x{?empty|none}", "x?empty=")
|
uri_template_string (ht, "x{?empty=none}", "x?empty=")
|
||||||
|
|
||||||
uri_template_string (ht, "x{?empty_list}", "x")
|
uri_template_string (ht, "x{?empty_list}", "x")
|
||||||
uri_template_string (ht, "x{?empty_list|none}", "x?empty_list=none")
|
uri_template_string (ht, "x{?empty_list=none}", "x?empty_list=none")
|
||||||
uri_template_string (ht, "x{?empty_list*}", "x")
|
uri_template_string (ht, "x{?empty_list*}", "x")
|
||||||
uri_template_string (ht, "x{?empty_list*|none}", "x?none")
|
uri_template_string (ht, "x{?empty_list*=none}", "x?none")
|
||||||
uri_template_string (ht, "x{?empty_list+}", "x")
|
uri_template_string (ht, "x{?empty_list+}", "x")
|
||||||
uri_template_string (ht, "x{?empty_list+|none}", "x?empty_list.none")
|
uri_template_string (ht, "x{?empty_list+=none}", "x?empty_list.none")
|
||||||
|
|
||||||
uri_template_string (ht, "x{?empty_keys}", "x")
|
uri_template_string (ht, "x{?empty_keys}", "x")
|
||||||
uri_template_string (ht, "x{?empty_keys|none}", "x?empty_keys=none")
|
uri_template_string (ht, "x{?empty_keys=none}", "x?empty_keys=none")
|
||||||
uri_template_string (ht, "x{?empty_keys*}", "x")
|
uri_template_string (ht, "x{?empty_keys*}", "x")
|
||||||
uri_template_string (ht, "x{?empty_keys*|none}", "x?none")
|
uri_template_string (ht, "x{?empty_keys*=none}", "x?none")
|
||||||
uri_template_string (ht, "x{?empty_keys+}", "x")
|
uri_template_string (ht, "x{?empty_keys+}", "x")
|
||||||
uri_template_string (ht, "x{?empty_keys+|none}", "x?empty_keys.none")
|
uri_template_string (ht, "x{?empty_keys+=none}", "x?empty_keys.none")
|
||||||
|
|
||||||
uri_template_string (ht, "x{;name|none}", "x;name=Fred,Wilma,Pebbles")
|
uri_template_string (ht, "x{;name=none}", "x;name=Fred,Wilma,Pebbles")
|
||||||
uri_template_string (ht, "x{;favs|none}", "x;favs=color,red,volume,high")
|
uri_template_string (ht, "x{;favs=none}", "x;favs=color,red,volume,high")
|
||||||
uri_template_string (ht, "x{;favs*|none}", "x;color=red;volume=high")
|
uri_template_string (ht, "x{;favs*=none}", "x;color=red;volume=high")
|
||||||
uri_template_string (ht, "x{;favs+|none}", "x;favs.color=red;favs.volume=high")
|
uri_template_string (ht, "x{;favs+=none}", "x;favs.color=red;favs.volume=high")
|
||||||
uri_template_string (ht, "x{;undef}", "x")
|
uri_template_string (ht, "x{;undef}", "x")
|
||||||
uri_template_string (ht, "x{;undef|none}", "x;undef=none")
|
uri_template_string (ht, "x{;undef=none}", "x;undef=none")
|
||||||
uri_template_string (ht, "x{;undef|none}", "x;none")
|
uri_template_string (ht, "x{;undef=none}", "x;none")
|
||||||
uri_template_string (ht, "x{;empty}", "x;empty")
|
uri_template_string (ht, "x{;empty}", "x;empty")
|
||||||
uri_template_string (ht, "x{;empty|none}", "x;empty")
|
uri_template_string (ht, "x{;empty=none}", "x;empty")
|
||||||
|
|
||||||
uri_template_string (ht, "x{;empty_list}", "x")
|
uri_template_string (ht, "x{;empty_list}", "x")
|
||||||
uri_template_string (ht, "x{;empty_list|none}", "x;empty_list=none")
|
uri_template_string (ht, "x{;empty_list=none}", "x;empty_list=none")
|
||||||
uri_template_string (ht, "x{;empty_list*}", "x")
|
uri_template_string (ht, "x{;empty_list*}", "x")
|
||||||
uri_template_string (ht, "x{;empty_list*|none}", "x;none")
|
uri_template_string (ht, "x{;empty_list*=none}", "x;none")
|
||||||
uri_template_string (ht, "x{;empty_list+}", "x")
|
uri_template_string (ht, "x{;empty_list+}", "x")
|
||||||
uri_template_string (ht, "x{;empty_list+|none}", "x;empty_list.none")
|
uri_template_string (ht, "x{;empty_list+=none}", "x;empty_list.none")
|
||||||
|
|
||||||
uri_template_string (ht, "x{;empty_keys}", "x")
|
uri_template_string (ht, "x{;empty_keys}", "x")
|
||||||
uri_template_string (ht, "x{;empty_keys|none}", "x;empty_keys=none")
|
uri_template_string (ht, "x{;empty_keys=none}", "x;empty_keys=none")
|
||||||
uri_template_string (ht, "x{;empty_keys*}", "x")
|
uri_template_string (ht, "x{;empty_keys*}", "x")
|
||||||
uri_template_string (ht, "x{;empty_keys*|none}", "x;none")
|
uri_template_string (ht, "x{;empty_keys*=none}", "x;none")
|
||||||
uri_template_string (ht, "x{;empty_keys+}", "x")
|
uri_template_string (ht, "x{;empty_keys+}", "x")
|
||||||
uri_template_string (ht, "x{;empty_keys+|none}", "x;empty_keys.none")
|
uri_template_string (ht, "x{;empty_keys+=none}", "x;empty_keys.none")
|
||||||
|
|
||||||
uri_template_string (ht, "x{/name|none}", "x/Fred,Wilma,Pebbles")
|
uri_template_string (ht, "x{/name=none}", "x/Fred,Wilma,Pebbles")
|
||||||
uri_template_string (ht, "x{/name*|none}", "x/Fred/Wilma/Pebbles")
|
uri_template_string (ht, "x{/name*=none}", "x/Fred/Wilma/Pebbles")
|
||||||
uri_template_string (ht, "x{/name+|none}", "x/name.Fred/name.Wilma/name.Pebbles")
|
uri_template_string (ht, "x{/name+=none}", "x/name.Fred/name.Wilma/name.Pebbles")
|
||||||
uri_template_string (ht, "x{/favs|none}", "x/color,red,volume,high")
|
uri_template_string (ht, "x{/favs=none}", "x/color,red,volume,high")
|
||||||
uri_template_string (ht, "x{/favs*|none}", "x/color/red/volume/high")
|
uri_template_string (ht, "x{/favs*=none}", "x/color/red/volume/high")
|
||||||
uri_template_string (ht, "x{/favs+|none}", "x/favs.color/red/favs.volume/high")
|
uri_template_string (ht, "x{/favs+=none}", "x/favs.color/red/favs.volume/high")
|
||||||
|
|
||||||
uri_template_string (ht, "x{/undef}", "x")
|
uri_template_string (ht, "x{/undef}", "x")
|
||||||
uri_template_string (ht, "x{/undef|none}", "x/none")
|
uri_template_string (ht, "x{/undef=none}", "x/none")
|
||||||
uri_template_string (ht, "x{/empty}", "x/")
|
uri_template_string (ht, "x{/empty}", "x/")
|
||||||
uri_template_string (ht, "x{/empty|none}", "x/")
|
uri_template_string (ht, "x{/empty=none}", "x/")
|
||||||
|
|
||||||
uri_template_string (ht, "x{/empty_list}", "x")
|
uri_template_string (ht, "x{/empty_list}", "x")
|
||||||
uri_template_string (ht, "x{/empty_list|none}", "x/none")
|
uri_template_string (ht, "x{/empty_list=none}", "x/none")
|
||||||
uri_template_string (ht, "x{/empty_list*}", "x")
|
uri_template_string (ht, "x{/empty_list*}", "x")
|
||||||
uri_template_string (ht, "x{/empty_list*|none}", "x/none")
|
uri_template_string (ht, "x{/empty_list*=none}", "x/none")
|
||||||
uri_template_string (ht, "x{/empty_list+}", "x")
|
uri_template_string (ht, "x{/empty_list+}", "x")
|
||||||
uri_template_string (ht, "x{/empty_list+|none}", "x/empty_list.none")
|
uri_template_string (ht, "x{/empty_list+=none}", "x/empty_list.none")
|
||||||
|
|
||||||
uri_template_string (ht, "x{/empty_keys}", "x")
|
uri_template_string (ht, "x{/empty_keys}", "x")
|
||||||
uri_template_string (ht, "x{/empty_keys|none}", "x/none")
|
uri_template_string (ht, "x{/empty_keys=none}", "x/none")
|
||||||
uri_template_string (ht, "x{/empty_keys*}", "x")
|
uri_template_string (ht, "x{/empty_keys*}", "x")
|
||||||
uri_template_string (ht, "x{/empty_keys*|none}", "x/none")
|
uri_template_string (ht, "x{/empty_keys*=none}", "x/none")
|
||||||
uri_template_string (ht, "x{/empty_keys+}", "x")
|
uri_template_string (ht, "x{/empty_keys+}", "x")
|
||||||
uri_template_string (ht, "x{/empty_keys+|none}", "x/empty_keys.none")
|
uri_template_string (ht, "x{/empty_keys+=none}", "x/empty_keys.none")
|
||||||
|
|
||||||
--| Simple expansion with comma-separated values
|
--| Simple expansion with comma-separated values
|
||||||
uri_template_string (ht, "{var}", "value")
|
uri_template_string (ht, "{var}", "value")
|
||||||
uri_template_string (ht, "{hello}", "Hello+World%%21")
|
uri_template_string (ht, "{hello}", "Hello+World%%21")
|
||||||
uri_template_string (ht, "{path}/here", "%%2Ffoo%%2Fbar/here")
|
uri_template_string (ht, "{path}/here", "%%2Ffoo%%2Fbar/here")
|
||||||
uri_template_string (ht, "{x,y}", "1024,768")
|
uri_template_string (ht, "{x,y}", "1024,768")
|
||||||
uri_template_string (ht, "{var|default}", "value")
|
uri_template_string (ht, "{var=default}", "value")
|
||||||
uri_template_string (ht, "{undef|default}", "default")
|
uri_template_string (ht, "{undef=default}", "default")
|
||||||
uri_template_string (ht, "{list}", "val1,val2,val3")
|
uri_template_string (ht, "{list}", "val1,val2,val3")
|
||||||
uri_template_string (ht, "{list*}", "val1,val2,val3")
|
uri_template_string (ht, "{list*}", "val1,val2,val3")
|
||||||
uri_template_string (ht, "{list+}", "list.val1,list.val2,list.val3")
|
uri_template_string (ht, "{list+}", "list.val1,list.val2,list.val3")
|
||||||
@@ -498,7 +500,7 @@ feature -- Test routines
|
|||||||
uri_template_string (ht, "{foo}", "fred")
|
uri_template_string (ht, "{foo}", "fred")
|
||||||
uri_template_string (ht, "{foo,foo}", "fred,fred")
|
uri_template_string (ht, "{foo,foo}", "fred,fred")
|
||||||
uri_template_string (ht, "{bar,foo}", "fred")
|
uri_template_string (ht, "{bar,foo}", "fred")
|
||||||
uri_template_string (ht, "{bar|wilma}", "wilma")
|
uri_template_string (ht, "{bar=wilma}", "wilma")
|
||||||
|
|
||||||
--| Reserved Expansion
|
--| Reserved Expansion
|
||||||
uri_template_string (ht, "{foo2}", "That%%27s+right%%21")
|
uri_template_string (ht, "{foo2}", "That%%27s+right%%21")
|
||||||
@@ -516,7 +518,7 @@ feature -- Test routines
|
|||||||
m: STRING
|
m: STRING
|
||||||
do
|
do
|
||||||
create tpl.make (a_expression)
|
create tpl.make (a_expression)
|
||||||
s := tpl.string (a_ht)
|
s := tpl.expanded_string (a_ht)
|
||||||
if not s.same_string (a_expected) then
|
if not s.same_string (a_expected) then
|
||||||
m := "Expected string for %"" + a_expression + "%" expected=%""+ a_expected +"%" but got %"" + s + "%"%N"
|
m := "Expected string for %"" + a_expression + "%" expected=%""+ a_expected +"%" but got %"" + s + "%"%N"
|
||||||
if attached uri_template_string_errors as err then
|
if attached uri_template_string_errors as err then
|
||||||
@@ -596,7 +598,7 @@ feature -- Test routines
|
|||||||
b := attached path_ht.item (path_res[i].name) as s and then s.same_string (path_res[i].value)
|
b := attached path_ht.item (path_res[i].name) as s and then s.same_string (path_res[i].value)
|
||||||
i := i + 1
|
i := i + 1
|
||||||
end
|
end
|
||||||
assert ("uri matched path variables", b)
|
assert ("uri %"" + a_uri + "%" matched path variables", b)
|
||||||
end
|
end
|
||||||
if attached l_match.query_variables as query_ht then
|
if attached l_match.query_variables as query_ht then
|
||||||
b := query_ht.count >= query_res.count
|
b := query_ht.count >= query_res.count
|
||||||
@@ -608,10 +610,10 @@ feature -- Test routines
|
|||||||
b := attached query_ht.item (query_res[i].name) as s and then s.same_string (query_res[i].value)
|
b := attached query_ht.item (query_res[i].name) as s and then s.same_string (query_res[i].value)
|
||||||
i := i + 1
|
i := i + 1
|
||||||
end
|
end
|
||||||
assert ("uri matched query variables", b)
|
assert ("uri %"" + a_uri + "%" matched query variables", b)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
assert ("uri matched", False)
|
assert ("uri %"" + a_uri + "%" matched", False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,22 @@
|
|||||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||||
<library name="encoder" location="..\..\text\encoder\encoder-safe.ecf"/>
|
<library name="encoder" location="..\..\text\encoder\encoder-safe.ecf"/>
|
||||||
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
|
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
|
||||||
<cluster name="src" location="src\" recursive="true"/>
|
<cluster name="src" location="src\" recursive="true">
|
||||||
|
<file_rule>
|
||||||
|
<exclude>/draft_05$</exclude>
|
||||||
|
</file_rule>
|
||||||
|
<file_rule>
|
||||||
|
<exclude>/uri_template_constants.e</exclude>
|
||||||
|
<condition>
|
||||||
|
<custom name="uri_template" value="draft_05"/>
|
||||||
|
</condition>
|
||||||
|
</file_rule>
|
||||||
|
</cluster>
|
||||||
|
<cluster name="draft_05" location=".\src\draft_05\">
|
||||||
|
<condition>
|
||||||
|
<custom name="uri_template" value="draft_05"/>
|
||||||
|
</condition>
|
||||||
|
</cluster>
|
||||||
</target>
|
</target>
|
||||||
<target name="tests" extends="uri_template">
|
<target name="tests" extends="uri_template">
|
||||||
<root class="ANY" feature="default_create"/>
|
<root class="ANY" feature="default_create"/>
|
||||||
@@ -26,6 +41,7 @@
|
|||||||
<assertions precondition="true"/>
|
<assertions precondition="true"/>
|
||||||
</option>
|
</option>
|
||||||
<setting name="console_application" value="false"/>
|
<setting name="console_application" value="false"/>
|
||||||
|
<variable name="uri_template" value="draft_05"/>
|
||||||
<library name="testing" location="$ISE_LIBRARY\library\testing\testing-safe.ecf"/>
|
<library name="testing" location="$ISE_LIBRARY\library\testing\testing-safe.ecf"/>
|
||||||
<tests name="tests" location=".\tests\"/>
|
<tests name="tests" location=".\tests\"/>
|
||||||
</target>
|
</target>
|
||||||
|
|||||||
@@ -7,12 +7,45 @@
|
|||||||
<exclude>/EIFGENs$</exclude>
|
<exclude>/EIFGENs$</exclude>
|
||||||
<exclude>/.svn$</exclude>
|
<exclude>/.svn$</exclude>
|
||||||
</file_rule>
|
</file_rule>
|
||||||
|
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all">
|
||||||
|
<assertions precondition="true"/>
|
||||||
|
</option>
|
||||||
<option warning="true" full_class_checking="true">
|
<option warning="true" full_class_checking="true">
|
||||||
<assertions precondition="true"/>
|
<assertions precondition="true"/>
|
||||||
</option>
|
</option>
|
||||||
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
|
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
|
||||||
|
<library name="encoder" location="..\..\text\encoder\encoder.ecf"/>
|
||||||
<library name="time" location="$ISE_LIBRARY\library\time\time.ecf"/>
|
<library name="time" location="$ISE_LIBRARY\library\time\time.ecf"/>
|
||||||
<cluster name="src" location="src\" recursive="true"/>
|
<cluster name="src" location="src\" recursive="true">
|
||||||
|
<file_rule>
|
||||||
|
<exclude>/draft_05$</exclude>
|
||||||
|
</file_rule>
|
||||||
|
<file_rule>
|
||||||
|
<exclude>/uri_template_constants.e</exclude>
|
||||||
|
<condition>
|
||||||
|
<custom name="uri_template" value="draft_05"/>
|
||||||
|
</condition>
|
||||||
|
</file_rule>
|
||||||
|
</cluster>
|
||||||
|
<cluster name="draft_05" location=".\src\draft_05\">
|
||||||
|
<condition>
|
||||||
|
<custom name="uri_template" value="draft_05"/>
|
||||||
|
</condition>
|
||||||
|
</cluster>
|
||||||
|
</target>
|
||||||
|
<target name="tests" extends="uri_template">
|
||||||
|
<root class="ANY" feature="default_create"/>
|
||||||
|
<file_rule>
|
||||||
|
<exclude>/.git$</exclude>
|
||||||
|
<exclude>/EIFGENs$</exclude>
|
||||||
|
<exclude>/.svn$</exclude>
|
||||||
|
</file_rule>
|
||||||
|
<option warning="true" full_class_checking="true">
|
||||||
|
<assertions precondition="true"/>
|
||||||
|
</option>
|
||||||
|
<setting name="console_application" value="false"/>
|
||||||
|
<variable name="uri_template" value="draft_05"/>
|
||||||
|
<library name="testing" location="$ISE_LIBRARY\library\testing\testing.ecf"/>
|
||||||
|
<tests name="tests" location=".\tests\"/>
|
||||||
</target>
|
</target>
|
||||||
</system>
|
</system>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user