pione 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.simplecov +1 -0
- data/History.txt +9 -0
- data/Rakefile +1 -71
- data/example/Fib/Fib.pione +9 -8
- data/example/HelloWorld/HelloWorld.pione +2 -0
- data/example/HelloWorld/pione-package.json +15 -0
- data/example/HelloWorld/scenario/Scenario.pione +2 -0
- data/example/HelloWorld/scenario/pione-scenario.json +10 -0
- data/example/SerialProcessing/SerialProcessing.pione +2 -0
- data/example/SerialProcessing/pione-package.json +15 -0
- data/example/SerialProcessing/scenario/Scenario.pione +1 -0
- data/example/SerialProcessing/scenario/pione-scenario.json +10 -0
- data/lib/pione.rb +28 -35
- data/lib/pione/agent.rb +4 -4
- data/lib/pione/agent/agent-exception.rb +52 -0
- data/lib/pione/agent/basic-agent.rb +246 -239
- data/lib/pione/agent/broker.rb +232 -216
- data/lib/pione/agent/input-generator.rb +113 -133
- data/lib/pione/agent/job-terminator.rb +38 -0
- data/lib/pione/agent/logger.rb +24 -54
- data/lib/pione/agent/messenger.rb +11 -16
- data/lib/pione/agent/process-manager.rb +50 -19
- data/lib/pione/agent/task-worker.rb +126 -236
- data/lib/pione/agent/tuple-space-client.rb +16 -39
- data/lib/pione/agent/tuple-space-provider.rb +66 -0
- data/lib/pione/agent/tuple-space-receiver.rb +137 -0
- data/lib/pione/command.rb +2 -3
- data/lib/pione/command/basic-command.rb +347 -207
- data/lib/pione/command/command-exception.rb +38 -0
- data/lib/pione/command/option.rb +112 -104
- data/lib/pione/command/pione-broker.rb +85 -43
- data/lib/pione/command/pione-clean.rb +51 -8
- data/lib/pione/command/pione-client.rb +321 -292
- data/lib/pione/command/pione-log.rb +92 -53
- data/lib/pione/command/pione-package.rb +112 -59
- data/lib/pione/command/pione-relay-account-db.rb +107 -78
- data/lib/pione/command/pione-relay-client-db.rb +93 -72
- data/lib/pione/command/pione-relay.rb +37 -32
- data/lib/pione/command/pione-syntax-checker.rb +112 -87
- data/lib/pione/command/pione-task-worker.rb +135 -118
- data/lib/pione/command/pione-tuple-space-provider.rb +83 -50
- data/lib/pione/command/pione-tuple-space-receiver.rb +89 -50
- data/lib/pione/command/pione-tuple-space-viewer.rb +101 -99
- data/lib/pione/command/pione-val.rb +50 -29
- data/lib/pione/command/spawner.rb +74 -0
- data/lib/pione/front.rb +0 -2
- data/lib/pione/front/basic-front.rb +48 -26
- data/lib/pione/front/broker-front.rb +8 -16
- data/lib/pione/front/client-front.rb +10 -18
- data/lib/pione/front/front-exception.rb +12 -0
- data/lib/pione/front/relay-front.rb +6 -6
- data/lib/pione/front/task-worker-front.rb +3 -9
- data/lib/pione/front/tuple-space-provider-front.rb +6 -14
- data/lib/pione/front/tuple-space-receiver-front.rb +4 -11
- data/lib/pione/global.rb +135 -0
- data/lib/pione/global/broker-variable.rb +20 -0
- data/lib/pione/global/client-variable.rb +18 -0
- data/lib/pione/global/input-generator-variable.rb +7 -0
- data/lib/pione/global/log-variable.rb +53 -0
- data/lib/pione/global/network-variable.rb +7 -0
- data/lib/pione/global/package-variable.rb +28 -0
- data/lib/pione/global/path-variable.rb +52 -0
- data/lib/pione/global/relay-variable.rb +86 -0
- data/lib/pione/global/system-variable.rb +39 -0
- data/lib/pione/global/task-worker-variable.rb +17 -0
- data/lib/pione/global/tuple-space-notifier-variable.rb +60 -0
- data/lib/pione/lang.rb +55 -0
- data/lib/pione/lang/basic-model.rb +45 -0
- data/lib/pione/lang/boolean.rb +86 -0
- data/lib/pione/lang/common-parser.rb +202 -0
- data/lib/pione/lang/conditional-branch-parser.rb +57 -0
- data/lib/pione/lang/conditional-branch-transformer.rb +36 -0
- data/lib/pione/lang/conditional-branch.rb +73 -0
- data/lib/pione/lang/context-parser.rb +39 -0
- data/lib/pione/lang/context-transformer.rb +41 -0
- data/lib/pione/lang/context.rb +229 -0
- data/lib/pione/lang/data-expr.rb +265 -0
- data/lib/pione/lang/declaration-parser.rb +174 -0
- data/lib/pione/lang/declaration-transformer.rb +153 -0
- data/lib/pione/lang/declaration.rb +322 -0
- data/lib/pione/lang/definition.rb +88 -0
- data/lib/pione/lang/document-parser.rb +19 -0
- data/lib/pione/lang/document-transformer.rb +12 -0
- data/lib/pione/lang/environment.rb +344 -0
- data/lib/pione/{parser → lang}/error-message.yml +0 -0
- data/lib/pione/lang/expr-parser.rb +228 -0
- data/lib/pione/{transformer → lang}/expr-transformer.rb +32 -44
- data/lib/pione/lang/expr.rb +70 -0
- data/lib/pione/lang/feature-expr.rb +425 -0
- data/lib/pione/lang/float.rb +104 -0
- data/lib/pione/lang/integer.rb +159 -0
- data/lib/pione/lang/interpolator-parser.rb +44 -0
- data/lib/pione/lang/interpolator-transformer.rb +13 -0
- data/lib/pione/lang/keyed-sequence.rb +98 -0
- data/lib/pione/lang/lang-exception.rb +224 -0
- data/lib/pione/lang/literal-parser.rb +134 -0
- data/lib/pione/lang/literal-transformer.rb +171 -0
- data/lib/pione/lang/message.rb +41 -0
- data/lib/pione/lang/ordinal-sequence.rb +203 -0
- data/lib/pione/lang/package-expr.rb +86 -0
- data/lib/pione/lang/parameters.rb +121 -0
- data/lib/pione/lang/piece.rb +42 -0
- data/lib/pione/{model → lang}/pione-method.rb +26 -63
- data/lib/pione/lang/rule-expr.rb +70 -0
- data/lib/pione/lang/sequence.rb +215 -0
- data/lib/pione/lang/string.rb +116 -0
- data/lib/pione/lang/ticket-expr.rb +48 -0
- data/lib/pione/{model → lang}/type.rb +70 -99
- data/lib/pione/lang/variable.rb +35 -0
- data/lib/pione/location.rb +13 -1
- data/lib/pione/{uri-scheme → location}/broadcast-scheme.rb +2 -2
- data/lib/pione/location/data-location.rb +22 -5
- data/lib/pione/location/dropbox-location.rb +10 -8
- data/lib/pione/{uri-scheme → location}/dropbox-scheme.rb +2 -2
- data/lib/pione/location/ftp-location.rb +6 -0
- data/lib/pione/location/git-repository-location.rb +6 -17
- data/lib/pione/{uri-scheme → location}/git-scheme.rb +2 -2
- data/lib/pione/location/http-location.rb +8 -1
- data/lib/pione/location/local-location.rb +57 -4
- data/lib/pione/{uri-scheme → location}/local-scheme.rb +2 -2
- data/lib/pione/location/{exception.rb → location-exception.rb} +13 -1
- data/lib/pione/{uri-scheme/basic-scheme.rb → location/location-scheme.rb} +7 -6
- data/lib/pione/{uri-scheme → location}/myftp-scheme.rb +2 -2
- data/lib/pione/log.rb +7 -6
- data/lib/pione/log/debug.rb +75 -0
- data/lib/pione/log/domain-log.rb +4 -5
- data/lib/pione/log/message-log.rb +2 -2
- data/lib/pione/log/process-log.rb +16 -25
- data/lib/pione/log/process-record.rb +1 -0
- data/lib/pione/log/system-log.rb +165 -55
- data/lib/pione/package.rb +21 -0
- data/lib/pione/package/document.rb +27 -0
- data/lib/pione/package/package-archiver.rb +152 -0
- data/lib/pione/package/package-cache.rb +79 -0
- data/lib/pione/package/package-database.rb +121 -0
- data/lib/pione/package/package-exception.rb +38 -0
- data/lib/pione/{component → package}/package-expander.rb +13 -7
- data/lib/pione/package/package-filename.rb +46 -0
- data/lib/pione/package/package-handler.rb +106 -0
- data/lib/pione/package/package-info.rb +72 -0
- data/lib/pione/package/package-reader.rb +202 -0
- data/lib/pione/package/package-scanner.rb +133 -0
- data/lib/pione/package/scenario-handler.rb +95 -0
- data/lib/pione/package/scenario-info.rb +34 -0
- data/lib/pione/package/scenario-reader.rb +29 -0
- data/lib/pione/package/scenario-scanner.rb +96 -0
- data/lib/pione/patch.rb +0 -1
- data/lib/pione/patch/drb-patch.rb +377 -298
- data/lib/pione/patch/rinda-patch.rb +4 -3
- data/lib/pione/relay/relay-socket.rb +1 -4
- data/lib/pione/rule-engine.rb +27 -0
- data/lib/pione/{rule-handler → rule-engine}/action-handler.rb +41 -40
- data/lib/pione/rule-engine/basic-handler.rb +266 -0
- data/lib/pione/rule-engine/data-finder.rb +97 -0
- data/lib/pione/{rule-handler → rule-engine}/empty-handler.rb +2 -3
- data/lib/pione/rule-engine/engine-exception.rb +33 -0
- data/lib/pione/rule-engine/flow-handler.rb +490 -0
- data/lib/pione/{rule-handler → rule-engine}/root-handler.rb +5 -14
- data/lib/pione/{rule-handler → rule-engine}/system-handler.rb +1 -1
- data/lib/pione/rule-engine/update-criteria.rb +111 -0
- data/lib/pione/system.rb +3 -1
- data/lib/pione/system/config.rb +12 -45
- data/lib/pione/system/domain-info.rb +3 -12
- data/lib/pione/system/init.rb +2 -8
- data/lib/pione/system/system-exception.rb +29 -0
- data/lib/pione/test-helper.rb +43 -0
- data/lib/pione/test-helper/command-helper.rb +65 -0
- data/lib/pione/test-helper/extension.rb +9 -0
- data/lib/pione/test-helper/lang-helper.rb +196 -0
- data/lib/pione/test-helper/location-helper.rb +27 -0
- data/lib/pione/test-helper/package-helper.rb +11 -0
- data/lib/pione/test-helper/parser-helper.rb +45 -0
- data/lib/pione/test-helper/transformer-helper.rb +136 -0
- data/lib/pione/test-helper/tuple-helper.rb +13 -0
- data/lib/pione/test-helper/tuple-space-helper.rb +31 -0
- data/lib/pione/test-helper/webserver.rb +50 -0
- data/lib/pione/tuple-space.rb +4 -6
- data/lib/pione/{tuple → tuple-space}/basic-tuple.rb +63 -50
- data/lib/pione/tuple-space/tuple-definition.yml +165 -0
- data/lib/pione/tuple-space/tuple-space-exception.rb +25 -0
- data/lib/pione/tuple-space/tuple-space-interface.rb +123 -0
- data/lib/pione/tuple-space/tuple-space-server.rb +15 -26
- data/lib/pione/util.rb +16 -11
- data/lib/pione/util/backslash-notation.rb +11 -0
- data/lib/pione/util/digest.rb +71 -0
- data/lib/pione/util/embeded-expr-expander.rb +23 -0
- data/lib/pione/util/evaluatable.rb +9 -6
- data/lib/pione/util/free-thread-generator.rb +46 -0
- data/lib/pione/util/ftp-server.rb +3 -4
- data/lib/pione/util/id.rb +28 -23
- data/lib/pione/util/misc.rb +22 -4
- data/lib/pione/util/package-parameters-list.rb +12 -9
- data/lib/pione/{parser → util}/parslet-extension.rb +75 -64
- data/lib/pione/util/positionable.rb +65 -0
- data/lib/pione/util/zip.rb +12 -11
- data/lib/pione/version.rb +1 -1
- data/{test → misc}/endurance-test/graph.plt +0 -0
- data/{test → misc}/endurance-test/run.sh +0 -0
- data/pione.gemspec +45 -37
- data/test/agent/spec_basic-agent.rb +116 -99
- data/test/agent/spec_broker.rb +41 -25
- data/test/agent/spec_input-generator.rb +66 -57
- data/test/agent/spec_job-terminator.rb +27 -0
- data/test/agent/spec_logger.rb +28 -25
- data/test/agent/spec_messenger.rb +6 -6
- data/test/agent/spec_task-worker.rb +97 -246
- data/test/agent/spec_tuple-space-client.rb +19 -15
- data/test/agent/spec_tuple-space-provider.rb +26 -0
- data/test/agent/spec_tuple-space-receiver.rb +47 -0
- data/test/command/command-behavior.rb +2 -2
- data/test/command/data/PionePackageP1/P1.pione +9 -0
- data/test/command/data/PionePackageP1/pione-package.json +15 -0
- data/test/command/data/PionePackageP2/P2.pione +10 -0
- data/test/command/data/PionePackageP2/pione-package.json +16 -0
- data/test/command/data/PionePackageP3/P3.pione +10 -0
- data/test/command/data/PionePackageP3/pione-package.json +16 -0
- data/test/command/data/PionePackageP4/P4.pione +10 -0
- data/test/command/data/PionePackageP4/pione-package.json +17 -0
- data/test/command/data/pione-process.log +471 -0
- data/test/command/data/pione-val.domain.dump +0 -0
- data/test/command/spec_pione-clean.rb +12 -0
- data/test/command/spec_pione-client.rb +6 -6
- data/test/command/spec_pione-log.rb +28 -0
- data/test/command/spec_pione-package.rb +111 -12
- data/test/command/spec_pione-val.rb +4 -4
- data/test/lang/data/boolean.yml +134 -0
- data/test/lang/data/common-parser.yml +187 -0
- data/test/{parser/spec_flow-element-parser.yml → lang/data/conditional-branch-parser.yml} +12 -50
- data/test/lang/data/context-parser.yml +148 -0
- data/test/lang/data/data-expr.yml +93 -0
- data/test/lang/data/data-expr_match.yml +59 -0
- data/test/lang/data/declaration-parser.yml +279 -0
- data/test/lang/data/document-parser.yml +29 -0
- data/test/{parser/spec_expr-parser.yml → lang/data/expr-parser.yml} +9 -11
- data/test/lang/data/feature-expr.yml +148 -0
- data/test/lang/data/float.yml +30 -0
- data/test/lang/data/integer.yml +80 -0
- data/test/lang/data/interpolator-parser.yml +61 -0
- data/test/lang/data/keyed-sequence.yml +27 -0
- data/test/lang/data/literal-parser.yml +207 -0
- data/test/lang/data/parameter-set.yml +14 -0
- data/test/lang/data/rule-expr.yml +27 -0
- data/test/lang/data/sequence.yml +66 -0
- data/test/lang/data/string.yml +92 -0
- data/test/{model/spec_ticket-expr.yml → lang/data/ticket-expr.yml} +0 -0
- data/test/lang/spec_boolean.rb +5 -0
- data/test/{parser → lang}/spec_common-parser.rb +10 -32
- data/test/lang/spec_conditional-branch-parser.rb +5 -0
- data/test/lang/spec_conditional-branch-transformer.rb +97 -0
- data/test/lang/spec_conditional-branch.rb +176 -0
- data/test/lang/spec_context-parser.rb +5 -0
- data/test/lang/spec_context-transformer.rb +206 -0
- data/test/lang/spec_context.rb +283 -0
- data/test/lang/spec_data-expr.rb +198 -0
- data/test/lang/spec_declaration-parser.rb +5 -0
- data/test/lang/spec_declaration-transformer.rb +272 -0
- data/test/lang/spec_declaration.rb +550 -0
- data/test/lang/spec_document-parser.rb +5 -0
- data/test/lang/spec_document-transformer.rb +10 -0
- data/test/lang/spec_environment.rb +129 -0
- data/test/lang/spec_expr-parser.rb +6 -0
- data/test/lang/spec_expr-transformer.rb +149 -0
- data/test/lang/spec_feature-expr.rb +5 -0
- data/test/lang/spec_float.rb +23 -0
- data/test/lang/spec_integer.rb +29 -0
- data/test/lang/spec_interpolator-parser.rb +5 -0
- data/test/lang/spec_interpolator-transformer.rb +15 -0
- data/test/lang/spec_keyed-sequence.rb +5 -0
- data/test/lang/spec_literal-parser.rb +5 -0
- data/test/lang/spec_literal-transformer.rb +111 -0
- data/test/lang/spec_message.rb +22 -0
- data/test/lang/spec_package-expr.rb +19 -0
- data/test/lang/spec_parameter-set.rb +64 -0
- data/test/lang/spec_pione-method.rb +57 -0
- data/test/lang/spec_rule-expr.rb +18 -0
- data/test/lang/spec_sequence.rb +5 -0
- data/test/lang/spec_string.rb +5 -0
- data/test/lang/spec_ticket-expr.rb +39 -0
- data/test/lang/spec_variable.rb +29 -0
- data/test/{uri-scheme/spec_myftp-scheme.yml → location/data/myftp-scheme.yml} +0 -0
- data/test/location/location-behavior.rb +2 -2
- data/test/location/spec_basic-location.rb +5 -1
- data/test/{uri-scheme → location}/spec_broadcast-scheme.rb +4 -4
- data/test/{uri-scheme → location}/spec_dropbox-scheme.rb +3 -3
- data/test/location/spec_ftp-location.rb +3 -2
- data/test/location/spec_git-repository-location.rb +19 -19
- data/test/{uri-scheme → location}/spec_git-scheme.rb +2 -2
- data/test/location/spec_http-location.rb +4 -12
- data/test/location/spec_https-location.rb +1 -3
- data/test/location/spec_local-location.rb +1 -1
- data/test/{uri-scheme → location}/spec_local-scheme.rb +3 -3
- data/test/{uri-scheme → location}/spec_myftp-scheme.rb +8 -10
- data/test/log/spec_debug.rb +53 -0
- data/test/log/spec_domain-log.rb +4 -5
- data/test/log/spec_message-log.rb +39 -33
- data/test/log/spec_process-log.rb +4 -2
- data/test/log/spec_process-record.rb +12 -10
- data/test/log/spec_system-log.rb +29 -11
- data/test/log/spec_xes-log.rb +6 -4
- data/test/package/data/HelloWorld+v0.1.1.ppg +0 -0
- data/test/package/data/HelloWorld-gitrepos.zip +0 -0
- data/test/{test-data/package → package/data}/HelloWorld/HelloWorld.pione +3 -0
- data/test/package/data/HelloWorld/pione-package.json +16 -0
- data/test/package/data/HelloWorld/scenario/Scenario.pione +2 -0
- data/test/{test-data/package → package/data}/HelloWorld/scenario/output/message.txt +0 -0
- data/test/package/data/HelloWorld/scenario/pione-scenario.json +10 -0
- data/test/{test-data/package → package/data}/HelloWorld/scenario/scenario.yml +0 -0
- data/test/package/data/PackageScannerP1/P1.pione +11 -0
- data/test/package/data/PackageScannerP2/P2.pione +9 -0
- data/test/package/data/PackageScannerP3/P3.pione +17 -0
- data/test/package/data/PackageScannerP4/.Ignore.pione +1 -0
- data/test/package/data/PackageScannerP4/Doc1.pione +8 -0
- data/test/package/data/PackageScannerP4/Doc2.pione +6 -0
- data/test/package/data/PackageScannerP4/Doc3.pione +6 -0
- data/test/package/data/PackageScannerP4/P4.pione +8 -0
- data/test/package/data/PackageScannerP4/sub1/.Ignore.pione +1 -0
- data/test/package/data/PackageScannerP4/sub1/Doc4.pione +6 -0
- data/test/package/data/PackageScannerP4/sub1/sub1-1/.Ignore.pione +1 -0
- data/test/package/data/PackageScannerP4/sub1/sub1-1/Doc5.pione +6 -0
- data/test/package/data/PackageScannerP4/sub2/.Ignore.pione +1 -0
- data/test/package/data/PackageScannerP4/sub2/sub2-1/.Ignore.pione +1 -0
- data/test/package/data/PackageScannerP4/sub2/sub2-1/sub2-1-1/.Ignore.pione +1 -0
- data/test/package/data/PackageScannerP4/sub2/sub2-1/sub2-1-1/Doc6.pione +6 -0
- data/test/package/data/PackageScannerP4/sub2/sub2-1/sub2-1-2/.Ignore.pione +1 -0
- data/test/package/data/PackageScannerP4/sub2/sub2-1/sub2-1-2/Doc7.pione +6 -0
- data/test/package/data/PackageScannerP5/P5.pione +8 -0
- data/test/{model/spec_feature-expr.yml → package/data/PackageScannerP5/scenario1/Scenario.pione} +0 -0
- data/test/package/data/PackageScannerP5/scenario2/Scenario.pione +0 -0
- data/test/package/data/PackageScannerP5/scenario3/Scenario.pione +0 -0
- data/test/package/data/PackageScannerP5/sub1/scenario4/Scenario.pione +0 -0
- data/test/package/data/PackageScannerP5/sub1/sub1-1/scenario5/Scenario.pione +0 -0
- data/test/package/data/PackageScannerP5/sub2/sub2-1/sub2-1-1/scenario6/Scenario.pione +0 -0
- data/test/package/data/PackageScannerP5/sub2/sub2-1/sub2-1-2/scenario7/Scenario.pione +0 -0
- data/test/package/data/ScenarioScannerS1/Scenario.pione +1 -0
- data/test/package/data/ScenarioScannerS1/input/i1 +0 -0
- data/test/package/data/ScenarioScannerS1/input/i2 +0 -0
- data/test/package/data/ScenarioScannerS1/input/i3 +0 -0
- data/test/package/data/ScenarioScannerS1/output/o1 +0 -0
- data/test/package/data/ScenarioScannerS1/output/o2 +0 -0
- data/test/package/data/ScenarioScannerS1/output/o3 +0 -0
- data/test/package/data/ScenarioScannerS2/Scenario.pione +1 -0
- data/test/package/data/ScenarioScannerS2/output/o1 +0 -0
- data/test/package/data/ScenarioScannerS3/Scenario.pione +2 -0
- data/test/package/data/ScenarioScannerS4/Scenario.pione +0 -0
- data/test/package/data/ScenarioScannerS5/Scenario.pione +2 -0
- data/test/package/data/ScenarioScannerS6/Scenario.pione +5 -0
- data/test/package/data/ScenarioScannerS8/Scenario.pione +1 -0
- data/test/{test-data/package → package/data}/TestPackage1+v0.1.0.ppg +0 -0
- data/test/{test-data/package → package/data}/TestPackage1/Test.pione +3 -0
- data/test/{test-data/package → package/data}/TestPackage1/bin/count +0 -0
- data/test/{test-data/package → package/data}/TestPackage1/package.yml +0 -0
- data/test/package/data/TestPackage1/pione-package.json +18 -0
- data/test/package/data/TestPackage1/scenario/case1/Scenario.pione +1 -0
- data/test/{test-data/package → package/data}/TestPackage1/scenario/case1/input/1.txt +0 -0
- data/test/{test-data/package → package/data}/TestPackage1/scenario/case1/output/1.count +0 -0
- data/test/package/data/TestPackage1/scenario/case1/pione-scenario.json +10 -0
- data/test/{test-data/package → package/data}/TestPackage1/scenario/case1/scenario.yml +0 -0
- data/test/package/data/TestPackage1/scenario/case2/Scenario.pione +1 -0
- data/test/{test-data/package → package/data}/TestPackage1/scenario/case2/input/1.txt +0 -0
- data/test/{test-data/package → package/data}/TestPackage1/scenario/case2/input/2.txt +0 -0
- data/test/{test-data/package → package/data}/TestPackage1/scenario/case2/input/3.txt +0 -0
- data/test/{test-data/package → package/data}/TestPackage1/scenario/case2/output/1.count +0 -0
- data/test/{test-data/package → package/data}/TestPackage1/scenario/case2/output/2.count +0 -0
- data/test/{test-data/package → package/data}/TestPackage1/scenario/case2/output/3.count +0 -0
- data/test/package/data/TestPackage1/scenario/case2/pione-scenario.json +14 -0
- data/test/{test-data/package → package/data}/TestPackage1/scenario/case2/scenario.yml +0 -0
- data/test/package/data/TestPackage1/scenario/case3/Scenario.pione +1 -0
- data/test/{test-data/package → package/data}/TestPackage1/scenario/case3/input/a.txt +0 -0
- data/test/{test-data/package → package/data}/TestPackage1/scenario/case3/input/b.txt +0 -0
- data/test/{test-data/package → package/data}/TestPackage1/scenario/case3/output/a.count +0 -0
- data/test/{test-data/package → package/data}/TestPackage1/scenario/case3/output/b.count +0 -0
- data/test/package/data/TestPackage1/scenario/case3/pione-scenario.json +12 -0
- data/test/{test-data/package → package/data}/TestPackage1/scenario/case3/scenario.yml +0 -0
- data/test/{component → package}/spec_document.pione +0 -0
- data/test/package/spec_document.rb +52 -0
- data/test/package/spec_package-archiver.rb +31 -0
- data/test/package/spec_package-database.rb +42 -0
- data/test/package/spec_package-expander.rb +14 -0
- data/test/package/spec_package-filename.rb +56 -0
- data/test/package/spec_package-handler.rb +50 -0
- data/test/package/spec_package-info.rb +22 -0
- data/test/package/spec_package-reader.rb +85 -0
- data/test/package/spec_package-scanner.rb +68 -0
- data/test/package/spec_scenario-handler.rb +46 -0
- data/test/package/spec_scenario-info.rb +16 -0
- data/test/package/spec_scenario-scanner.rb +92 -0
- data/test/patch/spec_rinda-patch.rb +1 -1
- data/test/patch/spec_uri-patch.rb +1 -1
- data/test/{rule-handler → rule-engine}/spec_action-handler.pione +0 -0
- data/test/rule-engine/spec_action-handler.rb +94 -0
- data/test/rule-engine/spec_data-finder.rb +94 -0
- data/test/{tuple-space → rule-engine}/spec_data-finder.yml +39 -28
- data/test/rule-engine/spec_empty-handler.rb +170 -0
- data/test/{rule-handler → rule-engine}/spec_flow-handler.pione +0 -0
- data/test/rule-engine/spec_flow-handler.rb +421 -0
- data/test/{rule-handler → rule-engine}/spec_update-criteria.pione +0 -0
- data/test/{rule-handler → rule-engine}/spec_update-criteria.rb +16 -12
- data/test/{rule-handler → rule-engine}/spec_update-criteria.yml +0 -0
- data/test/system/spec_domain-info.rb +13 -9
- data/test/system/spec_file-cache.rb +9 -9
- data/test/tuple-space/spec_tuple-space-server.rb +42 -40
- data/test/tuple/spec_basic-tuple.rb +77 -75
- data/test/tuple/spec_data-tuple.rb +4 -4
- data/test/tuple/spec_finished-tuple.rb +5 -6
- data/test/tuple/spec_message-tuple.rb +3 -3
- data/test/tuple/spec_task-tuple.rb +11 -9
- data/test/tuple/spec_touch-tuple.rb +3 -3
- data/test/tuple/spec_working-tuple.rb +8 -12
- data/test/tuple/tuple-behavior.rb +1 -1
- data/test/util/data/HelloWorld+v0.1.1.ppg +0 -0
- data/test/util/spec_cpu.rb +1 -1
- data/test/util/spec_digest.rb +15 -0
- data/test/util/spec_evaluatable.rb +3 -3
- data/test/util/spec_free-thread-generator.rb +42 -0
- data/test/util/spec_ftp-server.rb +4 -9
- data/test/util/spec_id.rb +53 -36
- data/test/util/spec_indentation.rb +1 -1
- data/test/util/spec_ip-address.rb +1 -1
- data/test/util/spec_package-parameters-list.rb +10 -9
- data/test/util/spec_process-info.rb +2 -2
- data/test/util/spec_uuid.rb +1 -1
- data/test/util/spec_variable-holdable.rb +1 -1
- data/test/util/spec_zip.rb +1 -1
- metadata +508 -364
- data/example/SerialProcessing/package.yml +0 -5
- data/example/SerialProcessing/scenario/scenario.yml +0 -10
- data/lib/pione/agent/command-listener.rb +0 -47
- data/lib/pione/agent/rule-provider.rb +0 -59
- data/lib/pione/agent/trivial-routine-worker.rb +0 -29
- data/lib/pione/agent/tuple-space-server-client-life-checker.rb +0 -31
- data/lib/pione/command/child-process.rb +0 -56
- data/lib/pione/command/daemon-process.rb +0 -10
- data/lib/pione/command/front-owner-command.rb +0 -25
- data/lib/pione/component.rb +0 -13
- data/lib/pione/component/document.rb +0 -88
- data/lib/pione/component/package-archiver.rb +0 -92
- data/lib/pione/component/package-filename.rb +0 -38
- data/lib/pione/component/package-reader.rb +0 -276
- data/lib/pione/component/package.rb +0 -199
- data/lib/pione/component/rule.rb +0 -206
- data/lib/pione/front/task-worker-owner.rb +0 -43
- data/lib/pione/front/tuple-space-provider-owner.rb +0 -11
- data/lib/pione/model.rb +0 -32
- data/lib/pione/model/assignment.rb +0 -120
- data/lib/pione/model/basic-model.rb +0 -228
- data/lib/pione/model/block.rb +0 -262
- data/lib/pione/model/boolean.rb +0 -168
- data/lib/pione/model/call-rule.rb +0 -86
- data/lib/pione/model/constraints.rb +0 -46
- data/lib/pione/model/data-expr.rb +0 -548
- data/lib/pione/model/feature-expr.rb +0 -875
- data/lib/pione/model/float.rb +0 -105
- data/lib/pione/model/integer.rb +0 -166
- data/lib/pione/model/keyed-sequence.rb +0 -150
- data/lib/pione/model/message.rb +0 -95
- data/lib/pione/model/ordinal-sequence.rb +0 -73
- data/lib/pione/model/package-expr.rb +0 -53
- data/lib/pione/model/parameters.rb +0 -374
- data/lib/pione/model/rule-expr.rb +0 -234
- data/lib/pione/model/sequence.rb +0 -273
- data/lib/pione/model/string.rb +0 -127
- data/lib/pione/model/ticket-expr.rb +0 -71
- data/lib/pione/model/variable-table.rb +0 -344
- data/lib/pione/model/variable.rb +0 -116
- data/lib/pione/parser.rb +0 -14
- data/lib/pione/parser/block-parser.rb +0 -107
- data/lib/pione/parser/common-parser.rb +0 -173
- data/lib/pione/parser/document-parser.rb +0 -141
- data/lib/pione/parser/expr-parser.rb +0 -354
- data/lib/pione/parser/feature-expr-parser.rb +0 -105
- data/lib/pione/parser/flow-element-parser.rb +0 -181
- data/lib/pione/parser/literal-parser.rb +0 -196
- data/lib/pione/parser/rule-definition-parser.rb +0 -158
- data/lib/pione/patch/monitor-patch.rb +0 -16
- data/lib/pione/rule-handler.rb +0 -14
- data/lib/pione/rule-handler/basic-handler.rb +0 -326
- data/lib/pione/rule-handler/flow-handler.rb +0 -414
- data/lib/pione/rule-handler/update-criteria.rb +0 -175
- data/lib/pione/system/global.rb +0 -433
- data/lib/pione/transformer.rb +0 -24
- data/lib/pione/transformer/block-transformer.rb +0 -28
- data/lib/pione/transformer/document-transformer.rb +0 -58
- data/lib/pione/transformer/feature-expr-transformer.rb +0 -60
- data/lib/pione/transformer/flow-element-transformer.rb +0 -66
- data/lib/pione/transformer/literal-transformer.rb +0 -91
- data/lib/pione/transformer/rule-definition-transformer.rb +0 -80
- data/lib/pione/transformer/transformer-module.rb +0 -39
- data/lib/pione/tuple-space/data-finder.rb +0 -155
- data/lib/pione/tuple-space/presence-notifier.rb +0 -84
- data/lib/pione/tuple-space/tuple-space-provider.rb +0 -85
- data/lib/pione/tuple-space/tuple-space-receiver.rb +0 -141
- data/lib/pione/tuple-space/tuple-space-server-interface.rb +0 -123
- data/lib/pione/tuple.rb +0 -30
- data/lib/pione/tuple/agent-tuple.rb +0 -10
- data/lib/pione/tuple/attribute-tuple.rb +0 -7
- data/lib/pione/tuple/base-location-tuple.rb +0 -9
- data/lib/pione/tuple/bye-tuple.rb +0 -9
- data/lib/pione/tuple/command-tuple.rb +0 -9
- data/lib/pione/tuple/data-null-tuple.rb +0 -14
- data/lib/pione/tuple/data-tuple.rb +0 -21
- data/lib/pione/tuple/dry-run-tuple.rb +0 -8
- data/lib/pione/tuple/exception-tuple.rb +0 -11
- data/lib/pione/tuple/finished-tuple.rb +0 -17
- data/lib/pione/tuple/foreground-tuple.rb +0 -7
- data/lib/pione/tuple/lift-tuple.rb +0 -14
- data/lib/pione/tuple/message-tuple.rb +0 -7
- data/lib/pione/tuple/process-info-tuple.rb +0 -9
- data/lib/pione/tuple/process-log-tuple.rb +0 -13
- data/lib/pione/tuple/request-rule-tuple.rb +0 -9
- data/lib/pione/tuple/rule-tuple.rb +0 -10
- data/lib/pione/tuple/task-tuple.rb +0 -40
- data/lib/pione/tuple/task-worker-resource-tuple.rb +0 -9
- data/lib/pione/tuple/ticket-tuple.rb +0 -8
- data/lib/pione/tuple/touch-tuple.rb +0 -14
- data/lib/pione/tuple/working-tuple.rb +0 -13
- data/lib/pione/uri-scheme.rb +0 -11
- data/lib/pione/util/error-report.rb +0 -27
- data/test/agent/spec_command-listener.rb +0 -30
- data/test/agent/spec_rule-provider.rb +0 -78
- data/test/command/spec_pione-val.domain.dump +0 -0
- data/test/component/spec_document.rb +0 -67
- data/test/component/spec_package-archiver.rb +0 -27
- data/test/component/spec_package-expander.rb +0 -11
- data/test/component/spec_package-filename.rb +0 -79
- data/test/component/spec_package-reader.rb +0 -100
- data/test/component/spec_package.rb +0 -109
- data/test/component/spec_rule.rb +0 -140
- data/test/model/spec_assignment.rb +0 -52
- data/test/model/spec_block.rb +0 -108
- data/test/model/spec_boolean.rb +0 -39
- data/test/model/spec_boolean.yml +0 -134
- data/test/model/spec_call-rule.rb +0 -23
- data/test/model/spec_data-expr.rb +0 -361
- data/test/model/spec_data-expr.yml +0 -24
- data/test/model/spec_data-expr_match.yml +0 -45
- data/test/model/spec_feature-expr.rb +0 -333
- data/test/model/spec_feature-expr_decide.yml +0 -28
- data/test/model/spec_float.rb +0 -23
- data/test/model/spec_float.yml +0 -30
- data/test/model/spec_integer.rb +0 -23
- data/test/model/spec_integer.yml +0 -68
- data/test/model/spec_keyed-sequence.rb +0 -5
- data/test/model/spec_keyed-sequence.yml +0 -27
- data/test/model/spec_message.rb +0 -40
- data/test/model/spec_package-expr.rb +0 -19
- data/test/model/spec_parameters.rb +0 -103
- data/test/model/spec_pione-method.rb +0 -57
- data/test/model/spec_rule-expr.rb +0 -28
- data/test/model/spec_rule-expr.yml +0 -11
- data/test/model/spec_sequence.rb +0 -5
- data/test/model/spec_sequence.yml +0 -66
- data/test/model/spec_string.rb +0 -47
- data/test/model/spec_string.yml +0 -91
- data/test/model/spec_ticket-expr.rb +0 -39
- data/test/model/spec_variable-table.rb +0 -116
- data/test/model/spec_variable.rb +0 -82
- data/test/parser/spec_block-parser.rb +0 -5
- data/test/parser/spec_block-parser.yml +0 -94
- data/test/parser/spec_document-parser.rb +0 -5
- data/test/parser/spec_document-parser.yml +0 -77
- data/test/parser/spec_expr-parser.rb +0 -6
- data/test/parser/spec_feature-expr-parser.rb +0 -32
- data/test/parser/spec_feature-expr-parser.yml +0 -25
- data/test/parser/spec_flow-element-parser.rb +0 -5
- data/test/parser/spec_literal-parser.rb +0 -5
- data/test/parser/spec_literal-parser.yml +0 -134
- data/test/parser/spec_rule-definition-parser.rb +0 -5
- data/test/parser/spec_rule-definition-parser.yml +0 -94
- data/test/rule-handler/spec_action-handler.rb +0 -79
- data/test/rule-handler/spec_flow-handler.rb +0 -61
- data/test/spec_common.rb +0 -14
- data/test/spec_object.rb +0 -20
- data/test/test-data/package/HelloWorld+v0.1.0.ppg +0 -0
- data/test/test-data/package/HelloWorld-gitrepos.zip +0 -0
- data/test/test-data/package/HelloWorld/package.yml +0 -6
- data/test/test-util.rb +0 -211
- data/test/test-util/command.rb +0 -53
- data/test/test-util/package.rb +0 -9
- data/test/test-util/parser.rb +0 -45
- data/test/test-util/transformer.rb +0 -50
- data/test/test-util/webserver.rb +0 -43
- data/test/transformer/spec_block-transformer.rb +0 -33
- data/test/transformer/spec_document-transformer.rb +0 -50
- data/test/transformer/spec_expr-transformer.rb +0 -126
- data/test/transformer/spec_feature-expr-transformer.rb +0 -21
- data/test/transformer/spec_flow-element-transformer.rb +0 -154
- data/test/transformer/spec_literal-transformer.rb +0 -64
- data/test/transformer/spec_rule-definition-transformer.rb +0 -172
- data/test/tuple-space/spec_data-finder.rb +0 -94
- data/test/tuple-space/spec_tuple-space-provider.rb +0 -36
- data/test/tuple-space/spec_tuple-space-receiver.rb +0 -32
- data/test/util/spec_error-report.rb +0 -51
@@ -0,0 +1,215 @@
|
|
1
|
+
module Pione
|
2
|
+
module Lang
|
3
|
+
# SequenceAttributeError is an exception for attribute mismatching.
|
4
|
+
class SequenceAttributeError < StandardError
|
5
|
+
def initialize(attribute)
|
6
|
+
@attribute = attribute
|
7
|
+
end
|
8
|
+
|
9
|
+
def message
|
10
|
+
"attribute mismatched: %s" % @attribute
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# Sequence is a base class for all expressions.
|
15
|
+
class Sequence < Expr
|
16
|
+
include Enumerable # use iteration
|
17
|
+
include Util::Positionable # Sequence have position in source maybe
|
18
|
+
include Callable # provides #call_pione_method
|
19
|
+
immutable true
|
20
|
+
|
21
|
+
class << self
|
22
|
+
def inherited(subclass)
|
23
|
+
members.each {|member_name| subclass.member(member_name, default: default_values[member_name])}
|
24
|
+
subclass.immutable true
|
25
|
+
subclass.index_type(index_type)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Get/set piece class.
|
29
|
+
def piece_class(klass)
|
30
|
+
(@piece_classes ||= []) << klass
|
31
|
+
end
|
32
|
+
|
33
|
+
def piece_classes
|
34
|
+
@piece_classes ||= []
|
35
|
+
end
|
36
|
+
|
37
|
+
# Set the index type.
|
38
|
+
def index_type(type=nil)
|
39
|
+
type ? @index_type = type : @index_type
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Make a void sequence.
|
44
|
+
def Sequence.void
|
45
|
+
Sequence.new([])
|
46
|
+
end
|
47
|
+
|
48
|
+
member :pieces, default: []
|
49
|
+
member :distribution, default: :each, values: [:each, :all]
|
50
|
+
member :annotation_type
|
51
|
+
|
52
|
+
forward! :class, :piece_classes, :index_type
|
53
|
+
forward! Proc.new{pieces}, :size, :length, :include?
|
54
|
+
|
55
|
+
# Return true if the sequence is void.
|
56
|
+
#
|
57
|
+
# @return [Boolean]
|
58
|
+
# true if the sequence is void
|
59
|
+
def void?
|
60
|
+
self.class == Sequence and empty?
|
61
|
+
end
|
62
|
+
|
63
|
+
# Return true if the sequence is assertive about attributes.
|
64
|
+
def assertive?
|
65
|
+
true
|
66
|
+
end
|
67
|
+
|
68
|
+
def attribute
|
69
|
+
members - [:pieces]
|
70
|
+
end
|
71
|
+
|
72
|
+
# Concatenate self and another sequence. If self and another are
|
73
|
+
# assertive, raise +SequenceAttributeError+ exception when the attributes
|
74
|
+
# are different.
|
75
|
+
#
|
76
|
+
# @param other [Sequence]
|
77
|
+
# other sequence
|
78
|
+
# @return [Sequence]
|
79
|
+
# a new sequence that have members of self and other
|
80
|
+
def concat(other)
|
81
|
+
if assertive? and other.assertive?
|
82
|
+
raise SequenceAttributeError.new(other) unless attribute == other.attribute
|
83
|
+
end
|
84
|
+
attr = not(other.assertive?) ? @attribute : other.attribute
|
85
|
+
set(pieces: pieces + other.pieces)
|
86
|
+
end
|
87
|
+
alias :+ :concat
|
88
|
+
|
89
|
+
# Push the piece to the sequecence.
|
90
|
+
def push(piece)
|
91
|
+
set(pieces: pieces + [piece])
|
92
|
+
end
|
93
|
+
|
94
|
+
# Iterate each elements.
|
95
|
+
#
|
96
|
+
# @return [Enumerator]
|
97
|
+
# return an enumerator if the block is not given
|
98
|
+
def each
|
99
|
+
if block_given?
|
100
|
+
pieces.each {|e| yield set(pieces: [e])}
|
101
|
+
else
|
102
|
+
Enumerator.new(self, :each)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def eval(env)
|
107
|
+
set(pieces: pieces.map{|piece| piece.eval(env)})
|
108
|
+
end
|
109
|
+
|
110
|
+
# Update pieces with the data.
|
111
|
+
def update_pieces(data)
|
112
|
+
_pieces = pieces.map do |piece|
|
113
|
+
_data = data.inject({}) do |tbl, (key, val)|
|
114
|
+
tbl.tap {|x| x[key] = val.kind_of?(Proc) ? val.call(piece) : val}
|
115
|
+
end
|
116
|
+
piece.set(_data)
|
117
|
+
end
|
118
|
+
set(pieces: _pieces)
|
119
|
+
end
|
120
|
+
|
121
|
+
# Set the annotation type to the sequence.
|
122
|
+
def set_annotation_type(type)
|
123
|
+
set(annotation_type: type)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
TypeSequence.instance_eval do
|
128
|
+
# Provides not-equal method.
|
129
|
+
define_pione_method("!=", [:receiver_type], TypeBoolean) do |env, rec, other|
|
130
|
+
rec.call_pione_method(env, "==", [other]).call_pione_method(env, "not", [])
|
131
|
+
end
|
132
|
+
|
133
|
+
# Concatenate sequences.
|
134
|
+
define_pione_method("|", [:receiver_type], :receiver_type) do |env, rec, other|
|
135
|
+
rec + other
|
136
|
+
end
|
137
|
+
|
138
|
+
# Set "each" into the distribution.
|
139
|
+
define_pione_method("each", [], :receiver_type) do |env, rec|
|
140
|
+
rec.set(distribution: :each)
|
141
|
+
end
|
142
|
+
|
143
|
+
# Return true if the distribution of sequence is "each".
|
144
|
+
define_pione_method("each?", [], TypeBoolean) do |env, rec|
|
145
|
+
BooleanSequence.of(rec.distribution == :each)
|
146
|
+
end
|
147
|
+
|
148
|
+
# Set "all" into the distribution.
|
149
|
+
define_pione_method("all", [], :receiver_type) do |env, rec|
|
150
|
+
rec.set(distribution: :all)
|
151
|
+
end
|
152
|
+
|
153
|
+
# Return true if the distribution of sequence is "all".
|
154
|
+
define_pione_method("all?", [], TypeBoolean) do |env, rec|
|
155
|
+
BooleanSequence.of(rec.distribution == :all)
|
156
|
+
end
|
157
|
+
|
158
|
+
# Return the integer sequence.
|
159
|
+
define_pione_method("i", [], TypeInteger) do |env, rec|
|
160
|
+
rec.call_pione_method(env, "as_integer", [])
|
161
|
+
end
|
162
|
+
|
163
|
+
# Return the float sequence.
|
164
|
+
define_pione_method("f", [], TypeFloat) do |env, rec|
|
165
|
+
rec.call_pione_method(env, "as_float", [])
|
166
|
+
end
|
167
|
+
|
168
|
+
# Return the string sequence.
|
169
|
+
define_pione_method("str", [], TypeString) do |env, rec|
|
170
|
+
rec.call_pione_method(env, "as_string", [])
|
171
|
+
end
|
172
|
+
|
173
|
+
# Return the data expression sequence.
|
174
|
+
define_pione_method("d", [], TypeDataExpr) do |env, rec|
|
175
|
+
rec.call_pione_method(env, "as_data_expr", [])
|
176
|
+
end
|
177
|
+
|
178
|
+
# Return length of the sequence.
|
179
|
+
define_pione_method("length", [], TypeInteger) do |env, rec|
|
180
|
+
IntegerSequence.of(rec.pieces.size)
|
181
|
+
end
|
182
|
+
|
183
|
+
# Alias of #nth.
|
184
|
+
define_pione_method("[]", [:index_type], :receiver_type) do |env, rec, index|
|
185
|
+
rec.call_pione_method(env, "nth", [index])
|
186
|
+
end
|
187
|
+
|
188
|
+
# Return boolean sequence that receiver includes the piece of target.
|
189
|
+
define_pione_method("member?", [:receiver_type], TypeBoolean) do |env, rec, target|
|
190
|
+
BooleanSequence.map(target) {|piece| rec.pieces.include?(piece)}
|
191
|
+
end
|
192
|
+
|
193
|
+
# Return true if the sequence is empty.
|
194
|
+
define_pione_method("empty?", [], TypeBoolean) do |env, rec|
|
195
|
+
BooleanSequence.of(rec.pieces.size == 0)
|
196
|
+
end
|
197
|
+
|
198
|
+
# Create a keyed sequence.
|
199
|
+
define_pione_method(":", [TypeSequence], TypeKeyedSequence) do |env, key, val|
|
200
|
+
key.pieces.map do |key_elt|
|
201
|
+
KeyedSequence.new(pieces: {key.set(pieces: [key_elt]) => val})
|
202
|
+
end.inject{|s1, s2| s1 + s2}
|
203
|
+
end
|
204
|
+
|
205
|
+
# Return PIONE string of the sequence.
|
206
|
+
define_pione_method("textize", [], TypeString) do |env, rec|
|
207
|
+
# convert pieces to strings
|
208
|
+
strings = rec.call_pione_method(env, "as_string", [])
|
209
|
+
|
210
|
+
# join it with separator
|
211
|
+
strings.call_pione_method(env, "join", [StringSequence.of(rec.separator)])
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
module Pione
|
2
|
+
module Lang
|
3
|
+
# PioneString is a string value in PIONE system.
|
4
|
+
class PioneString < SimplePiece
|
5
|
+
piece_type_name "String"
|
6
|
+
|
7
|
+
# Expand embeded expressions.
|
8
|
+
def eval(env)
|
9
|
+
set(value: Util::EmbededExprExpander.expand(env, value))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class StringSequence < OrdinalSequence
|
14
|
+
pione_type TypeString
|
15
|
+
piece_class PioneString
|
16
|
+
|
17
|
+
# Return a string that is joined pieces string.
|
18
|
+
def value
|
19
|
+
@__value__ ||= pieces.map{|piece| piece.value}.join
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
TypeString.instance_eval do
|
24
|
+
# Concatenate strings.
|
25
|
+
define_pione_method("+", [TypeString], TypeString) do |env, rec, other|
|
26
|
+
rec.map2(other) do |rec_piece, other_piece|
|
27
|
+
rec_piece.value + other_piece.value
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Return the receiver as is.
|
32
|
+
define_pione_method("as_string", [], TypeString) do |env, rec|
|
33
|
+
rec
|
34
|
+
end
|
35
|
+
|
36
|
+
# Convert to integer.
|
37
|
+
define_pione_method("as_integer", [], TypeInteger) do |env, rec|
|
38
|
+
IntegerSequence.map(rec) {|piece| piece.value.to_i}
|
39
|
+
end
|
40
|
+
|
41
|
+
# Convert to float.
|
42
|
+
define_pione_method("as_float", [], TypeFloat) do |env, rec|
|
43
|
+
FloatSequence.map(rec) {|piece| piece.value.to_f}
|
44
|
+
end
|
45
|
+
|
46
|
+
# Convert to data expression.
|
47
|
+
define_pione_method("as_data_expr", [], TypeDataExpr) do |env, rec|
|
48
|
+
DataExprSequence.map(rec) {|piece| piece.value}
|
49
|
+
end
|
50
|
+
|
51
|
+
# Count characters in the string.
|
52
|
+
define_pione_method("count", [], TypeInteger) do |env, rec|
|
53
|
+
IntegerSequence.map(rec) {|piece| piece.value.size}
|
54
|
+
end
|
55
|
+
|
56
|
+
# Return true if the string includes the target.
|
57
|
+
define_pione_method("include?", [TypeString], TypeBoolean) do |env, rec, target|
|
58
|
+
BooleanSequence.map2(rec, target) do |rec_piece, target_piece|
|
59
|
+
rec_piece.value.include?(target_piece.value)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# Return substring from the position to the length.
|
64
|
+
define_pione_method("substring", [TypeInteger, TypeInteger], TypeString) do |env, rec, nth, len|
|
65
|
+
rec.map3(nth, len) do |rec_piece, nth_piece, len_piece|
|
66
|
+
rec_piece.value[nth_piece.value-1, len_piece.value]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# insert : (pos : integer) -> (other : string) -> string
|
71
|
+
define_pione_method("insert", [TypeInteger, TypeString], TypeString) do |env, rec, pos, other|
|
72
|
+
rec.map3(pos, other) do |rec_piece, pos_piece, other_piece|
|
73
|
+
rec_piece.value.clone.insert(pos_piece.value-1, other_piece.value)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# join : string
|
78
|
+
define_pione_method("join", [], TypeString) do |env, rec|
|
79
|
+
rec.call_pione_method(env, "join", [StringSequence.of(rec.separator)])
|
80
|
+
end
|
81
|
+
|
82
|
+
# join : (sep : string) -> string
|
83
|
+
define_pione_method("join", [TypeString], TypeString) do |env, rec, sep|
|
84
|
+
rec.map_by(sep) do |sep_piece|
|
85
|
+
rec.pieces.map{|piece| piece.value}.join(sep_piece.value)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
# author : string
|
90
|
+
# FIXME
|
91
|
+
define_pione_method("author", [], TypeString) do |env, rec|
|
92
|
+
rec.set_annotation_type(:author)
|
93
|
+
end
|
94
|
+
|
95
|
+
define_pione_method("PackageName", [], TypeString) do |env, rec|
|
96
|
+
rec.set_annotation_type("PackageName")
|
97
|
+
end
|
98
|
+
|
99
|
+
define_pione_method("Editor", [], TypeString) do |env, rec|
|
100
|
+
rec.set_annotation_type("Editor")
|
101
|
+
end
|
102
|
+
|
103
|
+
define_pione_method("Tag", [], TypeString) do |env, rec|
|
104
|
+
rec.set_annotation_type("Tag")
|
105
|
+
end
|
106
|
+
|
107
|
+
define_pione_method("ScenarioName", [], TypeString) do |env, rec|
|
108
|
+
rec.set_annotation_type("ScenarioName")
|
109
|
+
end
|
110
|
+
|
111
|
+
define_pione_method("ParamSet", [], TypeString) do |env, rec|
|
112
|
+
rec.set_annotation_type("ParamSet")
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Pione
|
2
|
+
module Lang
|
3
|
+
# TicketExpr is a ticket expression as alternative input or output
|
4
|
+
# conditions of rules for serial processing.
|
5
|
+
#
|
6
|
+
# @example Serial process of rule A and B by tickets in PIONE flow rule
|
7
|
+
# Rule Main
|
8
|
+
# input '*.in'
|
9
|
+
# output '*.out'
|
10
|
+
# Flow
|
11
|
+
# rule A ==> <T>
|
12
|
+
# <T> ==> rule B
|
13
|
+
# End
|
14
|
+
class TicketExpr < Piece
|
15
|
+
piece_type_name "TicketExpr"
|
16
|
+
member :name
|
17
|
+
|
18
|
+
# Convert to text string.
|
19
|
+
def textize
|
20
|
+
"<%s>" % name
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# TicketExprSequence is a ordinal sequence of ticket expressions.
|
25
|
+
class TicketExprSequence < OrdinalSequence
|
26
|
+
pione_type TypeTicketExpr
|
27
|
+
piece_class TicketExpr
|
28
|
+
|
29
|
+
# Return ticket names of all elements in the sequence.
|
30
|
+
def names
|
31
|
+
pieces.map {|piece| piece.name}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
TypeTicketExpr.instance_eval do
|
36
|
+
# Update ticket condition of the other by adding receiver tickets
|
37
|
+
define_pione_method("==>", [TypeRuleExpr], TypeRuleExpr) do |env, rec, other|
|
38
|
+
other.map do |piece|
|
39
|
+
piece.set(input_tickets: piece.input_tickets + rec)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
define_pione_method("as_string", [], TypeString) do |env, rec|
|
44
|
+
StringSequence.map(rec) {|piece| piece.textize}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -1,34 +1,21 @@
|
|
1
1
|
module Pione
|
2
|
-
module
|
2
|
+
module Lang
|
3
3
|
# Type is a class for type expression of PIONE model objects.
|
4
|
-
class Type <
|
5
|
-
@table =
|
4
|
+
class Type < StructX
|
5
|
+
@table = Hash.new
|
6
6
|
|
7
7
|
class << self
|
8
|
-
|
9
|
-
@table = @table.put(name, value)
|
10
|
-
end
|
11
|
-
|
12
|
-
def get(name)
|
13
|
-
@table.get(name)
|
14
|
-
end
|
8
|
+
attr_reader :table
|
15
9
|
end
|
16
10
|
|
17
|
-
|
18
|
-
|
19
|
-
|
11
|
+
member :name
|
12
|
+
member :parent_type
|
13
|
+
member :pione_method, default: lambda { Hash.new }
|
20
14
|
|
21
15
|
# Create a type for PIONE model object.
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
# @param parent_type [Type]
|
26
|
-
# parent type
|
27
|
-
def initialize(name, parent_type=nil)
|
28
|
-
@name = name
|
29
|
-
@parent_type = parent_type
|
30
|
-
@pione_method = Hamster.hash
|
31
|
-
Type.put(name, self)
|
16
|
+
def initialize(*args)
|
17
|
+
super(*args)
|
18
|
+
Type.table[name] = {parent: parent_type}
|
32
19
|
end
|
33
20
|
|
34
21
|
# Return true if the type or the pione model object matches.
|
@@ -38,7 +25,7 @@ module Pione
|
|
38
25
|
# @return [Boolean]
|
39
26
|
# true if it matches, or false
|
40
27
|
def match(target)
|
41
|
-
target_type = target.
|
28
|
+
target_type = target.pione_type
|
42
29
|
while target_type do
|
43
30
|
return true if self == target_type
|
44
31
|
target_type = target_type.parent_type
|
@@ -47,42 +34,37 @@ module Pione
|
|
47
34
|
end
|
48
35
|
|
49
36
|
# Find named method.
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
name = name.to_s
|
60
|
-
if @pione_method.has_key?(name)
|
61
|
-
@pione_method[name].each do |pione_method|
|
62
|
-
if pione_method.validate_inputs(rec, *args)
|
63
|
-
return pione_method
|
37
|
+
def find_method(env, name, rec, args)
|
38
|
+
# find a suitable method
|
39
|
+
if pione_method.has_key?(name)
|
40
|
+
group = pione_method[name].group_by{|m| m.method_type}
|
41
|
+
|
42
|
+
# exist deferred methods
|
43
|
+
if group.has_key?(:deferred)
|
44
|
+
if m = group[:deferred].find {|m| m.validate_inputs(rec, args)}
|
45
|
+
return m
|
64
46
|
end
|
65
47
|
end
|
66
|
-
|
67
|
-
|
48
|
+
|
49
|
+
# try immediate methods
|
50
|
+
_args = args.map {|arg| arg.eval(env)} # FIXME : should be replaced by type inference
|
51
|
+
return group[:immediate].find {|m| m.validate_inputs(rec, _args)}
|
52
|
+
end
|
53
|
+
|
54
|
+
# find from parent type
|
55
|
+
if parent_type
|
56
|
+
return parent_type.find_method(env, name, rec, args)
|
68
57
|
end
|
69
58
|
end
|
70
59
|
|
71
|
-
# Define PIONE
|
72
|
-
#
|
73
|
-
# @param name [Symbol]
|
74
|
-
# method name
|
75
|
-
# @param inputs [Array<Type>]
|
76
|
-
# input types of the method
|
77
|
-
# @param output [Type]
|
78
|
-
# output type of the method
|
79
|
-
# @param [Proc] b
|
80
|
-
# @return [void]
|
60
|
+
# Define PIONE methods. Arguments are evaluated immediately.
|
81
61
|
def define_pione_method(name, inputs, output, &b)
|
82
|
-
name
|
83
|
-
|
84
|
-
|
85
|
-
|
62
|
+
(pione_method[name] ||= []) << PioneMethod.new(:immediate, name, inputs, output, b)
|
63
|
+
end
|
64
|
+
|
65
|
+
# Define PIONE methods. Arguments are non-evaluated.
|
66
|
+
def define_deferred_pione_method(name, inputs, output, &b)
|
67
|
+
(pione_method[name] ||= []) << PioneMethod.new(:deferred, name, inputs, output, b)
|
86
68
|
end
|
87
69
|
|
88
70
|
# Return true if the data has the type.
|
@@ -90,85 +72,70 @@ module Pione
|
|
90
72
|
# @return [void]
|
91
73
|
def check(data)
|
92
74
|
unless match(data)
|
93
|
-
raise
|
75
|
+
raise PioneTypeError.new(data, self)
|
94
76
|
end
|
95
77
|
end
|
96
78
|
|
97
|
-
def
|
98
|
-
|
99
|
-
when TypeString
|
100
|
-
StringSequence
|
101
|
-
when TypeInteger
|
102
|
-
IntegerSequence
|
103
|
-
when TypeFloat
|
104
|
-
FloatSequence
|
105
|
-
when TypeBoolean
|
106
|
-
BooleanSequence
|
107
|
-
when TypeDataExpr
|
108
|
-
DataExprSequence
|
109
|
-
when TypeTicketExpr
|
110
|
-
TicketExprSequence
|
111
|
-
end
|
79
|
+
def sequence_class
|
80
|
+
Type.table[self.name][:sequence_class]
|
112
81
|
end
|
113
82
|
|
114
83
|
def map1(seq, &b)
|
115
|
-
|
116
|
-
seq_class.new(seq.elements.map{|elt| b.call(elt)}, seq.attribute)
|
84
|
+
sequence_class.of(seq.pieces.map{|elt| b.call(elt)}, seq.attribute)
|
117
85
|
end
|
118
86
|
|
119
87
|
def map2(seq1, seq2, &b)
|
120
|
-
|
121
|
-
|
122
|
-
seq2.elements.map do |elt2|
|
88
|
+
seq1.pieces.map do |elt1|
|
89
|
+
seq2.pieces.map do |elt2|
|
123
90
|
b.call(elt1, elt2)
|
124
91
|
end
|
125
|
-
end.flatten.tap {|x| break
|
92
|
+
end.flatten.tap {|x| break sequence_class.new(x, seq1.attribute)}
|
126
93
|
end
|
127
94
|
|
128
95
|
def sequential_map1(type, seq1, &b)
|
129
96
|
seq_class = type_to_class(type)
|
130
|
-
seq1.
|
131
|
-
seq_class.
|
97
|
+
seq1.pieces.map do |elt1|
|
98
|
+
seq_class.piece_class.new(b.call(elt1))
|
132
99
|
end.tap {|x| break seq_class.new(x, seq1.attribute)}
|
133
100
|
end
|
134
101
|
|
135
102
|
def sequential_map2(type, seq1, seq2, &b)
|
136
103
|
seq_class = type_to_class(type)
|
137
|
-
seq1.
|
138
|
-
seq2.
|
139
|
-
seq_class.
|
104
|
+
seq1.pieces.map do |elt1|
|
105
|
+
seq2.pieces.map do |elt2|
|
106
|
+
seq_class.piece_class.new(b.call(elt1, elt2))
|
140
107
|
end
|
141
|
-
end.flatten.tap {|x| break
|
108
|
+
end.flatten.tap {|x| break seq1.set(x, seq1.attribute)}
|
142
109
|
end
|
143
110
|
|
144
111
|
def sequential_map3(type, seq1, seq2, seq3, &b)
|
145
112
|
seq_class = type_to_class(type)
|
146
|
-
seq1.
|
147
|
-
seq2.
|
148
|
-
seq3.
|
149
|
-
seq_class.
|
113
|
+
seq1.pieces.map do |elt1|
|
114
|
+
seq2.pieces.map do |elt2|
|
115
|
+
seq3.pieces.map do |elt3|
|
116
|
+
seq_class.piece_class.new(b.call(elt1, elt2, elt3))
|
150
117
|
end
|
151
118
|
end
|
152
119
|
end.flatten.tap {|x| break seq_class.new(x, seq1.attribute)}
|
153
120
|
end
|
154
121
|
|
155
122
|
def fold1(val, seq1, &b)
|
156
|
-
seq1.
|
123
|
+
seq1.pieces.inject(val) do |obj, elt1|
|
157
124
|
b.call(obj, elt1)
|
158
125
|
end
|
159
126
|
end
|
160
127
|
|
161
128
|
def sequential_fold1(type, seq1, &b)
|
162
129
|
seq_class = type_to_class(type)
|
163
|
-
seq1.
|
130
|
+
seq1.pieces.inject(seq_class.new([], seq1.attribute)) do |obj, elt1|
|
164
131
|
b.call(elt1, obj)
|
165
132
|
end
|
166
133
|
end
|
167
134
|
|
168
135
|
def sequential_fold2(type, seq1, seq2, &b)
|
169
136
|
seq_class = type_to_class(type)
|
170
|
-
seq1.
|
171
|
-
seq2.
|
137
|
+
seq1.pieces.inject(seq_class.new([], seq1.attribute)) do |obj1, elt1|
|
138
|
+
seq2.pieces.inject(obj1) do |obj2, elt2|
|
172
139
|
b.call(obj2, elt1, elt2)
|
173
140
|
end
|
174
141
|
end
|
@@ -176,7 +143,7 @@ module Pione
|
|
176
143
|
|
177
144
|
def sequential_pred1(seq1, &b)
|
178
145
|
method1 = seq1.every? ? :all? : :any?
|
179
|
-
seq1.
|
146
|
+
seq1.pieces.send(method1) do |elt1|
|
180
147
|
PioneBoolean.new(b.call(elt1))
|
181
148
|
end.tap {|x| break BooleanSequence.new(x)}
|
182
149
|
end
|
@@ -184,18 +151,25 @@ module Pione
|
|
184
151
|
def sequential_pred2(seq1, seq2, &b)
|
185
152
|
method1 = seq1.every? ? :all? : :any?
|
186
153
|
method2 = seq2.every? ? :all? : :any?
|
187
|
-
seq1.
|
188
|
-
seq2.
|
154
|
+
seq1.pieces.send(method1) do |elt1|
|
155
|
+
seq2.pieces.send(method2) do |elt2|
|
189
156
|
b.call(elt1, elt2)
|
190
157
|
end
|
191
158
|
end.tap {|x| break BooleanSequence.new([PioneBoolean.new(x)])}
|
192
159
|
end
|
193
160
|
|
194
161
|
def to_s
|
195
|
-
"#<Type %s>" %
|
162
|
+
"#<Type %s>" % name
|
163
|
+
end
|
164
|
+
|
165
|
+
def inspect
|
166
|
+
"#<Type %s>" % name
|
196
167
|
end
|
197
168
|
end
|
198
169
|
|
170
|
+
# TypeVariable is a type for variable names.
|
171
|
+
TypeVariable = Type.new("variable")
|
172
|
+
|
199
173
|
# TypeSequence is a type for sequence of something.
|
200
174
|
TypeSequence = Type.new("sequence")
|
201
175
|
|
@@ -226,15 +200,12 @@ module Pione
|
|
226
200
|
# rule expression type for PIONE system
|
227
201
|
TypeRuleExpr = Type.new("rule-expr", TypeOrdinalSequence)
|
228
202
|
|
229
|
-
#
|
230
|
-
|
203
|
+
# parameter set type for PIONE system
|
204
|
+
TypeParameterSet = Type.new("parameter-set", TypeOrdinalSequence)
|
231
205
|
|
232
206
|
# assignment type for PIONE system
|
233
207
|
TypeAssignment = Type.new("assignment", TypeOrdinalSequence)
|
234
208
|
|
235
|
-
# variable table type for PIONE system
|
236
|
-
TypeVariableTable = Type.new("variable-table", TypeOrdinalSequence)
|
237
|
-
|
238
209
|
# package type for PIONE system
|
239
210
|
TypePackageExpr = Type.new("package-expr", TypeOrdinalSequence)
|
240
211
|
|