pione 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) hide show
  1. data/.gitignore +16 -13
  2. data/.travis.yml +1 -1
  3. data/History.txt +11 -0
  4. data/Rakefile +13 -0
  5. data/bin/pione-package +5 -0
  6. data/example/AbstractRule/package.yml +6 -0
  7. data/example/AbstractRule/scenario/a/output/message.txt +1 -0
  8. data/example/AbstractRule/scenario/a/scenario.yml +4 -0
  9. data/example/AbstractRule/scenario/b/output/message.txt +1 -0
  10. data/example/AbstractRule/scenario/b/scenario.yml +4 -0
  11. data/example/AbstractRule/scenario/c/output/message.txt +1 -0
  12. data/example/AbstractRule/scenario/c/scenario.yml +4 -0
  13. data/example/HelloWorld/package.yml +5 -1
  14. data/example/HelloWorld/scenario/scenario.yml +2 -1
  15. data/example/LoopByTouch/package.yml +4 -1
  16. data/example/MakePair/package.yml +6 -0
  17. data/example/MakePair/scenario/{input → case1/input}/1.i +0 -0
  18. data/example/MakePair/scenario/{input → case1/input}/2.i +0 -0
  19. data/example/MakePair/scenario/{input → case1/input}/3.i +0 -0
  20. data/example/MakePair/scenario/{input → case1/input}/4.i +0 -0
  21. data/example/MakePair/scenario/{input → case1/input}/5.i +0 -0
  22. data/example/MakePair/scenario/{output → case1/output}/comb-1-2.pair +0 -0
  23. data/example/MakePair/scenario/{output → case1/output}/comb-1-3.pair +0 -0
  24. data/example/MakePair/scenario/{output → case1/output}/comb-1-4.pair +0 -0
  25. data/example/MakePair/scenario/{output → case1/output}/comb-1-5.pair +0 -0
  26. data/example/MakePair/scenario/{output → case1/output}/comb-2-3.pair +0 -0
  27. data/example/MakePair/scenario/{output → case1/output}/comb-2-4.pair +0 -0
  28. data/example/MakePair/scenario/{output → case1/output}/comb-2-5.pair +0 -0
  29. data/example/MakePair/scenario/{output → case1/output}/comb-3-4.pair +0 -0
  30. data/example/MakePair/scenario/{output → case1/output}/comb-3-5.pair +0 -0
  31. data/example/MakePair/scenario/{output → case1/output}/comb-4-5.pair +0 -0
  32. data/example/MakePair/scenario/{output → case1/output}/perm-1-2.pair +0 -0
  33. data/example/MakePair/scenario/{output → case1/output}/perm-1-3.pair +0 -0
  34. data/example/MakePair/scenario/{output → case1/output}/perm-1-4.pair +0 -0
  35. data/example/MakePair/scenario/{output → case1/output}/perm-1-5.pair +0 -0
  36. data/example/MakePair/scenario/{output → case1/output}/perm-2-1.pair +0 -0
  37. data/example/MakePair/scenario/{output → case1/output}/perm-2-3.pair +0 -0
  38. data/example/MakePair/scenario/{output → case1/output}/perm-2-4.pair +0 -0
  39. data/example/MakePair/scenario/{output → case1/output}/perm-2-5.pair +0 -0
  40. data/example/MakePair/scenario/{output → case1/output}/perm-3-1.pair +0 -0
  41. data/example/MakePair/scenario/{output → case1/output}/perm-3-2.pair +0 -0
  42. data/example/MakePair/scenario/{output → case1/output}/perm-3-4.pair +0 -0
  43. data/example/MakePair/scenario/{output → case1/output}/perm-3-5.pair +0 -0
  44. data/example/MakePair/scenario/{output → case1/output}/perm-4-1.pair +0 -0
  45. data/example/MakePair/scenario/{output → case1/output}/perm-4-2.pair +0 -0
  46. data/example/MakePair/scenario/{output → case1/output}/perm-4-3.pair +0 -0
  47. data/example/MakePair/scenario/{output → case1/output}/perm-4-5.pair +0 -0
  48. data/example/MakePair/scenario/{output → case1/output}/perm-5-1.pair +0 -0
  49. data/example/MakePair/scenario/{output → case1/output}/perm-5-2.pair +0 -0
  50. data/example/MakePair/scenario/{output → case1/output}/perm-5-3.pair +0 -0
  51. data/example/MakePair/scenario/{output → case1/output}/perm-5-4.pair +0 -0
  52. data/example/MakePair/scenario/{output → case1/output}/succ-1-2.pair +0 -0
  53. data/example/MakePair/scenario/{output → case1/output}/succ-2-3.pair +0 -0
  54. data/example/MakePair/scenario/{output → case1/output}/succ-3-4.pair +0 -0
  55. data/example/MakePair/scenario/{output → case1/output}/succ-4-5.pair +0 -0
  56. data/example/MakePair/scenario/case1/scenario.yml +42 -0
  57. data/example/MakePair/scenario/case2/input/10.i +0 -0
  58. data/example/MakePair/scenario/case2/input/11.i +0 -0
  59. data/example/MakePair/scenario/case2/input/9.i +0 -0
  60. data/example/MakePair/scenario/case2/output/comb-10-11.pair +0 -0
  61. data/example/MakePair/scenario/case2/output/comb-9-10.pair +0 -0
  62. data/example/MakePair/scenario/case2/output/comb-9-11.pair +0 -0
  63. data/example/MakePair/scenario/case2/output/perm-10-11.pair +0 -0
  64. data/example/MakePair/scenario/case2/output/perm-10-9.pair +0 -0
  65. data/example/MakePair/scenario/case2/output/perm-11-10.pair +0 -0
  66. data/example/MakePair/scenario/case2/output/perm-11-9.pair +0 -0
  67. data/example/MakePair/scenario/case2/output/perm-9-10.pair +0 -0
  68. data/example/MakePair/scenario/case2/output/perm-9-11.pair +0 -0
  69. data/example/MakePair/scenario/case2/output/succ-10-11.pair +0 -0
  70. data/example/MakePair/scenario/case2/output/succ-9-10.pair +0 -0
  71. data/example/MakePair/scenario/case2/scenario.yml +17 -0
  72. data/example/MakePair/scenario/case3/input/1.i +0 -0
  73. data/example/MakePair/scenario/case3/input/3.i +0 -0
  74. data/example/MakePair/scenario/case3/input/5.i +0 -0
  75. data/example/MakePair/scenario/case3/input/7.i +0 -0
  76. data/example/MakePair/scenario/case3/input/9.i +0 -0
  77. data/example/MakePair/scenario/case3/output/comb-1-3.pair +0 -0
  78. data/example/MakePair/scenario/case3/output/comb-1-5.pair +0 -0
  79. data/example/MakePair/scenario/case3/output/comb-1-7.pair +0 -0
  80. data/example/MakePair/scenario/case3/output/comb-1-9.pair +0 -0
  81. data/example/MakePair/scenario/case3/output/comb-3-5.pair +0 -0
  82. data/example/MakePair/scenario/case3/output/comb-3-7.pair +0 -0
  83. data/example/MakePair/scenario/case3/output/comb-3-9.pair +0 -0
  84. data/example/MakePair/scenario/case3/output/comb-5-7.pair +0 -0
  85. data/example/MakePair/scenario/case3/output/comb-5-9.pair +0 -0
  86. data/example/MakePair/scenario/case3/output/comb-7-9.pair +0 -0
  87. data/example/MakePair/scenario/case3/output/perm-1-3.pair +0 -0
  88. data/example/MakePair/scenario/case3/output/perm-1-5.pair +0 -0
  89. data/example/MakePair/scenario/case3/output/perm-1-7.pair +0 -0
  90. data/example/MakePair/scenario/case3/output/perm-1-9.pair +0 -0
  91. data/example/MakePair/scenario/case3/output/perm-3-1.pair +0 -0
  92. data/example/MakePair/scenario/case3/output/perm-3-5.pair +0 -0
  93. data/example/MakePair/scenario/case3/output/perm-3-7.pair +0 -0
  94. data/example/MakePair/scenario/case3/output/perm-3-9.pair +0 -0
  95. data/example/MakePair/scenario/case3/output/perm-5-1.pair +0 -0
  96. data/example/MakePair/scenario/case3/output/perm-5-3.pair +0 -0
  97. data/example/MakePair/scenario/case3/output/perm-5-7.pair +0 -0
  98. data/example/MakePair/scenario/case3/output/perm-5-9.pair +0 -0
  99. data/example/MakePair/scenario/case3/output/perm-7-1.pair +0 -0
  100. data/example/MakePair/scenario/case3/output/perm-7-3.pair +0 -0
  101. data/example/MakePair/scenario/case3/output/perm-7-5.pair +0 -0
  102. data/example/MakePair/scenario/case3/output/perm-7-9.pair +0 -0
  103. data/example/MakePair/scenario/case3/output/perm-9-1.pair +0 -0
  104. data/example/MakePair/scenario/case3/output/perm-9-3.pair +0 -0
  105. data/example/MakePair/scenario/case3/output/perm-9-5.pair +0 -0
  106. data/example/MakePair/scenario/case3/output/perm-9-7.pair +0 -0
  107. data/example/MakePair/scenario/case3/scenario.yml +39 -0
  108. data/example/PegasusWMS/Merge/Merge.pione +21 -0
  109. data/example/PegasusWMS/Merge/package.yml +2 -0
  110. data/example/PegasusWMS/Pipeline/Pipeline.pione +20 -0
  111. data/example/PegasusWMS/Pipeline/package.yml +2 -0
  112. data/example/PegasusWMS/Split/Split.pione +27 -0
  113. data/example/PegasusWMS/Split/package.yml +2 -0
  114. data/example/ScoreAggregation/package.yml +4 -0
  115. data/example/ScoreAggregation/scenario/case1/scenario.yml +27 -1
  116. data/example/SerialProcessing/package.yml +5 -1
  117. data/example/SerialProcessing/scenario/scenario.yml +10 -0
  118. data/lib/pione.rb +20 -71
  119. data/lib/pione/agent.rb +17 -0
  120. data/lib/pione/agent/basic-agent.rb +2 -4
  121. data/lib/pione/command.rb +1 -0
  122. data/lib/pione/command/option.rb +4 -1
  123. data/lib/pione/command/pione-package.rb +97 -0
  124. data/lib/pione/command/pione-task-worker.rb +11 -7
  125. data/lib/pione/component.rb +5 -0
  126. data/lib/pione/component/document.rb +22 -5
  127. data/lib/pione/component/package-archiver.rb +92 -0
  128. data/lib/pione/component/package-expander.rb +37 -0
  129. data/lib/pione/component/package-filename.rb +38 -0
  130. data/lib/pione/component/package-reader.rb +276 -0
  131. data/lib/pione/component/package.rb +50 -162
  132. data/lib/pione/front.rb +14 -0
  133. data/lib/pione/location.rb +5 -0
  134. data/lib/pione/location/basic-location.rb +47 -274
  135. data/lib/pione/location/data-location.rb +328 -0
  136. data/lib/pione/location/dropbox-location.rb +30 -7
  137. data/lib/pione/location/exception.rb +38 -0
  138. data/lib/pione/location/ftp-location.rb +24 -13
  139. data/lib/pione/location/git-repository-location.rb +153 -0
  140. data/lib/pione/location/http-location.rb +65 -0
  141. data/lib/pione/location/https-location.rb +37 -0
  142. data/lib/pione/location/local-location.rb +24 -5
  143. data/lib/pione/parser.rb +14 -0
  144. data/lib/pione/patch.rb +10 -0
  145. data/lib/pione/patch/drb-patch.rb +2 -2
  146. data/lib/pione/relay.rb +11 -0
  147. data/lib/pione/system/file-cache.rb +1 -1
  148. data/lib/pione/system/global.rb +15 -0
  149. data/lib/pione/tuple-space.rb +11 -0
  150. data/lib/pione/tuple-space/tuple-space-server.rb +1 -1
  151. data/lib/pione/util.rb +1 -0
  152. data/lib/pione/util/error-report.rb +7 -0
  153. data/lib/pione/util/misc.rb +2 -2
  154. data/lib/pione/util/zip.rb +60 -0
  155. data/lib/pione/version.rb +1 -1
  156. data/pione.gemspec +5 -1
  157. data/test/agent/spec_rule-provider.rb +2 -2
  158. data/test/command/spec_pione-package.rb +15 -0
  159. data/test/component/spec_document.rb +2 -2
  160. data/test/component/spec_package-archiver.rb +27 -0
  161. data/test/component/spec_package-expander.rb +11 -0
  162. data/test/component/spec_package-filename.rb +79 -0
  163. data/test/component/spec_package-reader.rb +100 -0
  164. data/test/component/spec_package.rb +50 -33
  165. data/test/location/http-behavior.rb +59 -0
  166. data/test/location/location-behavior.rb +8 -0
  167. data/test/location/spec_basic-location.rb +5 -1
  168. data/test/location/spec_git-repository-location.rb +143 -0
  169. data/test/location/spec_http-location.rb +28 -0
  170. data/test/location/spec_http-location/a.txt +1 -0
  171. data/test/location/spec_http-location/b.txt +1 -0
  172. data/test/location/spec_http-location/c.txt +1 -0
  173. data/test/location/spec_http-location/dir/d.txt +1 -0
  174. data/test/location/spec_https-location.rb +37 -0
  175. data/test/rule-handler/spec_flow-handler.rb +1 -1
  176. data/test/rule-handler/spec_update-criteria.rb +1 -1
  177. data/test/test-data/package/HelloWorld+v0.1.0.ppg +0 -0
  178. data/test/test-data/package/HelloWorld-gitrepos.zip +0 -0
  179. data/test/test-data/package/HelloWorld/HelloWorld.pione +5 -0
  180. data/test/test-data/package/HelloWorld/package.yml +6 -0
  181. data/test/test-data/package/HelloWorld/scenario/output/message.txt +1 -0
  182. data/test/test-data/package/HelloWorld/scenario/scenario.yml +3 -0
  183. data/test/test-data/package/TestPackage1+v0.1.0.ppg +0 -0
  184. data/test/{component/spec_package/TestPackage → test-data/package/TestPackage1}/Test.pione +3 -1
  185. data/test/test-data/package/TestPackage1/bin/count +11 -0
  186. data/test/test-data/package/TestPackage1/package.yml +9 -0
  187. data/test/{component/spec_package/TestPackage → test-data/package/TestPackage1}/scenario/case1/input/1.txt +0 -0
  188. data/test/test-data/package/TestPackage1/scenario/case1/output/1.count +1 -0
  189. data/test/test-data/package/TestPackage1/scenario/case1/scenario.yml +6 -0
  190. data/test/test-data/package/TestPackage1/scenario/case2/input/1.txt +2 -0
  191. data/test/test-data/package/TestPackage1/scenario/case2/input/2.txt +1 -0
  192. data/test/test-data/package/TestPackage1/scenario/case2/input/3.txt +3 -0
  193. data/test/test-data/package/TestPackage1/scenario/case2/output/1.count +1 -0
  194. data/test/test-data/package/TestPackage1/scenario/case2/output/2.count +1 -0
  195. data/test/test-data/package/TestPackage1/scenario/case2/output/3.count +1 -0
  196. data/test/test-data/package/TestPackage1/scenario/case2/scenario.yml +10 -0
  197. data/test/test-data/package/TestPackage1/scenario/case3/input/a.txt +1 -0
  198. data/test/test-data/package/TestPackage1/scenario/case3/input/b.txt +1 -0
  199. data/test/test-data/package/TestPackage1/scenario/case3/output/a.count +1 -0
  200. data/test/test-data/package/TestPackage1/scenario/case3/output/b.count +1 -0
  201. data/test/test-data/package/TestPackage1/scenario/case3/scenario.yml +8 -0
  202. data/test/test-util.rb +10 -146
  203. data/test/test-util/command.rb +53 -0
  204. data/test/test-util/package.rb +9 -0
  205. data/test/test-util/parser.rb +45 -0
  206. data/test/test-util/transformer.rb +50 -0
  207. data/test/test-util/webserver.rb +43 -0
  208. data/test/util/spec_error-report.rb +12 -3
  209. data/test/util/spec_zip.rb +36 -0
  210. metadata +282 -54
  211. data/example/MakePair/scenario/scenario.yml +0 -1
  212. data/test/component/spec_package/TestPackage/bin/count +0 -3
  213. data/test/component/spec_package/TestPackage/package.yml +0 -7
  214. data/test/component/spec_package/TestPackage/scenario/case1/scenario.yml +0 -1
@@ -0,0 +1,153 @@
1
+ module Pione
2
+ module Location
3
+ # GitRepositoryLocation represents locations of git repository.
4
+ class GitRepositoryLocation < BasicLocation
5
+ location_type :git_repository
6
+
7
+ attr_reader :tag
8
+
9
+ def initialize(address)
10
+ @address = address[:git].to_s
11
+ @tag = address[:tag].to_s
12
+ @branch = address[:branch].to_s
13
+ @hash_id = address[:hash_id].to_s
14
+ @address_digest = Digest::SHA1.hexdigest(@address)
15
+ end
16
+
17
+ # Return a new location with the option.
18
+ def +(option)
19
+ self.class.new({git: @address, tag: @tag, branch: @branch, hash_id: @hash_id}.merge(option))
20
+ end
21
+
22
+ # Return the local location of repository.
23
+ def local
24
+ Global.git_repository_directory + @address_digest
25
+ end
26
+
27
+ # Return true if the local location exists.
28
+ def has_local?
29
+ local.exist?
30
+ end
31
+
32
+ # Return a hash id string of the referrence name.
33
+ def ref(query)
34
+ clone_to_local unless has_local?
35
+
36
+ # parse query
37
+ type = query.keys.first
38
+ name = query[type]
39
+
40
+ # execute "git show-ref"
41
+ out = Temppath.create.open("w+")
42
+ process = ChildProcess.build("git", "show-ref")
43
+ process.cwd = local.path.to_s
44
+ process.io.stdout = out
45
+ process.start
46
+ process.wait
47
+
48
+ if process.crashed?
49
+ raise GitError.new("The command 'git clone' failed.", @address)
50
+ end
51
+
52
+ # find hash id
53
+ out.rewind
54
+ out.readlines.each do |line|
55
+ hash_id, refname = line.split(" ")
56
+
57
+ cond_tag = (type == :tag and "refs/tags/%s" % name == refname)
58
+ cond_branch = (type == :branch and "refs/remotes/origin/%s" % name == refname)
59
+
60
+ return hash_id if cond_tag or cond_branch
61
+ end
62
+
63
+ # the name not found
64
+ return nil
65
+ end
66
+
67
+ # Return compact version hash id string.
68
+ def compact_hash_id
69
+ id = @hash_id if @hash_id
70
+ id = ref(tag: @tag) if @tag
71
+ id = ref(branch: @branch) if @branch
72
+ id = ref(branch: "HEAD") unless id
73
+ return short_hash_id(id)
74
+ end
75
+
76
+ # Export git repository by hash id.
77
+ def export(location)
78
+ clone_to_local unless has_local?
79
+
80
+ hash_id = compact_hash_id
81
+
82
+ # git archive
83
+ path = Temppath.mkdir + "archive.zip"
84
+ ChildProcess.build("git", "archive", "-o", path.to_s, hash_id).tap do |process|
85
+ process.cwd = local.path
86
+ process.start
87
+ process.wait
88
+ if process.crashed?
89
+ raise GitError.new(@location, message: "'git archive' failed")
90
+ end
91
+ end
92
+
93
+ # unzip
94
+ local = Location[Temppath.mkdir]
95
+ Util::Zip.uncompress(Location[path], local)
96
+
97
+ # update package.yml
98
+ info = YAML.load((local + "package.yml").read)
99
+ info["HashID"] = hash_id
100
+ (local + "package.yml").update(YAML.dump(info))
101
+
102
+ # upload
103
+ local.entries.each {|entry| entry.move(location)}
104
+ end
105
+
106
+ private
107
+
108
+ # Call "git clone" from the repository into local location.
109
+ #
110
+ # @param path [Pathname]
111
+ # the path of cloned repository
112
+ def clone_to_local
113
+ out = Temppath.create.open("w+")
114
+
115
+ # call git clone
116
+ process = ChildProcess.build("git", "clone", @address, local.path.to_s)
117
+ process.io.stdout = out
118
+ process.start
119
+ process.wait
120
+
121
+ # show debug message
122
+ out.rewind
123
+ ErrorReport.debug("git clone: %s" % out.read, self, __FILE__, __LINE__)
124
+
125
+ # check the process result
126
+ if process.crashed?
127
+ raise GitError.new(self, message: "'git clone' failed")
128
+ end
129
+ end
130
+
131
+ # Return short hash id.
132
+ def short_hash_id(hash_id)
133
+ out = Temppath.create.open("w+")
134
+
135
+ # git rev-parse
136
+ process = ChildProcess.build("git", "rev-parse", "--short", hash_id)
137
+ process.cwd = local.path.to_s
138
+ process.io.stdout = out
139
+ process.start
140
+ process.wait
141
+
142
+ # check the process result
143
+ if process.crashed?
144
+ raise GitError.new(self, message: "Hash ID '%s' is unknown or too short" % hash_id)
145
+ end
146
+
147
+ # show debug message
148
+ out.rewind
149
+ return out.read.chomp
150
+ end
151
+ end
152
+ end
153
+ end
@@ -0,0 +1,65 @@
1
+ module Pione
2
+ module Location
3
+ class HTTPLocation < DataLocation
4
+ set_scheme "http"
5
+ set_real_appendable false
6
+ set_writable false
7
+
8
+ def read
9
+ http_get {|res| res.body}
10
+ end
11
+
12
+ def mtime
13
+ http_head {|res| Time.httpdate(res['last-modified']) }
14
+ end
15
+
16
+ def size
17
+ http_head {|res| res.content_length } || read.size
18
+ end
19
+
20
+ def exist?
21
+ http_head {|res| true}
22
+ rescue
23
+ false
24
+ end
25
+
26
+ def file?
27
+ exist?
28
+ end
29
+
30
+ def directory?
31
+ false
32
+ end
33
+
34
+ def copy(dest)
35
+ http_get {|rec| dest.write rec.body}
36
+ end
37
+
38
+ private
39
+
40
+ # Send a request HTTP Get and evaluate the block with the response.
41
+ def http_get(&b)
42
+ http = Net::HTTP.new(@uri.host, @uri.port)
43
+ req = Net::HTTP::Get.new(@uri.path)
44
+ res = http.request(req)
45
+ if res.kind_of?(Net::HTTPSuccess)
46
+ return b.call(res)
47
+ else
48
+ raise NotFound.new(@uri)
49
+ end
50
+ end
51
+
52
+ # Send a request HTTP Head and evaluate the block with the response.
53
+ def http_head(&b)
54
+ http = Net::HTTP.new(@uri.host, @uri.port)
55
+ req = Net::HTTP::Head.new(@uri.path)
56
+ res = http.request(req)
57
+ if res.kind_of?(Net::HTTPSuccess)
58
+ return b.call(res)
59
+ else
60
+ raise NotFound(@uri)
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,37 @@
1
+ module Pione
2
+ module Location
3
+ class HTTPSLocation < HTTPLocation
4
+ set_scheme "https"
5
+ set_real_appendable false
6
+ set_writable false
7
+
8
+ # Send a request HTTPS Get and evaluate the block with the response.
9
+ def http_get(&b)
10
+ http = Net::HTTP.new(@uri.host, @uri.port)
11
+ http.use_ssl = true
12
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
13
+ req = Net::HTTP::Get.new(@uri.path)
14
+ res = http.request(req)
15
+ if res.kind_of?(Net::HTTPSuccess)
16
+ return b.call(res)
17
+ else
18
+ raise NotFound.new(@uri)
19
+ end
20
+ end
21
+
22
+ # Send a request HTTPS Head and evaluate the block with the response.
23
+ def http_head(&b)
24
+ http = Net::HTTP.new(@uri.host, @uri.port)
25
+ http.use_ssl = true
26
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
27
+ req = Net::HTTP::Head.new(@uri.path)
28
+ res = http.request(req)
29
+ if res.kind_of?(Net::HTTPSuccess)
30
+ return b.call(res)
31
+ else
32
+ raise NotFound(@uri)
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,7 +1,7 @@
1
1
  module Pione
2
2
  module Location
3
3
  # LocalLocation represents local disk locations.
4
- class LocalLocation < BasicLocation
4
+ class LocalLocation < DataLocation
5
5
  set_scheme "local"
6
6
  set_real_appendable true
7
7
 
@@ -54,6 +54,10 @@ module Pione
54
54
  end
55
55
  end
56
56
 
57
+ def mkdir
58
+ @path.mkpath unless exist?
59
+ end
60
+
57
61
  def mtime
58
62
  @path.exist? ? @path.mtime : (raise NotFound.new(self))
59
63
  end
@@ -62,16 +66,31 @@ module Pione
62
66
  @path.exist? ? @path.size : (raise NotFound.new(self))
63
67
  end
64
68
 
65
- def entries
66
- @path.entries.select do |entry|
67
- not(entry.to_s == "." or entry.to_s == "..")
68
- end.map do |entry|
69
+ def entries(option={})
70
+ rel_entries(option).map do |entry|
69
71
  Location["local:%s" % (@path + entry).expand_path]
70
72
  end
71
73
  rescue Errno::ENOENT
72
74
  raise NotFound.new(self)
73
75
  end
74
76
 
77
+ def rel_entries(option={})
78
+ list = []
79
+ @path.entries.each do |entry|
80
+ if not(entry.to_s == "." or entry.to_s == "..")
81
+ list << entry
82
+ entry_location = self + entry
83
+ if option[:rec] and entry_location.directory?
84
+ _list = entry_location.rel_entries(option).map {|subentry| entry + subentry}
85
+ list = list + _list
86
+ end
87
+ end
88
+ end
89
+ return list
90
+ rescue Errno::ENOENT
91
+ raise NotFound.new(self)
92
+ end
93
+
75
94
  def file?
76
95
  @path.file?
77
96
  end
@@ -0,0 +1,14 @@
1
+ module Pione
2
+ # Parser is a namespace for PIONE parsers.
3
+ module Parser; end
4
+ end
5
+
6
+ require 'pione/parser/parslet-extension'
7
+ require 'pione/parser/common-parser'
8
+ require 'pione/parser/literal-parser'
9
+ require 'pione/parser/feature-expr-parser'
10
+ require 'pione/parser/expr-parser'
11
+ require 'pione/parser/flow-element-parser'
12
+ require 'pione/parser/block-parser'
13
+ require 'pione/parser/rule-definition-parser'
14
+ require 'pione/parser/document-parser'
@@ -0,0 +1,10 @@
1
+ module Pione
2
+ # Patch is a namespace for patches.
3
+ module Patch; end
4
+ end
5
+
6
+ require 'pione/patch/array-patch'
7
+ require 'pione/patch/drb-patch'
8
+ require 'pione/patch/rinda-patch'
9
+ require 'pione/patch/uri-patch'
10
+ require 'pione/patch/monitor-patch'
@@ -136,7 +136,7 @@ module DRb
136
136
  req_id, succ, result = recv_reply
137
137
  DRb.waiter_table.push(req_id, [succ, result])
138
138
  end
139
- rescue Exception => e
139
+ rescue => e
140
140
  @watcher_mutex.synchronize do
141
141
  @watchers.each do |watcher|
142
142
  if watcher.alive?
@@ -333,7 +333,7 @@ module DRb
333
333
  result = DRbArray.new(result)
334
334
  end
335
335
  return true, result
336
- rescue StandardError, ScriptError, Interrupt => e
336
+ rescue StandardError, ScriptError => e
337
337
  return false, e
338
338
  end
339
339
 
@@ -0,0 +1,11 @@
1
+ module Pione
2
+ # Relay is a namespace for relay.
3
+ module Relay; end
4
+ end
5
+
6
+ require 'pione/relay/transmitter-socket'
7
+ require 'pione/relay/trampoline'
8
+ require 'pione/relay/receiver-socket'
9
+ require 'pione/relay/relay-socket'
10
+ require 'pione/relay/relay-client-db'
11
+ require 'pione/relay/relay-account-db'
@@ -135,7 +135,7 @@ module Pione
135
135
  def get(location)
136
136
  # cache if record doesn't exist
137
137
  unless @table.has_key?(location)
138
- cache_location = Location[Temppath.create(nil, @tmpdir)]
138
+ cache_location = Location[Temppath.create(basedir: @tmpdir)]
139
139
  location.turn(cache_location)
140
140
  @table[location] = cache_location
141
141
  end
@@ -191,6 +191,21 @@ module Pione
191
191
  Pathname.new(Dir.mktmpdir(nil, Global.file_cache_directory_root))
192
192
  end
193
193
 
194
+ # Git repository directory
195
+ define_item(:git_repository_directory, false) do
196
+ Location[Global.dot_pione_dir + "git-repository"]
197
+ end
198
+
199
+ # Git package directory
200
+ define_item(:git_package_directory, false) do
201
+ Location[Global.dot_pione_dir] + "git-package"
202
+ end
203
+
204
+ # archive_package_cache_dir
205
+ define_item(:archive_package_cache_dir, false) do
206
+ Location[Global.dot_pione_dir + "archive-package-cache"]
207
+ end
208
+
194
209
  # system front server
195
210
  define_item(:front, false)
196
211
 
@@ -0,0 +1,11 @@
1
+ module Pione
2
+ # TupleSpace is a namespace for tuple space classes.
3
+ module TupleSpace; end
4
+ end
5
+
6
+ require 'pione/tuple-space/tuple-space-server-interface'
7
+ require 'pione/tuple-space/presence-notifier'
8
+ require 'pione/tuple-space/tuple-space-server'
9
+ require 'pione/tuple-space/tuple-space-receiver'
10
+ require 'pione/tuple-space/tuple-space-provider'
11
+ require 'pione/tuple-space/data-finder'
@@ -151,7 +151,7 @@ module Pione
151
151
  @terminated = true
152
152
  write(Tuple[:command].new("terminate", nil))
153
153
  @client_life_checker.terminate
154
- @client_life_checker.running_thread.join
154
+ @client_life_checker.running_thread.kill
155
155
  sleep 1
156
156
  end
157
157
 
@@ -17,4 +17,5 @@ require 'pione/util/variable-holdable'
17
17
  require 'pione/util/evaluatable'
18
18
  require 'pione/util/process-info'
19
19
  require 'pione/util/package-parameters-list'
20
+ require 'pione/util/zip'
20
21
 
@@ -15,6 +15,13 @@ module Pione
15
15
  end
16
16
  end
17
17
  module_function :warn
18
+
19
+ def debug(msg, receiver, file, line)
20
+ if Pione.debug_mode?
21
+ $stderr.puts "PIONE debug [%s:%i] %s (%s)" % [file, line, msg, receiver]
22
+ end
23
+ end
24
+ module_function :debug
18
25
  end
19
26
  end
20
27
  end