pione 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +16 -13
- data/.travis.yml +1 -1
- data/History.txt +11 -0
- data/Rakefile +13 -0
- data/bin/pione-package +5 -0
- data/example/AbstractRule/package.yml +6 -0
- data/example/AbstractRule/scenario/a/output/message.txt +1 -0
- data/example/AbstractRule/scenario/a/scenario.yml +4 -0
- data/example/AbstractRule/scenario/b/output/message.txt +1 -0
- data/example/AbstractRule/scenario/b/scenario.yml +4 -0
- data/example/AbstractRule/scenario/c/output/message.txt +1 -0
- data/example/AbstractRule/scenario/c/scenario.yml +4 -0
- data/example/HelloWorld/package.yml +5 -1
- data/example/HelloWorld/scenario/scenario.yml +2 -1
- data/example/LoopByTouch/package.yml +4 -1
- data/example/MakePair/package.yml +6 -0
- data/example/MakePair/scenario/{input → case1/input}/1.i +0 -0
- data/example/MakePair/scenario/{input → case1/input}/2.i +0 -0
- data/example/MakePair/scenario/{input → case1/input}/3.i +0 -0
- data/example/MakePair/scenario/{input → case1/input}/4.i +0 -0
- data/example/MakePair/scenario/{input → case1/input}/5.i +0 -0
- data/example/MakePair/scenario/{output → case1/output}/comb-1-2.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/comb-1-3.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/comb-1-4.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/comb-1-5.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/comb-2-3.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/comb-2-4.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/comb-2-5.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/comb-3-4.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/comb-3-5.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/comb-4-5.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/perm-1-2.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/perm-1-3.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/perm-1-4.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/perm-1-5.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/perm-2-1.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/perm-2-3.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/perm-2-4.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/perm-2-5.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/perm-3-1.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/perm-3-2.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/perm-3-4.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/perm-3-5.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/perm-4-1.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/perm-4-2.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/perm-4-3.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/perm-4-5.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/perm-5-1.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/perm-5-2.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/perm-5-3.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/perm-5-4.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/succ-1-2.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/succ-2-3.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/succ-3-4.pair +0 -0
- data/example/MakePair/scenario/{output → case1/output}/succ-4-5.pair +0 -0
- data/example/MakePair/scenario/case1/scenario.yml +42 -0
- data/example/MakePair/scenario/case2/input/10.i +0 -0
- data/example/MakePair/scenario/case2/input/11.i +0 -0
- data/example/MakePair/scenario/case2/input/9.i +0 -0
- data/example/MakePair/scenario/case2/output/comb-10-11.pair +0 -0
- data/example/MakePair/scenario/case2/output/comb-9-10.pair +0 -0
- data/example/MakePair/scenario/case2/output/comb-9-11.pair +0 -0
- data/example/MakePair/scenario/case2/output/perm-10-11.pair +0 -0
- data/example/MakePair/scenario/case2/output/perm-10-9.pair +0 -0
- data/example/MakePair/scenario/case2/output/perm-11-10.pair +0 -0
- data/example/MakePair/scenario/case2/output/perm-11-9.pair +0 -0
- data/example/MakePair/scenario/case2/output/perm-9-10.pair +0 -0
- data/example/MakePair/scenario/case2/output/perm-9-11.pair +0 -0
- data/example/MakePair/scenario/case2/output/succ-10-11.pair +0 -0
- data/example/MakePair/scenario/case2/output/succ-9-10.pair +0 -0
- data/example/MakePair/scenario/case2/scenario.yml +17 -0
- data/example/MakePair/scenario/case3/input/1.i +0 -0
- data/example/MakePair/scenario/case3/input/3.i +0 -0
- data/example/MakePair/scenario/case3/input/5.i +0 -0
- data/example/MakePair/scenario/case3/input/7.i +0 -0
- data/example/MakePair/scenario/case3/input/9.i +0 -0
- data/example/MakePair/scenario/case3/output/comb-1-3.pair +0 -0
- data/example/MakePair/scenario/case3/output/comb-1-5.pair +0 -0
- data/example/MakePair/scenario/case3/output/comb-1-7.pair +0 -0
- data/example/MakePair/scenario/case3/output/comb-1-9.pair +0 -0
- data/example/MakePair/scenario/case3/output/comb-3-5.pair +0 -0
- data/example/MakePair/scenario/case3/output/comb-3-7.pair +0 -0
- data/example/MakePair/scenario/case3/output/comb-3-9.pair +0 -0
- data/example/MakePair/scenario/case3/output/comb-5-7.pair +0 -0
- data/example/MakePair/scenario/case3/output/comb-5-9.pair +0 -0
- data/example/MakePair/scenario/case3/output/comb-7-9.pair +0 -0
- data/example/MakePair/scenario/case3/output/perm-1-3.pair +0 -0
- data/example/MakePair/scenario/case3/output/perm-1-5.pair +0 -0
- data/example/MakePair/scenario/case3/output/perm-1-7.pair +0 -0
- data/example/MakePair/scenario/case3/output/perm-1-9.pair +0 -0
- data/example/MakePair/scenario/case3/output/perm-3-1.pair +0 -0
- data/example/MakePair/scenario/case3/output/perm-3-5.pair +0 -0
- data/example/MakePair/scenario/case3/output/perm-3-7.pair +0 -0
- data/example/MakePair/scenario/case3/output/perm-3-9.pair +0 -0
- data/example/MakePair/scenario/case3/output/perm-5-1.pair +0 -0
- data/example/MakePair/scenario/case3/output/perm-5-3.pair +0 -0
- data/example/MakePair/scenario/case3/output/perm-5-7.pair +0 -0
- data/example/MakePair/scenario/case3/output/perm-5-9.pair +0 -0
- data/example/MakePair/scenario/case3/output/perm-7-1.pair +0 -0
- data/example/MakePair/scenario/case3/output/perm-7-3.pair +0 -0
- data/example/MakePair/scenario/case3/output/perm-7-5.pair +0 -0
- data/example/MakePair/scenario/case3/output/perm-7-9.pair +0 -0
- data/example/MakePair/scenario/case3/output/perm-9-1.pair +0 -0
- data/example/MakePair/scenario/case3/output/perm-9-3.pair +0 -0
- data/example/MakePair/scenario/case3/output/perm-9-5.pair +0 -0
- data/example/MakePair/scenario/case3/output/perm-9-7.pair +0 -0
- data/example/MakePair/scenario/case3/scenario.yml +39 -0
- data/example/PegasusWMS/Merge/Merge.pione +21 -0
- data/example/PegasusWMS/Merge/package.yml +2 -0
- data/example/PegasusWMS/Pipeline/Pipeline.pione +20 -0
- data/example/PegasusWMS/Pipeline/package.yml +2 -0
- data/example/PegasusWMS/Split/Split.pione +27 -0
- data/example/PegasusWMS/Split/package.yml +2 -0
- data/example/ScoreAggregation/package.yml +4 -0
- data/example/ScoreAggregation/scenario/case1/scenario.yml +27 -1
- data/example/SerialProcessing/package.yml +5 -1
- data/example/SerialProcessing/scenario/scenario.yml +10 -0
- data/lib/pione.rb +20 -71
- data/lib/pione/agent.rb +17 -0
- data/lib/pione/agent/basic-agent.rb +2 -4
- data/lib/pione/command.rb +1 -0
- data/lib/pione/command/option.rb +4 -1
- data/lib/pione/command/pione-package.rb +97 -0
- data/lib/pione/command/pione-task-worker.rb +11 -7
- data/lib/pione/component.rb +5 -0
- data/lib/pione/component/document.rb +22 -5
- data/lib/pione/component/package-archiver.rb +92 -0
- data/lib/pione/component/package-expander.rb +37 -0
- data/lib/pione/component/package-filename.rb +38 -0
- data/lib/pione/component/package-reader.rb +276 -0
- data/lib/pione/component/package.rb +50 -162
- data/lib/pione/front.rb +14 -0
- data/lib/pione/location.rb +5 -0
- data/lib/pione/location/basic-location.rb +47 -274
- data/lib/pione/location/data-location.rb +328 -0
- data/lib/pione/location/dropbox-location.rb +30 -7
- data/lib/pione/location/exception.rb +38 -0
- data/lib/pione/location/ftp-location.rb +24 -13
- data/lib/pione/location/git-repository-location.rb +153 -0
- data/lib/pione/location/http-location.rb +65 -0
- data/lib/pione/location/https-location.rb +37 -0
- data/lib/pione/location/local-location.rb +24 -5
- data/lib/pione/parser.rb +14 -0
- data/lib/pione/patch.rb +10 -0
- data/lib/pione/patch/drb-patch.rb +2 -2
- data/lib/pione/relay.rb +11 -0
- data/lib/pione/system/file-cache.rb +1 -1
- data/lib/pione/system/global.rb +15 -0
- data/lib/pione/tuple-space.rb +11 -0
- data/lib/pione/tuple-space/tuple-space-server.rb +1 -1
- data/lib/pione/util.rb +1 -0
- data/lib/pione/util/error-report.rb +7 -0
- data/lib/pione/util/misc.rb +2 -2
- data/lib/pione/util/zip.rb +60 -0
- data/lib/pione/version.rb +1 -1
- data/pione.gemspec +5 -1
- data/test/agent/spec_rule-provider.rb +2 -2
- data/test/command/spec_pione-package.rb +15 -0
- data/test/component/spec_document.rb +2 -2
- data/test/component/spec_package-archiver.rb +27 -0
- data/test/component/spec_package-expander.rb +11 -0
- data/test/component/spec_package-filename.rb +79 -0
- data/test/component/spec_package-reader.rb +100 -0
- data/test/component/spec_package.rb +50 -33
- data/test/location/http-behavior.rb +59 -0
- data/test/location/location-behavior.rb +8 -0
- data/test/location/spec_basic-location.rb +5 -1
- data/test/location/spec_git-repository-location.rb +143 -0
- data/test/location/spec_http-location.rb +28 -0
- data/test/location/spec_http-location/a.txt +1 -0
- data/test/location/spec_http-location/b.txt +1 -0
- data/test/location/spec_http-location/c.txt +1 -0
- data/test/location/spec_http-location/dir/d.txt +1 -0
- data/test/location/spec_https-location.rb +37 -0
- data/test/rule-handler/spec_flow-handler.rb +1 -1
- data/test/rule-handler/spec_update-criteria.rb +1 -1
- 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/HelloWorld.pione +5 -0
- data/test/test-data/package/HelloWorld/package.yml +6 -0
- data/test/test-data/package/HelloWorld/scenario/output/message.txt +1 -0
- data/test/test-data/package/HelloWorld/scenario/scenario.yml +3 -0
- data/test/test-data/package/TestPackage1+v0.1.0.ppg +0 -0
- data/test/{component/spec_package/TestPackage → test-data/package/TestPackage1}/Test.pione +3 -1
- data/test/test-data/package/TestPackage1/bin/count +11 -0
- data/test/test-data/package/TestPackage1/package.yml +9 -0
- data/test/{component/spec_package/TestPackage → test-data/package/TestPackage1}/scenario/case1/input/1.txt +0 -0
- data/test/test-data/package/TestPackage1/scenario/case1/output/1.count +1 -0
- data/test/test-data/package/TestPackage1/scenario/case1/scenario.yml +6 -0
- data/test/test-data/package/TestPackage1/scenario/case2/input/1.txt +2 -0
- data/test/test-data/package/TestPackage1/scenario/case2/input/2.txt +1 -0
- data/test/test-data/package/TestPackage1/scenario/case2/input/3.txt +3 -0
- data/test/test-data/package/TestPackage1/scenario/case2/output/1.count +1 -0
- data/test/test-data/package/TestPackage1/scenario/case2/output/2.count +1 -0
- data/test/test-data/package/TestPackage1/scenario/case2/output/3.count +1 -0
- data/test/test-data/package/TestPackage1/scenario/case2/scenario.yml +10 -0
- data/test/test-data/package/TestPackage1/scenario/case3/input/a.txt +1 -0
- data/test/test-data/package/TestPackage1/scenario/case3/input/b.txt +1 -0
- data/test/test-data/package/TestPackage1/scenario/case3/output/a.count +1 -0
- data/test/test-data/package/TestPackage1/scenario/case3/output/b.count +1 -0
- data/test/test-data/package/TestPackage1/scenario/case3/scenario.yml +8 -0
- data/test/test-util.rb +10 -146
- data/test/test-util/command.rb +53 -0
- data/test/test-util/package.rb +9 -0
- data/test/test-util/parser.rb +45 -0
- data/test/test-util/transformer.rb +50 -0
- data/test/test-util/webserver.rb +43 -0
- data/test/util/spec_error-report.rb +12 -3
- data/test/util/spec_zip.rb +36 -0
- metadata +282 -54
- data/example/MakePair/scenario/scenario.yml +0 -1
- data/test/component/spec_package/TestPackage/bin/count +0 -3
- data/test/component/spec_package/TestPackage/package.yml +0 -7
- data/test/component/spec_package/TestPackage/scenario/case1/scenario.yml +0 -1
|
@@ -16,21 +16,30 @@ module Pione
|
|
|
16
16
|
|
|
17
17
|
# Package is a container of rules, scripts, scenarios, and etc.
|
|
18
18
|
class Package < StructX
|
|
19
|
+
member :location
|
|
19
20
|
member :info, default: {}
|
|
20
21
|
member :bin
|
|
21
|
-
member :
|
|
22
|
+
member :scenario_paths, default: []
|
|
22
23
|
member :documents, default: []
|
|
23
24
|
|
|
24
25
|
forward_as_key Proc.new{info}, "PackageName", :name
|
|
26
|
+
forward_as_key Proc.new{info}, "Edition", :edition
|
|
27
|
+
forward_as_key Proc.new{info}, "Tag", :tag
|
|
28
|
+
forward_as_key Proc.new{info}, "HashID", :hash_id
|
|
25
29
|
forward :@unified_document, :find, :find_rule
|
|
26
30
|
forward! :@unified_document, :rules, :create_root_rule, :params
|
|
27
31
|
|
|
28
32
|
def initialize(*args)
|
|
29
33
|
super(*args)
|
|
34
|
+
info["Edition"] = "origin" unless info["Edition"]
|
|
30
35
|
build_unified_document
|
|
31
36
|
validate
|
|
32
37
|
end
|
|
33
38
|
|
|
39
|
+
def scenarios
|
|
40
|
+
scenario_paths.map {|path| PackageScenarioReader.read(location, path)}
|
|
41
|
+
end
|
|
42
|
+
|
|
34
43
|
# Upload the package files to the location.
|
|
35
44
|
#
|
|
36
45
|
# @return [void]
|
|
@@ -50,10 +59,13 @@ module Pione
|
|
|
50
59
|
# @return [PackageScenario]
|
|
51
60
|
# the scenario
|
|
52
61
|
def find_scenario(name)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
62
|
+
scenario_paths.each do |path|
|
|
63
|
+
if name == :anything
|
|
64
|
+
return PackageScenarioReader.read(location, path)
|
|
65
|
+
else
|
|
66
|
+
scenario = PackageScenarioReader.read(location, path)
|
|
67
|
+
return scenario if scenario.name == name
|
|
68
|
+
end
|
|
57
69
|
end
|
|
58
70
|
end
|
|
59
71
|
|
|
@@ -81,119 +93,6 @@ module Pione
|
|
|
81
93
|
end
|
|
82
94
|
end
|
|
83
95
|
|
|
84
|
-
# PackageReader is a reader for packages.
|
|
85
|
-
class PackageReader
|
|
86
|
-
class << self
|
|
87
|
-
# Read a pacakge from the location.
|
|
88
|
-
#
|
|
89
|
-
# @param location [Location::BasicLocation]
|
|
90
|
-
# location of package
|
|
91
|
-
# @return [Package]
|
|
92
|
-
# the package
|
|
93
|
-
def read(location)
|
|
94
|
-
new(location).read
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
attr_reader :location
|
|
99
|
-
attr_reader :type
|
|
100
|
-
|
|
101
|
-
# @param location [Location]
|
|
102
|
-
# package location
|
|
103
|
-
def initialize(location)
|
|
104
|
-
@location = location
|
|
105
|
-
@type = check_package_type
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
# Read the package.
|
|
109
|
-
#
|
|
110
|
-
# @return [Package]
|
|
111
|
-
# the package
|
|
112
|
-
def read
|
|
113
|
-
case @type
|
|
114
|
-
when :directory
|
|
115
|
-
return read_package_directory
|
|
116
|
-
when :pione_document_file
|
|
117
|
-
return read_pione_document_file
|
|
118
|
-
end
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
private
|
|
122
|
-
|
|
123
|
-
# Check package type.
|
|
124
|
-
#
|
|
125
|
-
# @return [Symbol]
|
|
126
|
-
# package type
|
|
127
|
-
def check_package_type
|
|
128
|
-
return :directory if @location.directory?
|
|
129
|
-
if File.extname(@location.basename) == ".pione"
|
|
130
|
-
return :pione_document_file
|
|
131
|
-
end
|
|
132
|
-
raise ArgumentError.new(@location)
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
# Read package directory.
|
|
136
|
-
#
|
|
137
|
-
# @return [Package]
|
|
138
|
-
# the package
|
|
139
|
-
def read_package_directory
|
|
140
|
-
info = read_package_info
|
|
141
|
-
Package.new(
|
|
142
|
-
info: info,
|
|
143
|
-
bin: @location + "bin",
|
|
144
|
-
scenarios: find_scenarios,
|
|
145
|
-
documents: find_documents(info["PackageName"])
|
|
146
|
-
)
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
# Read PIONE document.
|
|
150
|
-
#
|
|
151
|
-
# @return [Package]
|
|
152
|
-
# the package
|
|
153
|
-
def read_pione_document_file
|
|
154
|
-
document = Component::Document.load(@location, "Main")
|
|
155
|
-
Package.new(info: {"PackageName" => "Main"}, documents: [document])
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
# Read the informations from the package location.
|
|
159
|
-
#
|
|
160
|
-
# @return [Hash]
|
|
161
|
-
# package information table
|
|
162
|
-
def read_package_info
|
|
163
|
-
YAML.load((@location + "package.yml").read)
|
|
164
|
-
rescue Location::NotFound
|
|
165
|
-
raise InvalidPackageError.new(self, "package.yml not found in %s" % @location.uri)
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
# Find scenarios from the package location.
|
|
169
|
-
#
|
|
170
|
-
# @return [Array<PackageScenario>]
|
|
171
|
-
# scenarios
|
|
172
|
-
def find_scenarios
|
|
173
|
-
if (@location + "scenario" + "scenario.yml").exist?
|
|
174
|
-
[PackageScenarioReader.read(@location + "scenario")]
|
|
175
|
-
else
|
|
176
|
-
if (@location + "scenario").exist? and (@location + "scenario").directory?
|
|
177
|
-
(@location + "scenario").entries.map do |scenario|
|
|
178
|
-
PackageScenarioReader.read(scenario)
|
|
179
|
-
end.compact
|
|
180
|
-
else
|
|
181
|
-
[]
|
|
182
|
-
end
|
|
183
|
-
end
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
# Find documents from the packcage location.
|
|
187
|
-
#
|
|
188
|
-
# @return [Array<Document>]
|
|
189
|
-
# documents
|
|
190
|
-
def find_documents(package_name)
|
|
191
|
-
@location.entries.select do |entry|
|
|
192
|
-
entry.file? and entry.path.extname == ".pione"
|
|
193
|
-
end.map {|entry| Document.load(entry, package_name) }
|
|
194
|
-
end
|
|
195
|
-
end
|
|
196
|
-
|
|
197
96
|
# RehearsalResult represents error result of rehearsal test.
|
|
198
97
|
class RehearsalResult < StructX
|
|
199
98
|
member :key
|
|
@@ -215,17 +114,23 @@ module Pione
|
|
|
215
114
|
include SimpleIdentity
|
|
216
115
|
|
|
217
116
|
attr_reader :location
|
|
117
|
+
attr_reader :package_path
|
|
218
118
|
attr_reader :info
|
|
219
119
|
|
|
220
120
|
forward_as_key :@info, "ScenarioName", :name
|
|
121
|
+
forward_as_key :@info, "Edition", :edition
|
|
122
|
+
forward_as_key :@info, "Version", :version
|
|
123
|
+
forward_as_key :@info, "Date", :date
|
|
221
124
|
|
|
222
125
|
# @param location [BasicLocation]
|
|
223
126
|
# scenario location
|
|
224
127
|
# @param info [Hash]
|
|
225
128
|
# scenario information table
|
|
226
|
-
def initialize(location, info)
|
|
129
|
+
def initialize(location, package_path, info)
|
|
227
130
|
@location = location
|
|
131
|
+
@package_path = package_path
|
|
228
132
|
@info = info
|
|
133
|
+
@package_path = package_path
|
|
229
134
|
end
|
|
230
135
|
|
|
231
136
|
# Return the input location. If the scenario doesn't have input location,
|
|
@@ -234,16 +139,40 @@ module Pione
|
|
|
234
139
|
# @return [BasicLocation]
|
|
235
140
|
# the input location
|
|
236
141
|
def input
|
|
237
|
-
input_location = @location + "input"
|
|
142
|
+
input_location = @location + @package_path + "input"
|
|
238
143
|
input_location if input_location.exist?
|
|
239
144
|
end
|
|
240
145
|
|
|
146
|
+
# Return input file locations.
|
|
147
|
+
#
|
|
148
|
+
# @return [BasicLocation]
|
|
149
|
+
# input file locations
|
|
150
|
+
def inputs
|
|
151
|
+
if info.has_key?("Inputs")
|
|
152
|
+
info["Inputs"].map {|name| @location + @package_path + "input" + name}
|
|
153
|
+
else
|
|
154
|
+
[]
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
241
158
|
# Return the output location.
|
|
242
159
|
#
|
|
243
160
|
# @return [BasicLocation]
|
|
244
161
|
# the output location
|
|
245
162
|
def output
|
|
246
|
-
@location + "output"
|
|
163
|
+
@location + @package_path + "output"
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# Return output file locations.
|
|
167
|
+
#
|
|
168
|
+
# @return [BasicLocation]
|
|
169
|
+
# output file locations
|
|
170
|
+
def outputs
|
|
171
|
+
if info.has_key?("Outputs")
|
|
172
|
+
info["Outputs"].map {|name| @location + @package_path + "output" + name}
|
|
173
|
+
else
|
|
174
|
+
[]
|
|
175
|
+
end
|
|
247
176
|
end
|
|
248
177
|
|
|
249
178
|
# Validate reheasal results.
|
|
@@ -265,47 +194,6 @@ module Pione
|
|
|
265
194
|
return errors
|
|
266
195
|
end
|
|
267
196
|
end
|
|
268
|
-
|
|
269
|
-
# PackageScenarioReader is a reader for loading scenarios.
|
|
270
|
-
class PackageScenarioReader
|
|
271
|
-
def self.read(location)
|
|
272
|
-
new(location).read
|
|
273
|
-
end
|
|
274
|
-
|
|
275
|
-
# @param location [Location]
|
|
276
|
-
# the scenario location
|
|
277
|
-
def initialize(location)
|
|
278
|
-
@location = location
|
|
279
|
-
end
|
|
280
|
-
|
|
281
|
-
# Read scenario files.
|
|
282
|
-
#
|
|
283
|
-
# @return [PackageScenario]
|
|
284
|
-
# the scenario
|
|
285
|
-
def read
|
|
286
|
-
begin
|
|
287
|
-
info = read_scenario_informations
|
|
288
|
-
PackageScenario.new(@location, info)
|
|
289
|
-
rescue
|
|
290
|
-
nil
|
|
291
|
-
end
|
|
292
|
-
end
|
|
293
|
-
|
|
294
|
-
private
|
|
295
|
-
|
|
296
|
-
# Read scenario information table.
|
|
297
|
-
#
|
|
298
|
-
# @return [Hash]
|
|
299
|
-
# scenario information table
|
|
300
|
-
def read_scenario_informations
|
|
301
|
-
path = @location + "scenario.yml"
|
|
302
|
-
if path.exist?
|
|
303
|
-
YAML.load(path.read)
|
|
304
|
-
else
|
|
305
|
-
{"ScenarioName" => @location.basename}
|
|
306
|
-
end
|
|
307
|
-
end
|
|
308
|
-
end
|
|
309
197
|
end
|
|
310
198
|
end
|
|
311
199
|
|
data/lib/pione/front.rb
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module Pione
|
|
2
|
+
# Front is a namespace for process fronts.
|
|
3
|
+
module Front; end
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
require 'pione/front/basic-front'
|
|
7
|
+
require 'pione/front/task-worker-owner'
|
|
8
|
+
require 'pione/front/tuple-space-provider-owner'
|
|
9
|
+
require 'pione/front/client-front'
|
|
10
|
+
require 'pione/front/broker-front'
|
|
11
|
+
require 'pione/front/task-worker-front'
|
|
12
|
+
require 'pione/front/tuple-space-provider-front'
|
|
13
|
+
require 'pione/front/tuple-space-receiver-front'
|
|
14
|
+
require 'pione/front/relay-front'
|
data/lib/pione/location.rb
CHANGED
|
@@ -3,8 +3,13 @@ module Pione
|
|
|
3
3
|
module Location; end
|
|
4
4
|
end
|
|
5
5
|
|
|
6
|
+
require 'pione/location/exception.rb'
|
|
6
7
|
require 'pione/location/basic-location'
|
|
8
|
+
require 'pione/location/data-location'
|
|
7
9
|
require 'pione/location/local-location'
|
|
8
10
|
require 'pione/location/ftp-location'
|
|
11
|
+
require 'pione/location/http-location'
|
|
12
|
+
require 'pione/location/https-location'
|
|
9
13
|
require 'pione/location/dropbox-location'
|
|
14
|
+
require 'pione/location/git-repository-location'
|
|
10
15
|
|
|
@@ -1,314 +1,87 @@
|
|
|
1
1
|
module Pione
|
|
2
2
|
module Location
|
|
3
|
-
#
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
# known schemes table
|
|
4
|
+
SCHEMES = {}
|
|
5
|
+
|
|
6
|
+
class << self
|
|
7
|
+
# Return the location object corresponding to the address.
|
|
8
|
+
#
|
|
9
|
+
# @param address [URI,String]
|
|
10
|
+
# URI or location address
|
|
11
|
+
# @return [BasicLocation]
|
|
12
|
+
# location object
|
|
13
|
+
def [](address)
|
|
14
|
+
if address.kind_of?(Hash)
|
|
15
|
+
return create_git_repository_location(address) if address[:git]
|
|
16
|
+
return create_data_location(address[:data]) if address[:data]
|
|
17
|
+
else
|
|
18
|
+
return create_data_location(address)
|
|
19
|
+
end
|
|
7
20
|
end
|
|
8
|
-
end
|
|
9
21
|
|
|
10
|
-
|
|
11
|
-
class ExistAlready < LocationError; end
|
|
22
|
+
private
|
|
12
23
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
24
|
+
# Return the resource location.
|
|
25
|
+
def create_data_location(address)
|
|
26
|
+
uri = URI.parse(address.to_s)
|
|
27
|
+
uri = uri.scheme ? uri : URI.parse("local:%s" % Pathname.new(uri.path).expand_path)
|
|
28
|
+
if location_class = SCHEMES[uri.scheme]
|
|
29
|
+
location_class.new(uri)
|
|
30
|
+
else
|
|
31
|
+
raise ArgumentError.new(uri)
|
|
32
|
+
end
|
|
17
33
|
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
# known schemes table
|
|
21
|
-
SCHEMES = {}
|
|
22
34
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
# URI or location representing string
|
|
27
|
-
# @return [BasicLocation]
|
|
28
|
-
# location object
|
|
29
|
-
def self.[](uri)
|
|
30
|
-
uri = URI.parse(uri.to_s)
|
|
31
|
-
uri = uri.scheme ? uri : URI.parse("local:%s" % Pathname.new(uri.path).expand_path)
|
|
32
|
-
if location_class = SCHEMES[uri.scheme]
|
|
33
|
-
location_class.new(uri)
|
|
34
|
-
else
|
|
35
|
-
raise ArgumentError.new(uri)
|
|
35
|
+
# Return the git repository location.
|
|
36
|
+
def create_git_repository_location(address)
|
|
37
|
+
GitRepositoryLocation.new(address)
|
|
36
38
|
end
|
|
37
39
|
end
|
|
38
40
|
|
|
39
41
|
# BasicLocation is a class for all location classes.
|
|
40
42
|
class BasicLocation
|
|
41
43
|
class << self
|
|
42
|
-
#
|
|
43
|
-
# location's scheme name
|
|
44
|
-
attr_reader :scheme
|
|
45
|
-
|
|
46
|
-
# Declare the name as location scheme.
|
|
44
|
+
# Set location type.
|
|
47
45
|
#
|
|
48
|
-
# @param name [
|
|
49
|
-
#
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def real_appendable?
|
|
60
|
-
@appendable
|
|
46
|
+
# @param name [Symbol]
|
|
47
|
+
# location type name
|
|
48
|
+
# @return [void]
|
|
49
|
+
def location_type(name=nil)
|
|
50
|
+
if name
|
|
51
|
+
@location_type = name
|
|
52
|
+
else
|
|
53
|
+
@location_type ? @location_type : superclass.location_type
|
|
54
|
+
end
|
|
61
55
|
end
|
|
62
56
|
end
|
|
63
57
|
|
|
64
|
-
forward
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
# @return [URI]
|
|
68
|
-
# URI of the location
|
|
69
|
-
attr_reader :uri
|
|
70
|
-
|
|
71
|
-
# @return [Pathname]
|
|
72
|
-
# path of the location
|
|
73
|
-
attr_reader :path
|
|
58
|
+
forward :class, :location_type
|
|
59
|
+
attr_reader :address
|
|
74
60
|
|
|
75
61
|
# Create a location with the URI.
|
|
76
62
|
#
|
|
77
63
|
# @param uri [URI]
|
|
78
64
|
# location URI
|
|
79
|
-
def initialize(
|
|
80
|
-
@
|
|
81
|
-
@path = Pathname.new(uri.path)
|
|
82
|
-
raise ArgumentError.new(uri) unless @uri.scheme = scheme
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
# Create new location appended the name.
|
|
86
|
-
#
|
|
87
|
-
# @param name [String]
|
|
88
|
-
# filename or directory name
|
|
89
|
-
# @return [BasicLocation]
|
|
90
|
-
# new location
|
|
91
|
-
def +(name)
|
|
92
|
-
self.class.new(@uri.as_directory + name.to_s)
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
# Create new location that has URI as a directory.
|
|
96
|
-
#
|
|
97
|
-
# @return [BasicLocation]
|
|
98
|
-
# new location
|
|
99
|
-
def as_directory
|
|
100
|
-
self.class.new(@uri.as_directory)
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
# Return the basename of the location.
|
|
104
|
-
#
|
|
105
|
-
# @param suffix [String]
|
|
106
|
-
# suffix name
|
|
107
|
-
# @return [String]
|
|
108
|
-
# basename
|
|
109
|
-
def basename(suffix="")
|
|
110
|
-
File.basename(@path, suffix)
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
# Rebuild location with the path.
|
|
114
|
-
#
|
|
115
|
-
# @param path [Pathname]
|
|
116
|
-
# new path
|
|
117
|
-
# @return [Location]
|
|
118
|
-
# location with new path
|
|
119
|
-
def rebuild(path)
|
|
120
|
-
scheme = @uri.scheme
|
|
121
|
-
auth = "%s:%s@" % [@uri.user, @uri.password] if @uri.user and @uri.password
|
|
122
|
-
host = @uri.host
|
|
123
|
-
port = ":%i" % @uri.port
|
|
124
|
-
path = path.expand_path("/").to_s
|
|
125
|
-
Location["%s://%s%s%s%s" % [scheme, auth, host, port, path]]
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
# Return true if the location is cached.
|
|
129
|
-
#
|
|
130
|
-
# @return [Boolean]
|
|
131
|
-
# true if the location is cached
|
|
132
|
-
def cached?
|
|
133
|
-
System::FileCache.cached?(self)
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
# Write a data into the location.
|
|
137
|
-
#
|
|
138
|
-
# @param data [String]
|
|
139
|
-
# data content
|
|
140
|
-
# @return [void]
|
|
141
|
-
def write(data)
|
|
142
|
-
if exist?
|
|
143
|
-
update(data)
|
|
144
|
-
else
|
|
145
|
-
create(data)
|
|
146
|
-
end
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
# Creates a file at the location. If a file exists at the location aleady,
|
|
150
|
-
# it raises an exception.
|
|
151
|
-
#
|
|
152
|
-
# @param data [String]
|
|
153
|
-
# data content
|
|
154
|
-
# @return [void]
|
|
155
|
-
def create(data)
|
|
156
|
-
raise NotImplementedError
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
# Append data to the location data.
|
|
160
|
-
#
|
|
161
|
-
# @param data [String]
|
|
162
|
-
# data content
|
|
163
|
-
# @return [void]
|
|
164
|
-
def append(data)
|
|
165
|
-
raise NotImplmentedError
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
# Read location data.
|
|
169
|
-
#
|
|
170
|
-
# @return [String]
|
|
171
|
-
# data content
|
|
172
|
-
def read
|
|
173
|
-
raise NotImplementedError
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
# Update with the data.
|
|
177
|
-
#
|
|
178
|
-
# @param data [String]
|
|
179
|
-
# new data content
|
|
180
|
-
# @return [void]
|
|
181
|
-
def update(data)
|
|
182
|
-
raise NotImplementedError
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
# Delete data of the location.
|
|
186
|
-
#
|
|
187
|
-
# @return [void]
|
|
188
|
-
def delete
|
|
189
|
-
raise NotImplementedError
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
# Return last modification time of the location.
|
|
193
|
-
#
|
|
194
|
-
# @return [Time]
|
|
195
|
-
# last modification time
|
|
196
|
-
def mtime
|
|
197
|
-
raise NotImplementedError
|
|
198
|
-
end
|
|
199
|
-
|
|
200
|
-
# Return byte size of data in the location.
|
|
201
|
-
#
|
|
202
|
-
# @return [Integer]
|
|
203
|
-
# byte size of data
|
|
204
|
-
def size
|
|
205
|
-
raise NotImplementedError
|
|
206
|
-
end
|
|
207
|
-
|
|
208
|
-
# Return entries of the location.
|
|
209
|
-
#
|
|
210
|
-
# @return [Array<Location>]
|
|
211
|
-
# entries of the location
|
|
212
|
-
def entries
|
|
213
|
-
raise NotImplementedError
|
|
214
|
-
end
|
|
215
|
-
|
|
216
|
-
# Return file entries of the location.
|
|
217
|
-
#
|
|
218
|
-
# @return [Array<Location>]
|
|
219
|
-
# file entries of the location
|
|
220
|
-
def file_entries
|
|
221
|
-
entries.select{|entry| entry.file?}
|
|
222
|
-
end
|
|
223
|
-
|
|
224
|
-
# Return directory entries of the location.
|
|
225
|
-
#
|
|
226
|
-
# @return [Array<Location>]
|
|
227
|
-
# directory entries of the location
|
|
228
|
-
def directory_entries
|
|
229
|
-
entries.select do |entry|
|
|
230
|
-
entry.directory? and not(entry.path.basename == "." or entry.path.basename == "..")
|
|
231
|
-
end
|
|
232
|
-
end
|
|
233
|
-
|
|
234
|
-
# Return true if there is data in the location.
|
|
235
|
-
#
|
|
236
|
-
# @return [Boolean]
|
|
237
|
-
# if there is data in the location
|
|
238
|
-
def exist?
|
|
239
|
-
raise NotImplementedError
|
|
240
|
-
end
|
|
241
|
-
|
|
242
|
-
# Return true if data in the location is a file.
|
|
243
|
-
#
|
|
244
|
-
# @return [Boolean]
|
|
245
|
-
# true if data in the location is a file
|
|
246
|
-
def file?
|
|
247
|
-
raise NotImplementedError
|
|
248
|
-
end
|
|
249
|
-
|
|
250
|
-
# Return true if data in the location is a directory.
|
|
251
|
-
#
|
|
252
|
-
# @return [Boolean]
|
|
253
|
-
# true if data in the location is a directory
|
|
254
|
-
def directory?
|
|
255
|
-
raise NotImplementedError
|
|
256
|
-
end
|
|
257
|
-
|
|
258
|
-
# Move to the destination.
|
|
259
|
-
#
|
|
260
|
-
# @param dest [BasicLocation]
|
|
261
|
-
# destination
|
|
262
|
-
# @return [void]
|
|
263
|
-
def move(dest)
|
|
264
|
-
raise NotImplementedError
|
|
265
|
-
end
|
|
266
|
-
|
|
267
|
-
# Copy location's content to the destination.
|
|
268
|
-
#
|
|
269
|
-
# @param dest [BasicLocation]
|
|
270
|
-
# destination
|
|
271
|
-
# @return [void]
|
|
272
|
-
def copy(dest)
|
|
273
|
-
raise NotImplementedError
|
|
274
|
-
end
|
|
275
|
-
|
|
276
|
-
# Link to the destination. If the location scheme is same to destination,
|
|
277
|
-
# create link by a symbolic link or lightweight copy method. If not, copy
|
|
278
|
-
# it simply.
|
|
279
|
-
#
|
|
280
|
-
# @param dest [BasicLocation]
|
|
281
|
-
# destination
|
|
282
|
-
# @return [void]
|
|
283
|
-
def link(dest)
|
|
284
|
-
raise NotImplementedError
|
|
285
|
-
end
|
|
286
|
-
|
|
287
|
-
# Move data to the destination and link self to it.
|
|
288
|
-
#
|
|
289
|
-
# @param dest [BasicLocation]
|
|
290
|
-
# destination
|
|
291
|
-
# @return [void]
|
|
292
|
-
def turn(dest)
|
|
293
|
-
raise NotImplementedError
|
|
65
|
+
def initialize(address)
|
|
66
|
+
@address = address
|
|
294
67
|
end
|
|
295
68
|
|
|
296
69
|
# @api private
|
|
297
70
|
def inspect
|
|
298
|
-
"#<%s %s
|
|
71
|
+
"#<%s %s>" % [self.class, address]
|
|
299
72
|
end
|
|
300
73
|
alias :to_s :inspect
|
|
301
74
|
|
|
302
75
|
# @api private
|
|
303
76
|
def ==(other)
|
|
304
77
|
return false unless other.kind_of?(self.class)
|
|
305
|
-
@
|
|
78
|
+
@address == other.address
|
|
306
79
|
end
|
|
307
80
|
alias :eql? :"=="
|
|
308
81
|
|
|
309
82
|
# @api private
|
|
310
83
|
def hash
|
|
311
|
-
@
|
|
84
|
+
@address.hash
|
|
312
85
|
end
|
|
313
86
|
end
|
|
314
87
|
end
|