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,282 @@
|
|
1
|
+
module Pione::Model
|
2
|
+
# Parameters is a PIONE mode class for parameters.
|
3
|
+
class Parameters < BasicModel
|
4
|
+
# InvalidParameter is raised when you specify invalid parameter.
|
5
|
+
class InvalidParameter < TypeError
|
6
|
+
# Creates a error.
|
7
|
+
# @param [Object] key
|
8
|
+
# specified key
|
9
|
+
def initialize(key)
|
10
|
+
@key = key
|
11
|
+
end
|
12
|
+
|
13
|
+
# @api private
|
14
|
+
def message
|
15
|
+
"invalid parameter key: %s" % [@key.inspect]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# InvalidArgument is raised when you specify invalid argument.
|
20
|
+
class InvalidArgument < TypeError
|
21
|
+
# Creates a error.
|
22
|
+
# @param [Object] val
|
23
|
+
# specified value
|
24
|
+
def initialize(val)
|
25
|
+
@val = val
|
26
|
+
end
|
27
|
+
|
28
|
+
# @api private
|
29
|
+
def message
|
30
|
+
"invalid argument value: %s" % [@val.inspect]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class << self
|
35
|
+
# Creates a empty parameters object.
|
36
|
+
# @return [Parameters]
|
37
|
+
# empty parameters
|
38
|
+
def empty
|
39
|
+
self.new({})
|
40
|
+
end
|
41
|
+
|
42
|
+
# Merges arguments' parameters.
|
43
|
+
# @param [Array<Parameters>] list
|
44
|
+
# merge target elements
|
45
|
+
# @return [Parameters]
|
46
|
+
# merged result
|
47
|
+
def merge(*list)
|
48
|
+
new_params = empty
|
49
|
+
list.each do |params|
|
50
|
+
new_params = new_params.merge(params)
|
51
|
+
end
|
52
|
+
return new_params
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
attr_reader :data
|
57
|
+
set_pione_model_type TypeParameters
|
58
|
+
|
59
|
+
# Creates a parameters object.
|
60
|
+
# @param [Hash{Variable => BasicModel}] data
|
61
|
+
# parameters data table
|
62
|
+
def initialize(data)
|
63
|
+
raise TypeError.new(data) unless data.kind_of?(Hash)
|
64
|
+
data.each do |key, val|
|
65
|
+
raise InvalidParameter.new(key) unless key.kind_of?(Variable)
|
66
|
+
raise InvalidArgument.new(val) unless val.kind_of?(BasicModel)
|
67
|
+
end
|
68
|
+
@data = data
|
69
|
+
super()
|
70
|
+
end
|
71
|
+
|
72
|
+
# Evaluates the object with variable table.
|
73
|
+
# @param [VariableTable] vtable
|
74
|
+
# variable tabale for evaluation
|
75
|
+
# @return [BasicModel]
|
76
|
+
# evaluated result
|
77
|
+
def eval(vtable)
|
78
|
+
return self.class.empty if empty?
|
79
|
+
data = @data.map{|key, val| [key, val.eval(vtable)]}.flatten(1)
|
80
|
+
self.class.new(Hash[*data])
|
81
|
+
end
|
82
|
+
|
83
|
+
# Returns true if parameters include variables.
|
84
|
+
# @return [Boolean]
|
85
|
+
# true if parameters include variables
|
86
|
+
def include_variable?
|
87
|
+
@data.any? {|_, val| val.include_variable?}
|
88
|
+
end
|
89
|
+
|
90
|
+
# @api private
|
91
|
+
def textize
|
92
|
+
"{" + @data.map{|k,v| "%s:%s" % [k.textize[1..-1], v.textize]}.join(", ") + "}"
|
93
|
+
end
|
94
|
+
|
95
|
+
# Returns value of parameter name.
|
96
|
+
# @param [String] name
|
97
|
+
# parameter name to get the value
|
98
|
+
# @return [BasicModel]
|
99
|
+
# the value
|
100
|
+
def [](name)
|
101
|
+
@data[Variable.new(name)]
|
102
|
+
end
|
103
|
+
|
104
|
+
# Returns the value corresponding to the parameter name. Raises an error
|
105
|
+
# when the parameter name is kind of a variable.
|
106
|
+
# @param [Variable] name
|
107
|
+
# variable to get the value
|
108
|
+
# @return [BasicModel]
|
109
|
+
# the value
|
110
|
+
def get(name)
|
111
|
+
raise InvalidParameter.new(name) unless name.kind_of?(Variable)
|
112
|
+
@data[name]
|
113
|
+
end
|
114
|
+
|
115
|
+
# Adds the parameter value and return new parameters.
|
116
|
+
# @param [Variable] name
|
117
|
+
# @param [BasicModel] value
|
118
|
+
# @return [Parameters]
|
119
|
+
# new parameters with the parameter
|
120
|
+
def set(name, value)
|
121
|
+
raise InvalidParameter.new(name) unless name.kind_of?(Variable)
|
122
|
+
raise InvalidArgument.new(value) unless value.kind_of?(BasicModel)
|
123
|
+
self.class.new(@data.merge({name => value}))
|
124
|
+
end
|
125
|
+
|
126
|
+
# Adds the parameter value.
|
127
|
+
# @param [Variable] name
|
128
|
+
# @param [BasicModel] value
|
129
|
+
# @return [void]
|
130
|
+
def set!(name, value)
|
131
|
+
raise InvalidParameter.new(name) unless name.kind_of?(Variable)
|
132
|
+
raise InvalidArgument.new(value) unless value.kind_of?(BasicModel)
|
133
|
+
@data.merge!({name => value})
|
134
|
+
end
|
135
|
+
|
136
|
+
# Adds the parameter value safety and return new parameters.
|
137
|
+
# @param [Variable] name
|
138
|
+
# @param [BasicModel] value
|
139
|
+
# @return [Parameters]
|
140
|
+
# new parameters with the parameter
|
141
|
+
def set_safety(name, value)
|
142
|
+
if not(@data.has_key?(name)) or @data[name].kind_of?(UndefinedValue)
|
143
|
+
set(name, value)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
# Adds the parameter value safety.
|
148
|
+
# @param [Variable] name
|
149
|
+
# @param [BasicModel] value
|
150
|
+
# @return [void]
|
151
|
+
def set_safety!(name, value)
|
152
|
+
if not(@data.has_key?(name)) or @data[name].kind_of?(UndefinedValue)
|
153
|
+
set!(name, value)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
# Deletes the parameter by name.
|
158
|
+
# @param [Variable] name
|
159
|
+
# target's name
|
160
|
+
# @return [Parameters]
|
161
|
+
# new parameters that deleted the target
|
162
|
+
def delete(name)
|
163
|
+
raise InvalidParameter.new(name) unless name.kind_of?(Variable)
|
164
|
+
new_data = @data.clone
|
165
|
+
new_data.delete(name)
|
166
|
+
self.class.new(new_data)
|
167
|
+
end
|
168
|
+
|
169
|
+
# Returns true if the parameters is empty.
|
170
|
+
# @return [Boolean]
|
171
|
+
# true if the parameters is empty
|
172
|
+
def empty?
|
173
|
+
@data.empty?
|
174
|
+
end
|
175
|
+
|
176
|
+
# Updates parameters with the argument and return new parameters with it.
|
177
|
+
# @param [BasicModel] other
|
178
|
+
# merge target
|
179
|
+
# @return [Parameters]
|
180
|
+
# new parameters that merged the target
|
181
|
+
def merge(other)
|
182
|
+
case other
|
183
|
+
when Parameters
|
184
|
+
self.class.new(@data.merge(other.data))
|
185
|
+
when Variable
|
186
|
+
self.class.new(@data.merge({other => UndefinedValue.new}))
|
187
|
+
when Assignment
|
188
|
+
self.class.new(@data.merge({other.variable => other.expr}))
|
189
|
+
else
|
190
|
+
raise TypeError.new(other)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
# Updates parameters with the argument destructively.
|
195
|
+
# @param [BasicModel] other
|
196
|
+
# merge target
|
197
|
+
# @return [void]
|
198
|
+
def merge!(other)
|
199
|
+
case other
|
200
|
+
when Parameters
|
201
|
+
@data.merge!(other.data)
|
202
|
+
when Variable
|
203
|
+
@data.merge!({other => UndefinedValue.new})
|
204
|
+
when Assignment
|
205
|
+
@data.merge!({other.variable => other.expr})
|
206
|
+
else
|
207
|
+
raise TypeError.new(other)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
# Converts into variable table.
|
212
|
+
# @return [VariableTable]
|
213
|
+
# variable table which values are same as the parameters.
|
214
|
+
def as_variable_table
|
215
|
+
VariableTable.new(@data)
|
216
|
+
end
|
217
|
+
|
218
|
+
# Returns key list.
|
219
|
+
# @return [Array<Variable>]
|
220
|
+
# parameter key list
|
221
|
+
def keys
|
222
|
+
@data.keys.sort
|
223
|
+
end
|
224
|
+
|
225
|
+
# @api private
|
226
|
+
def string_form
|
227
|
+
"{" + @data.map{|k,v| "#{k}: #{v}"}.join(", ") + "}"
|
228
|
+
end
|
229
|
+
|
230
|
+
# @api private
|
231
|
+
def to_json(*args)
|
232
|
+
@data.to_json(*args)
|
233
|
+
end
|
234
|
+
|
235
|
+
# @api private
|
236
|
+
def ==(other)
|
237
|
+
return false unless other.kind_of?(self.class)
|
238
|
+
@data == other.data
|
239
|
+
end
|
240
|
+
|
241
|
+
alias :eql? :"=="
|
242
|
+
|
243
|
+
# @api private
|
244
|
+
def hash
|
245
|
+
@data.hash
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
TypeParameters.instance_eval do
|
250
|
+
define_pione_method('==', [TypeParameters], TypeBoolean) do |rec, other|
|
251
|
+
PioneBoolean.new(rec.data == other.data)
|
252
|
+
end
|
253
|
+
|
254
|
+
define_pione_method("!=", [TypeParameters], TypeBoolean) do |rec, other|
|
255
|
+
PioneBoolean.not(rec.call_pione_method("==", other))
|
256
|
+
end
|
257
|
+
|
258
|
+
define_pione_method("[]", [TypeString], TypeAny) do |rec, name|
|
259
|
+
rec.get(Variable.new(name.value))
|
260
|
+
end
|
261
|
+
|
262
|
+
define_pione_method("get", [TypeString], TypeAny) do |rec, name|
|
263
|
+
rec.get(Variable.new(name.value))
|
264
|
+
end
|
265
|
+
|
266
|
+
define_pione_method(
|
267
|
+
"set",
|
268
|
+
[TypeString, TypeAny],
|
269
|
+
TypeParameters
|
270
|
+
) do |rec, name, val|
|
271
|
+
rec.set(Variable.new(name.value), val)
|
272
|
+
end
|
273
|
+
|
274
|
+
define_pione_method("empty?", [], TypeBoolean) do |rec|
|
275
|
+
PioneBoolean.new(rec.empty?)
|
276
|
+
end
|
277
|
+
|
278
|
+
define_pione_method("as_string", [], TypeString) do |rec|
|
279
|
+
PioneString.new(rec.string_form)
|
280
|
+
end
|
281
|
+
end
|
282
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
module Pione::Model
|
2
|
+
# Rule representation in the flow element context.
|
3
|
+
class RuleExpr < BasicModel
|
4
|
+
set_pione_model_type TypeRuleExpr
|
5
|
+
|
6
|
+
attr_reader :package
|
7
|
+
attr_reader :name
|
8
|
+
attr_reader :params
|
9
|
+
|
10
|
+
# Create a rule expression.
|
11
|
+
# @param [String] package pione package name
|
12
|
+
# @param [String] name rule name
|
13
|
+
# @param [Parameters] params parameters
|
14
|
+
def initialize(package, name, params=Parameters.empty)
|
15
|
+
@package = package
|
16
|
+
@name = name
|
17
|
+
@params = params
|
18
|
+
super()
|
19
|
+
end
|
20
|
+
|
21
|
+
# Returns rule path form.
|
22
|
+
# @return [String]
|
23
|
+
# rule path string
|
24
|
+
def path
|
25
|
+
"&%s:%s" % [@package.name, @name]
|
26
|
+
end
|
27
|
+
|
28
|
+
# FIXME
|
29
|
+
def rule_path
|
30
|
+
raise UnboundVariableError.new(self) if @package.include_variable?
|
31
|
+
"&%s:%s" % [@package.name, @name]
|
32
|
+
end
|
33
|
+
|
34
|
+
# @api private
|
35
|
+
def task_id_string
|
36
|
+
"RuleExpr<%s,#{@name}>" % [@package.task_id_string]
|
37
|
+
end
|
38
|
+
|
39
|
+
# @api private
|
40
|
+
def textize
|
41
|
+
"rule_expr(%s,\"%s\")" % [@package.textize, @name]
|
42
|
+
end
|
43
|
+
|
44
|
+
# Sets a package name and returns a new expression.
|
45
|
+
# @param [String] package
|
46
|
+
# package name
|
47
|
+
# @return [RuleExpr]
|
48
|
+
# new rule expression with the package name
|
49
|
+
def set_package(package)
|
50
|
+
return self.class.new(package, @name, @params)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Sets parameters and returns a new expression.
|
54
|
+
# @param [Parameters] params
|
55
|
+
# parameters
|
56
|
+
# @return [RuleExpr]
|
57
|
+
# new rule expression with the parameters
|
58
|
+
def set_params(params)
|
59
|
+
return self.class.new(@package, @name, params)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Evaluates the object with the variable table.
|
63
|
+
# @param [VariableTable] vtable
|
64
|
+
# variable table for evaluation
|
65
|
+
# @return [BasicModel]
|
66
|
+
# evaluation result
|
67
|
+
def eval(vtable)
|
68
|
+
return self.class.new(
|
69
|
+
@package.eval(vtable),
|
70
|
+
@name,
|
71
|
+
@params.eval(vtable)
|
72
|
+
)
|
73
|
+
end
|
74
|
+
|
75
|
+
# Returns true if the package or parameters include variables.
|
76
|
+
# @return [Boolean]
|
77
|
+
# true if the package or parameters include variables
|
78
|
+
def include_variable?
|
79
|
+
@package.include_variable? or @params.include_variable?
|
80
|
+
end
|
81
|
+
|
82
|
+
# @api private
|
83
|
+
def ==(other)
|
84
|
+
return false unless other.kind_of?(self.class)
|
85
|
+
return false unless @package = other.package
|
86
|
+
return false unless @name == other.name
|
87
|
+
return false unless @params == other.params
|
88
|
+
return true
|
89
|
+
end
|
90
|
+
|
91
|
+
# @api private
|
92
|
+
alias :eql? :"=="
|
93
|
+
|
94
|
+
# @api private
|
95
|
+
def hash
|
96
|
+
@package.hash + @name.hash + @params.hash
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
TypeRuleExpr.instance_eval do
|
101
|
+
define_pione_method("==", [TypeRuleExpr], TypeBoolean) do |rec, other|
|
102
|
+
PioneBoolean.new(
|
103
|
+
rec.package == other.package &&
|
104
|
+
rec.name == other.name &&
|
105
|
+
rec.params == other.params)
|
106
|
+
end
|
107
|
+
|
108
|
+
define_pione_method("!=", [TypeRuleExpr], TypeBoolean) do |rec, other|
|
109
|
+
PioneBoolean.not(rec.call_pione_method("==", other))
|
110
|
+
end
|
111
|
+
|
112
|
+
define_pione_method("params", [TypeParameters], TypeRuleExpr) do |rec, params|
|
113
|
+
rec.set_params(params)
|
114
|
+
end
|
115
|
+
|
116
|
+
define_pione_method("as_string", [], TypeString) do |rec|
|
117
|
+
PioneString.new(rec.name)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,166 @@
|
|
1
|
+
module Pione::Model
|
2
|
+
# RuleIOElement is a special PIONE model object for matched data name result.
|
3
|
+
class RuleIOElement < BasicModel
|
4
|
+
set_pione_model_type TypeRuleIOElement
|
5
|
+
|
6
|
+
attr_accessor :name
|
7
|
+
attr_accessor :uri
|
8
|
+
attr_accessor :match
|
9
|
+
|
10
|
+
# Creates a element with the name.
|
11
|
+
# @param [PioneString, String] name
|
12
|
+
# element name
|
13
|
+
def initialize(name)
|
14
|
+
@name = name.kind_of?(PioneString) ? name : PioneString.new(name)
|
15
|
+
@uri = PioneString.new("")
|
16
|
+
@match = PioneList.new()
|
17
|
+
end
|
18
|
+
|
19
|
+
# @api private
|
20
|
+
def textize
|
21
|
+
"rule-io-element(%s,%s,%s)" % [@name.to_ruby, @uri.textize, @match.textize]
|
22
|
+
end
|
23
|
+
|
24
|
+
# @api private
|
25
|
+
def uri=(uri)
|
26
|
+
@uri = uri.to_pione
|
27
|
+
end
|
28
|
+
|
29
|
+
# @api private
|
30
|
+
def ==(other)
|
31
|
+
return false unless other.kind_of?(self.class)
|
32
|
+
@name == other.name && @uri == other.uri && @match == other.match
|
33
|
+
end
|
34
|
+
|
35
|
+
alias :eql? :"=="
|
36
|
+
|
37
|
+
# @api private
|
38
|
+
def hash
|
39
|
+
@value.hash
|
40
|
+
end
|
41
|
+
|
42
|
+
#
|
43
|
+
# pione method
|
44
|
+
#
|
45
|
+
|
46
|
+
define_pione_method("==", [TypeRuleIOElement], TypeBoolean) do |rec, other|
|
47
|
+
PioneBoolean.new(rec.values == other.values)
|
48
|
+
end
|
49
|
+
|
50
|
+
define_pione_method("!=", [TypeRuleIOElement], TypeBoolean) do |rec, other|
|
51
|
+
PioneBoolean.not(rec.call_pione_method("==", other))
|
52
|
+
end
|
53
|
+
|
54
|
+
define_pione_method("uri", [], TypeString) do |rec, other|
|
55
|
+
PioneString.new(rec.uri)
|
56
|
+
end
|
57
|
+
|
58
|
+
define_pione_method("match", [], TypeList.new(TypeString)) do |rec|
|
59
|
+
rec.match
|
60
|
+
end
|
61
|
+
|
62
|
+
define_pione_method("MATCH", [], TypeList.new(TypeString)) do |rec|
|
63
|
+
rec.call_pione_method("match")
|
64
|
+
end
|
65
|
+
|
66
|
+
define_pione_method("[]", [TypeInteger], TypeAny) do |rec, i|
|
67
|
+
rec.match[i.value-1]
|
68
|
+
end
|
69
|
+
|
70
|
+
define_pione_method("as_string", [], TypeString) do |rec|
|
71
|
+
rec.name
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# RuleIOList is a input or output list for RuleIOElement.
|
76
|
+
class RuleIOList < BasicModel
|
77
|
+
extend Forwardable
|
78
|
+
|
79
|
+
set_pione_model_type TypeRuleIOList
|
80
|
+
|
81
|
+
attr_accessor :elements
|
82
|
+
def_delegators :@elements, :[], :size, :length
|
83
|
+
|
84
|
+
# Creates a list object.
|
85
|
+
# @param [Array<RuleIOElement>] elts
|
86
|
+
# list elements
|
87
|
+
def initialize(elts = [])
|
88
|
+
@elements = elts
|
89
|
+
end
|
90
|
+
|
91
|
+
# Returns new list which appended the element.
|
92
|
+
# @param [RuleIOElement] elt
|
93
|
+
# target element
|
94
|
+
# @return [RuleIOList]
|
95
|
+
# new list object that added the element
|
96
|
+
def add(elt)
|
97
|
+
unless elt.kind_of?(RuleIOElement) || elt.kind_of?(self.class)
|
98
|
+
raise ArgumentError.new(elt)
|
99
|
+
end
|
100
|
+
self.class.new(@elements + [elt])
|
101
|
+
end
|
102
|
+
|
103
|
+
# Adds the element to this list.
|
104
|
+
# @param [RuleIOElement] elt
|
105
|
+
# target element
|
106
|
+
# @return [void]
|
107
|
+
def add!(elt)
|
108
|
+
unless elt.kind_of?(RuleIOElement) || elt.kinf_of?(self.class)
|
109
|
+
raise ArgumentError.new(elt)
|
110
|
+
end
|
111
|
+
@elements << elt
|
112
|
+
end
|
113
|
+
|
114
|
+
# @api private
|
115
|
+
def textize
|
116
|
+
"rule-io-list(%s)" % @elements.map{|elt|
|
117
|
+
elt.textize
|
118
|
+
}.join(DataExpr::SEPARATOR)
|
119
|
+
end
|
120
|
+
|
121
|
+
# @api private
|
122
|
+
def ==(other)
|
123
|
+
return false unless other.kind_of?(self.class)
|
124
|
+
@elements == other.elements
|
125
|
+
end
|
126
|
+
|
127
|
+
alias :eql? :"=="
|
128
|
+
|
129
|
+
# @api private
|
130
|
+
def hash
|
131
|
+
@elements.hash
|
132
|
+
end
|
133
|
+
|
134
|
+
#
|
135
|
+
# pione method
|
136
|
+
#
|
137
|
+
|
138
|
+
define_pione_method("==", [TypeRuleIOList], TypeBoolean) do |rec, other|
|
139
|
+
PioneBoolean.new(rec.values == other.values)
|
140
|
+
end
|
141
|
+
|
142
|
+
define_pione_method("!=", [TypeRuleIOList], TypeBoolean) do |rec, other|
|
143
|
+
PioneBoolean.not(rec.call_pione_method("==", other))
|
144
|
+
end
|
145
|
+
|
146
|
+
define_pione_method("[]", [TypeInteger], TypeAny) do |rec, i|
|
147
|
+
rec.elements[i.value-1]
|
148
|
+
end
|
149
|
+
|
150
|
+
define_pione_method("join", [TypeString], TypeString) do |rec, connective|
|
151
|
+
PioneString.new(
|
152
|
+
rec.elements.map{|elt|
|
153
|
+
elt.call_pione_method("as_string").to_ruby
|
154
|
+
}.join(connective.to_ruby)
|
155
|
+
)
|
156
|
+
end
|
157
|
+
|
158
|
+
define_pione_method("as_string", [], TypeString) do |rec|
|
159
|
+
PioneString.new(
|
160
|
+
rec.elements.map{|elt|
|
161
|
+
elt.call_pione_method("as_string").to_ruby
|
162
|
+
}.join(DataExpr::SEPARATOR)
|
163
|
+
)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|