pione 0.4.0 → 0.4.1

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.
Files changed (60) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +1 -0
  3. data/History.txt +7 -0
  4. data/example/DeferredChoice/DeferredChoice.pione +14 -7
  5. data/{misc → example/DeferredChoice/bin}/ui.xml +11 -6
  6. data/example/DeferredChoice/pione-package.json +1 -1
  7. data/example/DeferredChoiceWithPage/DeferredChoiceWithPage.pione +47 -0
  8. data/example/DeferredChoiceWithPage/etc/index.html +22 -0
  9. data/example/DeferredChoiceWithPage/pione-package.json +18 -0
  10. data/example/Interaction/Interaction.pione +27 -0
  11. data/example/Interaction/bin/show-environment.cgi +45 -0
  12. data/example/Interaction/etc/.hidden-file.txt +1 -0
  13. data/example/Interaction/etc/cgi.html +46 -0
  14. data/example/Interaction/etc/create-files.html +51 -0
  15. data/example/Interaction/etc/delete-files.html +31 -0
  16. data/example/Interaction/etc/get-files.html +21 -0
  17. data/example/Interaction/etc/index.html +18 -0
  18. data/example/Interaction/etc/list-files.html +36 -0
  19. data/example/Interaction/pione-package.json +24 -0
  20. data/lib/pione/agent/job-manager.rb +19 -3
  21. data/lib/pione/agent/logger.rb +9 -9
  22. data/lib/pione/agent/messenger.rb +3 -2
  23. data/lib/pione/agent/task-worker.rb +32 -10
  24. data/lib/pione/command/option.rb +18 -0
  25. data/lib/pione/command/pione-client.rb +51 -22
  26. data/lib/pione/command/pione-interactive.rb +128 -55
  27. data/lib/pione/command/pione-package-build.rb +3 -3
  28. data/lib/pione/command/pione-task-worker.rb +23 -10
  29. data/lib/pione/command/pione-tuple-space-provider.rb +8 -8
  30. data/lib/pione/command/spawner.rb +28 -1
  31. data/lib/pione/front/interactive-front.rb +76 -0
  32. data/lib/pione/global/interactive-variable.rb +26 -0
  33. data/lib/pione/log/message-log-receiver.rb +4 -2
  34. data/lib/pione/model/task-worker-broker-model.rb +7 -1
  35. data/lib/pione/package/package-archiver.rb +16 -9
  36. data/lib/pione/package/package-handler.rb +6 -0
  37. data/lib/pione/package/package-info.rb +4 -0
  38. data/lib/pione/package/package-reader.rb +2 -4
  39. data/lib/pione/package/package-scanner.rb +23 -3
  40. data/lib/pione/rule-engine.rb +48 -19
  41. data/lib/pione/rule-engine/action-handler.rb +29 -5
  42. data/lib/pione/rule-engine/basic-handler.rb +27 -19
  43. data/lib/pione/test-helper/command-helper.rb +1 -1
  44. data/lib/pione/tuple-space/tuple-definition.yml +2 -3
  45. data/lib/pione/tuple-space/tuple-space-server.rb +8 -0
  46. data/lib/pione/util/cgi.rb +326 -0
  47. data/lib/pione/version.rb +1 -1
  48. data/lib/rootage/normalizer.rb +4 -0
  49. data/lib/rootage/option.rb +11 -4
  50. data/test/agent/spec_logger.rb +0 -1
  51. data/test/agent/spec_messenger.rb +1 -1
  52. data/test/command/spec_pione-client.rb +4 -4
  53. data/test/log/spec_message-log.rb +1 -1
  54. data/test/rule-engine/spec_action-handler.rb +25 -5
  55. data/test/rule-engine/spec_empty-handler.rb +36 -3
  56. data/test/rule-engine/spec_flow-handler.rb +90 -7
  57. metadata +22 -72
  58. data/misc/test-drb-stop-service.rb +0 -34
  59. data/misc/test-many-waiters-client.rb +0 -56
  60. data/misc/test-many-waiters-server.rb +0 -14
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZDZkOWNhZjVhNzZhZTE3MjU2MDM5OWFiYzM1NTUxMDEzMGQ0Y2FmNQ==
5
+ data.tar.gz: !binary |-
6
+ OWZiYTQ3YzA3YjNjNDQ5NTI3Y2ZhNTczYWMzN2FkNGM2MDdiN2Y5MA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZTZiMmE3ZmRlMmNhZjE3MjhkOGQ5YzFhNGY4Njg0NGQwNDBiYzZlMTE2M2Vi
10
+ YmU0NjVjMzUxYmYzYzgxZjQ2NDZkMmM1NWVjNWZlNDEzODZlNGUxNmFkYzM1
11
+ YjY5ZDliYmFhMWI2ZWRkZjQ3YjM1ZGUxNTc3YmY2MWEyZTNjYTY=
12
+ data.tar.gz: !binary |-
13
+ YjAwNjIxZWJlNDY2ZWZjODVlMDEzYWQyNmVmN2ZiZWFlMzgwOGQ1ZDAzZDk5
14
+ MzY3YTNlNzc1YjU0MTA2OWFlMjE0YWY1Y2RlYjY4MWRmYjI0ODM5MzNjYzQ1
15
+ MTMwZGUyYjNlN2EzZmUxNWFlM2ZhMmQ5NTA1ZjlkODY2MmE2MWE=
data/.gitignore CHANGED
@@ -14,6 +14,7 @@ test-report.txt
14
14
 
15
15
  /input
16
16
  /output
17
+ /process
17
18
  /result
18
19
  /html
19
20
  /vendor
@@ -1,5 +1,12 @@
1
1
  # History
2
2
 
3
+ ## 0.4.1(2014/8/11)
4
+
5
+ * Work with new PIONE webclient.
6
+ * Improved interactive operations(file API and CGI).
7
+ * Changed layouts of base directory. Output files exist in directory `output`.
8
+ * Changed base directory option as `--base LOCATION`.
9
+
3
10
  ## 0.4.0(2014/4/17)
4
11
 
5
12
  * Added new PNML compiler(`pione compile`).
@@ -13,14 +13,21 @@ End
13
13
 
14
14
  Rule UserSelect
15
15
  output 'a.txt' or 'b.txt' or 'c.txt'
16
- feature +Interactive
17
16
  Action
18
- if [ "{$DIALOG}" = "zenity" ]
19
- then
20
- zenity --list --title "select action" --column rule "rule A" "rule B" "rule C" > rule.txt
21
- else
22
- xmessage -print -center -buttons "rule A,rule B,rule C" "select action" > rule.txt
23
- fi
17
+ case "$PIONE_CLIENT_UI" in
18
+ "Browser")
19
+ pione-interactive --ui Browser --type dialog --definition bin/ui.xml -o rule.txt ;;
20
+ "GUI")
21
+ if [ "{$DIALOG}" = "zenity" ]
22
+ then
23
+ zenity --list --title "select action" --column rule "rule A" "rule B" "rule C" > rule.txt
24
+ else
25
+ xmessage -print -center -buttons "rule A,rule B,rule C" "select action" > rule.txt
26
+ fi ;;
27
+ *)
28
+ echo "rule A" > rule.txt
29
+ esac
30
+
24
31
  RULE=`cat rule.txt`
25
32
  case "$RULE" in
26
33
  "rule A") touch a.txt ;;
@@ -1,8 +1,9 @@
1
1
  <?xml version="1.0" encoding="utf-8" ?>
2
2
  <pione:interactive type="Browser" xmlns:pione="https://github.com/pione/pione">
3
3
  <pione:content type="text/html">
4
- <button id="yes">YES</button>
5
- <button id="no">NO</button>
4
+ <button id="RuleA">rule A</button>
5
+ <button id="RuleB">rule B</button>
6
+ <button id="RuleC">rule C</button>
6
7
  </pione:content>
7
8
  <pione:script type="text/javascript">
8
9
  var sendEvent = function (res) {
@@ -12,12 +13,16 @@
12
13
  document.dispatchEvent(event);
13
14
  };
14
15
 
15
- document.getElementById("yes").addEventListener("click", function () {
16
- sendEvent("yes");
16
+ document.getElementById("RuleA").addEventListener("click", function () {
17
+ sendEvent("rule A");
17
18
  });
18
19
 
19
- document.getElementById("no").addEventListener("click", function () {
20
- sendEvent("no");
20
+ document.getElementById("RuleB").addEventListener("click", function () {
21
+ sendEvent("rule B");
22
+ });
23
+
24
+ document.getElementById("RuleC").addEventListener("click", function () {
25
+ sendEvent("rule C");
21
26
  });
22
27
  </pione:script>
23
28
  </pione:interactive>
@@ -10,6 +10,6 @@
10
10
 
11
11
  ],
12
12
  "Bins": [
13
-
13
+ "bin/ui.xml"
14
14
  ]
15
15
  }
@@ -0,0 +1,47 @@
1
+ .@ PackageName :: "DefferredChoiceWithPage"
2
+
3
+ Rule Main
4
+ output 'result.txt'
5
+ Flow
6
+ rule UserSelect
7
+ rule A
8
+ rule B
9
+ rule C
10
+ End
11
+
12
+ Rule UserSelect
13
+ output 'a.txt' or 'b.txt' or 'c.txt'
14
+ Action
15
+ # start interactive operation
16
+ pione-interactive browser -o rule.txt --public ./etc
17
+
18
+ # generate an output
19
+ RULE=`cat rule.txt`
20
+ case "$RULE" in
21
+ "rule A") touch a.txt ;;
22
+ "rule B") touch b.txt ;;
23
+ "rule C") touch c.txt ;;
24
+ esac
25
+ End
26
+
27
+ Rule A
28
+ input 'a.txt'
29
+ output 'result.txt'
30
+ Action
31
+ echo 'You selected rule A' > {$O[1]}
32
+ End
33
+
34
+ Rule B
35
+ input 'b.txt'
36
+ output 'result.txt'
37
+ Action
38
+ echo 'You selected rule B' > {$O[1]}
39
+ End
40
+
41
+ Rule C
42
+ input 'c.txt'
43
+ output 'result.txt'
44
+ Action
45
+ echo 'You selected rule C' > {$O[1]}
46
+ End
47
+
@@ -0,0 +1,22 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Deferred Choice with Page</title>
6
+ </head>
7
+ <body>
8
+ <h1>Deferred Choice</h1>
9
+ <h2>Select a rule you want to fire</h2>
10
+ <form method="POST">
11
+ <div>
12
+ <input type="radio" name="pione-result" value="rule A" /> Rule A
13
+ <input type="radio" name="pione-result" value="rule B" /> Rule B
14
+ <input type="radio" name="pione-result" value="rule C" /> Rule C
15
+ </div>
16
+ <div>
17
+ <input type="hidden" name="pione-action" value="finish" />
18
+ <button type="submit">send</button>
19
+ </div>
20
+ </form>
21
+ </body>
22
+ </html>
@@ -0,0 +1,18 @@
1
+ {
2
+ "PackageName": "DefferredChoiceWithPage",
3
+ "Parents": [
4
+
5
+ ],
6
+ "Documents": [
7
+ "DeferredChoiceWithPage.pione"
8
+ ],
9
+ "Scenarios": [
10
+
11
+ ],
12
+ "Bins": [
13
+
14
+ ],
15
+ "Etcs": [
16
+ "etc/index.html"
17
+ ]
18
+ }
@@ -0,0 +1,27 @@
1
+ .@ PackageName :: "Interaction"
2
+
3
+ Rule Main
4
+ output 'output*.txt'.all
5
+ Flow
6
+ rule Interaction
7
+ End
8
+
9
+ Rule Interaction
10
+ output 'output*.txt'.all
11
+ Action
12
+ # build public directory for pione-interactive
13
+ mkdir public
14
+ cp bin/* public
15
+ cp etc/* public
16
+ cp etc/.hidden-file.txt public
17
+
18
+ # set environment variables for CGI
19
+ export ENV_EXAMPLE1=a
20
+ export ENV_EXAMPLE2=b
21
+ export ENV_EXAMPLE3=c
22
+
23
+ # start interactive operation
24
+ pione-interactive browser --public public
25
+
26
+ cp public/* .
27
+ End
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'cgi'
4
+ require 'erb'
5
+
6
+ cgi = CGI.new
7
+
8
+ TEMPLATE = <<-HTML
9
+ <!DOCTYPE html>
10
+ <html>
11
+ <header>
12
+ <title>CGI Execution</title>
13
+ </header>
14
+ <body>
15
+ <h1>CGI Execution</h1>
16
+
17
+ <section>
18
+ <h2>Arguments</h2>
19
+ <ol>
20
+ <% ARGV.each do |val| %>
21
+ <li><%= CGI.escapeHTML(val) %></li>
22
+ <% end %>
23
+ </ol>
24
+ </section>
25
+
26
+ <section>
27
+ <h2>Parameters</h2>
28
+ <div><%= CGI.escapeHTML(cgi.params.to_s) %></div>
29
+ </section>
30
+
31
+ <section>
32
+ <h2>ENV</h2>
33
+ <dl>
34
+ <% ENV.keys.sort.each do |key| %>
35
+ <dt><%= CGI.escapeHTML(key) %></dt><dd><%= CGI.escapeHTML(ENV[key]) %></dd>
36
+ <% end %>
37
+ </dl>
38
+ </section>
39
+ </body>
40
+ </html>
41
+ HTML
42
+
43
+ cgi.out(type: "text/html") do
44
+ ERB.new(TEMPLATE).result
45
+ end
@@ -0,0 +1 @@
1
+ This is a hidden file, so list operation doesn't show this file with "pione-show-all=false".
@@ -0,0 +1,46 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>CGI Execution Examples</title>
5
+ </head>
6
+ <body>
7
+ <h1>CGI Execution Examples</h1>
8
+ <section>
9
+ <h2>Call CGI Script with No Parameters</h2>
10
+ <a href="show-environment.cgi">show-environment.cgi</a>
11
+ </section>
12
+
13
+ <section>
14
+ <h2>Call CGI Script with Arguments</h2>
15
+ <a href="show-environment.cgi?a+b+c">show-environment.cgi?a+b+c</a>
16
+ </section>
17
+
18
+ <section>
19
+ <h2>Call CGI Script with application/x-www-form-urlencoded</h2>
20
+ <a href="show-environment.cgi?a=1&b=2&c=3">show-environment.cgi?a=1&b=2&c=3</a>
21
+ </section>
22
+
23
+ <section>
24
+ <h2>Call CGI Script by POST</h2>
25
+ <form action="show-environment.cgi">
26
+ <input type="hidden" name="pione-action" value="get"/>
27
+ <input type="hidden" name="a" value="1"/>
28
+ <input type="hidden" name="b" value="2"/>
29
+ <input type="hidden" name="c" value="3"/>
30
+ <button type="submit">Call by POST</button>
31
+ </form>
32
+ </section>
33
+
34
+ <section>
35
+ <h2>Call CGI Script with multipart/form-data</h2>
36
+ <form action="show-environment.cgi" method="POST" enctype="multipart/form-data">
37
+ <input type="hidden" name="pione-action" value="get"/>
38
+ <input type="hidden" name="a" value="1"/>
39
+ <input type="hidden" name="b" value="2"/>
40
+ <input type="hidden" name="c" value="3"/>
41
+ <input type="file" name="testfile"/>
42
+ <button type="submit">Call by POST</button>
43
+ </form>
44
+ </section>
45
+ </body>
46
+ </html>
@@ -0,0 +1,51 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Interaction Example: Create files</title>
6
+ </head>
7
+ <body>
8
+ <h1>POST Method Examples</h1>
9
+
10
+ <section>
11
+ <h2>Create by input text</h2>
12
+ <form action="output1.txt" method="POST">
13
+ <input type="hidden" name="pione-action" value="create" />
14
+ <input type="text" name="pione-content" />
15
+ <button type="submit">Create output1.txt</button>
16
+ </form>
17
+ </section>
18
+
19
+ <section>
20
+ <h2>Create by select box</h2>
21
+ <form action="output2.txt" method="POST">
22
+ <input type="hidden" name="pione-action" value="create" />
23
+ <select name="pione-content">
24
+ <option value="A">A</option>
25
+ <option value="B">B</option>
26
+ <option value="C">C</option>
27
+ </select>
28
+ <button type="submit">Create output2.txt</button>
29
+ </form>
30
+ </section>
31
+
32
+ <section>
33
+ <h2>Create by radio button</h2>
34
+ <form action="output3.txt" method="POST">
35
+ <input type="hidden" name="pione-action" value="create" />
36
+ <input type="radio" name="pione-content" value="1" checked="checked" />1
37
+ <input type="radio" name="pione-content" value="2" />2
38
+ <input type="radio" name="pione-content" value="3" />3
39
+ <button type="submit">Create output3.txt</button>
40
+ </form>
41
+ </section>
42
+
43
+ <section>
44
+ <h2>Create with multipart/form-data</h2>
45
+ <form action="output4" method="POST" enctype="multipart/form-data">
46
+ <input type="hidden" name="pione-action" value="create"/>
47
+ <input type="file" name="pione-content"/>
48
+ <button type="submit">Call by POST</button>
49
+ </form>
50
+ </body>
51
+ </html>
@@ -0,0 +1,31 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Interaction Example: Delete files</title>
6
+ </head>
7
+ <body>
8
+ <h1>POST Method Example</h1>
9
+
10
+ <section>
11
+ <form action="output1.txt" method="POST">
12
+ <input type="hidden" name="pione-action" value="delete" />
13
+ <button type="submit">Delete output1.txt</button>
14
+ </form>
15
+ </section>
16
+
17
+ <section>
18
+ <form action="output2.txt" method="POST">
19
+ <input type="hidden" name="pione-action" value="delete" />
20
+ <button type="submit">Delete output2.txt</button>
21
+ </form>
22
+ </section>
23
+
24
+ <section>
25
+ <form action="output3.txt" method="POST">
26
+ <input type="hidden" name="pione-action" value="delete" />
27
+ <button type="submit">Delete output3.txt</button>
28
+ </form>
29
+ </section>
30
+ </body>
31
+ </html>
@@ -0,0 +1,21 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Interaction Example: Get files</title>
6
+ </head>
7
+ <body>
8
+ <h2>Simple Link Examples</h2>
9
+ <ul>
10
+ <li><a href="get-files.html">get-files.html</a></li>
11
+ <li><a href="create-files.html">create-files.html</a></li>
12
+ <li><a href="delete-files.html">delete-files.html</a></li>
13
+ <li><a href="list-files.html">list-files.html</a></li>
14
+ </ul>
15
+ <h2>GET Method Example</h2>
16
+ <form action="get-files.html" method="GET">
17
+ <input type="hidden" name="pione-action" value="get" />
18
+ <button type="submit">get get-files.html by GET method</button>
19
+ </form>
20
+ </body>
21
+ </html>
@@ -0,0 +1,18 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Interaction Example</title>
6
+ </head>
7
+ <body>
8
+ <h1>Examples</h1>
9
+ <ul>
10
+ <li><a href="get-files.html">get files from working directory</a></li>
11
+ <li><a href="create-files.html">create files in working directory</a></li>
12
+ <li><a href="delete-files.html">delete files from working directory</a></li>
13
+ <li><a href="list-files.html">list files in working directory</a></li>
14
+ <li><a href="cgi.html">CGI execution examples</a></li>
15
+ </ul>
16
+ <a href="?pione-action=finish">Close this interaction</a>
17
+ </body>
18
+ </html>