zeddb 1.1.3
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/LICENSE +15 -0
- data/README.rdoc +8 -0
- data/Rakefile +75 -0
- data/VERSION +1 -0
- data/bin/zeddb +23 -0
- data/lib/cli/config.rb +20 -0
- data/lib/cli/model_associations.rb +38 -0
- data/lib/cli/model_items.rb +59 -0
- data/lib/cli/model_transformer.rb +53 -0
- data/lib/cli/model_validations.rb +56 -0
- data/lib/cli/models.rb +59 -0
- data/lib/cli/projects.rb +49 -0
- data/lib/cli/runner.rb +55 -0
- data/lib/cli/text.rb +52 -0
- data/lib/zeddb/instances/model.rb +71 -0
- data/lib/zeddb/instances/model_item.rb +77 -0
- data/lib/zeddb/instances/model_transformer.rb +34 -0
- data/lib/zeddb/instances/model_validation.rb +36 -0
- data/lib/zeddb/instances/project.rb +24 -0
- data/lib/zeddb/resources/model_associations.rb +66 -0
- data/lib/zeddb/resources/model_items.rb +73 -0
- data/lib/zeddb/resources/model_transformers.rb +62 -0
- data/lib/zeddb/resources/model_validations.rb +66 -0
- data/lib/zeddb/resources/models.rb +73 -0
- data/lib/zeddb/resources/projects.rb +40 -0
- data/lib/zeddb.rb +34 -0
- data/test/helper.rb +47 -0
- data/test/test_associations.rb +64 -0
- data/test/test_entities.rb +36 -0
- data/test/test_model_items.rb +79 -0
- data/test/test_models.rb +72 -0
- data/test/test_projects.rb +35 -0
- data/test/test_transformers.rb +60 -0
- data/test/test_validations.rb +73 -0
- metadata +134 -0
data/LICENSE
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
Copyright (c) Zedkit.
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
6
|
+
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
7
|
+
Software is furnished to do so, subject to the following conditions:
|
8
|
+
|
9
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
10
|
+
Software.
|
11
|
+
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
13
|
+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
14
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
15
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
##
|
2
|
+
# Copyright (c) Zedkit.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
5
|
+
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
6
|
+
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
7
|
+
# Software is furnished to do so, subject to the following conditions:
|
8
|
+
#
|
9
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
10
|
+
# Software.
|
11
|
+
#
|
12
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
13
|
+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
14
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
15
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
16
|
+
##
|
17
|
+
|
18
|
+
require 'rubygems'
|
19
|
+
require 'rake'
|
20
|
+
|
21
|
+
begin
|
22
|
+
require 'jeweler'
|
23
|
+
Jeweler::Tasks.new do |gem|
|
24
|
+
gem.name = "zeddb"
|
25
|
+
gem.summary = %Q{gem to access ZedDB within Zedkit applications}
|
26
|
+
gem.description = %Q{gem to access the ZedDB within Zedkit applications to CRUD application models, the KVS and queues}
|
27
|
+
|
28
|
+
gem.email = "support@zedkit.com"
|
29
|
+
gem.homepage = "http://github.com/zedkit/zeddb"
|
30
|
+
gem.authors = ["Zedkit"]
|
31
|
+
gem.rubyforge_project = "zeddb"
|
32
|
+
|
33
|
+
gem.files = FileList['[A-Z]*', 'bin/*', 'lib/**/*.rb', 'test/**/*.rb']
|
34
|
+
gem.executables = %w(zeddb)
|
35
|
+
gem.default_executable = %q{zeddb}
|
36
|
+
|
37
|
+
gem.add_dependency 'zedkit', '>= 1.1.3'
|
38
|
+
gem.add_dependency 'json', '>= 1.4.4'
|
39
|
+
end
|
40
|
+
Jeweler::GemcutterTasks.new
|
41
|
+
rescue LoadError
|
42
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
43
|
+
end
|
44
|
+
|
45
|
+
require 'rake/testtask'
|
46
|
+
Rake::TestTask.new(:test) do |test|
|
47
|
+
test.libs << 'lib' << 'test'
|
48
|
+
test.pattern = 'test/**/test_*.rb'
|
49
|
+
test.verbose = true
|
50
|
+
end
|
51
|
+
|
52
|
+
begin
|
53
|
+
require 'rcov/rcovtask'
|
54
|
+
Rcov::RcovTask.new do |test|
|
55
|
+
test.libs << 'test'
|
56
|
+
test.pattern = 'test/**/test_*.rb'
|
57
|
+
test.verbose = true
|
58
|
+
end
|
59
|
+
rescue LoadError
|
60
|
+
task :rcov do
|
61
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
task :test => :check_dependencies
|
66
|
+
task :default => :test
|
67
|
+
|
68
|
+
require 'rake/rdoctask'
|
69
|
+
Rake::RDocTask.new do |rdoc|
|
70
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
71
|
+
rdoc.rdoc_dir = 'rdoc'
|
72
|
+
rdoc.title = "zeddb #{version}"
|
73
|
+
rdoc.rdoc_files.include('README*')
|
74
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
75
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.1.3
|
data/bin/zeddb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
##
|
3
|
+
# Copyright (c) Zedkit.
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
6
|
+
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
7
|
+
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
8
|
+
# Software is furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
11
|
+
# Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
14
|
+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
15
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
16
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
17
|
+
##
|
18
|
+
|
19
|
+
require 'zeddb'
|
20
|
+
|
21
|
+
Dir["#{File.dirname(__FILE__)}/../lib/cli/*.rb"].each {|ci| require ci }
|
22
|
+
|
23
|
+
ZedDB::CLI::Runner.new.go!
|
data/lib/cli/config.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
##
|
2
|
+
# Copyright (c) Zedkit.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
5
|
+
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
6
|
+
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
7
|
+
# Software is furnished to do so, subject to the following conditions:
|
8
|
+
#
|
9
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
10
|
+
# Software.
|
11
|
+
#
|
12
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
13
|
+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
14
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
15
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
16
|
+
##
|
17
|
+
|
18
|
+
Zedkit.configure do |zk|
|
19
|
+
zk.exceptions = true
|
20
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
##
|
2
|
+
# Copyright (c) Zedkit.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
5
|
+
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
6
|
+
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
7
|
+
# Software is furnished to do so, subject to the following conditions:
|
8
|
+
#
|
9
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
10
|
+
# Software.
|
11
|
+
#
|
12
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
13
|
+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
14
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
15
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
16
|
+
##
|
17
|
+
|
18
|
+
module ZedDB
|
19
|
+
module CLI
|
20
|
+
class Assocs < Zedkit::CLI::Bottom
|
21
|
+
class << self
|
22
|
+
def create(opts = {})
|
23
|
+
puts "\n" << Zedkit::CLI.ee(opts[:locale], :general, :not_done) << "\n\n"
|
24
|
+
end
|
25
|
+
|
26
|
+
def delete(opts = {})
|
27
|
+
puts "\n" << Zedkit::CLI.ee(opts[:locale], :general, :not_done) << "\n\n"
|
28
|
+
end
|
29
|
+
|
30
|
+
protected
|
31
|
+
def before_create(opts = {})
|
32
|
+
end
|
33
|
+
def before_show_update_delete(opts = {})
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
##
|
2
|
+
# Copyright (c) Zedkit.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
5
|
+
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
6
|
+
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
7
|
+
# Software is furnished to do so, subject to the following conditions:
|
8
|
+
#
|
9
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
10
|
+
# Software.
|
11
|
+
#
|
12
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
13
|
+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
14
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
15
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
16
|
+
##
|
17
|
+
|
18
|
+
module ZedDB
|
19
|
+
module CLI
|
20
|
+
class Items < Zedkit::CLI::Bottom
|
21
|
+
class << self
|
22
|
+
def show(opts = {})
|
23
|
+
puts ZedDB::ModelItem.new(:user_key => opts[:user_key], :locale => opts[:locale], :uuid => opts[:argv][0])
|
24
|
+
end
|
25
|
+
|
26
|
+
def create(opts = {})
|
27
|
+
opts[:items]['name'] = opts[:argv][1]
|
28
|
+
puts ZedDB::ModelItem.new(:user_key => opts[:user_key], :locale => opts[:locale]).replace \
|
29
|
+
ZedDB::ModelItems.create(:user_key => opts[:user_key], :locale => opts[:locale],
|
30
|
+
:model => { :uuid => opts[:argv][0] }, :item => opts[:items])
|
31
|
+
end
|
32
|
+
|
33
|
+
def update(opts = {})
|
34
|
+
puts ZedDB::ModelItem.new(:user_key => opts[:user_key], :locale => opts[:locale]).replace \
|
35
|
+
ZedDB::ModelItems.update(:user_key => opts[:user_key],
|
36
|
+
:locale => opts[:locale], :uuid => opts[:argv][0], :item => opts[:items])
|
37
|
+
end
|
38
|
+
|
39
|
+
def delete(opts = {})
|
40
|
+
mi = ZedDB::ModelItem.new(:user_key => opts[:user_key], :locale => opts[:locale], :uuid => opts[:argv][0])
|
41
|
+
mi.delete
|
42
|
+
puts "\nDONE.\nZedDB Model Data Item Removed [#{mi['name']}].\n\n"
|
43
|
+
end
|
44
|
+
|
45
|
+
protected
|
46
|
+
def before_create(opts = {})
|
47
|
+
if opts[:argv][0].nil?
|
48
|
+
raise Zedkit::CLI::MissingParameter.new(:message => ZedDB::CLI.ee(opts[:locale], :model, :uuid)) end
|
49
|
+
if opts[:argv][1].nil?
|
50
|
+
raise Zedkit::CLI::MissingParameter.new(:message => ZedDB::CLI.ee(opts[:locale], :item, :name)) end
|
51
|
+
end
|
52
|
+
def before_show_update_delete(opts = {})
|
53
|
+
if opts[:argv][0].nil?
|
54
|
+
raise Zedkit::CLI::MissingParameter.new(:message => ZedDB::CLI.ee(opts[:locale], :item, :uuid)) end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
##
|
2
|
+
# Copyright (c) Zedkit.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
5
|
+
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
6
|
+
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
7
|
+
# Software is furnished to do so, subject to the following conditions:
|
8
|
+
#
|
9
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
10
|
+
# Software.
|
11
|
+
#
|
12
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
13
|
+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
14
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
15
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
16
|
+
##
|
17
|
+
|
18
|
+
module ZedDB
|
19
|
+
module CLI
|
20
|
+
class Trans < Zedkit::CLI::Bottom
|
21
|
+
class << self
|
22
|
+
def create(opts = {})
|
23
|
+
opts[:items]['code'] = opts[:argv][1]
|
24
|
+
mt = ZedDB::ModelTransformer.new(:user_key => opts[:user_key], :locale => opts[:locale]).replace \
|
25
|
+
ZedDB::ModelTransformers.create(:user_key => opts[:user_key], :locale => opts[:locale],
|
26
|
+
:item => { :uuid => opts[:argv][0] }, :transformer => opts[:items])
|
27
|
+
puts mt.model_item
|
28
|
+
end
|
29
|
+
|
30
|
+
def delete(opts = {})
|
31
|
+
mt = ZedDB::ModelTransformer.new(:user_key => opts[:user_key],
|
32
|
+
:locale => opts[:locale], :owner => opts[:argv][0], :uuid => opts[:argv][1])
|
33
|
+
mt.delete
|
34
|
+
puts "\nDONE.\nZedDB Model Transformer Removed [#{mt.transformer['code']}].\n\n"
|
35
|
+
end
|
36
|
+
|
37
|
+
protected
|
38
|
+
def before_create(opts = {})
|
39
|
+
if opts[:argv][0].nil?
|
40
|
+
raise Zedkit::CLI::MissingParameter.new(:message => ZedDB::CLI.ee(opts[:locale], :item, :uuid)) end
|
41
|
+
if opts[:argv][1].nil?
|
42
|
+
raise Zedkit::CLI::MissingParameter.new(:message => ZedDB::CLI.ee(opts[:locale], :transformer, :code)) end
|
43
|
+
end
|
44
|
+
def before_show_update_delete(opts = {})
|
45
|
+
if opts[:argv][0].nil?
|
46
|
+
raise Zedkit::CLI::MissingParameter.new(:message => ZedDB::CLI.ee(opts[:locale], :item, :uuid)) end
|
47
|
+
if opts[:argv][1].nil?
|
48
|
+
raise Zedkit::CLI::MissingParameter.new(:message => ZedDB::CLI.ee(opts[:locale], :transformer, :uuid)) end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
##
|
2
|
+
# Copyright (c) Zedkit.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
5
|
+
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
6
|
+
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
7
|
+
# Software is furnished to do so, subject to the following conditions:
|
8
|
+
#
|
9
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
10
|
+
# Software.
|
11
|
+
#
|
12
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
13
|
+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
14
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
15
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
16
|
+
##
|
17
|
+
|
18
|
+
module ZedDB
|
19
|
+
module CLI
|
20
|
+
class Vals < Zedkit::CLI::Bottom
|
21
|
+
class << self
|
22
|
+
def create(opts = {})
|
23
|
+
opts[:items]['code'] = opts[:argv][1]
|
24
|
+
mv = ZedDB::ModelValidation.new(:user_key => opts[:user_key], :locale => opts[:locale]).replace \
|
25
|
+
ZedDB::ModelValidations.create(:user_key => opts[:user_key], :locale => opts[:locale],
|
26
|
+
:item => { :uuid => opts[:argv][0] }, :validation => opts[:items])
|
27
|
+
puts mv.model_item
|
28
|
+
end
|
29
|
+
|
30
|
+
def update(opts = {})
|
31
|
+
puts "\n" << Zedkit::CLI.ee(opts[:locale], :general, :not_done) << "\n\n"
|
32
|
+
end
|
33
|
+
|
34
|
+
def delete(opts = {})
|
35
|
+
mv = ZedDB::ModelValidation.new(:user_key => opts[:user_key], :locale => opts[:locale], :owner => opts[:argv][0], :uuid => opts[:argv][1])
|
36
|
+
mv.delete
|
37
|
+
puts "\nDONE.\nZedDB Model Validation Removed [#{mv.validation['code']}].\n\n"
|
38
|
+
end
|
39
|
+
|
40
|
+
protected
|
41
|
+
def before_create(opts = {})
|
42
|
+
if opts[:argv][0].nil?
|
43
|
+
raise Zedkit::CLI::MissingParameter.new(:message => ZedDB::CLI.ee(opts[:locale], :item, :uuid)) end
|
44
|
+
if opts[:argv][1].nil?
|
45
|
+
raise Zedkit::CLI::MissingParameter.new(:message => ZedDB::CLI.ee(opts[:locale], :validation, :code)) end
|
46
|
+
end
|
47
|
+
def before_show_update_delete(opts = {})
|
48
|
+
if opts[:argv][0].nil?
|
49
|
+
raise Zedkit::CLI::MissingParameter.new(:message => ZedDB::CLI.ee(opts[:locale], :item, :uuid)) end
|
50
|
+
if opts[:argv][1].nil?
|
51
|
+
raise Zedkit::CLI::MissingParameter.new(:message => ZedDB::CLI.ee(opts[:locale], :validation, :uuid)) end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/cli/models.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
##
|
2
|
+
# Copyright (c) Zedkit.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
5
|
+
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
6
|
+
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
7
|
+
# Software is furnished to do so, subject to the following conditions:
|
8
|
+
#
|
9
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
10
|
+
# Software.
|
11
|
+
#
|
12
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
13
|
+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
14
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
15
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
16
|
+
##
|
17
|
+
|
18
|
+
module ZedDB
|
19
|
+
module CLI
|
20
|
+
class Models < Zedkit::CLI::Bottom
|
21
|
+
class << self
|
22
|
+
def show(opts = {})
|
23
|
+
puts ZedDB::Model.new(:user_key => opts[:user_key], :locale => opts[:locale], :uuid => opts[:argv][0])
|
24
|
+
end
|
25
|
+
|
26
|
+
def create(opts = {})
|
27
|
+
opts[:items]['name'] = opts[:argv][1]
|
28
|
+
puts ZedDB::Model.new(:user_key => opts[:user_key], :locale => opts[:locale]).replace \
|
29
|
+
ZedDB::Models.create(:user_key => opts[:user_key], :locale => opts[:locale],
|
30
|
+
:project => { :uuid => opts[:argv][0] }, :model => opts[:items])
|
31
|
+
end
|
32
|
+
|
33
|
+
def update(opts = {})
|
34
|
+
puts ZedDB::Model.new(:user_key => opts[:user_key], :locale => opts[:locale]).replace \
|
35
|
+
ZedDB::Models.update(:user_key => opts[:user_key],
|
36
|
+
:locale => opts[:locale], :uuid => opts[:argv][0], :model => opts[:items])
|
37
|
+
end
|
38
|
+
|
39
|
+
def delete(opts = {})
|
40
|
+
mm = ZedDB::Model.new(:user_key => opts[:user_key], :locale => opts[:locale], :uuid => opts[:argv][0])
|
41
|
+
mm.delete
|
42
|
+
puts "\nDONE.\nZedDB Model Removed [#{mm.name}].\n\n"
|
43
|
+
end
|
44
|
+
|
45
|
+
protected
|
46
|
+
def before_create(opts = {})
|
47
|
+
if opts[:argv][0].nil?
|
48
|
+
raise Zedkit::CLI::MissingParameter.new(:message => ZedDB::CLI.ee(opts[:locale], :project, :uuid)) end
|
49
|
+
if opts[:argv][1].nil?
|
50
|
+
raise Zedkit::CLI::MissingParameter.new(:message => ZedDB::CLI.ee(opts[:locale], :model, :name)) end
|
51
|
+
end
|
52
|
+
def before_show_update_delete(opts = {})
|
53
|
+
if opts[:argv][0].nil?
|
54
|
+
raise Zedkit::CLI::MissingParameter.new(:message => ZedDB::CLI.ee(opts[:locale], :model, :uuid)) end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/lib/cli/projects.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
##
|
2
|
+
# Copyright (c) Zedkit.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
5
|
+
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
6
|
+
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
7
|
+
# Software is furnished to do so, subject to the following conditions:
|
8
|
+
#
|
9
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
10
|
+
# Software.
|
11
|
+
#
|
12
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
13
|
+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
14
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
15
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
16
|
+
##
|
17
|
+
|
18
|
+
module ZedDB
|
19
|
+
module CLI
|
20
|
+
class Projects < Zedkit::CLI::Bottom
|
21
|
+
class << self
|
22
|
+
def list(opts = {})
|
23
|
+
show_models Zedkit::Project.new(:user_key => opts[:user_key], :locale => opts[:locale], :uuid => opts[:argv][0])
|
24
|
+
end
|
25
|
+
def codes(opts = {})
|
26
|
+
puts "\n" << ZedDB::CLI.ee(opts[:locale], :general, :not_done) << "\n\n"
|
27
|
+
end
|
28
|
+
|
29
|
+
protected
|
30
|
+
def before_list(opts = {})
|
31
|
+
if opts[:argv][0].nil?
|
32
|
+
raise Zedkit::CLI::MissingParameter.new(:message => ZedDB::CLI.ee(opts[:locale], :project, :nil)) end
|
33
|
+
end
|
34
|
+
def show_models(project)
|
35
|
+
mcnt = "[#{project.models.length} #{project.models.length > 1 ? 'Models' : 'Model'}]"
|
36
|
+
puts dashes(122) \
|
37
|
+
<< "| " << "ZedDB Models [#{project.name}] #{mcnt}".ljust(118) << " |\n" \
|
38
|
+
<< dashes(122) \
|
39
|
+
<< "| #{'UUID'.ljust(32)} | #{'Name'.ljust(32)} | #{'Location'.ljust(48)} |\n" \
|
40
|
+
<< dashes(122)
|
41
|
+
project.models.each do |mm|
|
42
|
+
puts "| #{mm['uuid'].ljust(32)} | #{mm['name'].ljust(32)} | #{mm['locations'][0].ljust(48)} |\n"
|
43
|
+
end
|
44
|
+
puts dashes(122)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/cli/runner.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
##
|
2
|
+
# Copyright (c) Zedkit.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
5
|
+
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
6
|
+
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
7
|
+
# Software is furnished to do so, subject to the following conditions:
|
8
|
+
#
|
9
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
10
|
+
# Software.
|
11
|
+
#
|
12
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
13
|
+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
14
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
15
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
16
|
+
##
|
17
|
+
|
18
|
+
module ZedDB
|
19
|
+
module CLI
|
20
|
+
class Runner < Zedkit::CLI::Runner
|
21
|
+
SECTIONS = ['projects','models','items']
|
22
|
+
|
23
|
+
def me
|
24
|
+
Object.const_get('ZedDB').const_get('CLI')
|
25
|
+
end
|
26
|
+
def commands
|
27
|
+
"\n" \
|
28
|
+
<< "== Project Commands\n\n" \
|
29
|
+
<< "list <uuid> # List a project's models\n" \
|
30
|
+
<< "codes # Outline applicable entity codes for ZedDB\n\n" \
|
31
|
+
<< "== Model Commands\n\n" \
|
32
|
+
<< "models:show <uuid> # Show model details\n" \
|
33
|
+
<< "models:create <project> <name> key=value [...] # Create a new model\n" \
|
34
|
+
<< "models:update <uuid> key=value [...] # Update an existing model\n" \
|
35
|
+
<< "models:delete <uuid> # Delete an existing model\n\n" \
|
36
|
+
<< "== Model Item Commands\n\n" \
|
37
|
+
<< "items:show <uuid> # Show details of a model's data items\n" \
|
38
|
+
<< "items:create <model> <name> key=value [...] # Create a new data item within a model\n" \
|
39
|
+
<< "items:update <uuid> key=value [...] # Update an existing data item\n" \
|
40
|
+
<< "items:delete <uuid> # Delete an existing data item\n\n" \
|
41
|
+
<< "== Model Association Commands\n\n" \
|
42
|
+
<< "assocs:create <code> key=value [...] # Create a new association between two models\n" \
|
43
|
+
<< "assocs:delete <uuid> # Delete an existing association between two models\n\n" \
|
44
|
+
<< "== Data Item Validation Commands\n\n" \
|
45
|
+
<< "vals:create <item> <code> key=value [...] # Create a new validation for an existing data item\n" \
|
46
|
+
<< "vals:update <item> <uuid> key=value [...] # Update an existing validation\n" \
|
47
|
+
<< "vals:delete <item> <uuid> # Delete an existing validation\n\n" \
|
48
|
+
<< "== Data Item Transformer Commands\n\n" \
|
49
|
+
<< "trans:create <item> <code> # Create a new transformer for an existing data item\n" \
|
50
|
+
<< "trans:delete <item> <uuid> # Delete an existing transformer\n\n" \
|
51
|
+
<< "==\n\n"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/cli/text.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
##
|
2
|
+
# Copyright (c) Zedkit.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
5
|
+
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
6
|
+
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
7
|
+
# Software is furnished to do so, subject to the following conditions:
|
8
|
+
#
|
9
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
10
|
+
# Software.
|
11
|
+
#
|
12
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
13
|
+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
14
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
15
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
16
|
+
##
|
17
|
+
|
18
|
+
module ZedDB::CLI
|
19
|
+
class << self
|
20
|
+
def tt(locale, key, item)
|
21
|
+
Zedkit::CLI.lookup_tt("ZedDB::CLI", locale, key, item)
|
22
|
+
end
|
23
|
+
def ee(locale, key, item)
|
24
|
+
Zedkit::CLI.lookup_ee("ZedDB::CLI", locale, key, item)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
CONTENT = {
|
29
|
+
:en => {
|
30
|
+
}
|
31
|
+
}
|
32
|
+
ERRORS = {
|
33
|
+
:en => {
|
34
|
+
:model => {
|
35
|
+
:uuid => "Model UUID is nil",
|
36
|
+
:name => "Model name is nil"
|
37
|
+
},
|
38
|
+
:item => {
|
39
|
+
:uuid => "Model Item UUID is nil",
|
40
|
+
:name => "Model Item name is nil"
|
41
|
+
},
|
42
|
+
:validation => {
|
43
|
+
:uuid => "Validation UUID is nil",
|
44
|
+
:code => "Validation code is nil"
|
45
|
+
},
|
46
|
+
:transformer => {
|
47
|
+
:uuid => "Transformer UUID is nil",
|
48
|
+
:code => "Transformer code is nil"
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}.freeze
|
52
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
##
|
2
|
+
# Copyright (c) Zedkit.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
5
|
+
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
6
|
+
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
7
|
+
# Software is furnished to do so, subject to the following conditions:
|
8
|
+
#
|
9
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
10
|
+
# Software.
|
11
|
+
#
|
12
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
13
|
+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
14
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
15
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
16
|
+
##
|
17
|
+
|
18
|
+
module ZedDB
|
19
|
+
class Model < Zedkit::Instance
|
20
|
+
def project
|
21
|
+
Zedkit::Project.new(:user_key => uk, :locale => lc, :uuid => self['project']['uuid'])
|
22
|
+
end
|
23
|
+
|
24
|
+
def associations
|
25
|
+
self.has_key?('associations') && self['associations'].is_a?(Array) ? self['associations'] : []
|
26
|
+
end
|
27
|
+
def items
|
28
|
+
self.has_key?('items') && self['items'].is_a?(Array) ? self['items'] : []
|
29
|
+
end
|
30
|
+
|
31
|
+
def update
|
32
|
+
end
|
33
|
+
def delete
|
34
|
+
ZedDB::Models.delete(:user_key => uk, :locale => lc, :uuid => uuid)
|
35
|
+
end
|
36
|
+
|
37
|
+
def to_s
|
38
|
+
rs = "\nZedDB Model within Project '#{project['name']}':\n" \
|
39
|
+
<< " Name : #{self['name']}\n" \
|
40
|
+
<< " UUID : #{self['uuid']}\n" \
|
41
|
+
<< " Resource : #{self['plural_name']}\n" \
|
42
|
+
<< " Class : #{self['model_name']}\n" \
|
43
|
+
<< " Associations : #{associations.count}\n" \
|
44
|
+
<< " Data Items : #{items.count}\n" \
|
45
|
+
<< " Locations : #{self['locations'][0]}\n" \
|
46
|
+
<< " #{self['locations'][1]}\n" \
|
47
|
+
<< " Version : #{self['version']}\n" \
|
48
|
+
<< " Created : #{Time.at(self['created_at']).to_date}\n" \
|
49
|
+
<< " Updated : #{Time.at(self['updated_at']).to_date}\n"
|
50
|
+
if items.empty?
|
51
|
+
rs << dashes(20)
|
52
|
+
else
|
53
|
+
rs << dashes(122) << "| #{'Data Items'.ljust(118)} |\n" << dashes(122) \
|
54
|
+
<< "| #{'UUID'.ljust(32)} | #{'Name'.ljust(32)} | #{'Type'.ljust(12)} | #{'Validations'.center(15)} " \
|
55
|
+
<< "| #{'Transformers'.center(15)} |\n" << dashes(122)
|
56
|
+
items.each do |mi|
|
57
|
+
rs << "| #{mi['uuid']} | #{mi['name'].ljust(32)} | #{mi['type']['code'].ljust(12)} " \
|
58
|
+
<< "| #{mi['validations'].length.to_s.center(15)} | #{mi['transformers'].length.to_s.center(15)} |\n"
|
59
|
+
end
|
60
|
+
rs << dashes(122)
|
61
|
+
end
|
62
|
+
rs << "\n"
|
63
|
+
end
|
64
|
+
|
65
|
+
protected
|
66
|
+
def set_with_uuid(uuid_to_use)
|
67
|
+
replace ZedDB::Models.get(:user_key => uk, :locale => lc, :uuid => uuid_to_use)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|