cpee-dstore 1.0.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: abfbfb8ae9eb6dcdee4a63e346a07adff179dd69a8f24f9a39cf05a91a3c1ef9
4
+ data.tar.gz: ff32c8d32760a160cfa4962123a6df4d6108f3b943dfd355a8912622f986c31e
5
+ SHA512:
6
+ metadata.gz: 7b10646a092658cbe842c4153be747ff3a047fc656e8704f7dc0700d745d6d6afb708708bab4a955749634dac9bba475fb8542599b36d0b365564735a732c7d5
7
+ data.tar.gz: 1f997f2268a32b1150fd6411ecccd339907126817756972b4e5addbd5a1dd19c659aafd52e80682d2e394b23d81e8f9606ab1ce7c168f5a17998071a0d92f7d5
data/AUTHORS ADDED
@@ -0,0 +1 @@
1
+ Jürgen "eTM" Mangler <juergen.mangler@gmail.com>
data/LICENSE ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
data/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # CPEE-DSTORE
2
+
3
+ A minimal generic file store for the cloud process execution engine
4
+ (cpee.org), built with [riddl](https://github.com/etm/riddl).
5
+
6
+ It exposes a single generic resource:
7
+
8
+ ```
9
+ GET /<uuid>/<name>
10
+ PUT /<uuid>/<name>
11
+ ```
12
+
13
+ * `uuid` must be a valid UUID (`8-4-4-4-12` hex digits).
14
+ * `name` must match `^[a-z_][a-zA-Z0-9_]*$`.
15
+
16
+ `PUT` accepts a single body parameter of any mimetype and stores it on
17
+ disk under the configured data directory as `data/<uuid>/<name>`
18
+ (alongside a small sidecar file recording the uploaded mimetype).
19
+
20
+ `GET` returns the stored content with the mimetype it was uploaded
21
+ with. Requests for an unknown `uuid`/`name` pair return `404`;
22
+ malformed `uuid`/`name` values return `400`.
23
+
24
+ ## Installation
25
+
26
+ * gem install cpee-dstore
27
+
28
+ ## Scaffold a local install
29
+
30
+ * cd ~/run
31
+ * cpee-dstore new dstore
32
+
33
+ ## Configuration
34
+
35
+ The data directory defaults to `data/` next to the server script and
36
+ can be overridden either in `dstore.conf`:
37
+
38
+ ```yaml
39
+ :data_dir: /home/user/run/store/data
40
+ ```
41
+
42
+ or on the command line:
43
+
44
+ ```
45
+ ./dstore -o data_dir=/home/mangler/Projects/cpee-resources/data -v start
46
+ ```
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ require 'rake'
2
+ require 'rubygems/package_task'
3
+
4
+ spec = eval(File.read('cpee-dstore.gemspec'))
5
+ Gem::PackageTask.new(spec) do |pkg|
6
+ pkg.need_zip = true
7
+ pkg.need_tar = true
8
+ FileUtils.mkdir 'pkg' rescue nil
9
+ FileUtils.rm_rf Dir.glob('pkg/*')
10
+ FileUtils.ln_sf "#{pkg.name}.gem", "pkg/#{spec.name}.gem"
11
+ end
12
+
13
+ task :default => [:gem]
14
+
15
+ task :push => :gem do |r|
16
+ `gem push pkg/cpee-dstore.gem`
17
+ end
18
+
19
+ task :install => :gem do |r|
20
+ `gem install pkg/cpee-dstore.gem`
21
+ end
@@ -0,0 +1,24 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "cpee-dstore"
3
+ s.version = "1.0.0"
4
+ s.platform = Gem::Platform::RUBY
5
+ s.license = "LGPL-3.0-or-later"
6
+ s.summary = "Generic document store for the cloud process execution engine (cpee.org)"
7
+
8
+ s.description = "see http://cpee.org"
9
+
10
+ s.files = Dir['{server/**/*,tools/**/*,lib/**/*}'] + %w(LICENSE Rakefile cpee-dstore.gemspec README.md AUTHORS)
11
+ s.require_path = 'lib'
12
+ s.extra_rdoc_files = ['README.md']
13
+ s.bindir = 'tools'
14
+ s.executables = ['cpee-dstore']
15
+
16
+ s.required_ruby_version = '>=2.4.0'
17
+
18
+ s.authors = ['Juergen eTM Mangler']
19
+
20
+ s.email = 'juergen.mangler@gmail.com'
21
+ s.homepage = 'http://cpee.org/'
22
+
23
+ s.add_runtime_dependency 'riddl', '~> 1.0'
24
+ end
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/ruby
2
+ #
3
+ # This file is part of CPEE-DSTORE.
4
+ #
5
+ # CPEE-DSTORE is free software: you can redistribute it and/or modify it
6
+ # under the terms of the GNU Lesser General Public License as published by the
7
+ # Free Software Foundation, either version 3 of the License, or (at your
8
+ # option) any later version.
9
+ #
10
+ # CPEE-DSTORE is distributed in the hope that it will be useful, but WITHOUT
11
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13
+ # details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with CPEE-DSTORE (file LICENSE in the main directory). If not, see
17
+ # <http://www.gnu.org/licenses/>.
18
+
19
+ require 'rubygems'
20
+ require 'mimemagic'
21
+ require 'riddl/server'
22
+ require 'fileutils'
23
+
24
+ module CPEE
25
+ module DStore
26
+ SERVER = File.expand_path(File.join(__dir__,'implementation.xml'))
27
+
28
+ class DoGet < Riddl::Implementation #{{{
29
+ def response
30
+ file = File.join(@a[0],@r[-2],@r[-1])
31
+ meta = file + '.mimetype'
32
+ if File.exist?(file) && File.exist?(meta)
33
+ Riddl::Parameter::Complex.new('file',File.read(meta).strip,File.open(file,'rb'))
34
+ else
35
+ @status = 404
36
+ nil
37
+ end
38
+ end
39
+ end #}}}
40
+
41
+ class DoPut < Riddl::Implementation #{{{
42
+ def response
43
+ name = @r[-1]
44
+ dir = File.join(@a[0],@r[-2])
45
+ FileUtils.mkdir_p(dir)
46
+
47
+ File.open(File.join(dir,name),'wb') do |f|
48
+ IO.copy_stream(@p[0].value,f)
49
+ mime = MimeMagic.by_magic(@p[0].value.read)
50
+ mt = if mime.nil?
51
+ 'text/plain'
52
+ else
53
+ mime.type
54
+ end
55
+ File.write(File.join(dir,name + '.mimetype'), mt)
56
+ end
57
+
58
+ nil
59
+ end
60
+ end #}}}
61
+
62
+ def self::implementation(opts)
63
+ opts[:data_dir] ||= File.expand_path(File.join(__dir__,'data'))
64
+
65
+ 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 # uuid
68
+ on resource '[a-z_][a-zA-Z0-9_]*' do # name
69
+ run DoGet, opts[:data_dir] if get
70
+ run DoPut, opts[:data_dir] if put 'file'
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,32 @@
1
+ <!--
2
+ This file is part of CPEE-DSTORE.
3
+
4
+ CPEE-DSTORE is free software: you can redistribute it and/or modify it
5
+ under the terms of the GNU Lesser General Public License as published by the
6
+ Free Software Foundation, either version 3 of the License, or (at your
7
+ option) any later version.
8
+
9
+ CPEE-DSTORE is distributed in the hope that it will be useful, but WITHOUT
10
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
12
+ more details.
13
+
14
+ You should have received a copy of the GNU Lesser General Public License
15
+ along with CPEE-DSTORE (file LICENSE in the main directory). If not, see
16
+ <http://www.gnu.org/licenses/>.
17
+ -->
18
+
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="file">
21
+ <parameter name="file" mimetype="*"/>
22
+ </message>
23
+
24
+ <resource>
25
+ <resource relative="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}">
26
+ <resource relative='[a-z_][a-zA-Z0-9_]*'>
27
+ <get out="file"/>
28
+ <put in="file"/>
29
+ </resource>
30
+ </resource>
31
+ </resource>
32
+ </description>
data/server/dstore ADDED
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/ruby
2
+ #
3
+ # This file is part of CPEE-DSTORE.
4
+ #
5
+ # CPEE-DSTORE is free software: you can redistribute it and/or modify it
6
+ # under the terms of the GNU Lesser General Public License as published by the
7
+ # Free Software Foundation, either version 3 of the License, or (at your
8
+ # option) any later version.
9
+ #
10
+ # CPEE-DSTORE is distributed in the hope that it will be useful, but WITHOUT
11
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13
+ # details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with CPEE-DSTORE (file LICENSE in the main directory). If not, see
17
+ # <http://www.gnu.org/licenses/>.
18
+
19
+ if File.exist?(File.join(__dir__,'..','lib','cpee-dstore','implementation.rb'))
20
+ require_relative File.join(__dir__,'..','lib','cpee-dstore','implementation')
21
+ elsif File.exist?(File.join(Dir.home,'Projects','cpee-dstore','lib','cpee-dstore','implementation.rb'))
22
+ require_relative File.join(Dir.home, 'Projects','cpee-dstore','lib','cpee-dstore','implementation')
23
+ else
24
+ require 'cpee-dstore/implementation'
25
+ end
26
+
27
+ options = {
28
+ :host => 'localhost',
29
+ :port => 9304,
30
+ :secure => false
31
+ }
32
+
33
+ Riddl::Server.new(CPEE::DStore::SERVER, options) do
34
+ accessible_description true
35
+ cross_site_xhr true
36
+
37
+ @riddl_opts[:data_dir] ||= File.join(__dir__,'data')
38
+
39
+ use CPEE::DStore::implementation(@riddl_opts)
40
+ end.loop!
data/tools/cpee-dstore ADDED
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/ruby
2
+ #
3
+ # This file is part of CPEE-DSTORE.
4
+ #
5
+ # CPEE-DSTORE is free software: you can redistribute it and/or modify it
6
+ # under the terms of the GNU Lesser General Public License as published by the
7
+ # Free Software Foundation, either version 3 of the License, or (at your
8
+ # option) any later version.
9
+ #
10
+ # CPEE-DSTORE is distributed in the hope that it will be useful, but WITHOUT
11
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13
+ # details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with CPEE-DSTORE (file LICENSE in the main directory). If not, see
17
+ # <http://www.gnu.org/licenses/>.
18
+
19
+ curpath = __dir__
20
+ require 'rubygems'
21
+ require 'optparse'
22
+ require 'fileutils'
23
+
24
+ def wrap(s, width=78, indent=18)
25
+ lines = []
26
+ line, s = s[0..indent-2], s[indent..-1]
27
+ s.split(/\n/).each do |ss|
28
+ ss.split(/[ \t]+/).each do |word|
29
+ if line.size + word.size >= width
30
+ lines << line
31
+ line = (" " * (indent)) + word
32
+ else
33
+ line << " " << word
34
+ end
35
+ end
36
+ lines << line if line
37
+ line = (" " * (indent-1))
38
+ end
39
+ return lines.join "\n"
40
+ end
41
+
42
+ ARGV.options { |opt|
43
+ opt.summary_indent = ' ' * 2
44
+ opt.summary_width = 15
45
+ opt.banner = "Usage:\n#{opt.summary_indent}#{File.basename($0)} [options] new DIR\n"
46
+ opt.on("Options:")
47
+ opt.on("--help", "-h", "This text") { puts opt; exit }
48
+ opt.on("")
49
+ opt.on(wrap("[new DIR] scaffolds a sample data store service."))
50
+ opt.parse!
51
+ }
52
+ if (ARGV.length < 2) ||
53
+ (ARGV.length == 2 && !(%w(new).include?(ARGV[0]))) ||
54
+ (ARGV.length > 2)
55
+ puts ARGV.options
56
+ exit
57
+ end
58
+ command = ARGV[0]
59
+ p1 = ARGV[1]
60
+
61
+ if command == 'new'
62
+ insta = "#{curpath}/../server/"
63
+ if !File.exist?(p1)
64
+ FileUtils.cp_r(insta,p1)
65
+ FileUtils.mkdir_p(File.join(p1,'data'))
66
+ else
67
+ FileUtils.cp_r(Dir.glob(File.join(insta,'*')).delete_if{|e| e =~ /\.conf/ },p1,remove_destination: true)
68
+ puts 'Directory already exists, updating ...'
69
+ end
70
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cpee-dstore
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Juergen eTM Mangler
8
+ bindir: tools
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: riddl
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '1.0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '1.0'
26
+ description: see http://cpee.org
27
+ email: juergen.mangler@gmail.com
28
+ executables:
29
+ - cpee-dstore
30
+ extensions: []
31
+ extra_rdoc_files:
32
+ - README.md
33
+ files:
34
+ - AUTHORS
35
+ - LICENSE
36
+ - README.md
37
+ - Rakefile
38
+ - cpee-dstore.gemspec
39
+ - lib/cpee-dstore/implementation.rb
40
+ - lib/cpee-dstore/implementation.xml
41
+ - server/dstore
42
+ - tools/cpee-dstore
43
+ homepage: http://cpee.org/
44
+ licenses:
45
+ - LGPL-3.0-or-later
46
+ metadata: {}
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 2.4.0
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements: []
61
+ rubygems_version: 3.6.9
62
+ specification_version: 4
63
+ summary: Generic document store for the cloud process execution engine (cpee.org)
64
+ test_files: []