pione 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.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,233 @@
|
|
|
1
|
+
module Pione::Model
|
|
2
|
+
# ActionBlock represents content script of action.
|
|
3
|
+
# @example
|
|
4
|
+
# Action
|
|
5
|
+
# echo "abc"
|
|
6
|
+
# End
|
|
7
|
+
# #=> ActionBlock.new(" echo \"abc\"")
|
|
8
|
+
class ActionBlock < BasicModel
|
|
9
|
+
attr_reader :content
|
|
10
|
+
|
|
11
|
+
# Creates a action block.
|
|
12
|
+
# @param [String] content
|
|
13
|
+
# action content of shell script
|
|
14
|
+
def initialize(content)
|
|
15
|
+
@content = content
|
|
16
|
+
super()
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Evaluates the object.
|
|
20
|
+
# @param [VariableTable] vtable
|
|
21
|
+
# variable table for evaluation
|
|
22
|
+
# @return [BasicModel]
|
|
23
|
+
# evaluation result
|
|
24
|
+
def eval(vtable)
|
|
25
|
+
self.class.new(vtable.expand(@content))
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Returns true if the content includes variables.
|
|
29
|
+
# @return [Boolean]
|
|
30
|
+
# true if the content includes variables
|
|
31
|
+
def include_variable?
|
|
32
|
+
return VariableTable.check_include_variable(@content)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# @api private
|
|
36
|
+
def textize
|
|
37
|
+
"action_block(\"#{@content}\")"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# @api private
|
|
41
|
+
def ==(other)
|
|
42
|
+
return false unless other.kind_of?(self.class)
|
|
43
|
+
@content == other.content
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
alias :eql? :==
|
|
47
|
+
|
|
48
|
+
# @api private
|
|
49
|
+
def hash
|
|
50
|
+
@content.hash
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# FlowBlock represents flow element sequence.
|
|
55
|
+
# @example
|
|
56
|
+
# Flow
|
|
57
|
+
# rule Test1
|
|
58
|
+
# rule Test2
|
|
59
|
+
# rule Test3
|
|
60
|
+
# End
|
|
61
|
+
# #=> Block.new([ CallRule.new('Test1'),
|
|
62
|
+
# CallRule.new('Test2'),
|
|
63
|
+
# CallRule.new('Test3') ])
|
|
64
|
+
class FlowBlock < BasicModel
|
|
65
|
+
attr_reader :elements
|
|
66
|
+
|
|
67
|
+
# Create a flow block.
|
|
68
|
+
# @param [Array<BasicModel>] elements
|
|
69
|
+
# flow elements
|
|
70
|
+
def initialize(*elements)
|
|
71
|
+
unless elements.all? {|elt| elt.kind_of?(BasicModel)}
|
|
72
|
+
raise ArgumentError.new(elements)
|
|
73
|
+
end
|
|
74
|
+
@elements = elements
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Evaluates each elements and return it.
|
|
78
|
+
# @param [VariableTable] vtable
|
|
79
|
+
# variable table for evaluation
|
|
80
|
+
# @return [BasicModel]
|
|
81
|
+
# evaluation result
|
|
82
|
+
def eval(vtable)
|
|
83
|
+
assignments = @elements.select{|elt| elt.kind_of?(Assignment)}
|
|
84
|
+
conditional_blocks = @elements.select{|elt| elt.kind_of?(ConditionalBlock)}
|
|
85
|
+
call_rules = @elements.select{|elt| elt.kind_of?(CallRule)}
|
|
86
|
+
|
|
87
|
+
if not(assignments.empty?)
|
|
88
|
+
assignments.each do |assignment|
|
|
89
|
+
assignment.eval(vtable)
|
|
90
|
+
end
|
|
91
|
+
FlowBlock.new(*(conditional_blocks+call_rules)).eval(vtable)
|
|
92
|
+
elsif not(conditional_blocks.empty?)
|
|
93
|
+
exception = nil
|
|
94
|
+
new_blocks = []
|
|
95
|
+
next_blocks = []
|
|
96
|
+
conditional_blocks.each do |block|
|
|
97
|
+
begin
|
|
98
|
+
new_blocks << block.eval(vtable)
|
|
99
|
+
rescue UnboundVariableError => e
|
|
100
|
+
exception = e
|
|
101
|
+
next_blocks << block
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
# fail to evaluate conditional blocks
|
|
105
|
+
if conditional_blocks == next_blocks
|
|
106
|
+
raise exception
|
|
107
|
+
end
|
|
108
|
+
# next
|
|
109
|
+
elements = new_blocks.inject([]){|elts, block| elts += block.elements}
|
|
110
|
+
FlowBlock.new(*(elements + next_blocks + call_rules)).eval(vtable)
|
|
111
|
+
else
|
|
112
|
+
FlowBlock.new(*call_rules.map{|call_rule| call_rule.eval(vtable)})
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# Returns true if the elements include variables.
|
|
117
|
+
# @return [Boolean]
|
|
118
|
+
# true if the elements include variables
|
|
119
|
+
def include_variable?
|
|
120
|
+
@elements.any?{|elt| elt.include_variable?}
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# @api private
|
|
124
|
+
def textize
|
|
125
|
+
"flow_block(%s)" % [@elements.map{|elt| elt.textize}.join(",")]
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# @api private
|
|
129
|
+
def ==(other)
|
|
130
|
+
return false unless other.kind_of?(self.class)
|
|
131
|
+
@elements == other.elements
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
alias :eql? :==
|
|
135
|
+
|
|
136
|
+
# @api private
|
|
137
|
+
def hash
|
|
138
|
+
@elements.hash
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# ConditionalBlock represents conditional flow applications.
|
|
143
|
+
# @example
|
|
144
|
+
# # if statement
|
|
145
|
+
# if $X == "a"
|
|
146
|
+
# rule Test1
|
|
147
|
+
# else
|
|
148
|
+
# rule Test2
|
|
149
|
+
# end
|
|
150
|
+
# #=> ConditionalBlock.new(
|
|
151
|
+
# BinaryOperator::Equals.new(Variable.new('X'), 'a'),
|
|
152
|
+
# { true => [CallRule.new('Test1')],
|
|
153
|
+
# :else => [CallRule.new('Test2')] })
|
|
154
|
+
# @example
|
|
155
|
+
# # case statement
|
|
156
|
+
# case $X
|
|
157
|
+
# when "a"
|
|
158
|
+
# rule Test1
|
|
159
|
+
# when "b"
|
|
160
|
+
# rule Test2
|
|
161
|
+
# else
|
|
162
|
+
# rule Test3
|
|
163
|
+
# end
|
|
164
|
+
# # => ConditionalBlock.new(
|
|
165
|
+
# Variable.new('X'),
|
|
166
|
+
# { 'a' => FlowBlock.new(CallRule.new('Test1')),
|
|
167
|
+
# 'b' => FlowBlock.new(CallRule.new('Test2')),
|
|
168
|
+
# :else => FlowBlock.new(CallRule.new('Test3')) })
|
|
169
|
+
class ConditionalBlock < BasicModel
|
|
170
|
+
attr_reader :condition
|
|
171
|
+
attr_reader :blocks
|
|
172
|
+
|
|
173
|
+
# Creates a conditional block.
|
|
174
|
+
# @param [BasicModel] condition
|
|
175
|
+
# condition value
|
|
176
|
+
# @param [Hash{BasicModel => FlowBlock}] blocks
|
|
177
|
+
# condition key and block
|
|
178
|
+
def initialize(condition, blocks={})
|
|
179
|
+
unless blocks.all?{|key,val|
|
|
180
|
+
(key.kind_of?(BasicModel) or key == :else) &&
|
|
181
|
+
val.kind_of?(FlowBlock)
|
|
182
|
+
}
|
|
183
|
+
raise ArgumentError.new(blocks)
|
|
184
|
+
end
|
|
185
|
+
@condition = condition
|
|
186
|
+
@blocks = blocks
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
# Evaluates the condition and returns the flow block.
|
|
190
|
+
# @param [VariableTable] vtable
|
|
191
|
+
# variable table for evaluation
|
|
192
|
+
# @return [BasicModel]
|
|
193
|
+
# evaluation result
|
|
194
|
+
def eval(vtable)
|
|
195
|
+
value = @condition.eval(vtable)
|
|
196
|
+
if block = @blocks.find {|key, _| key == value}
|
|
197
|
+
return block[1].eval(vtable)
|
|
198
|
+
elsif block = @blocks[:else]
|
|
199
|
+
return block.eval(vtable)
|
|
200
|
+
else
|
|
201
|
+
return FlowBlock.new
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
# Returns ture if blocks include variables.
|
|
206
|
+
# @return [Boolean]
|
|
207
|
+
# ture if blocks include variables
|
|
208
|
+
def include_variable?
|
|
209
|
+
@blocks.values.any?{|block| block.include_variable?}
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
# @api private
|
|
213
|
+
def textize
|
|
214
|
+
"conditional_block(%s,{%s})" % [
|
|
215
|
+
@condition.textize,
|
|
216
|
+
@blocks.map{|val, block| "%s=>%s" % [val,block]}.join(",")
|
|
217
|
+
]
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# @api private
|
|
221
|
+
def ==(other)
|
|
222
|
+
return false unless other.kind_of?(self.class)
|
|
223
|
+
@condition == other.condition && @blocks == other.blocks
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
alias :eql? :==
|
|
227
|
+
|
|
228
|
+
# @api private
|
|
229
|
+
def hash
|
|
230
|
+
@condition.hash + @blocks.hash
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
end
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
module Pione::Model
|
|
2
|
+
# PioneBoolean representes truth value in PIONE system.
|
|
3
|
+
class PioneBoolean < BasicModel
|
|
4
|
+
set_pione_model_type TypeBoolean
|
|
5
|
+
|
|
6
|
+
# Returns the value in ruby.
|
|
7
|
+
attr_reader :value
|
|
8
|
+
|
|
9
|
+
class << self
|
|
10
|
+
# Returns true value in PIONE system.
|
|
11
|
+
# @return [PioneBoolean]
|
|
12
|
+
# true value
|
|
13
|
+
def true
|
|
14
|
+
new(true)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Returns false value in PIONE system.
|
|
18
|
+
# @return [PioneBoolean]
|
|
19
|
+
# false value
|
|
20
|
+
def false
|
|
21
|
+
new(false)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Returns inverse value of it.
|
|
25
|
+
# @param [Boolean] boolean
|
|
26
|
+
# target value
|
|
27
|
+
# @return [PioneBoolean]
|
|
28
|
+
# true if the param is false, or false
|
|
29
|
+
def not(boolean)
|
|
30
|
+
new(not(boolean.value))
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Returns true value if arguments include true value.
|
|
34
|
+
# @param [Array<PioneBoolean>] args
|
|
35
|
+
# @return [PioneBoolean]
|
|
36
|
+
# true value if arguments include true value
|
|
37
|
+
def or(*args)
|
|
38
|
+
new(args.any?{|arg| arg.true?})
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Returns true value if all arguments has true value.
|
|
42
|
+
# @param [Array<PioneBoolean>] args
|
|
43
|
+
# @return [PioneBoolean]
|
|
44
|
+
# true value if all arguments has true value
|
|
45
|
+
def and(*args)
|
|
46
|
+
new(args.all?{|arg| arg.true?})
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Creates a value.
|
|
51
|
+
# @param [Boolean] value
|
|
52
|
+
# true or false
|
|
53
|
+
def initialize(value)
|
|
54
|
+
@value = value
|
|
55
|
+
super()
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# @api private
|
|
59
|
+
def task_id_string
|
|
60
|
+
"Boolean<#{@value}>"
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# @api private
|
|
64
|
+
def textize
|
|
65
|
+
@value.to_s
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Returns true if the value is true.
|
|
69
|
+
# @return [Boolean]
|
|
70
|
+
# true if the value is true
|
|
71
|
+
def true?
|
|
72
|
+
@value == true
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Returns true if the value is false.
|
|
76
|
+
# @return [Boolean]
|
|
77
|
+
# true if the value is false
|
|
78
|
+
def false?
|
|
79
|
+
@value == false
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Returns ruby's boolean value.
|
|
83
|
+
# @return [Boolean]
|
|
84
|
+
# ruby's boolean value
|
|
85
|
+
def to_ruby
|
|
86
|
+
return @value
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# @api private
|
|
90
|
+
def ==(other)
|
|
91
|
+
return false unless other.kind_of?(self.class)
|
|
92
|
+
@value == other.value
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
alias :eql? :==
|
|
96
|
+
|
|
97
|
+
# @api private
|
|
98
|
+
def hash
|
|
99
|
+
@value.hash
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
#
|
|
103
|
+
# pione methods
|
|
104
|
+
#
|
|
105
|
+
|
|
106
|
+
define_pione_method("==", [TypeBoolean], TypeBoolean) do |rec, other|
|
|
107
|
+
PioneBoolean.new(rec.value == other.value)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
define_pione_method("!=", [TypeBoolean], TypeBoolean) do |rec, other|
|
|
111
|
+
PioneBoolean.not(rec.call_pione_method("==", other))
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
define_pione_method("&&", [TypeBoolean], TypeBoolean) do |rec, other|
|
|
115
|
+
PioneBoolean.new(rec.value && other.value)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
define_pione_method("||", [TypeBoolean], TypeBoolean) do |rec, other|
|
|
119
|
+
PioneBoolean.new(rec.value || other.value)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
define_pione_method("and", [TypeBoolean], TypeBoolean) do |rec, other|
|
|
123
|
+
rec.call_pione_method("&&", other)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
define_pione_method("or", [TypeBoolean], TypeBoolean) do |rec, other|
|
|
127
|
+
rec.call_pione_method("||", other)
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
define_pione_method("as_string", [], TypeString) do |rec|
|
|
131
|
+
PioneString.new(rec.value.to_s)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
define_pione_method("not", [], TypeBoolean) do |rec|
|
|
135
|
+
PioneBoolean.not(rec)
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
module Pione::Model
|
|
2
|
+
# CallRule represents the application of a rule.
|
|
3
|
+
# @example
|
|
4
|
+
# # simple rule calling:
|
|
5
|
+
# rule r1
|
|
6
|
+
# #=> CallRule.new(RuleExpr.new('r1'))
|
|
7
|
+
# @example
|
|
8
|
+
# # with absolute path:
|
|
9
|
+
# rule /abc:a
|
|
10
|
+
# #=> CallRule.new(RuleExpr.new('/abc:a'))
|
|
11
|
+
# @example
|
|
12
|
+
# # with variable:
|
|
13
|
+
# rule $X
|
|
14
|
+
# #=> CallRule.new(Variable.new('X'))
|
|
15
|
+
class CallRule < BasicModel
|
|
16
|
+
attr_reader :expr
|
|
17
|
+
|
|
18
|
+
# Creates a callee rule.
|
|
19
|
+
# @param [BasicModel] expr
|
|
20
|
+
# callee rule
|
|
21
|
+
def initialize(expr)
|
|
22
|
+
@expr = expr
|
|
23
|
+
super()
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Returns a rule path string with expanding variables.
|
|
27
|
+
# @return [String]
|
|
28
|
+
# rule path(package name and rule name)
|
|
29
|
+
def rule_path
|
|
30
|
+
if @expr.include_variable?
|
|
31
|
+
raise UnboundVariableError.new(@expr)
|
|
32
|
+
end
|
|
33
|
+
@expr.rule_path
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Returns true if the expression has variables.
|
|
37
|
+
# @return [Boolean]
|
|
38
|
+
# true if the expression has variables
|
|
39
|
+
def include_variable?
|
|
40
|
+
@expr.include_variable?
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Evaluates the expression.
|
|
44
|
+
# @param [VariableTable] vtable
|
|
45
|
+
# variable table for evaluation
|
|
46
|
+
# @return [BasicModel]
|
|
47
|
+
# evaluation result
|
|
48
|
+
def eval(vtable)
|
|
49
|
+
self.class.new(@expr.eval(vtable))
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# @api private
|
|
53
|
+
def textize
|
|
54
|
+
"call_rule(%s)" % [@expr.textize]
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# @api private
|
|
58
|
+
def ==(other)
|
|
59
|
+
@expr == other.expr
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
alias :eql? :==
|
|
63
|
+
|
|
64
|
+
# @api private
|
|
65
|
+
def hash
|
|
66
|
+
@expr.hash
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
module Pione::Model
|
|
2
|
+
|
|
3
|
+
# DataExpr is a class for data name expressions of rule input and output.
|
|
4
|
+
# @example
|
|
5
|
+
# # complete name
|
|
6
|
+
# DataExpr.new("test.txt")
|
|
7
|
+
# @example
|
|
8
|
+
# # incomplete name
|
|
9
|
+
# DataExpr.new("*.txt")
|
|
10
|
+
class DataExpr < BasicModel
|
|
11
|
+
|
|
12
|
+
# separator symbol for all modifier
|
|
13
|
+
SEPARATOR = ':'
|
|
14
|
+
|
|
15
|
+
# DataExpr::Compiler is a regexp compiler for data expression.
|
|
16
|
+
module Compiler
|
|
17
|
+
TABLE = {}
|
|
18
|
+
|
|
19
|
+
# Define a string matcher.
|
|
20
|
+
def self.define_matcher(matcher, replace)
|
|
21
|
+
TABLE[Regexp.escape(matcher)] = replace
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Asterisk symbol is multi-characters matcher(empty string is matched).
|
|
25
|
+
define_matcher('*', '(.*)')
|
|
26
|
+
|
|
27
|
+
# Question symbol is single character matcher(empty string is not matched).
|
|
28
|
+
define_matcher('?', '(.)')
|
|
29
|
+
|
|
30
|
+
# Compiles data name into regular expression.
|
|
31
|
+
def compile(name)
|
|
32
|
+
return name unless name.kind_of?(String)
|
|
33
|
+
|
|
34
|
+
s = "^#{Regexp.escape(name)}$"
|
|
35
|
+
TABLE.keys.each {|key| s.gsub!(key, TABLE)}
|
|
36
|
+
s.gsub!(/\\\[(!|\\\^)?(.*)\\\]/){"[#{'^' if $1}#{$2.gsub('\-','-')}]"}
|
|
37
|
+
s.gsub!(/\\{(.*)\\}/){"(#{$1.split(',').join('|')})"}
|
|
38
|
+
Regexp.new(s)
|
|
39
|
+
end
|
|
40
|
+
module_function :compile
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# This module implements DataExpr singleton methods.
|
|
44
|
+
module SingletonMethod
|
|
45
|
+
# Create a named expression.
|
|
46
|
+
# @param [String] name
|
|
47
|
+
# data expression
|
|
48
|
+
def [](name)
|
|
49
|
+
new(name)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Create a name expression with 'each' modifier.
|
|
53
|
+
def each(name)
|
|
54
|
+
new(name, :each)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Create a name expression with 'all' modifier.
|
|
58
|
+
def all(name)
|
|
59
|
+
new(name, :all)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Creates a new data name for stdout ouput.
|
|
63
|
+
# @param [String] name
|
|
64
|
+
# data name
|
|
65
|
+
# @return [DataExpr]
|
|
66
|
+
# data expression for stdout
|
|
67
|
+
def stdout(name)
|
|
68
|
+
new(name, :each, :stdout)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Creates a new data name for stderr output.
|
|
72
|
+
# @param [String] name
|
|
73
|
+
# data name
|
|
74
|
+
# @return [DataExpr]
|
|
75
|
+
# data expression for stderr
|
|
76
|
+
def stderr(name)
|
|
77
|
+
new(name, :each, :stderr)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Returns convertion prcedure for enumerable.
|
|
81
|
+
# @return [Proc]
|
|
82
|
+
# +Proc+ object that returns data expression with name
|
|
83
|
+
def to_proc
|
|
84
|
+
Proc.new{|name| name.kind_of?(self) ? name : self.new(name)}
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
extend SingletonMethod
|
|
89
|
+
|
|
90
|
+
set_pione_model_type TypeDataExpr
|
|
91
|
+
|
|
92
|
+
attr_reader :name
|
|
93
|
+
attr_reader :modifier
|
|
94
|
+
attr_reader :mode
|
|
95
|
+
attr_reader :exceptions
|
|
96
|
+
|
|
97
|
+
# Creates a data expression.
|
|
98
|
+
# @param [String] name
|
|
99
|
+
# data expression name
|
|
100
|
+
# @param [Symbol] modifier
|
|
101
|
+
# :all or :each
|
|
102
|
+
# @param [Symbol] mode
|
|
103
|
+
# nil, :stdout, or :stderr
|
|
104
|
+
def initialize(name, modifier = :each, mode = nil, exceptions = [])
|
|
105
|
+
unless name.kind_of? String or name.kind_of? Regexp
|
|
106
|
+
raise ArgumentError.new(name)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
@name = name
|
|
110
|
+
@modifier = modifier
|
|
111
|
+
@mode = mode
|
|
112
|
+
@exceptions = exceptions
|
|
113
|
+
|
|
114
|
+
super()
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# Returns new data expression with each modifier.
|
|
118
|
+
# @return [DataExpr]
|
|
119
|
+
# new data expression with each modifier
|
|
120
|
+
def each
|
|
121
|
+
return self.class.new(@name, :each, @mode, @exceptions)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# Returns new data expression with all modifier.
|
|
125
|
+
# @return [DataExpr]
|
|
126
|
+
# new data expression with all modifier
|
|
127
|
+
def all
|
|
128
|
+
return self.class.new(@name, :all, @mode, @exceptions)
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# Returns new data expression with stdout mode.
|
|
132
|
+
# @return [DataExpr]
|
|
133
|
+
# new data expression with stdout mode
|
|
134
|
+
def stdout
|
|
135
|
+
return self.class.new(@name, @modifier, :stdout, @exceptions)
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# Returns new data expression with stderr mode.
|
|
139
|
+
# @return [DataExpr]
|
|
140
|
+
# new data expression with stderr mode
|
|
141
|
+
def stderr
|
|
142
|
+
return self.class.new(@name, @modifier, :stderr, @exceptions)
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# Evaluates the data expression.
|
|
146
|
+
# @param [VariableTable] vtable
|
|
147
|
+
# variable table for evaluation
|
|
148
|
+
# @return [BasicModel]
|
|
149
|
+
# evaluation result
|
|
150
|
+
def eval(vtable)
|
|
151
|
+
exceptions = @exceptions.map {|exc| exc.eval(vtable)}
|
|
152
|
+
self.class.new(vtable.expand(name), @modifier, @mode, exceptions)
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
# Returns true if the name includes variables.
|
|
156
|
+
# @return [Boolean]
|
|
157
|
+
# true if the name includes variables
|
|
158
|
+
def include_variable?
|
|
159
|
+
VariableTable.check_include_variable(@name)
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# @api private
|
|
163
|
+
def task_id_string
|
|
164
|
+
"DataExpr<#{@name},#{@modifier},[%s]>" % [
|
|
165
|
+
@exceptions.map{|exc| exc.task_id_string}.join(",")
|
|
166
|
+
]
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
# @api private
|
|
170
|
+
def textize
|
|
171
|
+
"data_expr(\"#{@name}\",:#{@modifier},[%s])" % [
|
|
172
|
+
@exceptions.map{|exc| exc.textize}.join(",")
|
|
173
|
+
]
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
# Return true if the name has 'all' modifier.
|
|
177
|
+
# @return [Boolean]
|
|
178
|
+
# true if the name has 'all' modifier
|
|
179
|
+
def all?
|
|
180
|
+
@modifier == :all
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
# Return true if the name has 'each' modifier.
|
|
184
|
+
# @return [Boolean]
|
|
185
|
+
# true if the name has 'each' modifier
|
|
186
|
+
def each?
|
|
187
|
+
@modifier == :each
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
# Return true if the data content is in stdout.
|
|
191
|
+
# @return [Boolean]
|
|
192
|
+
# true if the data content is in stdout
|
|
193
|
+
def stdout?
|
|
194
|
+
@mode == :stdout
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
# Returns true if the data content is in stderr.
|
|
198
|
+
# @return [Boolean]
|
|
199
|
+
# true if the data content is in stderr
|
|
200
|
+
def stderr?
|
|
201
|
+
@mode == :stderr
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
# Creates new data expression with a exception name.
|
|
205
|
+
# @param [DataExpr, String] name
|
|
206
|
+
# data name for exceptions
|
|
207
|
+
# @return [DataExpr]
|
|
208
|
+
# new data name with the exception
|
|
209
|
+
def except(name)
|
|
210
|
+
exceptions =
|
|
211
|
+
@exceptions.clone + [name.kind_of?(DataExpr) ? name : DataExpr.new(name)]
|
|
212
|
+
return self.class.new(@name, @modifier, @mode, exceptions)
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
# Returns matched data if the name is matched with the expression.
|
|
216
|
+
# @param [String] other
|
|
217
|
+
# data name string
|
|
218
|
+
def match(other)
|
|
219
|
+
# check exceptions
|
|
220
|
+
return false if match_exceptions(other)
|
|
221
|
+
# match test
|
|
222
|
+
md = nil
|
|
223
|
+
@name.split(SEPARATOR).each do |name|
|
|
224
|
+
break if md = compile_to_regexp(name).match(other)
|
|
225
|
+
end
|
|
226
|
+
return md
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
# Selects from name list matched with the expression.
|
|
230
|
+
# @param [Array<String>] names
|
|
231
|
+
# name list
|
|
232
|
+
def select(*names)
|
|
233
|
+
names.flatten.select {|name| match(name) }
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
# Generates concrete name string by arguments.
|
|
237
|
+
# @example
|
|
238
|
+
# DataExpr["test-*.rb"].generate(1)
|
|
239
|
+
# # => "test-1.rb"
|
|
240
|
+
def generate(*args)
|
|
241
|
+
name = @name.clone
|
|
242
|
+
while name =~ /(\*|\?)/ and not(args.empty?)
|
|
243
|
+
val = args.shift.to_s
|
|
244
|
+
name.sub!(/(\*|\?)/){$1 == "*" ? val : val[0]}
|
|
245
|
+
end
|
|
246
|
+
return name
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
# Create OR relation data expression. Self and the other element have the
|
|
250
|
+
# same attributes.
|
|
251
|
+
# @example
|
|
252
|
+
# expr = DataExpr.new("A") | DataExpr.new("B")
|
|
253
|
+
# expr.match("A") # => true
|
|
254
|
+
# expr.match("B") # => true
|
|
255
|
+
# expr.match("C") # => false
|
|
256
|
+
# @example
|
|
257
|
+
# DataExpr.all("A") | DataExpr.each("B")
|
|
258
|
+
# # => raise ArgumentError
|
|
259
|
+
def |(other)
|
|
260
|
+
raise ArgumentError.new(other) unless other.kind_of?(DataExpr)
|
|
261
|
+
return DataExprOr.new(self, other)
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
# @api private
|
|
265
|
+
def to_s
|
|
266
|
+
"#<#<#{self.class.name}> #{@name}>"
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
# Returns true if name, modifier, mode, and exceptions are the same.
|
|
270
|
+
# @api private
|
|
271
|
+
def ==(other)
|
|
272
|
+
return false unless other.kind_of?(self.class)
|
|
273
|
+
return false unless @name == other.name
|
|
274
|
+
return false unless @modifier == other.modifier
|
|
275
|
+
return false unless @mode == other.mode
|
|
276
|
+
return false unless @exceptions.sort == other.exceptions.sort
|
|
277
|
+
return true
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
alias eql? ==
|
|
281
|
+
|
|
282
|
+
# @api private
|
|
283
|
+
def hash
|
|
284
|
+
[@name, @modifier, @mode, @exceptions].join("\000").hash
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
# Same as Regexp#=~ but return 0 if it matched.
|
|
288
|
+
def =~(other)
|
|
289
|
+
match(other) ? 0 : nil
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
# Pattern match.
|
|
293
|
+
# @api private
|
|
294
|
+
def ===(other)
|
|
295
|
+
match(other) ? true : false
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
private
|
|
299
|
+
|
|
300
|
+
# @api private
|
|
301
|
+
def compile_to_regexp(name)
|
|
302
|
+
Compiler.compile(name)
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
# Returns true if the name matchs exceptions.
|
|
306
|
+
# @api private
|
|
307
|
+
def match_exceptions(name)
|
|
308
|
+
not(@exceptions.select{|ex| ex.match(name)}.empty?)
|
|
309
|
+
end
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
# DataExprOr represents or-relation of data expressions.
|
|
313
|
+
class DataExprOr < DataExpr
|
|
314
|
+
extend Forwardable
|
|
315
|
+
def_delegator :@left, :modifier
|
|
316
|
+
def_delegator :@left, :mode
|
|
317
|
+
|
|
318
|
+
def initialize(left, right)
|
|
319
|
+
raise ArgumentError.new([left, right]) unless left.modifier == right.modifier
|
|
320
|
+
raise ArmguentError.new([left, right]) unless left.mode == right.mode
|
|
321
|
+
@left = left
|
|
322
|
+
@right = right
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
# @api private
|
|
326
|
+
def match(name)
|
|
327
|
+
@left.match(name) or @right.match(name)
|
|
328
|
+
end
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
TypeDataExpr.instance_eval do
|
|
332
|
+
define_pione_method("==", [TypeDataExpr], TypeBoolean) do |rec, other|
|
|
333
|
+
PioneBoolean.new(rec == other)
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
define_pione_method("!=", [TypeDataExpr], TypeBoolean) do |rec, other|
|
|
337
|
+
PioneBoolean.not(rec.call_pione_method("==", other))
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
define_pione_method("all", [], TypeDataExpr) do |rec|
|
|
341
|
+
rec.all
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
define_pione_method("each", [], TypeDataExpr) do |rec|
|
|
345
|
+
rec.each
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
define_pione_method("except", [TypeDataExpr], TypeDataExpr) do |rec, target|
|
|
349
|
+
rec.except(target)
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
define_pione_method("stdout", [], TypeDataExpr) do |rec|
|
|
353
|
+
rec.stdout
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
define_pione_method("stderr", [], TypeDataExpr) do |rec|
|
|
357
|
+
rec.stderr
|
|
358
|
+
end
|
|
359
|
+
end
|
|
360
|
+
end
|