pione 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.s3cfg +42 -0
- data/.travis.yml +18 -4
- data/.yardopts +1 -0
- data/Gemfile +3 -0
- data/History.txt +14 -0
- data/Procfile +7 -0
- data/Rakefile +25 -0
- data/bin/pione-interactive +6 -0
- data/bin/{pione-compiler → pione-notification-listener} +1 -1
- data/bin/{pione-broker → pione-task-worker-broker} +1 -1
- data/doc/man/pione-list-param.md +36 -0
- data/example/ActionError/ActionError.pione +9 -0
- data/example/ActionError/pione-package.json +15 -0
- data/example/CountChar/CountChar.pione +1 -1
- data/example/ScoreAggregation/ScoreAggregation.pione +1 -1
- data/example/Touch/pione-package.json +15 -0
- data/lib/pione.rb +12 -0
- data/lib/pione/agent.rb +3 -3
- data/lib/pione/agent/basic-agent.rb +10 -4
- data/lib/pione/agent/input-generator.rb +3 -3
- data/lib/pione/agent/{process-manager.rb → job-manager.rb} +10 -7
- data/lib/pione/agent/job-terminator.rb +2 -2
- data/lib/pione/agent/logger.rb +3 -3
- data/lib/pione/agent/messenger.rb +20 -9
- data/lib/pione/agent/notification-listener.rb +88 -0
- data/lib/pione/agent/task-worker-broker.rb +84 -0
- data/lib/pione/agent/task-worker.rb +3 -2
- data/lib/pione/agent/tuple-space-client.rb +1 -0
- data/lib/pione/agent/tuple-space-provider.rb +17 -35
- data/lib/pione/command.rb +33 -15
- data/lib/pione/command/action.rb +105 -0
- data/lib/pione/command/basic-command.rb +34 -376
- data/lib/pione/command/command-exception.rb +12 -11
- data/lib/pione/command/common.rb +198 -0
- data/lib/pione/command/option.rb +159 -204
- data/lib/pione/command/pione-action-exec.rb +85 -0
- data/lib/pione/command/pione-action-list.rb +43 -19
- data/lib/pione/command/pione-action-print.rb +79 -0
- data/lib/pione/command/pione-action.rb +8 -67
- data/lib/pione/command/pione-clean.rb +88 -68
- data/lib/pione/command/pione-client.rb +475 -332
- data/lib/pione/command/pione-command.rb +14 -31
- data/lib/pione/command/pione-compile.rb +90 -0
- data/lib/pione/command/pione-config-get.rb +53 -0
- data/lib/pione/command/pione-config-list.rb +64 -0
- data/lib/pione/command/pione-config-set.rb +59 -0
- data/lib/pione/command/pione-config-unset.rb +50 -0
- data/lib/pione/command/pione-config.rb +61 -0
- data/lib/pione/command/pione-diagnosis-notification.rb +235 -0
- data/lib/pione/command/pione-diagnosis.rb +21 -0
- data/lib/pione/command/pione-interactive.rb +188 -0
- data/lib/pione/command/pione-lang-check-syntax.rb +163 -0
- data/lib/pione/command/pione-lang-interactive.rb +146 -0
- data/lib/pione/command/pione-lang.rb +22 -0
- data/lib/pione/command/pione-log-format.rb +163 -0
- data/lib/pione/command/pione-log-list-id.rb +48 -0
- data/lib/pione/command/pione-log.rb +19 -101
- data/lib/pione/command/pione-notification-listener.rb +95 -0
- data/lib/pione/command/pione-package-add.rb +137 -0
- data/lib/pione/command/pione-package-build.rb +122 -0
- data/lib/pione/command/pione-package-show.rb +96 -0
- data/lib/pione/command/pione-package-update.rb +59 -0
- data/lib/pione/command/pione-package.rb +11 -139
- data/lib/pione/command/pione-task-worker-broker.rb +88 -0
- data/lib/pione/command/pione-task-worker.rb +148 -98
- data/lib/pione/command/pione-tuple-space-provider.rb +62 -54
- data/lib/pione/command/pione-tuple-space-viewer.rb +105 -83
- data/lib/pione/command/pione-val.rb +39 -39
- data/lib/pione/command/spawner.rb +34 -27
- data/lib/pione/front.rb +4 -2
- data/lib/pione/front/basic-front.rb +86 -23
- data/lib/pione/front/client-front.rb +2 -2
- data/lib/pione/front/diagnosis-notification-front.rb +40 -0
- data/lib/pione/front/front-exception.rb +7 -1
- data/lib/pione/front/notification-listener-front.rb +36 -0
- data/lib/pione/front/notification-recipient-interface.rb +19 -0
- data/lib/pione/front/relay-front.rb +4 -4
- data/lib/pione/front/task-worker-broker-front.rb +19 -0
- data/lib/pione/front/task-worker-front.rb +2 -2
- data/lib/pione/front/tuple-space-provider-front.rb +3 -2
- data/lib/pione/global.rb +3 -1
- data/lib/pione/global/client-variable.rb +1 -1
- data/lib/pione/global/config.rb +63 -7
- data/lib/pione/global/diagnosis-variable.rb +26 -0
- data/lib/pione/global/item.rb +28 -5
- data/lib/pione/global/log-variable.rb +6 -5
- data/lib/pione/global/network-variable.rb +75 -4
- data/lib/pione/global/path-variable.rb +1 -1
- data/lib/pione/global/system-variable.rb +12 -12
- data/lib/pione/global/task-worker-broker-variable.rb +43 -0
- data/lib/pione/global/tuple-space-notifier-variable.rb +3 -55
- data/lib/pione/lang/boolean.rb +4 -0
- data/lib/pione/lang/data-expr.rb +1 -1
- data/lib/pione/lang/integer.rb +1 -1
- data/lib/pione/lang/string.rb +4 -0
- data/lib/pione/lang/type.rb +1 -1
- data/lib/pione/location.rb +1 -0
- data/lib/pione/location/data-location.rb +41 -13
- data/lib/pione/location/dropbox-location.rb +175 -56
- data/lib/pione/location/ftp-location.rb +4 -1
- data/lib/pione/location/http-location.rb +5 -3
- data/lib/pione/location/https-location.rb +4 -2
- data/lib/pione/location/local-location.rb +6 -3
- data/lib/pione/location/location-exception.rb +12 -0
- data/lib/pione/location/notification-scheme.rb +46 -0
- data/lib/pione/log.rb +8 -7
- data/lib/pione/log/debug.rb +9 -9
- data/lib/pione/log/domain-log.rb +6 -1
- data/lib/pione/log/message-log-receiver.rb +32 -0
- data/lib/pione/log/system-log.rb +62 -141
- data/lib/pione/model.rb +7 -0
- data/lib/pione/model/notification-listener-model.rb +29 -0
- data/lib/pione/model/task-worker-broker-model.rb +129 -0
- data/lib/pione/notification.rb +13 -0
- data/lib/pione/notification/address.rb +104 -0
- data/lib/pione/notification/exception.rb +10 -0
- data/lib/pione/notification/message.rb +109 -0
- data/lib/pione/notification/receiver.rb +90 -0
- data/lib/pione/notification/recipient.rb +68 -0
- data/lib/pione/notification/task-worker-broker-recipient.rb +85 -0
- data/lib/pione/notification/transmitter.rb +84 -0
- data/lib/pione/pnml.rb +35 -0
- data/lib/pione/pnml/annotation-extractor.rb +47 -0
- data/lib/pione/pnml/compiler.rb +176 -0
- data/lib/pione/pnml/input-merge-complement.rb +78 -0
- data/lib/pione/pnml/input-parallelization-complement.rb +75 -0
- data/lib/pione/pnml/input-reduction.rb +80 -0
- data/lib/pione/pnml/invalid-arc-elimination.rb +41 -0
- data/lib/pione/pnml/io-expansion.rb +88 -0
- data/lib/pione/pnml/isolated-element-elimination.rb +32 -0
- data/lib/pione/pnml/net-rewriter.rb +44 -0
- data/lib/pione/pnml/output-decomposition-complement.rb +77 -0
- data/lib/pione/pnml/output-reduction.rb +86 -0
- data/lib/pione/pnml/output-synchronization-complement.rb +77 -0
- data/lib/pione/pnml/pione-model.rb +417 -0
- data/lib/pione/pnml/pnml-exception.rb +23 -0
- data/lib/pione/pnml/pnml-model.rb +368 -0
- data/lib/pione/pnml/reader.rb +51 -0
- data/lib/pione/rule-engine/action-handler.rb +8 -6
- data/lib/pione/rule-engine/basic-handler.rb +5 -5
- data/lib/pione/rule-engine/engine-exception.rb +7 -6
- data/lib/pione/rule-engine/flow-handler.rb +27 -18
- data/lib/pione/system.rb +3 -1
- data/lib/pione/system/domain-dump.rb +34 -0
- data/lib/pione/system/file-cache.rb +92 -13
- data/lib/pione/system/init.rb +3 -0
- data/lib/pione/system/normalizer.rb +40 -0
- data/lib/pione/system/status.rb +5 -5
- data/lib/pione/system/system-exception.rb +14 -1
- data/lib/pione/task-worker-broker.rb +7 -0
- data/lib/pione/task-worker-broker/basic-provider.rb +20 -0
- data/lib/pione/task-worker-broker/easy-provider.rb +65 -0
- data/lib/pione/test-helper.rb +27 -0
- data/lib/pione/test-helper/command-helper.rb +9 -101
- data/lib/pione/tuple-space/basic-tuple.rb +1 -1
- data/lib/pione/tuple-space/tuple-definition.yml +4 -6
- data/lib/pione/tuple-space/tuple-space-interface.rb +3 -45
- data/lib/pione/tuple-space/tuple-space-server.rb +45 -0
- data/lib/pione/util.rb +1 -2
- data/lib/pione/util/boolean-value.rb +62 -0
- data/lib/pione/util/completion.rb +111 -0
- data/lib/pione/util/evaluatable.rb +13 -27
- data/lib/pione/util/package-parameters-list.rb +15 -27
- data/lib/pione/util/zip.rb +8 -3
- data/lib/pione/version.rb +1 -1
- data/lib/rootage.rb +20 -0
- data/lib/rootage/action.rb +114 -0
- data/lib/rootage/argument.rb +46 -0
- data/lib/rootage/command.rb +218 -0
- data/lib/rootage/core.rb +532 -0
- data/lib/rootage/exception.rb +107 -0
- data/lib/rootage/help.rb +148 -0
- data/lib/rootage/help.txt.erb +31 -0
- data/lib/rootage/log.rb +226 -0
- data/lib/rootage/normalizer.rb +184 -0
- data/lib/rootage/option.rb +152 -0
- data/lib/rootage/scenario-test-result.erb +39 -0
- data/lib/rootage/scenario.rb +362 -0
- data/lib/rootage/test-helper.rb +115 -0
- data/man/pione-list-param.1 +44 -0
- data/misc/clock.rb +9 -0
- data/misc/machine-info.sh +21 -0
- data/misc/pione-completion.bash +238 -0
- data/misc/pione-completion.erb +53 -0
- data/misc/pione-completion.zsh +238 -0
- data/misc/pione.god +22 -0
- data/misc/ui.xml +23 -0
- data/pione.gemspec +3 -1
- data/test/agent/spec_basic-agent.rb +1 -1
- data/test/agent/spec_input-generator.rb +2 -2
- data/test/agent/spec_messenger.rb +6 -9
- data/test/agent/spec_notification-listener.rb +80 -0
- data/test/agent/{spec_broker.rb → spec_task-worker-broker.rb} +13 -10
- data/test/agent/spec_tuple-space-provider.rb +10 -6
- data/test/command/command-behavior.rb +3 -11
- data/test/command/data/pione-list-param/AdvancedParameters.pione +12 -0
- data/test/command/data/pione-list-param/BasicParameters.pione +12 -0
- data/test/command/spec_pione-action-exec.rb +16 -0
- data/test/command/spec_pione-action-list.rb +15 -10
- data/test/command/spec_pione-action-print.rb +14 -0
- data/test/command/spec_pione-action.rb +6 -19
- data/test/command/spec_pione-clean.rb +29 -46
- data/test/command/spec_pione-client.rb +29 -36
- data/test/command/spec_pione-command.rb +6 -6
- data/test/command/{spec_pione-compiler.rb → spec_pione-compile.rb} +11 -13
- data/test/command/spec_pione-config-get.rb +47 -0
- data/test/command/spec_pione-config-list.rb +42 -0
- data/test/command/spec_pione-config-set.rb +38 -0
- data/test/command/spec_pione-config-unset.rb +44 -0
- data/test/command/spec_pione-config.rb +11 -0
- data/test/command/spec_pione-diagnosis-notification.rb +23 -0
- data/test/command/spec_pione-diagnosis.rb +11 -0
- data/test/command/spec_pione-lang-check-syntax.rb +12 -0
- data/test/command/spec_pione-lang.rb +11 -0
- data/test/command/spec_pione-log-format.rb +29 -0
- data/test/command/spec_pione-log-list-id.rb +17 -0
- data/test/command/spec_pione-log.rb +6 -20
- data/test/command/spec_pione-package-add.rb +55 -0
- data/test/command/spec_pione-package-build.rb +57 -0
- data/test/command/spec_pione-package-show.rb +72 -0
- data/test/command/{spec_pione-update-package-info.rb → spec_pione-package-update.rb} +12 -13
- data/test/command/spec_pione-package.rb +4 -104
- data/test/command/spec_pione-val.rb +10 -7
- data/test/global/spec_config.rb +50 -0
- data/test/global/spec_item.rb +1 -1
- data/test/literate-action/data/HelloWorld.md +1 -1
- data/test/location/location-behavior.rb +1 -1
- data/test/location/spec_dropbox-location.rb +39 -0
- data/test/location/spec_notification-scheme.rb +37 -0
- data/test/log/spec_debug.rb +5 -4
- data/test/log/spec_message-log-receiver.rb +13 -0
- data/test/log/spec_message-log.rb +6 -9
- data/test/log/spec_system-log.rb +5 -3
- data/test/notification/spec_address.rb +229 -0
- data/test/notification/spec_message.rb +30 -0
- data/test/notification/spec_receiver.rb +36 -0
- data/test/notification/spec_transmitter.rb +37 -0
- data/test/pnml/data/ConditionalBranchIf.pnml +270 -0
- data/test/pnml/data/ConditionalBranchIfElse.pnml +309 -0
- data/test/pnml/data/IOExpansionComplex.pnml +363 -0
- data/test/pnml/data/IOExpansionSimple.pnml +140 -0
- data/test/pnml/data/InputMergeComplementComplex.pnml +381 -0
- data/test/pnml/data/InputMergeComplementSimple.pnml +248 -0
- data/test/pnml/data/InputParallelizationComplementComplex.pnml +433 -0
- data/test/pnml/data/InputParallelizationComplementSimple.pnml +288 -0
- data/test/pnml/data/InputReductionComplex.pnml +192 -0
- data/test/pnml/data/InputReductionLong.pnml +344 -0
- data/test/pnml/data/InputReductionSimple.pnml +140 -0
- data/test/pnml/data/IsolatedElementElimination.pnml +171 -0
- data/test/pnml/data/OutputDecompositionComplementComplex.pnml +381 -0
- data/test/pnml/data/OutputDecompositionComplementSimple.pnml +242 -0
- data/test/pnml/data/OutputReductionComplex.pnml +186 -0
- data/test/pnml/data/OutputReductionLong.pnml +344 -0
- data/test/pnml/data/OutputReductionSimple.pnml +140 -0
- data/test/pnml/data/OutputSynchronizationComplementComplex.pnml +498 -0
- data/test/pnml/data/OutputSynchronizationComplementSimple.pnml +347 -0
- data/test/pnml/data/SampleNet.pnml +238 -0
- data/test/pnml/spec_input-merge-complement.rb +40 -0
- data/test/pnml/spec_input-parallelization-complement.rb +50 -0
- data/test/pnml/spec_input-reduction.rb +113 -0
- data/test/pnml/spec_invalid-arc-elimination.rb +33 -0
- data/test/pnml/spec_io-expansion.rb +126 -0
- data/test/pnml/spec_isolated-element-elimination.rb +25 -0
- data/test/pnml/spec_output-decomposition-complement.rb +40 -0
- data/test/pnml/spec_output-reduction.rb +114 -0
- data/test/pnml/spec_output-synchronization-complement.rb +62 -0
- data/test/pnml/spec_pione-element.rb +144 -0
- data/test/pnml/spec_pnml-element.rb +373 -0
- data/test/pnml/spec_reader.rb +16 -0
- data/test/rootage/spec_argument.rb +18 -0
- data/test/rootage/spec_command.rb +239 -0
- data/test/rootage/spec_core.rb +198 -0
- data/test/rootage/spec_scenario.rb +149 -0
- data/test/system/{spec_domain-info.rb → spec_domain-dump.rb} +6 -6
- data/test/system/spec_file-cache.rb +6 -9
- data/test/tuple-space/spec_finished-tuple.rb +1 -1
- data/test/util/{spec_package-parameters-list_1.pione → data/package-parameters-list/Param1.pione} +0 -0
- data/test/util/{spec_package-parameters-list_2.pione → data/package-parameters-list/Param2.pione} +0 -0
- data/test/util/{spec_package-parameters-list_3.pione → data/package-parameters-list/Param3.pione} +0 -0
- data/test/util/{spec_package-parameters-list_4.pione → data/package-parameters-list/Param4.pione} +0 -0
- data/test/util/spec_boolean-value.rb +32 -0
- data/test/util/spec_completion.rb +22 -0
- data/test/util/spec_package-parameters-list.rb +39 -52
- data/test/util/spec_zip.rb +28 -1
- metadata +288 -47
- data/bin/pione-tuple-space-receiver +0 -5
- data/lib/pione/agent/broker.rb +0 -304
- data/lib/pione/agent/tuple-space-receiver.rb +0 -137
- data/lib/pione/command/pione-broker.rb +0 -104
- data/lib/pione/command/pione-compiler.rb +0 -57
- data/lib/pione/command/pione-relay-account-db.rb +0 -141
- data/lib/pione/command/pione-relay-client-db.rb +0 -118
- data/lib/pione/command/pione-relay.rb +0 -59
- data/lib/pione/command/pione-syntax-checker.rb +0 -214
- data/lib/pione/command/pione-tuple-space-receiver.rb +0 -111
- data/lib/pione/command/pione-update-package-info.rb +0 -53
- data/lib/pione/front/broker-front.rb +0 -22
- data/lib/pione/front/tuple-space-receiver-front.rb +0 -11
- data/lib/pione/global/broker-variable.rb +0 -33
- data/lib/pione/system/domain-info.rb +0 -25
- data/lib/pione/util/pnml-compiler.rb +0 -168
- data/test/agent/spec_tuple-space-receiver.rb +0 -47
- data/test/util/spec_pnml-compiler.rb +0 -32
@@ -0,0 +1,137 @@
|
|
1
|
+
module Pione
|
2
|
+
module Command
|
3
|
+
# `PionePackageAdd` is a subcommand that adds PIONE package to package
|
4
|
+
# database in your system.
|
5
|
+
class PionePackageAdd < BasicCommand
|
6
|
+
#
|
7
|
+
# informations
|
8
|
+
#
|
9
|
+
|
10
|
+
define(:name, "add")
|
11
|
+
define(:desc, "Add the package to package database")
|
12
|
+
|
13
|
+
#
|
14
|
+
# arguments
|
15
|
+
#
|
16
|
+
|
17
|
+
argument(:target) do |item|
|
18
|
+
item.type = :location
|
19
|
+
item.desc = "the package to add in package database"
|
20
|
+
item.missing = "There are no PIONE documents or packages."
|
21
|
+
end
|
22
|
+
|
23
|
+
#
|
24
|
+
# options
|
25
|
+
#
|
26
|
+
|
27
|
+
option(:tag) do |item|
|
28
|
+
item.type = :string
|
29
|
+
item.long = "--tag"
|
30
|
+
item.arg = "NAME"
|
31
|
+
item.desc = "Specify tag name"
|
32
|
+
end
|
33
|
+
|
34
|
+
#
|
35
|
+
# command lifecycle: setup phase
|
36
|
+
#
|
37
|
+
|
38
|
+
phase(:setup) do |seq|
|
39
|
+
seq << :handler
|
40
|
+
seq << :db
|
41
|
+
end
|
42
|
+
|
43
|
+
setup(:handler) do |item|
|
44
|
+
item.desc = "Create a package handler and get informations"
|
45
|
+
|
46
|
+
# create a package handler
|
47
|
+
item.assign(:handler) do
|
48
|
+
Package::PackageReader.read(model[:target])
|
49
|
+
end
|
50
|
+
|
51
|
+
# get package name
|
52
|
+
item.assign(:name) do
|
53
|
+
model[:handler].info.name
|
54
|
+
end
|
55
|
+
|
56
|
+
# get package editor
|
57
|
+
item.assign(:editor) do
|
58
|
+
model[:handler].info.editor
|
59
|
+
end
|
60
|
+
|
61
|
+
# get package tag
|
62
|
+
item.assign(:tag) do
|
63
|
+
test(not(model[:tag]))
|
64
|
+
model[:handler].info.tag
|
65
|
+
end
|
66
|
+
|
67
|
+
# get package digest
|
68
|
+
item.assign(:digest) do
|
69
|
+
model[:handler].digest
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
setup(:db) do |item|
|
74
|
+
item.desc = "Setup package database"
|
75
|
+
|
76
|
+
item.assign(:db) do
|
77
|
+
Package::Database.load
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
#
|
82
|
+
# command lifecycle: execution phase
|
83
|
+
#
|
84
|
+
|
85
|
+
phase(:execution) do |seq|
|
86
|
+
seq << :add_package
|
87
|
+
seq << :show
|
88
|
+
end
|
89
|
+
|
90
|
+
execution(:add_package) do |item|
|
91
|
+
item.desc = "Add the package to package database"
|
92
|
+
|
93
|
+
item.process do
|
94
|
+
model[:db].add(
|
95
|
+
name: model[:name],
|
96
|
+
editor: model[:editor],
|
97
|
+
tag: model[:tag],
|
98
|
+
digest: model[:digest]
|
99
|
+
)
|
100
|
+
model[:db].save
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
execution(:show) do |item|
|
105
|
+
item.desc = "Show the result"
|
106
|
+
|
107
|
+
item.assign(:additions) do
|
108
|
+
Array.new
|
109
|
+
end
|
110
|
+
|
111
|
+
item.process do
|
112
|
+
test(model[:editor])
|
113
|
+
model[:additions] << "editor: %s" % model[:editor]
|
114
|
+
end
|
115
|
+
|
116
|
+
item.process do
|
117
|
+
test(model[:tag])
|
118
|
+
model[:additions] << "tag: %s" % model[:tag]
|
119
|
+
end
|
120
|
+
|
121
|
+
item.assign(:info) do
|
122
|
+
model[:additions].size > 0 ? "(" + model[:additions].join(", ") + ")" : ""
|
123
|
+
end
|
124
|
+
|
125
|
+
# show log
|
126
|
+
item.process do
|
127
|
+
arg = {name: model[:name], info: model[:info]}
|
128
|
+
Log::SystemLog.info(
|
129
|
+
'Package "%{name}"%{info} was added to package database' % arg
|
130
|
+
)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
PionePackage.define_subcommand("add", PionePackageAdd)
|
136
|
+
end
|
137
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
module Pione
|
2
|
+
module Command
|
3
|
+
# `PionePackageBuild` is a subcommand that builds PIONE archive package.
|
4
|
+
class PionePackageBuild < BasicCommand
|
5
|
+
#
|
6
|
+
# informations
|
7
|
+
#
|
8
|
+
|
9
|
+
define(:name, "build")
|
10
|
+
define(:desc, "Build PIONE archive package")
|
11
|
+
|
12
|
+
#
|
13
|
+
# arguments
|
14
|
+
#
|
15
|
+
|
16
|
+
argument(:source) do |item|
|
17
|
+
item.type = :location
|
18
|
+
item.desc = "the source package location"
|
19
|
+
item.missing = "There are no PIONE documents or packages."
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
# options
|
24
|
+
#
|
25
|
+
|
26
|
+
option CommonOption.color
|
27
|
+
option CommonOption.debug
|
28
|
+
|
29
|
+
option(:output) do |item|
|
30
|
+
item.type = :location
|
31
|
+
item.short = "-o"
|
32
|
+
item.long = "--output"
|
33
|
+
item.arg = "LOCATION"
|
34
|
+
item.desc = "Output file or directory location"
|
35
|
+
item.init = "./"
|
36
|
+
end
|
37
|
+
|
38
|
+
option(:tag) do |item|
|
39
|
+
item.type = :string
|
40
|
+
item.long = "--tag"
|
41
|
+
item.arg = "NAME"
|
42
|
+
item.desc = "Specify tag name"
|
43
|
+
end
|
44
|
+
|
45
|
+
option(:hash_id) do |item|
|
46
|
+
item.type = :string
|
47
|
+
item.long = "--hash-id"
|
48
|
+
item.arg = "HASH"
|
49
|
+
item.desc = "Specify git hash ID"
|
50
|
+
end
|
51
|
+
|
52
|
+
option_post(:check_output_directory) do |item|
|
53
|
+
item.desc = "Check output location is directory"
|
54
|
+
|
55
|
+
item.process do
|
56
|
+
test(not(model[:output].directory?))
|
57
|
+
cmd.abort("Output location should be a directory: %s" % model[:output])
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
#
|
62
|
+
# command lifecycle: setup phase
|
63
|
+
#
|
64
|
+
|
65
|
+
phase(:setup) do |seq|
|
66
|
+
seq << :source_locations
|
67
|
+
end
|
68
|
+
|
69
|
+
setup(:source_locations) do |item|
|
70
|
+
item.desc = "Setup source locations"
|
71
|
+
|
72
|
+
item.assign(:source_locations) do
|
73
|
+
source = model[:source].address
|
74
|
+
[Location[git: source], Location[data: source]]
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
#
|
79
|
+
# command lifecycle: execution phase
|
80
|
+
#
|
81
|
+
|
82
|
+
phase(:execution) do |seq|
|
83
|
+
seq << :build_package
|
84
|
+
end
|
85
|
+
|
86
|
+
execution(:build_package) do |item|
|
87
|
+
item.desc = "Build a PPG package"
|
88
|
+
|
89
|
+
item.process do
|
90
|
+
model[:source_locations].each do |location|
|
91
|
+
if ppg = try_to_archive(location)
|
92
|
+
Log::SystemLog.info("Package build suceeded: %s" % ppg.address)
|
93
|
+
cmd.terminate
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
cmd.abort("Package build has failed to archive.")
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
# `PionePackageBuildContext` is a context for `pione package build`.
|
103
|
+
class PionePackageBuildContext < Rootage::CommandContext
|
104
|
+
def try_to_archive(location)
|
105
|
+
handler = Package::PackageReader.read(location)
|
106
|
+
cache_location = Package::PackageCache.directory_cache(handler.digest)
|
107
|
+
|
108
|
+
# make archiver
|
109
|
+
archiver = Package::PackageArchiver.new(cache_location)
|
110
|
+
|
111
|
+
# archive
|
112
|
+
return archiver.archive(model[:output], false)
|
113
|
+
rescue => e
|
114
|
+
Log::Debug.system("PIONE failed to archive %s: %s" % [location, e.message])
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
PionePackageBuild.define(:process_context_class, PionePackageBuildContext)
|
119
|
+
|
120
|
+
PionePackage.define_subcommand("build", PionePackageBuild)
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
module Pione
|
2
|
+
module Command
|
3
|
+
class PionePackageShow < BasicCommand
|
4
|
+
#
|
5
|
+
# informations
|
6
|
+
#
|
7
|
+
|
8
|
+
define(:name, "show")
|
9
|
+
define(:desc, "Show the package informations")
|
10
|
+
|
11
|
+
#
|
12
|
+
# arguments
|
13
|
+
#
|
14
|
+
|
15
|
+
argument(:location) do |item|
|
16
|
+
item.type = :location
|
17
|
+
item.desc = "the package location that you want to show"
|
18
|
+
item.missing = "There are no PIONE documents or packages."
|
19
|
+
end
|
20
|
+
|
21
|
+
#
|
22
|
+
# options
|
23
|
+
#
|
24
|
+
|
25
|
+
option CommonOption.color
|
26
|
+
option CommonOption.debug
|
27
|
+
|
28
|
+
option(:advanced) do |item|
|
29
|
+
item.type = :boolean
|
30
|
+
item.short = "-a"
|
31
|
+
item.long = "--advanced"
|
32
|
+
item.desc = "show advanced parameters"
|
33
|
+
end
|
34
|
+
|
35
|
+
#
|
36
|
+
# command lifecycle: execution phase
|
37
|
+
#
|
38
|
+
|
39
|
+
phase(:execution) do |seq|
|
40
|
+
seq << :print_list
|
41
|
+
end
|
42
|
+
|
43
|
+
execution(:print_list) do |item|
|
44
|
+
item.desc = "Print a list of parameters in the document"
|
45
|
+
|
46
|
+
item.process do
|
47
|
+
# read package
|
48
|
+
package_handler = Package::PackageReader.read(model[:location])
|
49
|
+
env = package_handler.eval(Lang::Environment.new)
|
50
|
+
|
51
|
+
# print a list
|
52
|
+
basic, advanced = Util::PackageParametersList.find(env, env.current_package_id)
|
53
|
+
if basic.empty? and advanced.empty?
|
54
|
+
puts "there are no user parameters in %s" % env.current_package_id
|
55
|
+
else
|
56
|
+
if not(basic.empty?)
|
57
|
+
print_by_block("Basic Parameters", basic, env)
|
58
|
+
end
|
59
|
+
if not(advanced.empty?) and model[:advanced]
|
60
|
+
print_by_block("Advanced Parameters", advanced, env)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
item.exception(Package::InvalidPackage) do |e|
|
66
|
+
cmd.abort("Package error: " + e.message)
|
67
|
+
end
|
68
|
+
|
69
|
+
item.exception(Lang::ParserError) do |e|
|
70
|
+
cmd.abort("Pione syntax error: " + e.message)
|
71
|
+
end
|
72
|
+
|
73
|
+
item.exception(Lang::LangError) do |e|
|
74
|
+
cmd.abort("Pione language error: %s(%s)" % [e.message, e.class.name])
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# `PionePackageShowContext` is a context for `pione package show`.
|
80
|
+
class PionePackageShowContext < Rootage::CommandContext
|
81
|
+
# Print parameters by block.
|
82
|
+
def print_by_block(header, params, env)
|
83
|
+
unless params.empty?
|
84
|
+
puts "%s:" % header
|
85
|
+
params.each do |param|
|
86
|
+
puts " %s := %s" % [param.name, param.value.eval(env).textize]
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
PionePackageShow.define(:process_context_class, PionePackageShowContext)
|
93
|
+
|
94
|
+
PionePackage.define_subcommand("show", PionePackageShow)
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Pione
|
2
|
+
module Command
|
3
|
+
# `PionePackageUpdate` is a subcommand that updates PIONE package.
|
4
|
+
class PionePackageUpdate < BasicCommand
|
5
|
+
#
|
6
|
+
# informations
|
7
|
+
#
|
8
|
+
|
9
|
+
define(:name, "update")
|
10
|
+
define(:desc, "Update the package to package database")
|
11
|
+
|
12
|
+
#
|
13
|
+
# arguments
|
14
|
+
#
|
15
|
+
|
16
|
+
argument(:location) do |item|
|
17
|
+
item.type = :location
|
18
|
+
item.desc = "the package location that you want to update"
|
19
|
+
item.missing = "There are no PIONE documents or packages."
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
# options
|
24
|
+
#
|
25
|
+
|
26
|
+
option CommonOption.color
|
27
|
+
option CommonOption.debug
|
28
|
+
|
29
|
+
option(:force) do |item|
|
30
|
+
item.type = :boolean
|
31
|
+
item.long = "--force"
|
32
|
+
item.desc = "update pacakge info files"
|
33
|
+
item.default = true
|
34
|
+
end
|
35
|
+
|
36
|
+
#
|
37
|
+
# command lifecycle: execution phase
|
38
|
+
#
|
39
|
+
|
40
|
+
phase(:execution) do |seq|
|
41
|
+
seq << :update
|
42
|
+
end
|
43
|
+
|
44
|
+
execution(:update) do |item|
|
45
|
+
item.desc = "Update update info files"
|
46
|
+
|
47
|
+
item.process do
|
48
|
+
Package::PackageHandler.write_info_files(model[:location], force: model[:force])
|
49
|
+
end
|
50
|
+
|
51
|
+
item.exception(Package::InvalidScenario) do |e|
|
52
|
+
cmd.abort(e)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
PionePackage.define_subcommand("update", PionePackageUpdate)
|
58
|
+
end
|
59
|
+
end
|
@@ -1,152 +1,24 @@
|
|
1
1
|
module Pione
|
2
2
|
module Command
|
3
|
-
# PionePackage is a
|
3
|
+
# `PionePackage` is a subcommand that provides package utility tools.
|
4
4
|
class PionePackage < BasicCommand
|
5
5
|
#
|
6
|
-
#
|
6
|
+
# informations
|
7
7
|
#
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
define(:name, "package")
|
10
|
+
define(:desc, "PIONE package utility")
|
11
11
|
|
12
12
|
#
|
13
|
-
#
|
13
|
+
# requirements
|
14
14
|
#
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
define_option(:add) do |item|
|
22
|
-
item.long = '--add'
|
23
|
-
item.desc = 'add the package to package database'
|
24
|
-
item.action = lambda do |_, option, location|
|
25
|
-
option[:action_mode] = :add
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
define_option(:build) do |item|
|
30
|
-
item.long = '--build'
|
31
|
-
item.desc = 'build PIONE archive file(*.ppg)'
|
32
|
-
item.action = lambda do |_, option, location|
|
33
|
-
option[:action_mode] = :build
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
define_option(:write_info) do |item|
|
38
|
-
item.long = '--write-info'
|
39
|
-
item.desc = 'write package and scenario info files'
|
40
|
-
item.action = lambda do |_, option, location|
|
41
|
-
option[:action_mode] = :write_info
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
define_option(:output) do |item|
|
46
|
-
item.short = "-o"
|
47
|
-
item.long = "--output=LOCATION"
|
48
|
-
item.desc = "output file or directory location"
|
49
|
-
item.value = lambda {|val| Location[val]}
|
50
|
-
end
|
51
|
-
|
52
|
-
define_option(:tag) do |item|
|
53
|
-
item.long = "--tag=NAME"
|
54
|
-
item.desc = "specify tag name"
|
55
|
-
item.value = :as_is
|
56
|
-
end
|
57
|
-
|
58
|
-
define_option(:hash_id) do |item|
|
59
|
-
item.long = "--hash-id=HASH"
|
60
|
-
item.desc = "specify git hash id"
|
61
|
-
item.value = :as_is
|
62
|
-
end
|
63
|
-
|
64
|
-
validate_option do |option|
|
65
|
-
unless option[:output].directory?
|
66
|
-
abort("output location should be a directory: %s" % option[:output])
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
#
|
71
|
-
# command lifecycle: setup phase
|
72
|
-
#
|
73
|
-
|
74
|
-
setup :target
|
75
|
-
|
76
|
-
# Check archiver target location.
|
77
|
-
def setup_target
|
78
|
-
abort("There are no PIONE documents or packages.") if @argv.first.nil?
|
79
|
-
@target = @argv.first
|
80
|
-
end
|
81
|
-
|
82
|
-
#
|
83
|
-
# command lifecycle: execution phase
|
84
|
-
#
|
85
|
-
|
86
|
-
execute :add => :add_package
|
87
|
-
|
88
|
-
# Add the package to package database.
|
89
|
-
def execute_add_package
|
90
|
-
handler = Package::PackageReader.read(Location[@target])
|
91
|
-
tag = option[:tag] || handler.info.tag
|
92
|
-
db = Package::Database.load
|
93
|
-
db.add(name: handler.info.name, editor: handler.info.editor, tag: tag, digest: handler.digest)
|
94
|
-
db.save
|
95
|
-
|
96
|
-
# show log
|
97
|
-
args = []
|
98
|
-
args << "editor: " + handler.info.editor if handler.info.editor
|
99
|
-
args << "tag: " + handler.info.tag if handler.info.tag
|
100
|
-
_args = args.size > 0 ? "(" + args.join(", ") + ")" : ""
|
101
|
-
Log::SystemLog.info(
|
102
|
-
"package \"%s\"%s was added to package database" % [handler.info.name, _args]
|
103
|
-
)
|
104
|
-
end
|
105
|
-
|
106
|
-
execute :build => :build_package
|
107
|
-
|
108
|
-
# Build a PPG package.
|
109
|
-
def execute_build_package
|
110
|
-
if ppg = try_to_archive(Location[git: @target], Location[data: @target])
|
111
|
-
Log::SystemLog.info("pione-package suceeded to build %s" % ppg.address)
|
112
|
-
else
|
113
|
-
abort("pione-package faild to archive.")
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
execute :write_info => :write_info
|
118
|
-
|
119
|
-
# Update update info files.
|
120
|
-
def execute_write_info
|
121
|
-
Package::PackageHandler.write_info_files(Location[@target])
|
122
|
-
rescue Package::InvalidScenario => e
|
123
|
-
abort(e.message)
|
124
|
-
end
|
125
|
-
|
126
|
-
#
|
127
|
-
# helper methods
|
128
|
-
#
|
129
|
-
|
130
|
-
private
|
131
|
-
|
132
|
-
def try_to_archive(*locations)
|
133
|
-
locations.each do |location|
|
134
|
-
begin
|
135
|
-
handler = Package::PackageReader.read(location)
|
136
|
-
cache_location = Package::PackageCache.directory_cache(handler.digest)
|
137
|
-
|
138
|
-
# make archiver
|
139
|
-
archiver = Package::PackageArchiver.new(cache_location)
|
140
|
-
|
141
|
-
# archive
|
142
|
-
return archiver.archive(option[:output], false)
|
143
|
-
rescue => e
|
144
|
-
p e
|
145
|
-
Log::Debug.system("pione-package failed to archive %s: %s" % [location, e.message])
|
146
|
-
end
|
147
|
-
end
|
148
|
-
return false
|
149
|
-
end
|
16
|
+
require 'pione/command/pione-package-add'
|
17
|
+
require 'pione/command/pione-package-build'
|
18
|
+
require 'pione/command/pione-package-show'
|
19
|
+
require 'pione/command/pione-package-update'
|
150
20
|
end
|
21
|
+
|
22
|
+
PioneCommand.define_subcommand("package", PionePackage)
|
151
23
|
end
|
152
24
|
end
|