pione 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (366) hide show
  1. data/.gitignore +14 -0
  2. data/Gemfile +5 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +94 -0
  5. data/Rakefile +118 -0
  6. data/bin/pione-broker +5 -0
  7. data/bin/pione-clean +5 -0
  8. data/bin/pione-client +5 -0
  9. data/bin/pione-eval +111 -0
  10. data/bin/pione-relay +5 -0
  11. data/bin/pione-relay-account-db +5 -0
  12. data/bin/pione-relay-client-db +5 -0
  13. data/bin/pione-search-log +30 -0
  14. data/bin/pione-syntax-checker +5 -0
  15. data/bin/pione-task-worker +5 -0
  16. data/bin/pione-tuple-space-provider +5 -0
  17. data/bin/pione-tuple-space-receiver +5 -0
  18. data/bin/pione-tuple-space-viewer +5 -0
  19. data/demo/demo.rb +311 -0
  20. data/demo/public/base.css +94 -0
  21. data/demo/public/demo.js +107 -0
  22. data/demo/public/index.html +91 -0
  23. data/demo/public/jquery-1.8.3.min.js +2 -0
  24. data/example/CountChar/CountChar.pione +64 -0
  25. data/example/CountChar/misc/CountChar.rb +22 -0
  26. data/example/CountChar/text/aidokushono_insho.txt +32 -0
  27. data/example/CountChar/text/aikokuka_shokan.txt +108 -0
  28. data/example/CountChar/text/carlyle_hakubutsukan.txt +58 -0
  29. data/example/CountChar/text/dark_minister.txt +2440 -0
  30. data/example/CountChar/text/kaikano_otto.txt +61 -0
  31. data/example/CountChar/text/kaikon.txt +30 -0
  32. data/example/CountChar/text/nagashimano_shi.txt +45 -0
  33. data/example/CountChar/text/saikachibuchi.txt +80 -0
  34. data/example/CountChar/text/saikonihonno_josei.txt +91 -0
  35. data/example/CountChar/text/taishojugonenno_bundan.txt +21 -0
  36. data/example/FeatureExample/FeatureExample.pione +7 -0
  37. data/example/Fib/Fib.pione +56 -0
  38. data/example/Fib/FibBC.pione +56 -0
  39. data/example/HelloWorld/HelloWorld.pione +5 -0
  40. data/example/LucasNumber/LucasNumber.pione +64 -0
  41. data/example/MakePair/MakePair.pione +14 -0
  42. data/example/MakePair/data/1.i +0 -0
  43. data/example/MakePair/data/2.i +0 -0
  44. data/example/MakePair/data/3.i +0 -0
  45. data/example/MakePair/data/4.i +0 -0
  46. data/example/MakePair/data/5.i +0 -0
  47. data/example/SieveOfEratosthenes/SieveOfEratosthenes.pione +61 -0
  48. data/example/SingleParticlesWithRef/Makefile +289 -0
  49. data/example/SingleParticlesWithRef/SingleParticlesWithRef.Makefile +153 -0
  50. data/example/SingleParticlesWithRef/SingleParticlesWithRef.pione +116 -0
  51. data/example/SingleParticlesWithRef/SingleParticlesWithRefFull.pione +400 -0
  52. data/example/SingleParticlesWithRef/data/121p-shift-0-0-0.roi +0 -0
  53. data/example/SingleParticlesWithRef/data/121p-shift-0-120-0.roi +0 -0
  54. data/example/SingleParticlesWithRef/data/121p-shift-0-180-0.roi +0 -0
  55. data/example/SingleParticlesWithRef/data/121p-shift-0-240-0.roi +0 -0
  56. data/example/SingleParticlesWithRef/data/121p-shift-0-300-0.roi +0 -0
  57. data/example/SingleParticlesWithRef/data/121p-shift-0-60-0.roi +0 -0
  58. data/example/SingleParticlesWithRef/data/121p-shift-120-0-0.roi +0 -0
  59. data/example/SingleParticlesWithRef/data/121p-shift-120-120-0.roi +0 -0
  60. data/example/SingleParticlesWithRef/data/121p-shift-120-180-0.roi +0 -0
  61. data/example/SingleParticlesWithRef/data/121p-shift-120-240-0.roi +0 -0
  62. data/example/SingleParticlesWithRef/data/121p-shift-120-300-0.roi +0 -0
  63. data/example/SingleParticlesWithRef/data/121p-shift-120-60-0.roi +0 -0
  64. data/example/SingleParticlesWithRef/data/121p-shift-180-0-0.roi +0 -0
  65. data/example/SingleParticlesWithRef/data/121p-shift-180-120-0.roi +0 -0
  66. data/example/SingleParticlesWithRef/data/121p-shift-180-180-0.roi +0 -0
  67. data/example/SingleParticlesWithRef/data/121p-shift-180-240-0.roi +0 -0
  68. data/example/SingleParticlesWithRef/data/121p-shift-180-300-0.roi +0 -0
  69. data/example/SingleParticlesWithRef/data/121p-shift-180-60-0.roi +0 -0
  70. data/example/SingleParticlesWithRef/data/121p-shift-240-0-0.roi +0 -0
  71. data/example/SingleParticlesWithRef/data/121p-shift-240-120-0.roi +0 -0
  72. data/example/SingleParticlesWithRef/data/121p-shift-240-180-0.roi +0 -0
  73. data/example/SingleParticlesWithRef/data/121p-shift-240-240-0.roi +0 -0
  74. data/example/SingleParticlesWithRef/data/121p-shift-240-300-0.roi +0 -0
  75. data/example/SingleParticlesWithRef/data/121p-shift-240-60-0.roi +0 -0
  76. data/example/SingleParticlesWithRef/data/121p-shift-300-0-0.roi +0 -0
  77. data/example/SingleParticlesWithRef/data/121p-shift-300-120-0.roi +0 -0
  78. data/example/SingleParticlesWithRef/data/121p-shift-300-180-0.roi +0 -0
  79. data/example/SingleParticlesWithRef/data/121p-shift-300-240-0.roi +0 -0
  80. data/example/SingleParticlesWithRef/data/121p-shift-300-300-0.roi +0 -0
  81. data/example/SingleParticlesWithRef/data/121p-shift-300-60-0.roi +0 -0
  82. data/example/SingleParticlesWithRef/data/121p-shift-60-0-0.roi +0 -0
  83. data/example/SingleParticlesWithRef/data/121p-shift-60-120-0.roi +0 -0
  84. data/example/SingleParticlesWithRef/data/121p-shift-60-180-0.roi +0 -0
  85. data/example/SingleParticlesWithRef/data/121p-shift-60-240-0.roi +0 -0
  86. data/example/SingleParticlesWithRef/data/121p-shift-60-300-0.roi +0 -0
  87. data/example/SingleParticlesWithRef/data/121p-shift-60-60-0.roi +0 -0
  88. data/example/SingleParticlesWithRef/data/121p-shift-noise-0-0-0.roi +0 -0
  89. data/example/SingleParticlesWithRef/data/121p-shift-noise-0-120-0.roi +0 -0
  90. data/example/SingleParticlesWithRef/data/121p-shift-noise-0-180-0.roi +0 -0
  91. data/example/SingleParticlesWithRef/data/121p-shift-noise-0-240-0.roi +0 -0
  92. data/example/SingleParticlesWithRef/data/121p-shift-noise-0-300-0.roi +0 -0
  93. data/example/SingleParticlesWithRef/data/121p-shift-noise-0-60-0.roi +0 -0
  94. data/example/SingleParticlesWithRef/data/121p-shift-noise-120-0-0.roi +0 -0
  95. data/example/SingleParticlesWithRef/data/121p-shift-noise-120-120-0.roi +0 -0
  96. data/example/SingleParticlesWithRef/data/121p-shift-noise-120-180-0.roi +0 -0
  97. data/example/SingleParticlesWithRef/data/121p-shift-noise-120-240-0.roi +0 -0
  98. data/example/SingleParticlesWithRef/data/121p-shift-noise-120-300-0.roi +0 -0
  99. data/example/SingleParticlesWithRef/data/121p-shift-noise-120-60-0.roi +0 -0
  100. data/example/SingleParticlesWithRef/data/121p-shift-noise-180-0-0.roi +0 -0
  101. data/example/SingleParticlesWithRef/data/121p-shift-noise-180-120-0.roi +0 -0
  102. data/example/SingleParticlesWithRef/data/121p-shift-noise-180-180-0.roi +0 -0
  103. data/example/SingleParticlesWithRef/data/121p-shift-noise-180-240-0.roi +0 -0
  104. data/example/SingleParticlesWithRef/data/121p-shift-noise-180-300-0.roi +0 -0
  105. data/example/SingleParticlesWithRef/data/121p-shift-noise-180-60-0.roi +0 -0
  106. data/example/SingleParticlesWithRef/data/121p-shift-noise-240-0-0.roi +0 -0
  107. data/example/SingleParticlesWithRef/data/121p-shift-noise-240-120-0.roi +0 -0
  108. data/example/SingleParticlesWithRef/data/121p-shift-noise-240-180-0.roi +0 -0
  109. data/example/SingleParticlesWithRef/data/121p-shift-noise-240-240-0.roi +0 -0
  110. data/example/SingleParticlesWithRef/data/121p-shift-noise-240-300-0.roi +0 -0
  111. data/example/SingleParticlesWithRef/data/121p-shift-noise-240-60-0.roi +0 -0
  112. data/example/SingleParticlesWithRef/data/121p-shift-noise-300-0-0.roi +0 -0
  113. data/example/SingleParticlesWithRef/data/121p-shift-noise-300-120-0.roi +0 -0
  114. data/example/SingleParticlesWithRef/data/121p-shift-noise-300-180-0.roi +0 -0
  115. data/example/SingleParticlesWithRef/data/121p-shift-noise-300-240-0.roi +0 -0
  116. data/example/SingleParticlesWithRef/data/121p-shift-noise-300-300-0.roi +0 -0
  117. data/example/SingleParticlesWithRef/data/121p-shift-noise-300-60-0.roi +0 -0
  118. data/example/SingleParticlesWithRef/data/121p-shift-noise-60-0-0.roi +0 -0
  119. data/example/SingleParticlesWithRef/data/121p-shift-noise-60-120-0.roi +0 -0
  120. data/example/SingleParticlesWithRef/data/121p-shift-noise-60-180-0.roi +0 -0
  121. data/example/SingleParticlesWithRef/data/121p-shift-noise-60-240-0.roi +0 -0
  122. data/example/SingleParticlesWithRef/data/121p-shift-noise-60-300-0.roi +0 -0
  123. data/example/SingleParticlesWithRef/data/121p-shift-noise-60-60-0.roi +0 -0
  124. data/example/SingleParticlesWithRef/data/121p-shift.pdb +3381 -0
  125. data/example/SingleParticlesWithRef/data/all.ref2d +0 -0
  126. data/example/SingleParticlesWithRef/data/all.ref3d +0 -0
  127. data/example/Sum/Sum.pione +52 -0
  128. data/example/SyntaxError/call_rule_error.pione +6 -0
  129. data/example/SyntaxError/feature_line_error.pione +7 -0
  130. data/example/SyntaxError/flow_block_error.pione +5 -0
  131. data/example/SyntaxError/input_line_error.pione +6 -0
  132. data/example/SyntaxError/invalid_rule_name.pione +6 -0
  133. data/example/SyntaxError/param_line_error.pione +7 -0
  134. data/example/SyntaxError/variable-binding-error.pione +11 -0
  135. data/lib/pione.rb +241 -0
  136. data/lib/pione/agent/basic-agent.rb +333 -0
  137. data/lib/pione/agent/broker.rb +274 -0
  138. data/lib/pione/agent/command-listener.rb +47 -0
  139. data/lib/pione/agent/input-generator.rb +194 -0
  140. data/lib/pione/agent/logger.rb +65 -0
  141. data/lib/pione/agent/process-manager.rb +38 -0
  142. data/lib/pione/agent/rule-provider.rb +64 -0
  143. data/lib/pione/agent/task-worker.rb +274 -0
  144. data/lib/pione/agent/trivial-routine-worker.rb +28 -0
  145. data/lib/pione/agent/tuple-space-client.rb +146 -0
  146. data/lib/pione/agent/tuple-space-server-client-life-checker.rb +29 -0
  147. data/lib/pione/command-option/basic-option.rb +42 -0
  148. data/lib/pione/command-option/child-process-option.rb +17 -0
  149. data/lib/pione/command-option/common-option.rb +29 -0
  150. data/lib/pione/command-option/daemon-option.rb +12 -0
  151. data/lib/pione/command-option/presence-notifier-option.rb +15 -0
  152. data/lib/pione/command-option/task-worker-owner-option.rb +17 -0
  153. data/lib/pione/command-option/tuple-space-provider-option.rb +26 -0
  154. data/lib/pione/command-option/tuple-space-provider-owner-option.rb +16 -0
  155. data/lib/pione/command-option/tuple-space-receiver-option.rb +12 -0
  156. data/lib/pione/command/basic-command.rb +126 -0
  157. data/lib/pione/command/child-process.rb +43 -0
  158. data/lib/pione/command/daemon-process.rb +18 -0
  159. data/lib/pione/command/front-owner-command.rb +37 -0
  160. data/lib/pione/command/pione-broker.rb +53 -0
  161. data/lib/pione/command/pione-clean.rb +16 -0
  162. data/lib/pione/command/pione-client.rb +273 -0
  163. data/lib/pione/command/pione-relay-account-db.rb +85 -0
  164. data/lib/pione/command/pione-relay-client-db.rb +80 -0
  165. data/lib/pione/command/pione-relay.rb +47 -0
  166. data/lib/pione/command/pione-syntax-checker.rb +103 -0
  167. data/lib/pione/command/pione-task-worker.rb +123 -0
  168. data/lib/pione/command/pione-tuple-space-provider.rb +87 -0
  169. data/lib/pione/command/pione-tuple-space-receiver.rb +55 -0
  170. data/lib/pione/command/pione-tuple-space-viewer.rb +151 -0
  171. data/lib/pione/command/tuple-space-provider-owner.rb +6 -0
  172. data/lib/pione/front/basic-front.rb +64 -0
  173. data/lib/pione/front/broker-front.rb +30 -0
  174. data/lib/pione/front/client-front.rb +28 -0
  175. data/lib/pione/front/relay-front.rb +19 -0
  176. data/lib/pione/front/task-worker-front.rb +16 -0
  177. data/lib/pione/front/task-worker-owner.rb +42 -0
  178. data/lib/pione/front/tuple-space-provider-front.rb +22 -0
  179. data/lib/pione/front/tuple-space-provider-owner.rb +11 -0
  180. data/lib/pione/front/tuple-space-receiver-front.rb +18 -0
  181. data/lib/pione/model/assignment.rb +89 -0
  182. data/lib/pione/model/basic-model.rb +395 -0
  183. data/lib/pione/model/binary-operator.rb +80 -0
  184. data/lib/pione/model/block.rb +233 -0
  185. data/lib/pione/model/boolean.rb +138 -0
  186. data/lib/pione/model/call-rule.rb +69 -0
  187. data/lib/pione/model/data-expr.rb +360 -0
  188. data/lib/pione/model/feature-expr.rb +794 -0
  189. data/lib/pione/model/float.rb +107 -0
  190. data/lib/pione/model/integer.rb +140 -0
  191. data/lib/pione/model/list.rb +104 -0
  192. data/lib/pione/model/message.rb +80 -0
  193. data/lib/pione/model/package.rb +48 -0
  194. data/lib/pione/model/parameters.rb +282 -0
  195. data/lib/pione/model/rule-expr.rb +120 -0
  196. data/lib/pione/model/rule-io.rb +166 -0
  197. data/lib/pione/model/rule.rb +294 -0
  198. data/lib/pione/model/string.rb +111 -0
  199. data/lib/pione/model/undefined-value.rb +24 -0
  200. data/lib/pione/model/variable-table.rb +315 -0
  201. data/lib/pione/model/variable.rb +87 -0
  202. data/lib/pione/parser/block-parser.rb +83 -0
  203. data/lib/pione/parser/common-parser.rb +145 -0
  204. data/lib/pione/parser/document-parser.rb +58 -0
  205. data/lib/pione/parser/error-message.yml +4 -0
  206. data/lib/pione/parser/expr-parser.rb +266 -0
  207. data/lib/pione/parser/feature-expr-parser.rb +105 -0
  208. data/lib/pione/parser/flow-element-parser.rb +181 -0
  209. data/lib/pione/parser/literal-parser.rb +182 -0
  210. data/lib/pione/parser/rule-definition-parser.rb +163 -0
  211. data/lib/pione/parser/syntax-error.rb +61 -0
  212. data/lib/pione/patch/array-patch.rb +3 -0
  213. data/lib/pione/patch/drb-patch.rb +467 -0
  214. data/lib/pione/patch/monitor-patch.rb +16 -0
  215. data/lib/pione/patch/rinda-patch.rb +759 -0
  216. data/lib/pione/patch/uri-patch.rb +66 -0
  217. data/lib/pione/relay/receiver-socket.rb +69 -0
  218. data/lib/pione/relay/relay-account-db.rb +55 -0
  219. data/lib/pione/relay/relay-client-db.rb +53 -0
  220. data/lib/pione/relay/relay-socket.rb +215 -0
  221. data/lib/pione/relay/trampoline.rb +22 -0
  222. data/lib/pione/relay/transmitter-socket.rb +167 -0
  223. data/lib/pione/resource/basic-resource.rb +92 -0
  224. data/lib/pione/resource/dropbox-resource.rb +106 -0
  225. data/lib/pione/resource/ftp.rb +84 -0
  226. data/lib/pione/resource/local.rb +113 -0
  227. data/lib/pione/rule-handler/action-handler.rb +184 -0
  228. data/lib/pione/rule-handler/basic-handler.rb +217 -0
  229. data/lib/pione/rule-handler/flow-handler.rb +339 -0
  230. data/lib/pione/rule-handler/root-handler.rb +23 -0
  231. data/lib/pione/rule-handler/system-handler.rb +13 -0
  232. data/lib/pione/system/common.rb +22 -0
  233. data/lib/pione/system/config.rb +20 -0
  234. data/lib/pione/system/document.rb +81 -0
  235. data/lib/pione/system/file-cache.rb +150 -0
  236. data/lib/pione/system/global.rb +346 -0
  237. data/lib/pione/system/identifier.rb +61 -0
  238. data/lib/pione/system/init.rb +16 -0
  239. data/lib/pione/system/object.rb +35 -0
  240. data/lib/pione/transformer/block-transformer.rb +23 -0
  241. data/lib/pione/transformer/document-transformer.rb +36 -0
  242. data/lib/pione/transformer/expr-transformer.rb +89 -0
  243. data/lib/pione/transformer/feature-expr-transformer.rb +56 -0
  244. data/lib/pione/transformer/flow-element-transformer.rb +66 -0
  245. data/lib/pione/transformer/literal-transformer.rb +76 -0
  246. data/lib/pione/transformer/rule-definition-transformer.rb +62 -0
  247. data/lib/pione/transformer/transformer-module.rb +37 -0
  248. data/lib/pione/tuple-space/data-finder.rb +165 -0
  249. data/lib/pione/tuple-space/presence-notifier.rb +83 -0
  250. data/lib/pione/tuple-space/relay.rb +9 -0
  251. data/lib/pione/tuple-space/tuple-space-provider.rb +85 -0
  252. data/lib/pione/tuple-space/tuple-space-receiver.rb +140 -0
  253. data/lib/pione/tuple-space/tuple-space-server-interface.rb +60 -0
  254. data/lib/pione/tuple-space/tuple-space-server.rb +156 -0
  255. data/lib/pione/tuple-space/update-criteria.rb +96 -0
  256. data/lib/pione/tuple/agent-tuple.rb +10 -0
  257. data/lib/pione/tuple/attribute-tuple.rb +7 -0
  258. data/lib/pione/tuple/base-uri-tuple.rb +9 -0
  259. data/lib/pione/tuple/basic-tuple.rb +317 -0
  260. data/lib/pione/tuple/bye-tuple.rb +9 -0
  261. data/lib/pione/tuple/command-tuple.rb +9 -0
  262. data/lib/pione/tuple/data-tuple.rb +18 -0
  263. data/lib/pione/tuple/dry-run-tuple.rb +8 -0
  264. data/lib/pione/tuple/exception-tuple.rb +11 -0
  265. data/lib/pione/tuple/finished-tuple.rb +17 -0
  266. data/lib/pione/tuple/foreground-tuple.rb +7 -0
  267. data/lib/pione/tuple/log-tuple.rb +14 -0
  268. data/lib/pione/tuple/process-info-tuple.rb +9 -0
  269. data/lib/pione/tuple/request-rule-tuple.rb +9 -0
  270. data/lib/pione/tuple/rule-tuple.rb +10 -0
  271. data/lib/pione/tuple/shift-tuple.rb +13 -0
  272. data/lib/pione/tuple/task-tuple.rb +36 -0
  273. data/lib/pione/tuple/task-worker-resource-tuple.rb +9 -0
  274. data/lib/pione/tuple/working-tuple.rb +13 -0
  275. data/lib/pione/uri-scheme/basic-scheme.rb +40 -0
  276. data/lib/pione/uri-scheme/broadcast-scheme.rb +11 -0
  277. data/lib/pione/uri-scheme/dropbox-scheme.rb +9 -0
  278. data/lib/pione/uri-scheme/local-scheme.rb +28 -0
  279. data/lib/pione/util/error-report.rb +12 -0
  280. data/lib/pione/util/log.rb +79 -0
  281. data/lib/pione/util/message.rb +155 -0
  282. data/lib/pione/util/misc.rb +73 -0
  283. data/lib/pione/util/terminal.rb +78 -0
  284. data/lib/pione/util/waiter-table.rb +53 -0
  285. data/lib/pione/version.rb +3 -0
  286. data/misc/env.sh +2 -0
  287. data/misc/test-drb-stop-service.rb +34 -0
  288. data/misc/test-ensure-and-thread-kill.rb +40 -0
  289. data/misc/test-many-waiters-client.rb +56 -0
  290. data/misc/test-many-waiters-server.rb +14 -0
  291. data/misc/write_and_take_test.png +0 -0
  292. data/misc/write_and_take_test.rb +36 -0
  293. data/pione.gemspec +49 -0
  294. data/test/agent/spec_basic-agent.rb +170 -0
  295. data/test/agent/spec_broker.rb +36 -0
  296. data/test/agent/spec_command-listener.rb +30 -0
  297. data/test/agent/spec_input-generator.rb +123 -0
  298. data/test/agent/spec_logger.rb +71 -0
  299. data/test/agent/spec_rule-provider.rb +65 -0
  300. data/test/agent/spec_task-worker.rb +307 -0
  301. data/test/agent/spec_tuple-space-client.rb +30 -0
  302. data/test/model/spec_assignment.rb +51 -0
  303. data/test/model/spec_binary-operator.rb +39 -0
  304. data/test/model/spec_block.rb +154 -0
  305. data/test/model/spec_boolean.rb +115 -0
  306. data/test/model/spec_call-rule.rb +23 -0
  307. data/test/model/spec_data-expr.rb +312 -0
  308. data/test/model/spec_feature-expr.rb +359 -0
  309. data/test/model/spec_feature-expr.yml +16 -0
  310. data/test/model/spec_float.rb +141 -0
  311. data/test/model/spec_integer.rb +141 -0
  312. data/test/model/spec_list.rb +26 -0
  313. data/test/model/spec_message.rb +42 -0
  314. data/test/model/spec_package.rb +15 -0
  315. data/test/model/spec_parameters.rb +148 -0
  316. data/test/model/spec_rule-expr.rb +66 -0
  317. data/test/model/spec_rule-io.rb +32 -0
  318. data/test/model/spec_rule.rb +158 -0
  319. data/test/model/spec_string.rb +106 -0
  320. data/test/model/spec_variable-table.rb +117 -0
  321. data/test/model/spec_variable.rb +84 -0
  322. data/test/parser/spec_block-parser.rb +5 -0
  323. data/test/parser/spec_block-parser.yml +85 -0
  324. data/test/parser/spec_common-parser.rb +281 -0
  325. data/test/parser/spec_expr-parser.rb +6 -0
  326. data/test/parser/spec_expr-parser.yml +82 -0
  327. data/test/parser/spec_feature-expr-parser.rb +32 -0
  328. data/test/parser/spec_feature-expr-parser.yml +25 -0
  329. data/test/parser/spec_flow-element-parser.rb +5 -0
  330. data/test/parser/spec_flow-element-parser.yml +180 -0
  331. data/test/parser/spec_literal-parser.rb +5 -0
  332. data/test/parser/spec_literal-parser.yml +123 -0
  333. data/test/parser/spec_rule-definition-parser.rb +5 -0
  334. data/test/parser/spec_rule-definition-parser.yml +93 -0
  335. data/test/patch/spec_rinda-patch.rb +32 -0
  336. data/test/patch/spec_uri-patch.rb +23 -0
  337. data/test/rule-handler/spec_action-handler.rb +135 -0
  338. data/test/rule-handler/spec_flow-handler.rb +127 -0
  339. data/test/spec_common.rb +14 -0
  340. data/test/spec_data-finder.rb +88 -0
  341. data/test/spec_data-finder.yml +115 -0
  342. data/test/spec_document.rb +76 -0
  343. data/test/spec_identifier.rb +29 -0
  344. data/test/spec_log.rb +52 -0
  345. data/test/spec_object.rb +20 -0
  346. data/test/spec_resource.rb +73 -0
  347. data/test/spec_update-criteria.rb +83 -0
  348. data/test/test-util.rb +223 -0
  349. data/test/transformer/spec_block-transformer.rb +26 -0
  350. data/test/transformer/spec_expr-transformer.rb +106 -0
  351. data/test/transformer/spec_feature-expr-transformer.rb +21 -0
  352. data/test/transformer/spec_flow-element-transformer.rb +154 -0
  353. data/test/transformer/spec_literal-transformer.rb +58 -0
  354. data/test/transformer/spec_rule-definition-transformer.rb +168 -0
  355. data/test/tuple-space/spec_tuple-space-provider.rb +36 -0
  356. data/test/tuple-space/spec_tuple-space-receiver.rb +32 -0
  357. data/test/tuple-space/spec_tuple-space-server.rb +49 -0
  358. data/test/tuple/spec_basic-tuple.rb +87 -0
  359. data/test/tuple/spec_data-tuple.rb +85 -0
  360. data/test/tuple/spec_finished-tuple.rb +61 -0
  361. data/test/tuple/spec_task-tuple.rb +127 -0
  362. data/test/tuple/spec_working-tuple.rb +58 -0
  363. data/test/uri-scheme/spec_broadcast-scheme.rb +40 -0
  364. data/test/uri-scheme/spec_dropbox-scheme.rb +31 -0
  365. data/test/uri-scheme/spec_local-scheme.rb +69 -0
  366. metadata +660 -0
@@ -0,0 +1,52 @@
1
+ Rule Main
2
+ input 'list.txt'
3
+ output 'sum.txt'
4
+ Flow
5
+ rule CalcEachLine
6
+ rule Aggregation
7
+ End
8
+
9
+ Rule CalcEachLine
10
+ input 'list.txt'
11
+ output 'line_sum*.txt'.all
12
+ Flow
13
+ rule MakeHeadTail
14
+ rule Sum
15
+ End
16
+
17
+ Rule MakeHeadTail
18
+ input 'list.txt'
19
+ output 'head*.txt'.all
20
+ output 'tail*.txt'.all
21
+ Action
22
+ #!/usr/bin/env ruby
23
+ i = 1
24
+ File.readlines('list.txt').each do |line|
25
+ head, tail = line.split(',')
26
+ File.open("head#{i}.txt", "w+"){|f| f.print head}
27
+ File.open("tail#{i}.txt", "w+"){|f| f.print tail}
28
+ i += 1
29
+ end
30
+ End
31
+
32
+ Rule Sum
33
+ input 'head*.txt'
34
+ input 'tail{$*}.txt'
35
+ output 'line_sum{$*}.txt'.stdout
36
+ Action
37
+ expr `cat {$INPUT[1]}` + `cat {$INPUT[2]}`
38
+ End
39
+
40
+ Rule Aggregation
41
+ input 'line_sum*.txt'.all
42
+ output 'sum.txt'.stdout
43
+ Action
44
+ #!/usr/bin/env ruby
45
+ sum = 0
46
+ '{$INPUT[1]}'.split(':').sort.each do |filename|
47
+ n = File.read(filename)
48
+ sum += n.to_i
49
+ puts n
50
+ end
51
+ puts "total: #{sum}"
52
+ End
@@ -0,0 +1,6 @@
1
+ Rule ABC
2
+ input '*.a'
3
+ output '*.b'
4
+ Flow
5
+ rule "abc"
6
+ End
@@ -0,0 +1,7 @@
1
+ Rule ABC
2
+ input '*.a'
3
+ output '*.b'
4
+ feature GGGGG
5
+ Action
6
+ cat {$I[1]} > {$O[1]}
7
+ End
@@ -0,0 +1,5 @@
1
+ Rule ABC
2
+ input '*.a'
3
+ output '*.b'
4
+ Flow
5
+ End
@@ -0,0 +1,6 @@
1
+ Rule ABC
2
+ input #####
3
+ output '*.b'
4
+ Action
5
+ cat {$I[1]} > {$O[1]}
6
+ End
@@ -0,0 +1,6 @@
1
+ Rule "aaa"
2
+ input '*.a'
3
+ output '*.b'
4
+ Action
5
+ cat {$I[1]} > {$O[1]}
6
+ End
@@ -0,0 +1,7 @@
1
+ Rule ABC
2
+ input '*.a'
3
+ output '*.b'
4
+ param 1
5
+ Action
6
+ cat {$I[1]} > {$O[1]}
7
+ End
@@ -0,0 +1,11 @@
1
+ $X := 1
2
+
3
+ Rule Main
4
+ input '*.a'
5
+ output '*b'
6
+ Action
7
+ cat {$I[1]} > {$O[1]}
8
+ echo {$X} >> {$O[1]}
9
+ End
10
+
11
+ $X := 2
@@ -0,0 +1,241 @@
1
+ #
2
+ # load libraries
3
+ #
4
+ require 'bundler/setup'
5
+ require 'set'
6
+ require 'socket'
7
+ require 'digest'
8
+ require 'forwardable'
9
+ require 'socket'
10
+ require 'drb/drb'
11
+ require 'drb/ssl'
12
+ require 'rinda/rinda'
13
+ require 'rinda/tuplespace'
14
+ require 'tempfile'
15
+ require 'yaml'
16
+ require 'singleton'
17
+ require 'timeout'
18
+ require 'thread'
19
+ require 'monitor'
20
+ require 'uri'
21
+ require 'pathname'
22
+ require 'time'
23
+ require 'etc'
24
+ require 'json'
25
+
26
+ require 'uuidtools'
27
+ require 'parslet'
28
+ require 'ostruct'
29
+ require 'net/ftp'
30
+ require 'highline'
31
+ require 'dropbox_sdk'
32
+
33
+ #
34
+ # load pione
35
+ #
36
+
37
+ # version
38
+ require 'pione/version'
39
+
40
+ # util
41
+ require 'pione/util/misc'
42
+ require 'pione/util/terminal'
43
+ require 'pione/util/message'
44
+ require 'pione/util/log'
45
+ require 'pione/util/waiter-table'
46
+ require 'pione/util/error-report'
47
+
48
+ # patch
49
+ require 'pione/patch/array-patch'
50
+ require 'pione/patch/drb-patch'
51
+ require 'pione/patch/rinda-patch'
52
+ require 'pione/patch/uri-patch'
53
+ require 'pione/patch/monitor-patch'
54
+
55
+ # system
56
+ require 'pione/system/object'
57
+ require 'pione/system/common'
58
+ require 'pione/system/config'
59
+ require 'pione/system/global'
60
+ require 'pione/system/init'
61
+ require 'pione/system/identifier'
62
+ require 'pione/system/document'
63
+ require 'pione/system/file-cache'
64
+
65
+ Pione.module_exec {const_set(:PioneObject, Pione::System::PioneObject)}
66
+ Pione.module_exec {const_set(:Global, Pione::System::Global)}
67
+
68
+ # uri-scheme
69
+ require 'pione/uri-scheme/basic-scheme'
70
+ require 'pione/uri-scheme/local-scheme'
71
+ require 'pione/uri-scheme/dropbox-scheme'
72
+ require 'pione/uri-scheme/broadcast-scheme'
73
+
74
+ # relay
75
+ require 'pione/relay/transmitter-socket'
76
+ require 'pione/relay/trampoline'
77
+ require 'pione/relay/receiver-socket'
78
+ require 'pione/relay/relay-socket'
79
+ require 'pione/relay/relay-client-db'
80
+ require 'pione/relay/relay-account-db'
81
+
82
+ # model
83
+ require 'pione/model/basic-model'
84
+ require 'pione/model/undefined-value'
85
+ require 'pione/model/list'
86
+ require 'pione/model/boolean'
87
+ require 'pione/model/integer'
88
+ require 'pione/model/float'
89
+ require 'pione/model/string'
90
+ require 'pione/model/feature-expr'
91
+ require 'pione/model/variable'
92
+ require 'pione/model/variable-table'
93
+ require 'pione/model/data-expr'
94
+ require 'pione/model/parameters'
95
+ require 'pione/model/package'
96
+ require 'pione/model/rule-expr'
97
+ require 'pione/model/binary-operator'
98
+ require 'pione/model/message'
99
+ require 'pione/model/call-rule'
100
+ require 'pione/model/assignment'
101
+ require 'pione/model/block'
102
+ require 'pione/model/rule'
103
+ require 'pione/model/rule-io'
104
+
105
+ # tuple
106
+ require 'pione/tuple/basic-tuple'
107
+ require 'pione/tuple/agent-tuple'
108
+ require 'pione/tuple/data-tuple'
109
+ require 'pione/tuple/finished-tuple'
110
+ require 'pione/tuple/process-info-tuple'
111
+ require 'pione/tuple/shift-tuple'
112
+ require 'pione/tuple/working-tuple'
113
+ require 'pione/tuple/attribute-tuple'
114
+ require 'pione/tuple/bye-tuple'
115
+ require 'pione/tuple/dry-run-tuple'
116
+ require 'pione/tuple/foreground-tuple'
117
+ require 'pione/tuple/request-rule-tuple'
118
+ require 'pione/tuple/task-tuple'
119
+ require 'pione/tuple/base-uri-tuple'
120
+ require 'pione/tuple/command-tuple'
121
+ require 'pione/tuple/exception-tuple'
122
+ require 'pione/tuple/log-tuple'
123
+ require 'pione/tuple/rule-tuple'
124
+ require 'pione/tuple/task-worker-resource-tuple'
125
+
126
+ # tuple-space
127
+ require 'pione/tuple-space/tuple-space-server-interface'
128
+ require 'pione/tuple-space/presence-notifier'
129
+ require 'pione/tuple-space/tuple-space-server'
130
+ require 'pione/tuple-space/tuple-space-receiver'
131
+ require 'pione/tuple-space/tuple-space-provider'
132
+ require 'pione/tuple-space/data-finder'
133
+ require 'pione/tuple-space/update-criteria'
134
+
135
+ # parser
136
+ require 'pione/parser/syntax-error'
137
+ require 'pione/parser/common-parser'
138
+ require 'pione/parser/literal-parser'
139
+ require 'pione/parser/feature-expr-parser'
140
+ require 'pione/parser/expr-parser'
141
+ require 'pione/parser/flow-element-parser'
142
+ require 'pione/parser/block-parser'
143
+ require 'pione/parser/rule-definition-parser'
144
+ require 'pione/parser/document-parser'
145
+
146
+ # transformer
147
+ require 'pione/transformer/transformer-module'
148
+ require 'pione/transformer/literal-transformer'
149
+ require 'pione/transformer/feature-expr-transformer'
150
+ require 'pione/transformer/expr-transformer'
151
+ require 'pione/transformer/flow-element-transformer'
152
+ require 'pione/transformer/block-transformer'
153
+ require 'pione/transformer/rule-definition-transformer'
154
+ require 'pione/transformer/document-transformer'
155
+
156
+ # resource
157
+ require 'pione/resource/basic-resource'
158
+ require 'pione/resource/local'
159
+ require 'pione/resource/ftp'
160
+ require 'pione/resource/dropbox-resource'
161
+
162
+ # rule-handler
163
+ require 'pione/rule-handler/basic-handler'
164
+ require 'pione/rule-handler/flow-handler'
165
+ require 'pione/rule-handler/action-handler'
166
+ require 'pione/rule-handler/root-handler'
167
+ require 'pione/rule-handler/system-handler'
168
+
169
+ # agent
170
+ require 'pione/agent/basic-agent'
171
+ require 'pione/agent/tuple-space-client'
172
+ require 'pione/agent/command-listener'
173
+ require 'pione/agent/task-worker'
174
+ require 'pione/agent/input-generator'
175
+ require 'pione/agent/rule-provider'
176
+ require 'pione/agent/logger'
177
+ require 'pione/agent/broker'
178
+ require 'pione/agent/process-manager'
179
+ require 'pione/agent/trivial-routine-worker'
180
+ require 'pione/agent/tuple-space-server-client-life-checker'
181
+
182
+ # front
183
+ require 'pione/front/basic-front'
184
+ require 'pione/front/task-worker-owner'
185
+ require 'pione/front/tuple-space-provider-owner'
186
+ require 'pione/front/client-front'
187
+ require 'pione/front/broker-front'
188
+ require 'pione/front/task-worker-front'
189
+ require 'pione/front/tuple-space-provider-front'
190
+ require 'pione/front/tuple-space-receiver-front'
191
+ require 'pione/front/relay-front'
192
+
193
+ # command-option
194
+ require 'pione/command-option/basic-option'
195
+ require 'pione/command-option/common-option'
196
+ require 'pione/command-option/daemon-option'
197
+ require 'pione/command-option/child-process-option'
198
+ require 'pione/command-option/presence-notifier-option'
199
+ require 'pione/command-option/tuple-space-provider-option'
200
+ require 'pione/command-option/tuple-space-provider-owner-option'
201
+ require 'pione/command-option/tuple-space-receiver-option'
202
+ require 'pione/command-option/task-worker-owner-option'
203
+
204
+ # command
205
+ require 'pione/command/basic-command'
206
+ require 'pione/command/front-owner-command'
207
+ require 'pione/command/daemon-process'
208
+ require 'pione/command/child-process'
209
+ require 'pione/command/pione-client'
210
+ require 'pione/command/pione-task-worker'
211
+ require 'pione/command/pione-broker'
212
+ require 'pione/command/pione-tuple-space-provider'
213
+ require 'pione/command/pione-tuple-space-receiver'
214
+ require 'pione/command/pione-tuple-space-viewer'
215
+ require 'pione/command/pione-relay'
216
+ require 'pione/command/pione-relay-client-db'
217
+ require 'pione/command/pione-relay-account-db'
218
+ require 'pione/command/pione-clean'
219
+ require 'pione/command/pione-syntax-checker'
220
+
221
+
222
+ #
223
+ # other settings
224
+ #
225
+ module Pione
226
+ include System
227
+ include Relay
228
+ include Util
229
+ include Util::Message
230
+ include Model
231
+ include TupleSpace
232
+ include Parser
233
+ include Transformer
234
+
235
+ module_function :debug_mode=
236
+ module_function :debug_mode?
237
+ end
238
+
239
+ include Pione
240
+ Thread.abort_on_exception = true
241
+ Pione::System::Init.new.init
@@ -0,0 +1,333 @@
1
+ module Pione
2
+ module Agent
3
+ # @api private
4
+ @table = Hash.new
5
+
6
+ class << self
7
+ # Returns a class corresponding to the agent type.
8
+ # @param [Symbol] type
9
+ # agent type
10
+ # @return [Pione::Agent::BasicAgent]
11
+ # agent class
12
+ def [](type)
13
+ @table[type]
14
+ end
15
+
16
+ # Sets an agent of the system.
17
+ # @param [Pione::Agent::BasicAgent] klass
18
+ # agent class
19
+ # @return [void]
20
+ def set_agent(klass)
21
+ @table[klass.agent_type] = klass
22
+ end
23
+ end
24
+
25
+ # Aborting is an exception for aborting agents.
26
+ class Aborting < Exception; end
27
+
28
+ # TransitionError happens when
29
+ class TransitionError < StandardError; end
30
+
31
+ # TimeoutStateWaiting happens when not reached expected in time.
32
+ class TimeoutStateWaiting < StandardError
33
+ # expected status
34
+ attr_reader :expected
35
+
36
+ # current status
37
+ attr_reader :current
38
+
39
+ # Creates an exception.
40
+ #
41
+ # @param [Symbol] expected
42
+ # expected state
43
+ # @param [Symbol] current
44
+ # current state
45
+ def initialize(expected, current)
46
+ @expected_state = expected
47
+ @current_state = current
48
+ end
49
+
50
+ # @private
51
+ def message
52
+ msg = "expected state is '%s' but current state is '%s'"
53
+ msg % [@expected_state, @current_state]
54
+ end
55
+ end
56
+
57
+ # StateTransitionSingleMethod provides state transition singleton methods.
58
+ module StateTransitionSingletonMethod
59
+ # Sets pre-defined states when the module is extended by others.
60
+ # @api private
61
+ def self.extended(mod)
62
+ mod.define_state :initialized
63
+ mod.define_state :terminated
64
+ mod.define_state :error
65
+
66
+ mod.define_state_transition :error => :terminated
67
+ end
68
+
69
+ # Defines new agent state.
70
+ # @param [Symbol] name
71
+ # state name
72
+ # @return [void]
73
+ def define_state(name)
74
+ @states ||= []
75
+ unless @states.include?(name)
76
+ @states << name
77
+
78
+ # define an instance method for checking current state
79
+ define_method("#{name}?") do
80
+ @__current_state__ == name
81
+ end
82
+
83
+ # define an instance method for transition
84
+ unless method_defined?("transit_to_#{name}")
85
+ define_method("transit_to_#{name}"){}
86
+ end
87
+ end
88
+ end
89
+
90
+ # Returns all states.
91
+ # @return [Array<Symbol>]
92
+ # state name list
93
+ def states
94
+ @states
95
+ end
96
+
97
+ # Returns state transition table.
98
+ # @return [Hash{Symbol => Symbol}]
99
+ # state transition table
100
+ def state_transition_table
101
+ @__state_transition_table__ ||= {nil => :initialized}
102
+ end
103
+
104
+ # Defines a state transition.
105
+ # @param [Hash{Symbol => Symbol}] data
106
+ # state transition as the key value pair of from-state and to-state
107
+ # @return [void]
108
+ def define_state_transition(data)
109
+ table = state_transition_table
110
+ table.merge!(data)
111
+ end
112
+
113
+ # Returns exception handler table.
114
+ # @return [Hash{Symbol => Symbol}]
115
+ # exception handler table
116
+ def exception_handler_table
117
+ @__exception_handler_table__ ||= {}
118
+ end
119
+
120
+ # Defines a state for handling exceptions.
121
+ # @param [Hash{Exception => Symbol}] data
122
+ # exception handler definition
123
+ # @return [void]
124
+ # @example
125
+ # define_exception_handler(StopIetration => :end_process)
126
+ def define_exception_handler(data)
127
+ table = exception_handler_table
128
+ table.merge!(data)
129
+ end
130
+
131
+ # Creates an agent and starts it.
132
+ # @param [Array<Object>] args
133
+ # arguments of state change
134
+ def start(*args, &b)
135
+ agent = new(*args)
136
+ b.call(self) if block_given?
137
+ agent.start
138
+ return agent
139
+ end
140
+
141
+ # Returns list of exceptions
142
+ # @return [Array<Exception>]
143
+ # exceptions
144
+ def known_exceptions
145
+ exception_handler_table.keys
146
+ end
147
+ end
148
+
149
+ # StateTransitionMethod provides state transition methods.
150
+ module StateTransitionMethod
151
+ # State transition thread.
152
+ attr_reader :running_thread
153
+
154
+ attr_accessor :show_agent_status
155
+
156
+ # Start agent activity.
157
+ # @return the agent
158
+ def start
159
+ raise TransitionError.new(current_state) if current_state == :terminated
160
+
161
+ @__owner_thread__ = Thread.current
162
+ @__result__ = nil
163
+ @running_thread = Thread.new { start_running }
164
+ return self
165
+ end
166
+
167
+ # Return state of current agent.
168
+ # @return [Symbol]
169
+ # state of current agent
170
+ def current_state
171
+ @__current_state__ ||= nil
172
+ end
173
+
174
+ # Transits to the next state.
175
+ # @return [void]
176
+ def transit
177
+ # raise error if the current state is terminated
178
+ if current_state == :terminated
179
+ raise TransitionError.new(current_state)
180
+ end
181
+
182
+ state_transition_table = self.class.state_transition_table
183
+ begin
184
+ next_state = get_next_state(state_transition_table[current_state])
185
+ set_current_state(next_state)
186
+ p next_state if @show_agent_status
187
+ @__result__ = call_transition_method(current_state, *@__result__)
188
+ rescue Aborting
189
+ raise
190
+ rescue Exception => e
191
+ if error_state = exception_handler(e)
192
+ # known exception : go error state
193
+ set_next_state(error_state)
194
+ @__result__ = [e]
195
+ else
196
+ # unknown exception : raise it to owner thread
197
+ if @__owner_thread__.alive?
198
+ @__owner_thread__.raise e
199
+ else
200
+ raise e
201
+ end
202
+ end
203
+ end
204
+ end
205
+
206
+ # Sleep till the agent becomes the state.
207
+ def wait_till(state, sec=5)
208
+ begin
209
+ timeout(sec) do
210
+ sleep 0.1 while not(current_state == state)
211
+ end
212
+ rescue Timeout::Error
213
+ raise TimeoutStateWaiting.new(state, current_state)
214
+ end
215
+ end
216
+
217
+ # Terminate to transit.
218
+ def terminate
219
+ # abort the agent when called by other thread
220
+ abort unless @running_thread == Thread.current
221
+ # transit to terminated
222
+ begin
223
+ res = call_transition_method(:terminated)
224
+ rescue DRb::DRbConnError, DRb::ReplyReaderThreadError
225
+ end
226
+ # set agent state
227
+ set_current_state(:terminated)
228
+ return res
229
+ end
230
+
231
+ private
232
+
233
+ # Set new agent's state.
234
+ def set_current_state(state)
235
+ @__current_state__ = state
236
+ end
237
+
238
+ # Return a transition method of the state.
239
+ def transition_method(state)
240
+ method("transit_to_#{state}")
241
+ end
242
+
243
+ # Call a transition method.
244
+ def call_transition_method(state, *args)
245
+ method = transition_method(state)
246
+ arity = method.arity
247
+ _args = args[0...arity]
248
+ method.call(*_args)
249
+ end
250
+
251
+ # Returns the handling state for the exception.
252
+ def exception_handler(e)
253
+ handler = nil
254
+ table = self.class.exception_handler_table
255
+ e.class.ancestors.each do |mod|
256
+ if table.has_key?(mod)
257
+ handler = table[mod]
258
+ break
259
+ end
260
+ end
261
+ return handler
262
+ end
263
+
264
+ # Start to transit agent's state.
265
+ # For example, logger should transit initialized, logging, logging, ...
266
+ def start_running
267
+ begin
268
+ while not(terminated?)
269
+ transit
270
+ end
271
+ rescue Aborting
272
+ # do nothing, agent will be dead...
273
+ end
274
+ end
275
+
276
+ def set_next_state(state)
277
+ @__next_state__ = state
278
+ end
279
+
280
+ def get_next_state(state)
281
+ if @__next_state__
282
+ next_state = @__next_state__
283
+ @__next_state__ = nil
284
+ return next_state
285
+ else
286
+ next_state = state.kind_of?(Proc) ? state.call(self, @__result__) : state
287
+ unless next_state
288
+ msg = "unknown state transition: #{current_state} -> #{state} at #{self}"
289
+ raise ScriptError.new(msg)
290
+ end
291
+ return next_state
292
+ end
293
+ end
294
+
295
+ # Abort the agent.
296
+ def abort
297
+ if @running_thread.alive?
298
+ # raise Aborting exception
299
+ @running_thread.raise Aborting
300
+ # wait to stop the thread
301
+ @running_thread.join
302
+ end if @running_thread
303
+ end
304
+ end
305
+
306
+ # BasicAgent is a super class for PIONE agents.
307
+ class BasicAgent < PioneObject
308
+ include DRbUndumped
309
+ extend StateTransitionSingletonMethod
310
+ include StateTransitionMethod
311
+
312
+ def self.inherited(subclass)
313
+ states.each {|state| subclass.define_state state }
314
+ define_state_transition(state_transition_table)
315
+ end
316
+
317
+ # Set the agent type.
318
+ def self.set_agent_type(agent_type)
319
+ @agent_type = agent_type
320
+ end
321
+
322
+ # Return the agent type.
323
+ def self.agent_type
324
+ @agent_type
325
+ end
326
+
327
+ # Return agent type of the object.
328
+ def agent_type
329
+ self.class.agent_type
330
+ end
331
+ end
332
+ end
333
+ end