hq-engine-xqilla 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/features/functions.feature +90 -0
- data/features/support/env.rb +34 -0
- data/features/support/steps.rb +127 -0
- data/features/xquery-server.feature +68 -0
- data/src/Rakefile +2 -3
- metadata +26 -2
@@ -0,0 +1,90 @@
|
|
1
|
+
Feature: Callback functions
|
2
|
+
|
3
|
+
Scenario: Get by id
|
4
|
+
|
5
|
+
When I compile the query:
|
6
|
+
"""
|
7
|
+
declare namespace hq = "hq";
|
8
|
+
declare function hq:get (
|
9
|
+
$id as xs:string
|
10
|
+
) as element () external;
|
11
|
+
hq:get ('a')
|
12
|
+
"""
|
13
|
+
|
14
|
+
And I run the query against:
|
15
|
+
"""
|
16
|
+
<doc/>
|
17
|
+
"""
|
18
|
+
|
19
|
+
Then the result should be:
|
20
|
+
"""
|
21
|
+
<get-record-by-id id="a"/>
|
22
|
+
"""
|
23
|
+
|
24
|
+
Scenario: Get by id parts
|
25
|
+
|
26
|
+
When I compile the query:
|
27
|
+
"""
|
28
|
+
declare namespace hq = "hq";
|
29
|
+
declare function hq:get (
|
30
|
+
$type as xs:string,
|
31
|
+
$id-parts as xs:string *
|
32
|
+
) as element () external;
|
33
|
+
hq:get ('a', ('b', 'c'))
|
34
|
+
"""
|
35
|
+
|
36
|
+
And I run the query against:
|
37
|
+
"""
|
38
|
+
<doc/>
|
39
|
+
"""
|
40
|
+
|
41
|
+
Then the result should be:
|
42
|
+
"""
|
43
|
+
<get-record-by-id id="a/b/c"/>
|
44
|
+
"""
|
45
|
+
|
46
|
+
Scenario: Find all by type
|
47
|
+
|
48
|
+
When I compile the query:
|
49
|
+
"""
|
50
|
+
declare namespace hq = "hq";
|
51
|
+
declare function hq:find (
|
52
|
+
$type as xs:string
|
53
|
+
) as element () external;
|
54
|
+
hq:find ('a')
|
55
|
+
"""
|
56
|
+
|
57
|
+
And I run the query against:
|
58
|
+
"""
|
59
|
+
<doc/>
|
60
|
+
"""
|
61
|
+
|
62
|
+
Then the result should be:
|
63
|
+
"""
|
64
|
+
<search-records type="a"/>
|
65
|
+
"""
|
66
|
+
|
67
|
+
Scenario: Find by type with criteria
|
68
|
+
|
69
|
+
When I compile the query:
|
70
|
+
"""
|
71
|
+
declare namespace hq = "hq";
|
72
|
+
declare function hq:find (
|
73
|
+
$type as xs:string,
|
74
|
+
$criteria as xs:string *
|
75
|
+
) as element () external;
|
76
|
+
hq:find ('a', ('b=1', 'c=2'))
|
77
|
+
"""
|
78
|
+
|
79
|
+
And I run the query against:
|
80
|
+
"""
|
81
|
+
<doc/>
|
82
|
+
"""
|
83
|
+
|
84
|
+
Then the result should be:
|
85
|
+
"""
|
86
|
+
<search-records type="a">
|
87
|
+
<criteria key="b" value="1"/>
|
88
|
+
<criteria key="c" value="2"/>
|
89
|
+
</search-records>
|
90
|
+
"""
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "yaml"
|
2
|
+
|
3
|
+
def rule_provider
|
4
|
+
|
5
|
+
return @rule_provider \
|
6
|
+
if @rule_provider
|
7
|
+
|
8
|
+
require "hq/engine/subprocess-rule-provider/start"
|
9
|
+
|
10
|
+
spec =
|
11
|
+
Gem::Specification.find_by_name \
|
12
|
+
"hq-engine-xqilla"
|
13
|
+
|
14
|
+
rule_provider_path =
|
15
|
+
"#{spec.gem_dir}/src/xquery-server"
|
16
|
+
|
17
|
+
@rule_provider =
|
18
|
+
HQ::Engine::SubProcessRuleProvider.start \
|
19
|
+
rule_provider_path
|
20
|
+
|
21
|
+
return @rule_provider
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
After do
|
26
|
+
@rule_provider.close if @rule_provider
|
27
|
+
end
|
28
|
+
|
29
|
+
def rule_provider_session
|
30
|
+
|
31
|
+
return @rule_provider_session ||=
|
32
|
+
rule_provider.session
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
Given /^an xquery module named "([^"]*)":$/ do
|
2
|
+
|module_name, module_text|
|
3
|
+
rule_provider_session.set_library_module module_name, module_text
|
4
|
+
end
|
5
|
+
|
6
|
+
Given /^an xquery script:$/ do
|
7
|
+
|xquery_text|
|
8
|
+
@xquery_text = xquery_text
|
9
|
+
end
|
10
|
+
|
11
|
+
Given /^an input document:$/ do
|
12
|
+
|input_text|
|
13
|
+
@input_text = input_text
|
14
|
+
end
|
15
|
+
|
16
|
+
Then /^the result should be:$/ do
|
17
|
+
|result_text|
|
18
|
+
@result_text.should == result_text
|
19
|
+
end
|
20
|
+
|
21
|
+
Then /^I should get an error$/ do
|
22
|
+
@exception.should_not be_nil
|
23
|
+
@exception = nil
|
24
|
+
end
|
25
|
+
|
26
|
+
Before do
|
27
|
+
@input_text = "<xml/>"
|
28
|
+
@exception = nil
|
29
|
+
end
|
30
|
+
|
31
|
+
When /^I compile the query$/ do
|
32
|
+
|
33
|
+
begin
|
34
|
+
|
35
|
+
@result_text =
|
36
|
+
rule_provider_session.compile_xquery \
|
37
|
+
@xquery_text,
|
38
|
+
"inline.xquery"
|
39
|
+
|
40
|
+
@exception = nil
|
41
|
+
|
42
|
+
rescue => exception
|
43
|
+
@exception = exception
|
44
|
+
@result_text = nil
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
When /^I run the query$/ do
|
49
|
+
|
50
|
+
require "xml"
|
51
|
+
|
52
|
+
begin
|
53
|
+
|
54
|
+
@result_text =
|
55
|
+
rule_provider_session.run_xquery @input_text \
|
56
|
+
do
|
57
|
+
|name, args|
|
58
|
+
|
59
|
+
case name
|
60
|
+
|
61
|
+
when "get record by id"
|
62
|
+
record = XML::Node.new "get-record-by-id"
|
63
|
+
args.each do
|
64
|
+
|name, value|
|
65
|
+
record[name] = value
|
66
|
+
end
|
67
|
+
[ record.to_s ]
|
68
|
+
|
69
|
+
when "get record by id parts"
|
70
|
+
record = XML::Node.new "get-record-by-id-parts"
|
71
|
+
record["type"] = args["type"]
|
72
|
+
args["id parts"].each do
|
73
|
+
|arg_part|
|
74
|
+
part = XML::Node.new "part"
|
75
|
+
part["value"] = arg_part
|
76
|
+
record << part
|
77
|
+
end
|
78
|
+
[ record.to_s ]
|
79
|
+
|
80
|
+
when "search records"
|
81
|
+
record = XML::Node.new "search-records"
|
82
|
+
record["type"] = args["type"]
|
83
|
+
(args["criteria"] || []).each do
|
84
|
+
|key, value|
|
85
|
+
criteria_elem = XML::Node.new "criteria"
|
86
|
+
criteria_elem["key"] = key
|
87
|
+
criteria_elem["value"] = value
|
88
|
+
record << criteria_elem
|
89
|
+
end
|
90
|
+
[ record.to_s ]
|
91
|
+
|
92
|
+
else
|
93
|
+
puts "ERROR #{name}"
|
94
|
+
[]
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
@exception = nil
|
101
|
+
|
102
|
+
rescue => exception
|
103
|
+
|
104
|
+
@exception = exception
|
105
|
+
@result_text = nil
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
When /^I compile the query:$/ do
|
112
|
+
|xquery_text|
|
113
|
+
step "an xquery script:", xquery_text
|
114
|
+
step "I compile the query"
|
115
|
+
end
|
116
|
+
|
117
|
+
When /^I run the query against:$/ do
|
118
|
+
|input_text|
|
119
|
+
step "an input document:", input_text
|
120
|
+
step "I run the query"
|
121
|
+
end
|
122
|
+
|
123
|
+
After do
|
124
|
+
if @exception
|
125
|
+
raise @exception
|
126
|
+
end
|
127
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
Feature: XQuery server
|
2
|
+
|
3
|
+
Scenario: Perform a transform
|
4
|
+
|
5
|
+
When I compile the query:
|
6
|
+
"""
|
7
|
+
1 + 1
|
8
|
+
"""
|
9
|
+
|
10
|
+
And I run the query
|
11
|
+
|
12
|
+
Then the result should be:
|
13
|
+
"""
|
14
|
+
2
|
15
|
+
"""
|
16
|
+
|
17
|
+
Scenario: Reference the source document
|
18
|
+
|
19
|
+
When I compile the query:
|
20
|
+
"""
|
21
|
+
string (/doc/elem/@attr)
|
22
|
+
"""
|
23
|
+
|
24
|
+
And I run the query against:
|
25
|
+
"""
|
26
|
+
<doc>
|
27
|
+
<elem attr="hello world"/>
|
28
|
+
</doc>
|
29
|
+
"""
|
30
|
+
|
31
|
+
Then the result should be:
|
32
|
+
"""
|
33
|
+
hello world
|
34
|
+
"""
|
35
|
+
|
36
|
+
Scenario: Import a module
|
37
|
+
|
38
|
+
Given an xquery module named "module.xquery":
|
39
|
+
"""
|
40
|
+
module namespace lib = "module.xquery";
|
41
|
+
declare function lib:message () as item () * {
|
42
|
+
("hello world 1", "hello world 2")
|
43
|
+
};
|
44
|
+
"""
|
45
|
+
|
46
|
+
When I compile the query:
|
47
|
+
"""
|
48
|
+
import module namespace lib = "module.xquery";
|
49
|
+
string-join (lib:message (), ', ')
|
50
|
+
"""
|
51
|
+
|
52
|
+
And I run the query
|
53
|
+
|
54
|
+
Then the result should be:
|
55
|
+
"""
|
56
|
+
hello world 1, hello world 2
|
57
|
+
"""
|
58
|
+
|
59
|
+
Scenario: Invalid xquery
|
60
|
+
|
61
|
+
When I compile the query:
|
62
|
+
"""
|
63
|
+
123;;;
|
64
|
+
"""
|
65
|
+
|
66
|
+
And I run the query
|
67
|
+
|
68
|
+
Then I should get an error
|
data/src/Rakefile
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hq-engine-xqilla
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -59,6 +59,22 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 1.2.1
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: libxml-ruby
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 2.6.0
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 2.6.0
|
62
78
|
- !ruby/object:Gem::Dependency
|
63
79
|
name: rake
|
64
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -134,6 +150,10 @@ files:
|
|
134
150
|
- src/Makefile
|
135
151
|
- src/Rakefile
|
136
152
|
- src/xquery-server.cc
|
153
|
+
- features/xquery-server.feature
|
154
|
+
- features/functions.feature
|
155
|
+
- features/support/steps.rb
|
156
|
+
- features/support/env.rb
|
137
157
|
homepage: https://github.com/jamespharaoh/hq-engine-xqilla
|
138
158
|
licenses: []
|
139
159
|
post_install_message:
|
@@ -158,4 +178,8 @@ rubygems_version: 1.8.23
|
|
158
178
|
signing_key:
|
159
179
|
specification_version: 3
|
160
180
|
summary: HQ engine xqilla
|
161
|
-
test_files:
|
181
|
+
test_files:
|
182
|
+
- features/xquery-server.feature
|
183
|
+
- features/functions.feature
|
184
|
+
- features/support/steps.rb
|
185
|
+
- features/support/env.rb
|