cpee-dstore 1.0.0 → 1.0.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.
- checksums.yaml +4 -4
- data/cpee-dstore.gemspec +2 -1
- data/lib/cpee-dstore/implementation.rb +39 -8
- data/lib/cpee-dstore/implementation.xml +14 -3
- metadata +15 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1ccd12e54e8d15208553763a9bc03e339892a4bfca6b5d777cc18e8218bba196
|
|
4
|
+
data.tar.gz: af2d5eba2eeb9b3e148ce4d06df8555d4101a57d5cbb572b24c48e15be100722
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2defba9a5d8c816a6d46d73e9db7e0bb555b223c22e79ddfd3a37803329552c35893e1456c2a6b87b6ae9d58a94df24e07a9713f325c00ebaccb4acb86c10631
|
|
7
|
+
data.tar.gz: '08253bf3a7fe587488606550fcacc968d6cee8a0605a064c7f365656de7ca686461cdbbd10970c7d6d5b8f013cf043b16829028ce1bc6d7df778d7c583f14383'
|
data/cpee-dstore.gemspec
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Gem::Specification.new do |s|
|
|
2
2
|
s.name = "cpee-dstore"
|
|
3
|
-
s.version = "1.0.
|
|
3
|
+
s.version = "1.0.2"
|
|
4
4
|
s.platform = Gem::Platform::RUBY
|
|
5
5
|
s.license = "LGPL-3.0-or-later"
|
|
6
6
|
s.summary = "Generic document store for the cloud process execution engine (cpee.org)"
|
|
@@ -21,4 +21,5 @@ Gem::Specification.new do |s|
|
|
|
21
21
|
s.homepage = 'http://cpee.org/'
|
|
22
22
|
|
|
23
23
|
s.add_runtime_dependency 'riddl', '~> 1.0'
|
|
24
|
+
s.add_runtime_dependency 'mimemagic', '~>0'
|
|
24
25
|
end
|
|
@@ -16,11 +16,31 @@
|
|
|
16
16
|
# along with CPEE-DSTORE (file LICENSE in the main directory). If not, see
|
|
17
17
|
# <http://www.gnu.org/licenses/>.
|
|
18
18
|
|
|
19
|
-
require 'rubygems'
|
|
20
19
|
require 'mimemagic'
|
|
21
20
|
require 'riddl/server'
|
|
22
21
|
require 'fileutils'
|
|
23
22
|
|
|
23
|
+
class File
|
|
24
|
+
def tail(n)
|
|
25
|
+
buffer = 1024
|
|
26
|
+
idx = [size - buffer, 0].max
|
|
27
|
+
chunks = []
|
|
28
|
+
lines = 0
|
|
29
|
+
|
|
30
|
+
begin
|
|
31
|
+
seek(idx)
|
|
32
|
+
chunk = read(buffer)
|
|
33
|
+
lines += chunk.count("\n")
|
|
34
|
+
chunks.unshift chunk
|
|
35
|
+
idx -= buffer
|
|
36
|
+
end while lines < ( n + 1 ) && pos != 0
|
|
37
|
+
|
|
38
|
+
tail_of_file = chunks.join('')
|
|
39
|
+
ary = tail_of_file.split("\n")
|
|
40
|
+
ary[ ary.size - n, ary.size - 1 ].join("\n")
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
24
44
|
module CPEE
|
|
25
45
|
module DStore
|
|
26
46
|
SERVER = File.expand_path(File.join(__dir__,'implementation.xml'))
|
|
@@ -30,7 +50,12 @@ module CPEE
|
|
|
30
50
|
file = File.join(@a[0],@r[-2],@r[-1])
|
|
31
51
|
meta = file + '.mimetype'
|
|
32
52
|
if File.exist?(file) && File.exist?(meta)
|
|
33
|
-
|
|
53
|
+
f = File.open(file,'rb')
|
|
54
|
+
if @p.length > 0 && @p[0].name == 'tail'
|
|
55
|
+
Riddl::Parameter::Complex.new('file',File.read(meta).strip,f.tail(@p[0].value.to_i))
|
|
56
|
+
else
|
|
57
|
+
Riddl::Parameter::Complex.new('file',File.read(meta).strip,f)
|
|
58
|
+
end
|
|
34
59
|
else
|
|
35
60
|
@status = 404
|
|
36
61
|
nil
|
|
@@ -40,11 +65,17 @@ module CPEE
|
|
|
40
65
|
|
|
41
66
|
class DoPut < Riddl::Implementation #{{{
|
|
42
67
|
def response
|
|
68
|
+
if @p[0].name == 'append'
|
|
69
|
+
mode = 'ab'
|
|
70
|
+
@p.shift
|
|
71
|
+
else
|
|
72
|
+
mode = 'wb'
|
|
73
|
+
end
|
|
43
74
|
name = @r[-1]
|
|
44
75
|
dir = File.join(@a[0],@r[-2])
|
|
45
76
|
FileUtils.mkdir_p(dir)
|
|
46
77
|
|
|
47
|
-
File.open(File.join(dir,name),
|
|
78
|
+
File.open(File.join(dir,name),mode) do |f|
|
|
48
79
|
IO.copy_stream(@p[0].value,f)
|
|
49
80
|
mime = MimeMagic.by_magic(@p[0].value.read)
|
|
50
81
|
mt = if mime.nil?
|
|
@@ -63,11 +94,11 @@ module CPEE
|
|
|
63
94
|
opts[:data_dir] ||= File.expand_path(File.join(__dir__,'data'))
|
|
64
95
|
|
|
65
96
|
Proc.new do
|
|
66
|
-
on resource do
|
|
67
|
-
on resource '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}' do
|
|
68
|
-
on resource '[a-z_][a-zA-Z0-9_]*' do
|
|
69
|
-
run DoGet, opts[:data_dir] if get
|
|
70
|
-
run DoPut, opts[:data_dir] if put '
|
|
97
|
+
on resource do
|
|
98
|
+
on resource '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}' do
|
|
99
|
+
on resource '[a-z_][a-zA-Z0-9_]*' do
|
|
100
|
+
run DoGet, opts[:data_dir] if get 'rfile'
|
|
101
|
+
run DoPut, opts[:data_dir] if put 'ifile'
|
|
71
102
|
end
|
|
72
103
|
end
|
|
73
104
|
end
|
|
@@ -17,15 +17,26 @@
|
|
|
17
17
|
-->
|
|
18
18
|
|
|
19
19
|
<description xmlns="http://riddl.org/ns/description/1.0" xmlns:ann="http://riddl.org/ns/annotation/1.0" xmlns:xi="http://www.w3.org/2001/XInclude" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
|
|
20
|
-
<message name="
|
|
20
|
+
<message name="ifile">
|
|
21
|
+
<optional>
|
|
22
|
+
<parameter name="append" type="string"/>
|
|
23
|
+
</optional>
|
|
24
|
+
<parameter name="file" mimetype="*"/>
|
|
25
|
+
</message>
|
|
26
|
+
<message name="rfile">
|
|
27
|
+
<optional>
|
|
28
|
+
<parameter name="tail" type="integer"/>
|
|
29
|
+
</optional>
|
|
30
|
+
</message>
|
|
31
|
+
<message name="ofile">
|
|
21
32
|
<parameter name="file" mimetype="*"/>
|
|
22
33
|
</message>
|
|
23
34
|
|
|
24
35
|
<resource>
|
|
25
36
|
<resource relative="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}">
|
|
26
37
|
<resource relative='[a-z_][a-zA-Z0-9_]*'>
|
|
27
|
-
<get out="
|
|
28
|
-
<put in="
|
|
38
|
+
<get in="rfile" out="ofile"/>
|
|
39
|
+
<put in="ifile"/>
|
|
29
40
|
</resource>
|
|
30
41
|
</resource>
|
|
31
42
|
</resource>
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cpee-dstore
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Juergen eTM Mangler
|
|
@@ -23,6 +23,20 @@ dependencies:
|
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
25
|
version: '1.0'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: mimemagic
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - "~>"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
26
40
|
description: see http://cpee.org
|
|
27
41
|
email: juergen.mangler@gmail.com
|
|
28
42
|
executables:
|