fabulator 0.0.14 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +6 -0
- data/VERSION +1 -1
- data/features/library.feature +69 -0
- data/features/simple-statemachine.feature +13 -0
- data/features/step_definitions/xml_steps.rb +13 -0
- data/lib/fabulator/core/actions/variables.rb +2 -2
- metadata +4 -3
data/History.txt
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.15
|
@@ -0,0 +1,69 @@
|
|
1
|
+
@library
|
2
|
+
Feature: Libraries
|
3
|
+
|
4
|
+
@library
|
5
|
+
Scenario: Using a actions and functions in a library
|
6
|
+
Given a context
|
7
|
+
And the prefix m as "http://example.com/ns/library"
|
8
|
+
And the prefix f as "http://dh.tamu.edu/ns/fabulator/1.0#"
|
9
|
+
Given the library
|
10
|
+
"""
|
11
|
+
<l:library
|
12
|
+
xmlns:l="http://dh.tamu.edu/ns/fabulator/library/1.0#"
|
13
|
+
xmlns:f="http://dh.tamu.edu/ns/fabulator/1.0#"
|
14
|
+
l:ns="http://example.com/ns/library"
|
15
|
+
xmlns:my="http://example.com/ns/library"
|
16
|
+
>
|
17
|
+
<l:mapping l:name="double">
|
18
|
+
<f:value-of f:select=". * 2" />
|
19
|
+
</l:mapping>
|
20
|
+
<l:function l:name="fctn">
|
21
|
+
<f:value-of f:select="$1 - $2" />
|
22
|
+
</l:function>
|
23
|
+
<l:function l:name="fctn2">
|
24
|
+
<f:value-of f:select="my:fctn($2, $1)" />
|
25
|
+
</l:function>
|
26
|
+
<l:action l:name="actn" l:has-actions="true">
|
27
|
+
<l:attribute l:name="foo" />
|
28
|
+
<f:value-of f:select="f:eval($actions) * 3" />
|
29
|
+
</l:action>
|
30
|
+
<l:action l:name="actn2" l:has-actions="true">
|
31
|
+
<my:actn><f:value-of f:select="f:eval($actions) * 5" /></my:actn>
|
32
|
+
</l:action>
|
33
|
+
<l:action l:name="actn3">
|
34
|
+
<l:attribute l:name="path" l:eval="true" />
|
35
|
+
<f:value f:path="f:eval($path)" f:select="3" />
|
36
|
+
</l:action>
|
37
|
+
<l:action l:name="actn4">
|
38
|
+
<l:attribute l:name="foo" l:eval="false" />
|
39
|
+
<f:value f:path="/actn4foo" f:select="f:eval($foo)" />
|
40
|
+
</l:action>
|
41
|
+
<l:template l:name="tmpl">
|
42
|
+
Foo
|
43
|
+
</l:template>
|
44
|
+
<l:template l:name="tmpl2">
|
45
|
+
<f:value-of f:select="$1" />
|
46
|
+
</l:template>
|
47
|
+
<l:template l:name="tmpl3">
|
48
|
+
<p>
|
49
|
+
<f:value-of f:select="$1" />
|
50
|
+
</p>
|
51
|
+
</l:template>
|
52
|
+
</l:library>
|
53
|
+
"""
|
54
|
+
And the statemachine
|
55
|
+
"""
|
56
|
+
<f:application xmlns:f="http://dh.tamu.edu/ns/fabulator/1.0#"
|
57
|
+
xmlns:m="http://example.com/ns/library"
|
58
|
+
>
|
59
|
+
<m:actn3 m:path="/actn3" />
|
60
|
+
<m:actn4 m:foo="bar" />
|
61
|
+
</f:application>
|
62
|
+
"""
|
63
|
+
Then the expression (/actn3) should equal [3]
|
64
|
+
And the expression (/actn4foo) should equal ['bar']
|
65
|
+
And the expression (m:fctn(3,2)) should equal [1]
|
66
|
+
And the expression (m:fctn2(2,3)) should equal [1]
|
67
|
+
And the expression (f:normalize-space(m:tmpl())) should equal ['Foo']
|
68
|
+
And the expression (f:normalize-space(m:tmpl2('Foo'))) should equal ['Foo']
|
69
|
+
And the expression (f:normalize-space(m:tmpl3('Foo'))) should equal ['<p> Foo </p>']
|
@@ -214,10 +214,23 @@ Feature: Simple state machines
|
|
214
214
|
</f:otherwise>
|
215
215
|
</f:choose>
|
216
216
|
</f:value>
|
217
|
+
<f:value f:path="/post/filter" f:select="'Markdown'" />
|
218
|
+
<f:variable f:name="filter">
|
219
|
+
<f:choose>
|
220
|
+
<f:when f:test="/post/filter = 'nil'">
|
221
|
+
<f:value-of f:select="''" />
|
222
|
+
</f:when>
|
223
|
+
<f:otherwise>
|
224
|
+
<f:value-of f:select="/post/filter" />
|
225
|
+
</f:otherwise>
|
226
|
+
</f:choose>
|
227
|
+
</f:variable>
|
228
|
+
<f:value f:path="/new-post/filter" f:select="$filter" />
|
217
229
|
</f:application>
|
218
230
|
"""
|
219
231
|
Then the expression (/foo) should equal [3]
|
220
232
|
Then the expression (/bar) should equal [3]
|
233
|
+
Then the expression (/new-post/filter) should equal ['Markdown']
|
221
234
|
|
222
235
|
@var
|
223
236
|
Scenario: simple machine with a <variable /> and <value />
|
@@ -11,6 +11,19 @@ Given /the statemachine/ do |doc_xml|
|
|
11
11
|
@sm.init_context(@context)
|
12
12
|
end
|
13
13
|
|
14
|
+
Given /the library/ do |doc_xml|
|
15
|
+
@context ||= Fabulator::Expr::Context.new
|
16
|
+
@compiler ||= Fabulator::Compiler.new
|
17
|
+
|
18
|
+
if @library.nil?
|
19
|
+
@library = @compiler.compile(doc_xml)
|
20
|
+
else
|
21
|
+
@library.compile_xml(doc_xml, @context)
|
22
|
+
end
|
23
|
+
|
24
|
+
@library.register_library
|
25
|
+
end
|
26
|
+
|
14
27
|
When /I run it with the following params:/ do |param_table|
|
15
28
|
params = { }
|
16
29
|
param_table.hashes.each do |hash|
|
@@ -28,14 +28,14 @@ module Fabulator
|
|
28
28
|
class Variable < Fabulator::Action
|
29
29
|
namespace Fabulator::FAB_NS
|
30
30
|
attribute :name, :eval => false, :static => true
|
31
|
-
has_select
|
31
|
+
has_select nil
|
32
32
|
has_actions
|
33
33
|
|
34
34
|
def run(context, autovivify = false)
|
35
35
|
return [] if self.name.nil?
|
36
36
|
res = [ ]
|
37
37
|
@context.with(context) do |ctx|
|
38
|
-
if
|
38
|
+
if !@select.nil?
|
39
39
|
res = self.select(ctx)
|
40
40
|
else
|
41
41
|
res = self.run_actions(ctx)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fabulator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 15
|
10
|
+
version: 0.0.15
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- James Smith
|
@@ -115,6 +115,7 @@ files:
|
|
115
115
|
- VERSION
|
116
116
|
- features/functions.feature
|
117
117
|
- features/group-params.feature
|
118
|
+
- features/library.feature
|
118
119
|
- features/loops.feature
|
119
120
|
- features/paths.feature
|
120
121
|
- features/primitives.feature
|