pione 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +14 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +94 -0
- data/Rakefile +118 -0
- data/bin/pione-broker +5 -0
- data/bin/pione-clean +5 -0
- data/bin/pione-client +5 -0
- data/bin/pione-eval +111 -0
- data/bin/pione-relay +5 -0
- data/bin/pione-relay-account-db +5 -0
- data/bin/pione-relay-client-db +5 -0
- data/bin/pione-search-log +30 -0
- data/bin/pione-syntax-checker +5 -0
- data/bin/pione-task-worker +5 -0
- data/bin/pione-tuple-space-provider +5 -0
- data/bin/pione-tuple-space-receiver +5 -0
- data/bin/pione-tuple-space-viewer +5 -0
- data/demo/demo.rb +311 -0
- data/demo/public/base.css +94 -0
- data/demo/public/demo.js +107 -0
- data/demo/public/index.html +91 -0
- data/demo/public/jquery-1.8.3.min.js +2 -0
- data/example/CountChar/CountChar.pione +64 -0
- data/example/CountChar/misc/CountChar.rb +22 -0
- data/example/CountChar/text/aidokushono_insho.txt +32 -0
- data/example/CountChar/text/aikokuka_shokan.txt +108 -0
- data/example/CountChar/text/carlyle_hakubutsukan.txt +58 -0
- data/example/CountChar/text/dark_minister.txt +2440 -0
- data/example/CountChar/text/kaikano_otto.txt +61 -0
- data/example/CountChar/text/kaikon.txt +30 -0
- data/example/CountChar/text/nagashimano_shi.txt +45 -0
- data/example/CountChar/text/saikachibuchi.txt +80 -0
- data/example/CountChar/text/saikonihonno_josei.txt +91 -0
- data/example/CountChar/text/taishojugonenno_bundan.txt +21 -0
- data/example/FeatureExample/FeatureExample.pione +7 -0
- data/example/Fib/Fib.pione +56 -0
- data/example/Fib/FibBC.pione +56 -0
- data/example/HelloWorld/HelloWorld.pione +5 -0
- data/example/LucasNumber/LucasNumber.pione +64 -0
- data/example/MakePair/MakePair.pione +14 -0
- data/example/MakePair/data/1.i +0 -0
- data/example/MakePair/data/2.i +0 -0
- data/example/MakePair/data/3.i +0 -0
- data/example/MakePair/data/4.i +0 -0
- data/example/MakePair/data/5.i +0 -0
- data/example/SieveOfEratosthenes/SieveOfEratosthenes.pione +61 -0
- data/example/SingleParticlesWithRef/Makefile +289 -0
- data/example/SingleParticlesWithRef/SingleParticlesWithRef.Makefile +153 -0
- data/example/SingleParticlesWithRef/SingleParticlesWithRef.pione +116 -0
- data/example/SingleParticlesWithRef/SingleParticlesWithRefFull.pione +400 -0
- data/example/SingleParticlesWithRef/data/121p-shift-0-0-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-0-120-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-0-180-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-0-240-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-0-300-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-0-60-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-120-0-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-120-120-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-120-180-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-120-240-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-120-300-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-120-60-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-180-0-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-180-120-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-180-180-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-180-240-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-180-300-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-180-60-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-240-0-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-240-120-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-240-180-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-240-240-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-240-300-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-240-60-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-300-0-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-300-120-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-300-180-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-300-240-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-300-300-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-300-60-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-60-0-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-60-120-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-60-180-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-60-240-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-60-300-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-60-60-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-0-0-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-0-120-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-0-180-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-0-240-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-0-300-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-0-60-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-120-0-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-120-120-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-120-180-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-120-240-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-120-300-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-120-60-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-180-0-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-180-120-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-180-180-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-180-240-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-180-300-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-180-60-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-240-0-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-240-120-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-240-180-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-240-240-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-240-300-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-240-60-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-300-0-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-300-120-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-300-180-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-300-240-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-300-300-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-300-60-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-60-0-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-60-120-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-60-180-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-60-240-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-60-300-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-60-60-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift.pdb +3381 -0
- data/example/SingleParticlesWithRef/data/all.ref2d +0 -0
- data/example/SingleParticlesWithRef/data/all.ref3d +0 -0
- data/example/Sum/Sum.pione +52 -0
- data/example/SyntaxError/call_rule_error.pione +6 -0
- data/example/SyntaxError/feature_line_error.pione +7 -0
- data/example/SyntaxError/flow_block_error.pione +5 -0
- data/example/SyntaxError/input_line_error.pione +6 -0
- data/example/SyntaxError/invalid_rule_name.pione +6 -0
- data/example/SyntaxError/param_line_error.pione +7 -0
- data/example/SyntaxError/variable-binding-error.pione +11 -0
- data/lib/pione.rb +241 -0
- data/lib/pione/agent/basic-agent.rb +333 -0
- data/lib/pione/agent/broker.rb +274 -0
- data/lib/pione/agent/command-listener.rb +47 -0
- data/lib/pione/agent/input-generator.rb +194 -0
- data/lib/pione/agent/logger.rb +65 -0
- data/lib/pione/agent/process-manager.rb +38 -0
- data/lib/pione/agent/rule-provider.rb +64 -0
- data/lib/pione/agent/task-worker.rb +274 -0
- data/lib/pione/agent/trivial-routine-worker.rb +28 -0
- data/lib/pione/agent/tuple-space-client.rb +146 -0
- data/lib/pione/agent/tuple-space-server-client-life-checker.rb +29 -0
- data/lib/pione/command-option/basic-option.rb +42 -0
- data/lib/pione/command-option/child-process-option.rb +17 -0
- data/lib/pione/command-option/common-option.rb +29 -0
- data/lib/pione/command-option/daemon-option.rb +12 -0
- data/lib/pione/command-option/presence-notifier-option.rb +15 -0
- data/lib/pione/command-option/task-worker-owner-option.rb +17 -0
- data/lib/pione/command-option/tuple-space-provider-option.rb +26 -0
- data/lib/pione/command-option/tuple-space-provider-owner-option.rb +16 -0
- data/lib/pione/command-option/tuple-space-receiver-option.rb +12 -0
- data/lib/pione/command/basic-command.rb +126 -0
- data/lib/pione/command/child-process.rb +43 -0
- data/lib/pione/command/daemon-process.rb +18 -0
- data/lib/pione/command/front-owner-command.rb +37 -0
- data/lib/pione/command/pione-broker.rb +53 -0
- data/lib/pione/command/pione-clean.rb +16 -0
- data/lib/pione/command/pione-client.rb +273 -0
- data/lib/pione/command/pione-relay-account-db.rb +85 -0
- data/lib/pione/command/pione-relay-client-db.rb +80 -0
- data/lib/pione/command/pione-relay.rb +47 -0
- data/lib/pione/command/pione-syntax-checker.rb +103 -0
- data/lib/pione/command/pione-task-worker.rb +123 -0
- data/lib/pione/command/pione-tuple-space-provider.rb +87 -0
- data/lib/pione/command/pione-tuple-space-receiver.rb +55 -0
- data/lib/pione/command/pione-tuple-space-viewer.rb +151 -0
- data/lib/pione/command/tuple-space-provider-owner.rb +6 -0
- data/lib/pione/front/basic-front.rb +64 -0
- data/lib/pione/front/broker-front.rb +30 -0
- data/lib/pione/front/client-front.rb +28 -0
- data/lib/pione/front/relay-front.rb +19 -0
- data/lib/pione/front/task-worker-front.rb +16 -0
- data/lib/pione/front/task-worker-owner.rb +42 -0
- data/lib/pione/front/tuple-space-provider-front.rb +22 -0
- data/lib/pione/front/tuple-space-provider-owner.rb +11 -0
- data/lib/pione/front/tuple-space-receiver-front.rb +18 -0
- data/lib/pione/model/assignment.rb +89 -0
- data/lib/pione/model/basic-model.rb +395 -0
- data/lib/pione/model/binary-operator.rb +80 -0
- data/lib/pione/model/block.rb +233 -0
- data/lib/pione/model/boolean.rb +138 -0
- data/lib/pione/model/call-rule.rb +69 -0
- data/lib/pione/model/data-expr.rb +360 -0
- data/lib/pione/model/feature-expr.rb +794 -0
- data/lib/pione/model/float.rb +107 -0
- data/lib/pione/model/integer.rb +140 -0
- data/lib/pione/model/list.rb +104 -0
- data/lib/pione/model/message.rb +80 -0
- data/lib/pione/model/package.rb +48 -0
- data/lib/pione/model/parameters.rb +282 -0
- data/lib/pione/model/rule-expr.rb +120 -0
- data/lib/pione/model/rule-io.rb +166 -0
- data/lib/pione/model/rule.rb +294 -0
- data/lib/pione/model/string.rb +111 -0
- data/lib/pione/model/undefined-value.rb +24 -0
- data/lib/pione/model/variable-table.rb +315 -0
- data/lib/pione/model/variable.rb +87 -0
- data/lib/pione/parser/block-parser.rb +83 -0
- data/lib/pione/parser/common-parser.rb +145 -0
- data/lib/pione/parser/document-parser.rb +58 -0
- data/lib/pione/parser/error-message.yml +4 -0
- data/lib/pione/parser/expr-parser.rb +266 -0
- data/lib/pione/parser/feature-expr-parser.rb +105 -0
- data/lib/pione/parser/flow-element-parser.rb +181 -0
- data/lib/pione/parser/literal-parser.rb +182 -0
- data/lib/pione/parser/rule-definition-parser.rb +163 -0
- data/lib/pione/parser/syntax-error.rb +61 -0
- data/lib/pione/patch/array-patch.rb +3 -0
- data/lib/pione/patch/drb-patch.rb +467 -0
- data/lib/pione/patch/monitor-patch.rb +16 -0
- data/lib/pione/patch/rinda-patch.rb +759 -0
- data/lib/pione/patch/uri-patch.rb +66 -0
- data/lib/pione/relay/receiver-socket.rb +69 -0
- data/lib/pione/relay/relay-account-db.rb +55 -0
- data/lib/pione/relay/relay-client-db.rb +53 -0
- data/lib/pione/relay/relay-socket.rb +215 -0
- data/lib/pione/relay/trampoline.rb +22 -0
- data/lib/pione/relay/transmitter-socket.rb +167 -0
- data/lib/pione/resource/basic-resource.rb +92 -0
- data/lib/pione/resource/dropbox-resource.rb +106 -0
- data/lib/pione/resource/ftp.rb +84 -0
- data/lib/pione/resource/local.rb +113 -0
- data/lib/pione/rule-handler/action-handler.rb +184 -0
- data/lib/pione/rule-handler/basic-handler.rb +217 -0
- data/lib/pione/rule-handler/flow-handler.rb +339 -0
- data/lib/pione/rule-handler/root-handler.rb +23 -0
- data/lib/pione/rule-handler/system-handler.rb +13 -0
- data/lib/pione/system/common.rb +22 -0
- data/lib/pione/system/config.rb +20 -0
- data/lib/pione/system/document.rb +81 -0
- data/lib/pione/system/file-cache.rb +150 -0
- data/lib/pione/system/global.rb +346 -0
- data/lib/pione/system/identifier.rb +61 -0
- data/lib/pione/system/init.rb +16 -0
- data/lib/pione/system/object.rb +35 -0
- data/lib/pione/transformer/block-transformer.rb +23 -0
- data/lib/pione/transformer/document-transformer.rb +36 -0
- data/lib/pione/transformer/expr-transformer.rb +89 -0
- data/lib/pione/transformer/feature-expr-transformer.rb +56 -0
- data/lib/pione/transformer/flow-element-transformer.rb +66 -0
- data/lib/pione/transformer/literal-transformer.rb +76 -0
- data/lib/pione/transformer/rule-definition-transformer.rb +62 -0
- data/lib/pione/transformer/transformer-module.rb +37 -0
- data/lib/pione/tuple-space/data-finder.rb +165 -0
- data/lib/pione/tuple-space/presence-notifier.rb +83 -0
- data/lib/pione/tuple-space/relay.rb +9 -0
- data/lib/pione/tuple-space/tuple-space-provider.rb +85 -0
- data/lib/pione/tuple-space/tuple-space-receiver.rb +140 -0
- data/lib/pione/tuple-space/tuple-space-server-interface.rb +60 -0
- data/lib/pione/tuple-space/tuple-space-server.rb +156 -0
- data/lib/pione/tuple-space/update-criteria.rb +96 -0
- data/lib/pione/tuple/agent-tuple.rb +10 -0
- data/lib/pione/tuple/attribute-tuple.rb +7 -0
- data/lib/pione/tuple/base-uri-tuple.rb +9 -0
- data/lib/pione/tuple/basic-tuple.rb +317 -0
- data/lib/pione/tuple/bye-tuple.rb +9 -0
- data/lib/pione/tuple/command-tuple.rb +9 -0
- data/lib/pione/tuple/data-tuple.rb +18 -0
- data/lib/pione/tuple/dry-run-tuple.rb +8 -0
- data/lib/pione/tuple/exception-tuple.rb +11 -0
- data/lib/pione/tuple/finished-tuple.rb +17 -0
- data/lib/pione/tuple/foreground-tuple.rb +7 -0
- data/lib/pione/tuple/log-tuple.rb +14 -0
- data/lib/pione/tuple/process-info-tuple.rb +9 -0
- data/lib/pione/tuple/request-rule-tuple.rb +9 -0
- data/lib/pione/tuple/rule-tuple.rb +10 -0
- data/lib/pione/tuple/shift-tuple.rb +13 -0
- data/lib/pione/tuple/task-tuple.rb +36 -0
- data/lib/pione/tuple/task-worker-resource-tuple.rb +9 -0
- data/lib/pione/tuple/working-tuple.rb +13 -0
- data/lib/pione/uri-scheme/basic-scheme.rb +40 -0
- data/lib/pione/uri-scheme/broadcast-scheme.rb +11 -0
- data/lib/pione/uri-scheme/dropbox-scheme.rb +9 -0
- data/lib/pione/uri-scheme/local-scheme.rb +28 -0
- data/lib/pione/util/error-report.rb +12 -0
- data/lib/pione/util/log.rb +79 -0
- data/lib/pione/util/message.rb +155 -0
- data/lib/pione/util/misc.rb +73 -0
- data/lib/pione/util/terminal.rb +78 -0
- data/lib/pione/util/waiter-table.rb +53 -0
- data/lib/pione/version.rb +3 -0
- data/misc/env.sh +2 -0
- data/misc/test-drb-stop-service.rb +34 -0
- data/misc/test-ensure-and-thread-kill.rb +40 -0
- data/misc/test-many-waiters-client.rb +56 -0
- data/misc/test-many-waiters-server.rb +14 -0
- data/misc/write_and_take_test.png +0 -0
- data/misc/write_and_take_test.rb +36 -0
- data/pione.gemspec +49 -0
- data/test/agent/spec_basic-agent.rb +170 -0
- data/test/agent/spec_broker.rb +36 -0
- data/test/agent/spec_command-listener.rb +30 -0
- data/test/agent/spec_input-generator.rb +123 -0
- data/test/agent/spec_logger.rb +71 -0
- data/test/agent/spec_rule-provider.rb +65 -0
- data/test/agent/spec_task-worker.rb +307 -0
- data/test/agent/spec_tuple-space-client.rb +30 -0
- data/test/model/spec_assignment.rb +51 -0
- data/test/model/spec_binary-operator.rb +39 -0
- data/test/model/spec_block.rb +154 -0
- data/test/model/spec_boolean.rb +115 -0
- data/test/model/spec_call-rule.rb +23 -0
- data/test/model/spec_data-expr.rb +312 -0
- data/test/model/spec_feature-expr.rb +359 -0
- data/test/model/spec_feature-expr.yml +16 -0
- data/test/model/spec_float.rb +141 -0
- data/test/model/spec_integer.rb +141 -0
- data/test/model/spec_list.rb +26 -0
- data/test/model/spec_message.rb +42 -0
- data/test/model/spec_package.rb +15 -0
- data/test/model/spec_parameters.rb +148 -0
- data/test/model/spec_rule-expr.rb +66 -0
- data/test/model/spec_rule-io.rb +32 -0
- data/test/model/spec_rule.rb +158 -0
- data/test/model/spec_string.rb +106 -0
- data/test/model/spec_variable-table.rb +117 -0
- data/test/model/spec_variable.rb +84 -0
- data/test/parser/spec_block-parser.rb +5 -0
- data/test/parser/spec_block-parser.yml +85 -0
- data/test/parser/spec_common-parser.rb +281 -0
- data/test/parser/spec_expr-parser.rb +6 -0
- data/test/parser/spec_expr-parser.yml +82 -0
- data/test/parser/spec_feature-expr-parser.rb +32 -0
- data/test/parser/spec_feature-expr-parser.yml +25 -0
- data/test/parser/spec_flow-element-parser.rb +5 -0
- data/test/parser/spec_flow-element-parser.yml +180 -0
- data/test/parser/spec_literal-parser.rb +5 -0
- data/test/parser/spec_literal-parser.yml +123 -0
- data/test/parser/spec_rule-definition-parser.rb +5 -0
- data/test/parser/spec_rule-definition-parser.yml +93 -0
- data/test/patch/spec_rinda-patch.rb +32 -0
- data/test/patch/spec_uri-patch.rb +23 -0
- data/test/rule-handler/spec_action-handler.rb +135 -0
- data/test/rule-handler/spec_flow-handler.rb +127 -0
- data/test/spec_common.rb +14 -0
- data/test/spec_data-finder.rb +88 -0
- data/test/spec_data-finder.yml +115 -0
- data/test/spec_document.rb +76 -0
- data/test/spec_identifier.rb +29 -0
- data/test/spec_log.rb +52 -0
- data/test/spec_object.rb +20 -0
- data/test/spec_resource.rb +73 -0
- data/test/spec_update-criteria.rb +83 -0
- data/test/test-util.rb +223 -0
- data/test/transformer/spec_block-transformer.rb +26 -0
- data/test/transformer/spec_expr-transformer.rb +106 -0
- data/test/transformer/spec_feature-expr-transformer.rb +21 -0
- data/test/transformer/spec_flow-element-transformer.rb +154 -0
- data/test/transformer/spec_literal-transformer.rb +58 -0
- data/test/transformer/spec_rule-definition-transformer.rb +168 -0
- data/test/tuple-space/spec_tuple-space-provider.rb +36 -0
- data/test/tuple-space/spec_tuple-space-receiver.rb +32 -0
- data/test/tuple-space/spec_tuple-space-server.rb +49 -0
- data/test/tuple/spec_basic-tuple.rb +87 -0
- data/test/tuple/spec_data-tuple.rb +85 -0
- data/test/tuple/spec_finished-tuple.rb +61 -0
- data/test/tuple/spec_task-tuple.rb +127 -0
- data/test/tuple/spec_working-tuple.rb +58 -0
- data/test/uri-scheme/spec_broadcast-scheme.rb +40 -0
- data/test/uri-scheme/spec_dropbox-scheme.rb +31 -0
- data/test/uri-scheme/spec_local-scheme.rb +69 -0
- metadata +660 -0
@@ -0,0 +1,76 @@
|
|
1
|
+
require_relative 'test-util'
|
2
|
+
|
3
|
+
src = <<DOCUMENT
|
4
|
+
$X := 1
|
5
|
+
|
6
|
+
Rule Main
|
7
|
+
input '*.txt'
|
8
|
+
output '*.result'
|
9
|
+
Flow
|
10
|
+
rule RuleA
|
11
|
+
rule RuleB
|
12
|
+
rule RuleC
|
13
|
+
End
|
14
|
+
|
15
|
+
Rule RuleA
|
16
|
+
input '*.txt'
|
17
|
+
output '{$I[1,1]}.a'
|
18
|
+
Action
|
19
|
+
command_a {$I[1]} > {$O[1]}
|
20
|
+
End
|
21
|
+
|
22
|
+
Rule RuleB
|
23
|
+
input '*.a'
|
24
|
+
output '{$I[1,1]}.b'
|
25
|
+
Action
|
26
|
+
command_b {$I[1]} > {$O[1]}
|
27
|
+
End
|
28
|
+
|
29
|
+
Rule RuleC
|
30
|
+
input '*.b'
|
31
|
+
output '{$I[1,1]}.result'
|
32
|
+
Action
|
33
|
+
command_c {$I[1]} > {$O[1]}
|
34
|
+
End
|
35
|
+
DOCUMENT
|
36
|
+
|
37
|
+
describe 'Document' do
|
38
|
+
it 'should read a document from a string' do
|
39
|
+
doc = Document.parse(src)
|
40
|
+
doc.rules.size.should == 4
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should read a document from a file' do
|
44
|
+
temp = Tempfile.new("spec_document")
|
45
|
+
temp.write(src)
|
46
|
+
path = temp.path
|
47
|
+
temp.close(false)
|
48
|
+
doc = Document.load(path)
|
49
|
+
doc.rules.size.should == 4
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should get rules by rule path' do
|
53
|
+
doc = Document.parse(src)
|
54
|
+
doc["&main:Main"].should.kind_of(Model::Rule)
|
55
|
+
doc["&main:RuleA"].should.kind_of(Model::Rule)
|
56
|
+
doc["&main:RuleB"].should.kind_of(Model::Rule)
|
57
|
+
doc["&main:RuleC"].should.kind_of(Model::Rule)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should have global variable' do
|
61
|
+
doc = Document.parse(src)
|
62
|
+
doc["&main:Main"].params["X"].should == 1.to_pione
|
63
|
+
doc["&main:RuleA"].params["X"].should == 1.to_pione
|
64
|
+
doc["&main:RuleB"].params["X"].should == 1.to_pione
|
65
|
+
doc["&main:RuleC"].params["X"].should == 1.to_pione
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should raise variable binding error' do
|
69
|
+
should.raise(VariableBindingError) do
|
70
|
+
Document.parse <<-PIONE
|
71
|
+
$X := 1
|
72
|
+
$X := 2
|
73
|
+
PIONE
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative 'test-util'
|
2
|
+
|
3
|
+
describe 'ID' do
|
4
|
+
it 'should get task id' do
|
5
|
+
ID.task_id([], Parameters.empty).size.should == 32
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should get same id from same task' do
|
9
|
+
id = ID.task_id([DataExpr["1.a"]], Parameters.empty)
|
10
|
+
id.should == ID.task_id([DataExpr["1.a"]], Parameters.empty)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should get different id from different task' do
|
14
|
+
id = [
|
15
|
+
ID.task_id([], Parameters.empty),
|
16
|
+
ID.task_id([DataExpr["1.a"]], Parameters.empty),
|
17
|
+
ID.task_id([DataExpr["2.a"]], Parameters.empty),
|
18
|
+
ID.task_id([], {"var" => "1.a"}.to_params),
|
19
|
+
ID.task_id([], {"var" => "2.a"}.to_params),
|
20
|
+
ID.task_id([DataExpr["1.a"]], {"var" => "1.a"}.to_params),
|
21
|
+
ID.task_id([DataExpr["2.a"]], {"var" => "2.a"}.to_params)
|
22
|
+
]
|
23
|
+
7.times do |i|
|
24
|
+
7.times do |ii|
|
25
|
+
id[i+1].should.not == id[ii+1] unless i == ii
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/test/spec_log.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require_relative 'test-util.rb'
|
2
|
+
|
3
|
+
include Pione
|
4
|
+
|
5
|
+
describe 'Log' do
|
6
|
+
it 'should create without block' do
|
7
|
+
should.not.raise { Log.new }
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should create with block' do
|
11
|
+
should.not.raise { Log.new{} }
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should add a record' do
|
15
|
+
log = Log.new do |l|
|
16
|
+
l.add_record("spec_log", "action", "test")
|
17
|
+
end
|
18
|
+
log.records.size.should == 1
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should add records' do
|
22
|
+
log = Log.new do |l|
|
23
|
+
l.add_record("spec_log", "test1", "a")
|
24
|
+
l.add_record("spec_log", "test2", "b")
|
25
|
+
end
|
26
|
+
log.records.size.should == 2
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should format as string' do
|
30
|
+
log = Log.new do |l|
|
31
|
+
l.add_record("spec_log", "action", "test")
|
32
|
+
end
|
33
|
+
md = /(.+)\s+[A-Z0-9]{4}\s+\.spec_log\.action:\s+\"test\"/.match(log.format)
|
34
|
+
md.should.not.be.nil
|
35
|
+
should.not.raise { Time.iso8601(md[1]) }
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should format as string' do
|
39
|
+
log = Log.new do |l|
|
40
|
+
l.add_record("spec_log", "test1", "a")
|
41
|
+
l.add_record("spec_log", "test2", "b")
|
42
|
+
end
|
43
|
+
lines = log.format.split("\n")
|
44
|
+
lines.size.should == 2
|
45
|
+
md1 = /^(.+)\s+[A-Z0-9]{4}\s+\.spec_log\.test1:\s+\"a\"$/.match(lines[0])
|
46
|
+
md1.should.not.be.nil
|
47
|
+
should.not.raise { Time.iso8601(md1[1]) }
|
48
|
+
md2 = /^(.+)\s+[A-Z0-9]{4}\s+\.spec_log\.test2:\s+\"b\"$/.match(lines[1])
|
49
|
+
md2.should.not.be.nil
|
50
|
+
should.not.raise { Time.iso8601(md2[1]) }
|
51
|
+
end
|
52
|
+
end
|
data/test/spec_object.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative 'test-util'
|
2
|
+
|
3
|
+
describe 'PioneObject' do
|
4
|
+
it "should get UUID as string" do
|
5
|
+
PioneObject.new.uuid.size.should == 36
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should get same UUID from same object" do
|
9
|
+
obj1 = PioneObject.new
|
10
|
+
obj1.uuid.should == obj1.uuid
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should get different uuids from different objects" do
|
14
|
+
obj1 = PioneObject.new
|
15
|
+
obj2 = PioneObject.new
|
16
|
+
obj1.uuid.should == obj1.uuid
|
17
|
+
obj1.uuid.should.not == obj2.uuid
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
require_relative 'test-util'
|
3
|
+
|
4
|
+
describe 'Resource' do
|
5
|
+
describe 'Local' do
|
6
|
+
before do
|
7
|
+
path = Tempfile.new("spec_resource_").path
|
8
|
+
@uri = ::URI.parse("local:#{path}")
|
9
|
+
@local = Resource[@uri]
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should create a file' do
|
13
|
+
@local.create("abc")
|
14
|
+
File.read(@uri.path).should == "abc"
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should read a file' do
|
18
|
+
@local.create("abc")
|
19
|
+
@local.read.should == "abc"
|
20
|
+
@local.read.should == "abc"
|
21
|
+
@local.read.should.not == "def"
|
22
|
+
File.delete(@uri.path)
|
23
|
+
should.raise(Resource::NotFound) { @local.read }
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should update a file' do
|
27
|
+
@local.create("abc")
|
28
|
+
@local.read.should == "abc"
|
29
|
+
@local.update("defg")
|
30
|
+
@local.read.should == "defg"
|
31
|
+
@local.update("hi")
|
32
|
+
@local.read.should == "hi"
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should delete a file' do
|
36
|
+
should.not.raise { @local.delete }
|
37
|
+
@local.create("abc")
|
38
|
+
@local.delete
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
begin
|
43
|
+
@uri = URI("ftp://anonymous:test@localhost/pione/test-a.txt")
|
44
|
+
@ftp = Resource[@uri]
|
45
|
+
@ftp.create("abc")
|
46
|
+
@ftp.delete
|
47
|
+
|
48
|
+
describe 'FTP' do
|
49
|
+
before do
|
50
|
+
path = Tempfile.new("spec_resource_").path
|
51
|
+
# @uri = URI("ftp://anonymous:test@localhost/pione/test-a.txt")
|
52
|
+
# @ftp = Resource[@uri]
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should create a file and read it' do
|
56
|
+
@ftp.create("abc")
|
57
|
+
@ftp.read.should == "abc"
|
58
|
+
@ftp.delete
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should update a file' do
|
62
|
+
@ftp.create("abc")
|
63
|
+
@ftp.read.should == "abc"
|
64
|
+
@ftp.update("defg")
|
65
|
+
@ftp.read.should == "defg"
|
66
|
+
@ftp.update("hi")
|
67
|
+
@ftp.read.should == "hi"
|
68
|
+
@ftp.delete
|
69
|
+
end
|
70
|
+
end
|
71
|
+
rescue Errno::ECONNREFUSED
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require_relative 'test-util'
|
2
|
+
|
3
|
+
data = DataExpr.new('*')
|
4
|
+
|
5
|
+
document = Document.parse(<<DOCUMENT)
|
6
|
+
Rule NoOutputsRule
|
7
|
+
input '*'
|
8
|
+
Action---
|
9
|
+
|
10
|
+
--End
|
11
|
+
|
12
|
+
Rule OutputsRule
|
13
|
+
input '*.a'
|
14
|
+
output '*.b'
|
15
|
+
Action
|
16
|
+
cat {$INPUT[1]} > {$OUTPUT[1]}
|
17
|
+
End
|
18
|
+
DOCUMENT
|
19
|
+
$no_outputs_rule = document["&main:NoOutputsRule"]
|
20
|
+
$outputs_rule = document["&main:OutputsRule"]
|
21
|
+
|
22
|
+
|
23
|
+
time1 = Time.now
|
24
|
+
time2 = Time.now
|
25
|
+
time3 = Time.now
|
26
|
+
tuple1 = Tuple[:data].new('test', '1.a', nil, time1)
|
27
|
+
tuple2 = Tuple[:data].new('test', '2.a', nil, time2)
|
28
|
+
tuple3 = Tuple[:data].new('test', '3.b', nil, time2)
|
29
|
+
|
30
|
+
UC = UpdateCriteria
|
31
|
+
|
32
|
+
describe 'UpdateCriteria' do
|
33
|
+
|
34
|
+
# no output rules
|
35
|
+
describe 'criteria: no output rules' do
|
36
|
+
it 'should be updatable' do
|
37
|
+
inputs = [tuple1, tuple2]
|
38
|
+
outputs = [tuple3]
|
39
|
+
|
40
|
+
UC.no_output_rules?(
|
41
|
+
$no_outputs_rule,
|
42
|
+
inputs,
|
43
|
+
outputs,
|
44
|
+
VariableTable.new
|
45
|
+
).should.true
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should not be updatable' do
|
49
|
+
inputs = [tuple1, tuple2]
|
50
|
+
outputs = [tuple3]
|
51
|
+
UC.no_output_rules?(
|
52
|
+
$outputs_rule,
|
53
|
+
inputs,
|
54
|
+
outputs,
|
55
|
+
VariableTable.new
|
56
|
+
).should.false
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe 'criteria: not_exist_output' do
|
61
|
+
it 'should be updatable' do
|
62
|
+
inputs = [tuple1, tuple2]
|
63
|
+
outputs = []
|
64
|
+
UC.not_exist_output?(
|
65
|
+
$outputs_rule,
|
66
|
+
inputs,
|
67
|
+
outputs,
|
68
|
+
VariableTable.new
|
69
|
+
).should.true
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should be not updatable' do
|
73
|
+
inputs = [tuple1]
|
74
|
+
outputs = [tuple3]
|
75
|
+
UC.not_exist_output?(
|
76
|
+
$outputs_rule,
|
77
|
+
inputs,
|
78
|
+
outputs,
|
79
|
+
VariableTable.new
|
80
|
+
).should.false
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/test/test-util.rb
ADDED
@@ -0,0 +1,223 @@
|
|
1
|
+
require 'bacon'
|
2
|
+
require 'pione'
|
3
|
+
|
4
|
+
module TestUtil
|
5
|
+
include Pione::TupleSpaceServerInterface
|
6
|
+
|
7
|
+
def write_and_wait_to_be_taken(tuple, sec=5)
|
8
|
+
observer = notify('take', tuple)
|
9
|
+
write(tuple)
|
10
|
+
timeout(sec) do
|
11
|
+
observer.pop
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def clear_exceptions
|
16
|
+
server = get_tuple_space_server
|
17
|
+
server.read_all(Tuple[:exception].any).each do |tuple|
|
18
|
+
ts_server.take(tuple)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def check_exceptions
|
23
|
+
exceptions = tuple_space_server.read_all(Tuple[:exception].any)
|
24
|
+
exceptions.each do |tuple|
|
25
|
+
e = tuple.value
|
26
|
+
Bacon::ErrorLog << "#{e.class}: #{e.message}\n"
|
27
|
+
e.backtrace.each_with_index { |line, i| Bacon::ErrorLog << "\t#{line}\n" }
|
28
|
+
Bacon::ErrorLog << "\n"
|
29
|
+
end
|
30
|
+
exceptions.should.be.empty
|
31
|
+
end
|
32
|
+
|
33
|
+
def observe_exceptions(sec=5, &b)
|
34
|
+
@thread = Thread.new { b.call }
|
35
|
+
begin
|
36
|
+
timeout(sec) do
|
37
|
+
while @thread.alive? do; sleep 0.1; end
|
38
|
+
end
|
39
|
+
ensure
|
40
|
+
check_exceptions
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def create_remote_tuple_space_server
|
45
|
+
# make drb server and it's connection
|
46
|
+
tuple_space_server = Pione::TupleSpace::TupleSpaceServer.new
|
47
|
+
# base uri
|
48
|
+
tuple_space_server.write(Tuple[:base_uri].new("local:#{Dir.mktmpdir('pione-test')}/"))
|
49
|
+
@__remote_drb_server__ = DRb::DRbServer.new(nil, tuple_space_server)
|
50
|
+
server = DRbObject.new_with_uri(@__remote_drb_server__.uri)
|
51
|
+
# set default tuple space server
|
52
|
+
set_tuple_space_server server
|
53
|
+
# return the connection
|
54
|
+
return server
|
55
|
+
end
|
56
|
+
|
57
|
+
def remote_drb_server
|
58
|
+
@__remote_drb_server__
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
module TestUtil::Parser
|
63
|
+
# Makes a test parser class by the sub-parser module.
|
64
|
+
def make_test_parser(parser_module)
|
65
|
+
klass = Class.new(Parslet::Parser)
|
66
|
+
klass.instance_eval do
|
67
|
+
include parser_module
|
68
|
+
end
|
69
|
+
return klass
|
70
|
+
end
|
71
|
+
module_function :make_test_parser
|
72
|
+
|
73
|
+
def spec(mod, rb, context)
|
74
|
+
#parser = make_test_parser(mod)
|
75
|
+
parser = Pione::Parser::DocumentParser
|
76
|
+
basename = File.basename(rb, ".rb")
|
77
|
+
path = File.join(File.dirname(rb), basename + ".yml")
|
78
|
+
YAML.load(File.read(path)).each do |name, testcase|
|
79
|
+
context.describe name do
|
80
|
+
if strings = testcase["valid"]
|
81
|
+
strings.each do |string|
|
82
|
+
it "should parse as #{name}: #{string}" do
|
83
|
+
should.not.raise(Parslet::ParseFailed) do
|
84
|
+
parser.new.send(name).parse(string)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
if strings = testcase["invalid"]
|
91
|
+
strings.each do |string|
|
92
|
+
it "should fail when parsing as #{name}: #{string}" do
|
93
|
+
should.raise(Parslet::ParseFailed) do
|
94
|
+
parser.new.send(name).parse(string)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
module_function :spec
|
103
|
+
end
|
104
|
+
|
105
|
+
module TestUtil::Transformer
|
106
|
+
TestCase = Struct.new(:string, :expected)
|
107
|
+
|
108
|
+
def spec(name, parser, context, &b)
|
109
|
+
testcases = Array.new
|
110
|
+
def testcases.tc(obj)
|
111
|
+
case obj
|
112
|
+
when Hash
|
113
|
+
obj.each do |key, val|
|
114
|
+
push(TestCase.new(key, val))
|
115
|
+
end
|
116
|
+
else
|
117
|
+
push(TestCase.new(obj, yield))
|
118
|
+
end
|
119
|
+
end
|
120
|
+
testcases.instance_eval(&b)
|
121
|
+
context.describe name do
|
122
|
+
testcases.each do |tc|
|
123
|
+
it "should get #{name}: #{tc.string}" do
|
124
|
+
res = DocumentTransformer.new.apply(
|
125
|
+
DocumentParser.new.send(parser).parse(tc.string)
|
126
|
+
)
|
127
|
+
res.should == tc.expected
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
module_function :spec
|
133
|
+
end
|
134
|
+
|
135
|
+
# Hash extension.
|
136
|
+
class Hash
|
137
|
+
# Symbolizes hash's keys recuirsively. This is convinient for YAML handling.
|
138
|
+
def symbolize_keys
|
139
|
+
each_with_object({}) do |(key, val), hash|
|
140
|
+
hash[key.to_sym] = (val.kind_of?(Hash) ? val.symbolize_keys : val)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def to_params
|
145
|
+
Parameters.new(
|
146
|
+
Hash[map{|key, val| [Pione::Model::Variable.new(key), val.to_pione]}]
|
147
|
+
)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
# Bacon::Context extension.
|
152
|
+
class Bacon::Context
|
153
|
+
# Install utilities.
|
154
|
+
include TestUtil
|
155
|
+
|
156
|
+
def transformer_spec(name, parser_name, &b)
|
157
|
+
TestUtil::Transformer.spec(name, parser_name, self, &b)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
module Pione::TupleSpace
|
162
|
+
class TupleSpaceServer
|
163
|
+
# Return all tuples of the tuple space.
|
164
|
+
def all_tuples
|
165
|
+
tuples = []
|
166
|
+
bag = @__ts__.instance_variable_get("@bag")
|
167
|
+
bag.instance_variable_get("@hash").values.each do |bin|
|
168
|
+
tuples += bin.instance_variable_get("@bin")
|
169
|
+
end
|
170
|
+
_tuples = tuples.map{|t| t.value}
|
171
|
+
return _tuples
|
172
|
+
end
|
173
|
+
|
174
|
+
# Return take waiting tuples.
|
175
|
+
def take_waiter
|
176
|
+
tuples = []
|
177
|
+
bag = @__ts__.instance_variable_get("@take_waiter")
|
178
|
+
bag.instance_variable_get("@hash").values.each do |bin|
|
179
|
+
tuples += bin.instance_variable_get("@bin")
|
180
|
+
end
|
181
|
+
_tuples = tuples.map{|t| t.value}
|
182
|
+
return _tuples
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
module Pione::Agent
|
188
|
+
class BasicAgent
|
189
|
+
include TestUtil
|
190
|
+
|
191
|
+
# Fake set_current_state for counting state changes.
|
192
|
+
alias :set_current_state_orig :set_current_state
|
193
|
+
def set_current_state(state)
|
194
|
+
@__counter__ ||= nil
|
195
|
+
set_current_state_orig(state)
|
196
|
+
if @__counter__
|
197
|
+
@__counter__.has_key?(state) ? @__counter__[state] += 1 : @__counter__[state] = 1
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
# Wait until state counter is reached at the number.
|
202
|
+
def wait_until_count(number, state, sec=5, &b)
|
203
|
+
timeout(sec) do
|
204
|
+
@__counter__ = {}
|
205
|
+
first_time = true
|
206
|
+
while @__counter__[state].nil? or @__counter__[state] < number do
|
207
|
+
b.call if first_time
|
208
|
+
first_time = false
|
209
|
+
check_exceptions
|
210
|
+
sleep 0.2
|
211
|
+
end
|
212
|
+
@__counter__ = nil
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
def setup_for_test
|
219
|
+
include Pione
|
220
|
+
Thread.abort_on_exception = true
|
221
|
+
end
|
222
|
+
|
223
|
+
setup_for_test
|