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,85 @@
|
|
1
|
+
module Pione
|
2
|
+
module Command
|
3
|
+
# PioneActionExec is a command that executes action from outside of rule
|
4
|
+
# engine.
|
5
|
+
class PioneActionExec < BasicCommand
|
6
|
+
#
|
7
|
+
# command informations
|
8
|
+
#
|
9
|
+
|
10
|
+
define(:name, "exec")
|
11
|
+
define(:desc, "Execute an action rule in literate action document")
|
12
|
+
|
13
|
+
#
|
14
|
+
# arguments
|
15
|
+
#
|
16
|
+
|
17
|
+
argument(:location) do |item|
|
18
|
+
item.type = :location
|
19
|
+
item.desc = "Location of action document"
|
20
|
+
item.missing = "There are no action documents or packages."
|
21
|
+
end
|
22
|
+
|
23
|
+
argument(:name) do |item|
|
24
|
+
item.type = :string
|
25
|
+
item.desc = "Action name"
|
26
|
+
item.missing = "There is no action name."
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
# options
|
31
|
+
#
|
32
|
+
|
33
|
+
option CommonOption.color
|
34
|
+
option CommonOption.debug
|
35
|
+
|
36
|
+
option(:domain_dump) do |item|
|
37
|
+
item.type = :location
|
38
|
+
item.long = "--domain-dump"
|
39
|
+
item.arg = "LOCATION"
|
40
|
+
item.desc = "Load the domain dump file"
|
41
|
+
end
|
42
|
+
|
43
|
+
option(:directory) do |item|
|
44
|
+
item.type = :location
|
45
|
+
item.short = "-d"
|
46
|
+
item.long = "--directory PATH"
|
47
|
+
item.desc = "execute in the PATH"
|
48
|
+
end
|
49
|
+
|
50
|
+
#
|
51
|
+
# command lifecycle: setup phase
|
52
|
+
#
|
53
|
+
|
54
|
+
phase(:setup) do |item|
|
55
|
+
item << CommonAction.load_domain_dump
|
56
|
+
end
|
57
|
+
|
58
|
+
#
|
59
|
+
# command lifecycle: execution phase
|
60
|
+
#
|
61
|
+
|
62
|
+
phase(:execution) do |item|
|
63
|
+
item << :exec
|
64
|
+
end
|
65
|
+
|
66
|
+
execution(:exec) do |item|
|
67
|
+
item.desc = "Update pacakge info files"
|
68
|
+
|
69
|
+
item.process do
|
70
|
+
if action = LiterateAction::Document.load(model[:location]).find(model[:name])
|
71
|
+
action.execute(model[:domain_info], model[:directory])
|
72
|
+
else
|
73
|
+
cmd.abort("The action not found.")
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
item.exception(Location::NotFound) do |e|
|
78
|
+
cmd.abort(e)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
PioneAction.define_subcommand("exec", PioneActionExec)
|
84
|
+
end
|
85
|
+
end
|
@@ -7,43 +7,67 @@ module Pione
|
|
7
7
|
# basic informations
|
8
8
|
#
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
PioneCommand.add_subcommand("action:list", self)
|
10
|
+
define(:name, "list")
|
11
|
+
define(:desc, "List action names in document")
|
13
12
|
|
14
13
|
#
|
15
|
-
#
|
14
|
+
# arguments
|
16
15
|
#
|
17
16
|
|
18
|
-
|
17
|
+
argument(:location) do |item|
|
18
|
+
item.type = :location
|
19
|
+
item.desc = "Location of literate action document"
|
20
|
+
item.missing = "There is no action document."
|
21
|
+
end
|
19
22
|
|
20
23
|
#
|
21
|
-
#
|
24
|
+
# options
|
22
25
|
#
|
23
26
|
|
24
|
-
|
27
|
+
option CommonOption.color
|
25
28
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
29
|
+
option(:compact) do |item|
|
30
|
+
item.type = :boolean
|
31
|
+
item.long = "--compact"
|
32
|
+
item.desc = "one-line list"
|
33
|
+
item.default = false
|
30
34
|
end
|
31
35
|
|
32
36
|
#
|
33
37
|
# command lifecycle: execution phase
|
34
38
|
#
|
35
39
|
|
36
|
-
|
40
|
+
phase(:execution) do |item|
|
41
|
+
item << :get_names
|
42
|
+
item << :show_list
|
43
|
+
end
|
44
|
+
|
45
|
+
execution(:get_names) do |item|
|
46
|
+
item.desc = "Get all action names"
|
47
|
+
|
48
|
+
item.assign(:names) do
|
49
|
+
LiterateAction::Document.load(model[:location]).action_names.sort
|
50
|
+
end
|
51
|
+
|
52
|
+
item.process do
|
53
|
+
test(model[:names].empty?)
|
54
|
+
cmd.abort("There are no action names in %{location}" % {location: model[:location]})
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
execution(:show_list) do |item|
|
59
|
+
item.desc = "Show list of action names"
|
37
60
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
names.each {|name| puts name}
|
61
|
+
item.process do
|
62
|
+
if model[:compact]
|
63
|
+
puts model[:names].join(" ")
|
64
|
+
else
|
65
|
+
model[:names].each {|name| puts name}
|
66
|
+
end
|
45
67
|
end
|
46
68
|
end
|
47
69
|
end
|
70
|
+
|
71
|
+
PioneAction.define_subcommand("list", PioneActionList)
|
48
72
|
end
|
49
73
|
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module Pione
|
2
|
+
module Command
|
3
|
+
# `PioneActionPrint` is a command that prints action contents.
|
4
|
+
class PioneActionPrint < BasicCommand
|
5
|
+
#
|
6
|
+
# basic informations
|
7
|
+
#
|
8
|
+
|
9
|
+
define(:name, "print")
|
10
|
+
define(:desc, "Print action contents")
|
11
|
+
|
12
|
+
#
|
13
|
+
# arguments
|
14
|
+
#
|
15
|
+
|
16
|
+
argument(:location) do |item|
|
17
|
+
item.type = :location
|
18
|
+
item.missing = "There are no action documents or packages."
|
19
|
+
end
|
20
|
+
|
21
|
+
argument(:name) do |item|
|
22
|
+
item.type = :string
|
23
|
+
item.missing = "There is no action name."
|
24
|
+
end
|
25
|
+
|
26
|
+
#
|
27
|
+
# options
|
28
|
+
#
|
29
|
+
|
30
|
+
option CommonOption.color
|
31
|
+
option CommonOption.debug
|
32
|
+
option CommonOption.domain_dump_location
|
33
|
+
|
34
|
+
#
|
35
|
+
# command lifecycle: setup phase
|
36
|
+
#
|
37
|
+
|
38
|
+
phase(:setup) do |seq|
|
39
|
+
seq << CommonAction.load_domain_dump
|
40
|
+
end
|
41
|
+
|
42
|
+
#
|
43
|
+
# command lifecycle: execution phase
|
44
|
+
#
|
45
|
+
|
46
|
+
phase(:execution) do |seq|
|
47
|
+
seq << :find_action
|
48
|
+
seq << :print
|
49
|
+
end
|
50
|
+
|
51
|
+
execution(:find_action) do |item|
|
52
|
+
item.desc = "Find the action from the document"
|
53
|
+
|
54
|
+
item.assign(:action) do
|
55
|
+
LiterateAction::Document.load(model[:location]).find(model[:name])
|
56
|
+
end
|
57
|
+
|
58
|
+
item.process do
|
59
|
+
test(not(model[:action]))
|
60
|
+
cmd.abort("Action not found.")
|
61
|
+
end
|
62
|
+
|
63
|
+
item.exception(Location::NotFound) do |e|
|
64
|
+
cmd.abort(e)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
execution(:print) do |item|
|
69
|
+
item.desc = "Print the action contents"
|
70
|
+
|
71
|
+
item.process do
|
72
|
+
puts model[:action].textize(model[:domain_dump])
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
PioneAction.define_subcommand("print", PioneActionPrint)
|
78
|
+
end
|
79
|
+
end
|
@@ -7,77 +7,18 @@ module Pione
|
|
7
7
|
# basic informations
|
8
8
|
#
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
PioneCommand.add_subcommand("action", self)
|
10
|
+
define(:name, "action")
|
11
|
+
define(:desc, "execute an action in literate action document")
|
13
12
|
|
14
13
|
#
|
15
|
-
#
|
14
|
+
# subcommands
|
16
15
|
#
|
17
16
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
define_option(:domain) do |item|
|
22
|
-
item.long = "--domain"
|
23
|
-
item.desc = "use the domain information file"
|
24
|
-
item.default = Location["./domain.dump"]
|
25
|
-
item.value = lambda {|b| b}
|
26
|
-
end
|
27
|
-
|
28
|
-
define_option(:show) do |item|
|
29
|
-
item.long = "--show"
|
30
|
-
item.desc = "show the action without execution"
|
31
|
-
item.value = lambda {|b| b}
|
32
|
-
end
|
33
|
-
|
34
|
-
define_option(:directory) do |item|
|
35
|
-
item.short = "-d"
|
36
|
-
item.long = "--directory PATH"
|
37
|
-
item.desc = "execute in the PATH"
|
38
|
-
item.value = lambda {|b| Location[b]}
|
39
|
-
end
|
40
|
-
|
41
|
-
#
|
42
|
-
# command lifecycle: setup phase
|
43
|
-
#
|
44
|
-
|
45
|
-
setup :target
|
46
|
-
setup :domain
|
47
|
-
|
48
|
-
# Setup location of literate action document and action name.
|
49
|
-
def setup_target
|
50
|
-
abort("There are no literate action documents or packages.") if @argv[0].nil?
|
51
|
-
abort("Action name is needed.") if @argv[1].nil?
|
52
|
-
@location = Location[@argv[0]]
|
53
|
-
@name = @argv[1]
|
54
|
-
end
|
55
|
-
|
56
|
-
# Load a domain information file.
|
57
|
-
def setup_domain
|
58
|
-
if option[:domain].exist?
|
59
|
-
@domain_info = System::DomainInfo.read(option[:domain])
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
#
|
64
|
-
# command lifecycle: execution phase
|
65
|
-
#
|
66
|
-
|
67
|
-
execute :exec
|
68
|
-
|
69
|
-
# Update pacakge info files.
|
70
|
-
def execute_exec
|
71
|
-
if action = LiterateAction::Document.load(@location).find(@name)
|
72
|
-
if option[:show]
|
73
|
-
puts action.textize(@domain_info)
|
74
|
-
else
|
75
|
-
action.execute(@domain_info, option[:directory])
|
76
|
-
end
|
77
|
-
else
|
78
|
-
abort(e.message)
|
79
|
-
end
|
80
|
-
end
|
17
|
+
require 'pione/command/pione-action-exec'
|
18
|
+
require 'pione/command/pione-action-list'
|
19
|
+
require 'pione/command/pione-action-print'
|
81
20
|
end
|
21
|
+
|
22
|
+
PioneCommand.define_subcommand("action", PioneAction)
|
82
23
|
end
|
83
24
|
end
|
@@ -7,78 +7,81 @@ module Pione
|
|
7
7
|
# basic informations
|
8
8
|
#
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
PioneCommand.add_subcommand("clean", self)
|
10
|
+
define(:name, "pione-clean")
|
11
|
+
define(:desc, "Remove PIONE's temporary files, cache, and etc")
|
13
12
|
|
14
13
|
#
|
15
14
|
# options
|
16
15
|
#
|
17
16
|
|
18
|
-
|
17
|
+
option CommonOption.debug
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
item.long = '--older
|
19
|
+
option(:older) do |item|
|
20
|
+
item.type = :string
|
21
|
+
item.long = '--older'
|
22
|
+
item.arg = 'DATE'
|
23
23
|
item.desc = 'remove file older than the date'
|
24
|
-
item.default = false
|
25
|
-
item.value = proc do |str|
|
26
|
-
begin
|
27
|
-
Date.iso8601(str)
|
28
|
-
rescue ArgumentError
|
29
|
-
begin
|
30
|
-
Date.today - str.to_i
|
31
|
-
rescue
|
32
|
-
abort("invalid value of older option: %s" % str)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
24
|
end
|
37
25
|
|
38
|
-
|
39
|
-
|
40
|
-
item.
|
26
|
+
option(:type) do |item|
|
27
|
+
item.type = :string
|
28
|
+
item.range = ["all", "temporary", "file-cache", "package-cache", "profile"]
|
29
|
+
item.long = '--type NAME'
|
41
30
|
item.desc = 'remove only files of the type'
|
42
|
-
item.
|
43
|
-
item.value = proc do |name|
|
44
|
-
case name
|
45
|
-
when "temporary"
|
46
|
-
:temporary
|
47
|
-
when "file-cache"
|
48
|
-
:file_cache
|
49
|
-
when "package-cache"
|
50
|
-
:package_cache
|
51
|
-
when "profile"
|
52
|
-
:profile
|
53
|
-
else
|
54
|
-
abort("unknown type: %s" % str)
|
55
|
-
end
|
56
|
-
end
|
31
|
+
item.init = "all"
|
57
32
|
end
|
58
33
|
|
59
34
|
#
|
60
35
|
# command lifecycle: setup phase
|
61
36
|
#
|
62
37
|
|
63
|
-
setup
|
38
|
+
phase(:setup) do |item|
|
39
|
+
item << :older_date
|
40
|
+
item << :package_database
|
41
|
+
end
|
42
|
+
|
43
|
+
setup(:older_date) do |item|
|
44
|
+
item.desc = "Setup older date"
|
64
45
|
|
65
|
-
|
66
|
-
|
46
|
+
item.assign(:older) do
|
47
|
+
Rootage::Normalizer.normalize(:date, model[:older])
|
48
|
+
end
|
49
|
+
|
50
|
+
item.exception do |e|
|
51
|
+
begin
|
52
|
+
model[:older] = Date.today - model[:older].to_i
|
53
|
+
rescue
|
54
|
+
cmd.abort("invalid value of older option: %s" % str)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
setup(:package_database) do |item|
|
60
|
+
item.desc = "Load pakcage database"
|
61
|
+
|
62
|
+
item.assign(:db) do
|
63
|
+
Package::Database.load
|
64
|
+
end
|
67
65
|
end
|
68
66
|
|
69
67
|
#
|
70
68
|
# command lifecycle: execution phase
|
71
69
|
#
|
72
70
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
71
|
+
phase(:execution) do |item|
|
72
|
+
item << :remove_temporary
|
73
|
+
item << :remove_file_cache
|
74
|
+
item << :remove_package_cache
|
75
|
+
item << :remove_profile
|
76
|
+
end
|
77
|
+
|
78
|
+
# This removes working files based on temporary directory's mtime.
|
79
|
+
execution(:remove_temporary) do |item|
|
80
|
+
item.desc = "Remove temporary files"
|
81
|
+
|
82
|
+
item.process do
|
83
|
+
test(type?("temprary"))
|
77
84
|
|
78
|
-
# Remove temporary files. This removes working files based on temporary
|
79
|
-
# directory's mtime.
|
80
|
-
def execute_remove_temporary
|
81
|
-
if type?(:temprary)
|
82
85
|
Location[Global.my_temporary_directory].each_entry do |entry|
|
83
86
|
if delete?(entry)
|
84
87
|
FileUtils.remove_entry_secure(entry.path)
|
@@ -87,9 +90,13 @@ module Pione
|
|
87
90
|
end
|
88
91
|
end
|
89
92
|
|
90
|
-
#
|
91
|
-
|
92
|
-
|
93
|
+
# This removes file caches base on cache directory's mtime.
|
94
|
+
execution(:remove_file_cache) do |item|
|
95
|
+
item.desc = "Remove file cache files"
|
96
|
+
|
97
|
+
item.process do
|
98
|
+
test(type?("file-cache"))
|
99
|
+
|
93
100
|
Location[Global.my_file_cache_directory].each_entry do |entry|
|
94
101
|
if delete?(entry)
|
95
102
|
FileUtils.remove_entry_secure(entry.path)
|
@@ -98,21 +105,28 @@ module Pione
|
|
98
105
|
end
|
99
106
|
end
|
100
107
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
108
|
+
execution(:remove_package_cache) do |item|
|
109
|
+
item.desc = "Remove package cache files"
|
110
|
+
|
111
|
+
item.condition do
|
112
|
+
test(type?("package-cache"))
|
113
|
+
end
|
114
|
+
|
115
|
+
# remove PPG packages
|
116
|
+
item.process do
|
105
117
|
Global.ppg_package_cache_directory.each_entry do |entry|
|
106
|
-
unless
|
118
|
+
unless model[:db].has_digest?(Package::PackageFilename.parse(entry.basename).digest)
|
107
119
|
if delete?(entry)
|
108
120
|
entry.delete
|
109
121
|
end
|
110
122
|
end
|
111
123
|
end
|
124
|
+
end
|
112
125
|
|
113
|
-
|
126
|
+
# remove directory packages
|
127
|
+
item.process do
|
114
128
|
Global.directory_package_cache_directory.each_entry do |entry|
|
115
|
-
unless
|
129
|
+
unless model[:db].has_digest?(entry.basename)
|
116
130
|
if delete?(entry)
|
117
131
|
entry.delete
|
118
132
|
end
|
@@ -121,9 +135,12 @@ module Pione
|
|
121
135
|
end
|
122
136
|
end
|
123
137
|
|
124
|
-
|
125
|
-
|
126
|
-
|
138
|
+
execution(:remove_profile) do |item|
|
139
|
+
item.desc = "Remove profile reports"
|
140
|
+
|
141
|
+
item.process do
|
142
|
+
test(type?("profile"))
|
143
|
+
|
127
144
|
Location[Global.profile_report_directory].each_entry do |entry|
|
128
145
|
if delete?(entry)
|
129
146
|
entry.delete
|
@@ -131,20 +148,23 @@ module Pione
|
|
131
148
|
end
|
132
149
|
end
|
133
150
|
end
|
151
|
+
end
|
134
152
|
|
135
|
-
|
136
|
-
|
137
|
-
#
|
138
|
-
|
139
|
-
# Return true if the entry has the type.
|
153
|
+
# `PioneCleanContext` is a process context for `pione-clean-context`.
|
154
|
+
class PioneCleanContext < Rootage::CommandContext
|
155
|
+
# Return true if the type is matched.
|
140
156
|
def type?(type)
|
141
|
-
|
157
|
+
model[:type] == "all" or model[:type] == type
|
142
158
|
end
|
143
159
|
|
144
160
|
# Return true if the entry should be removed.
|
145
161
|
def delete?(entry)
|
146
|
-
|
162
|
+
not(entry.exist?) or model[:older].nil? or model[:older] >= entry.mtime.to_date
|
147
163
|
end
|
148
164
|
end
|
165
|
+
|
166
|
+
PioneClean.define(:process_context_class, PioneCleanContext)
|
167
|
+
|
168
|
+
PioneCommand.define_subcommand("clean", PioneClean)
|
149
169
|
end
|
150
170
|
end
|