cpee-model-management 1.0.1 → 1.0.6
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-model-management.gemspec +1 -1
- data/lib/cpee-model-management/commit.rb +14 -0
- data/lib/cpee-model-management/implementation.rb +126 -62
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e0f8e33529278f8cf87df02f0b71e457f3b398a374ccb1ebd25e0819ea76d1b
|
4
|
+
data.tar.gz: a4407d50ade6af084b89c2b2760a0e6b3dbc506f87d609946af72e75bc741777
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7505da78dbaf10e6ce4cd085ccf5e1c8b786de6bbafd0c883a165c23d5d435ef069d4ca9006fd62ab333306f17438b8e6e923484a2810c09deedd00c54dfefff
|
7
|
+
data.tar.gz: 0036b1b3cd264e6fd88bc746785de160b3d9df9c99915eb00297da2d76844a85e6b1cc46b533c7c80ed9710e0d510f9bb7bd0d6344a19b159b8e1b95bdd63455
|
@@ -0,0 +1,14 @@
|
|
1
|
+
models = ARGV[0]
|
2
|
+
new = ARGV[1]
|
3
|
+
author = ARGV[2]
|
4
|
+
|
5
|
+
Dir.chdir(File.join(models,File.dirname(new)))
|
6
|
+
new = File.basename(new)
|
7
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple add "#{new}" 2>/dev/null`
|
8
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple add "#{new}.active" 2>/dev/null`
|
9
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple add "#{new}.active-uuid" 2>/dev/null`
|
10
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple add "#{new}.author" 2>/dev/null`
|
11
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple add "#{new}.creator" 2>/dev/null`
|
12
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple add "#{new}.stage" 2>/dev/null`
|
13
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple commit -m "#{author.gsub(/"/,"'")}"`
|
14
|
+
`GIT_TERMINAL_PROMPT=0 git push` rescue nil
|
@@ -22,72 +22,135 @@ require 'riddl/server'
|
|
22
22
|
require 'riddl/client'
|
23
23
|
require 'riddl/protocols/utils'
|
24
24
|
require 'fileutils'
|
25
|
+
require 'pathname'
|
26
|
+
require 'shellwords'
|
25
27
|
|
26
28
|
module CPEE
|
27
29
|
module ModelManagement
|
28
30
|
|
29
31
|
SERVER = File.expand_path(File.join(__dir__,'moma.xml'))
|
30
32
|
|
33
|
+
def self::git_mv(models,old,new)
|
34
|
+
cdir = Dir.pwd
|
35
|
+
Dir.chdir(File.join(models,File.dirname(old)))
|
36
|
+
p1 = Pathname.new(File.dirname(old))
|
37
|
+
p2 = Pathname.new(File.dirname(new))
|
38
|
+
old = File.basename(old)
|
39
|
+
new = File.join(p1.relative_path_from(p1).to_s,File.basename(new))
|
40
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple mv "#{old}" "#{new}" 2>/dev/null`
|
41
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple rm -rf "#{old + '.active'}" 2>/dev/null`
|
42
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple rm -rf "#{old + '.active-uuid'}" 2>/dev/null`
|
43
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple mv "#{old + '.author'}" "#{new + '.author'}" 2>/dev/null`
|
44
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple mv "#{old + '.creator'}" "#{new + '.creator'}" 2>/dev/null`
|
45
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple mv "#{old + '.stage'}" "#{new + '.stage'}" 2>/dev/null`
|
46
|
+
Dir.chdir(cdir)
|
47
|
+
end
|
48
|
+
def self::git_rm(models,new)
|
49
|
+
cdir = Dir.pwd
|
50
|
+
Dir.chdir(File.join(models,File.dirname(new)))
|
51
|
+
new = File.basename(new)
|
52
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple rm -rf "#{new}" 2>/dev/null`
|
53
|
+
FileUtils.rm_rf(new)
|
54
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple rm -rf "#{new}.active" 2>/dev/null`
|
55
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple rm -rf "#{new}.active-uuid" 2>/dev/null`
|
56
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple rm -rf "#{new}.author" 2>/dev/null`
|
57
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple rm -rf "#{new}.creator" 2>/dev/null`
|
58
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple rm -rf "#{new}.stage" 2>/dev/null`
|
59
|
+
Dir.chdir(cdir)
|
60
|
+
end
|
61
|
+
def self::git_shift(models,new)
|
62
|
+
cdir = Dir.pwd
|
63
|
+
Dir.chdir(File.join(models,File.dirname(new)))
|
64
|
+
new = File.basename(new)
|
65
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple rm -rf "#{new}.active" 2>/dev/null`
|
66
|
+
`git -c user.name='Christine Ashcreek' -c user.email=dev@null.com -c push.default=simple rm -rf "#{new}.active-uuid" 2>/dev/null`
|
67
|
+
Dir.chdir(cdir)
|
68
|
+
end
|
69
|
+
def self::git_commit(models,new,author)
|
70
|
+
rp = File.realpath(models)
|
71
|
+
crb = File.join(__dir__,'commit.rb')
|
72
|
+
system 'ruby ' + crb + ' ' + [rp, new, author].shelljoin + ' &'
|
73
|
+
end
|
74
|
+
def self::fs_mv(models,old,new)
|
75
|
+
fname = File.join(models,old)
|
76
|
+
fnname = File.join(models,new)
|
77
|
+
FileUtils.mv(fname,fnname)
|
78
|
+
File.delete(fname + '.active',fnname + '.active') rescue nil
|
79
|
+
File.delete(fname + '.active-uuid',fnname + '.active-uuid') rescue nil
|
80
|
+
FileUtils.mv(fname + '.author',fnname + '.author') rescue nil
|
81
|
+
FileUtils.mv(fname + '.creator',fnname + '.creator') rescue nil
|
82
|
+
FileUtils.mv(fname + '.stage',fnname + '.stage') rescue nil
|
83
|
+
end
|
84
|
+
def self::fs_cp(models,old,new)
|
85
|
+
fname = File.join(models,old)
|
86
|
+
fnname = File.join(models,new)
|
87
|
+
FileUtils.cp(fname,fnname)
|
88
|
+
File.delete(fname + '.active',fnname + '.active') rescue nil
|
89
|
+
File.delete(fname + '.active-uuid',fnname + '.active-uuid') rescue nil
|
90
|
+
FileUtils.cp(fname + '.author',fnname + '.author') rescue nil
|
91
|
+
FileUtils.cp(fname + '.creator',fnname + '.creator') rescue nil
|
92
|
+
FileUtils.cp(fname + '.stage',fnname + '.stage') rescue nil
|
93
|
+
end
|
94
|
+
def self::fs_rm(models,new)
|
95
|
+
fname = File.join(models,new)
|
96
|
+
FileUtils.rm_rf(fname)
|
97
|
+
File.delete(fname + '.active') rescue nil
|
98
|
+
File.delete(fname + '.active-uuid') rescue nil
|
99
|
+
File.delete(fname + '.author') rescue nil
|
100
|
+
File.delete(fname + '.creator') rescue nil
|
101
|
+
File.delete(fname + '.stage') rescue nil
|
102
|
+
end
|
103
|
+
def self::fs_shift(models,new)
|
104
|
+
fname = File.join(models,new)
|
105
|
+
File.delete(fname + '.active') rescue nil
|
106
|
+
File.delete(fname + '.active-uuid') rescue nil
|
107
|
+
Dir.chdir(cdir)
|
108
|
+
end
|
109
|
+
|
110
|
+
def self::git_dir(models,file)
|
111
|
+
return nil if file.nil?
|
112
|
+
cdir = Dir.pwd
|
113
|
+
tdir = File.dirname(file)
|
114
|
+
Dir.chdir(File.join(models,tdir))
|
115
|
+
res = `git rev-parse --absolute-git-dir 2>/dev/null`
|
116
|
+
Dir.chdir(cdir)
|
117
|
+
res == '' ? nil : res
|
118
|
+
end
|
119
|
+
|
31
120
|
def self::op(author,op,models,new,old=nil) #{{{
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
`git rm -rf "#{fname}.active-uuid" 2>/dev/null`
|
121
|
+
git_ndir = CPEE::ModelManagement::git_dir(models,new)
|
122
|
+
git_odir = CPEE::ModelManagement::git_dir(models,old)
|
123
|
+
|
124
|
+
if op == 'rm' && !git_ndir.nil?
|
125
|
+
git_rm models, new
|
126
|
+
git_commit models, new, author
|
127
|
+
elsif op == 'shift' && !git_ndir.nil?
|
128
|
+
git_shift models, new
|
129
|
+
git_commit models, new, author
|
130
|
+
elsif op == 'mv' && (!git_ndir.nil? || !git_odir.nil?)
|
131
|
+
if git_ndir == git_odir
|
132
|
+
git_mv models, old, new
|
133
|
+
git_commit models, new, author
|
134
|
+
elsif git_ndir != git_odir && !git_ndir.nil? && !git_odir.nil?
|
135
|
+
fs_cp models, old, new
|
136
|
+
git_rm models, old
|
137
|
+
git_commit models, old, author
|
138
|
+
git_commit models, new, author
|
139
|
+
elsif git_ndir != git_odir && git_ndir.nil?
|
140
|
+
fs_cp models, old, new
|
141
|
+
git_rm models, old
|
142
|
+
git_commit models, old, author
|
143
|
+
elsif git_ndir != git_odir && git_odir.nil?
|
144
|
+
fs_mv models, old, new
|
145
|
+
git_commit models, new, author
|
58
146
|
end
|
59
|
-
|
60
|
-
|
61
|
-
`git add "#{fname}.active" 2>/dev/null`
|
62
|
-
`git add "#{fname}.active-uuid" 2>/dev/null`
|
63
|
-
`git add "#{fname}.author" 2>/dev/null`
|
64
|
-
`git add "#{fname}.creator" 2>/dev/null`
|
65
|
-
`git add "#{fname}.stage" 2>/dev/null`
|
66
|
-
`git commit -m "#{author.gsub(/"/,"'")}"`
|
67
|
-
Dir.chdir(cdir)
|
147
|
+
elsif !git_ndir.nil?
|
148
|
+
git_commit models, new, author
|
68
149
|
else
|
69
150
|
case op
|
70
|
-
when 'mv'
|
71
|
-
|
72
|
-
|
73
|
-
FileUtils.mv(fname,fnname)
|
74
|
-
File.delete(fname + '.active',fnname + '.active') rescue nil
|
75
|
-
File.delete(fname + '.active-uuid',fnname + '.active-uuid') rescue nil
|
76
|
-
FileUtils.mv(fname + '.author',fnname + '.author') rescue nil
|
77
|
-
FileUtils.mv(fname + '.creator',fnname + '.creator') rescue nil
|
78
|
-
FileUtils.mv(fname + '.stage',fnname + '.stage') rescue nil
|
79
|
-
when 'rm'
|
80
|
-
fname = File.join(models,new)
|
81
|
-
FileUtils.rm_rf(fname)
|
82
|
-
File.delete(fname + '.active') rescue nil
|
83
|
-
File.delete(fname + '.active-uuid') rescue nil
|
84
|
-
File.delete(fname + '.author') rescue nil
|
85
|
-
File.delete(fname + '.creator') rescue nil
|
86
|
-
File.delete(fname + '.stage') rescue nil
|
87
|
-
when 'shift'
|
88
|
-
fname = File.join(models,new)
|
89
|
-
File.delete(fname + '.active') rescue nil
|
90
|
-
File.delete(fname + '.active-uuid') rescue nil
|
151
|
+
when 'mv'; fs_mv(models,old,new)
|
152
|
+
when 'rm'; fs_rm(models,new)
|
153
|
+
when 'shift'; fs_shift(models,new)
|
91
154
|
end
|
92
155
|
end
|
93
156
|
end #}}}
|
@@ -124,14 +187,15 @@ module CPEE
|
|
124
187
|
where = @a[0] == :main ? '' : Riddl::Protocols::Utils::unescape(@r.last)
|
125
188
|
views = @a[1]
|
126
189
|
models = @a[2]
|
127
|
-
stage = @p[0]&.value || 'draft'
|
128
|
-
stage
|
190
|
+
stage = [@p[0]&.value] || ['draft']
|
191
|
+
stage << views[stage[0]] if views && views[stage[0]]
|
192
|
+
|
129
193
|
|
130
194
|
names = Dir.glob(File.join(models,where,'*.dir')).map do |f|
|
131
195
|
{ :type => :dir, :name => File.basename(f), :creator => File.read(f + '.creator'), :date => File.mtime(f).xmlschema }
|
132
196
|
end.compact.uniq.sort_by{ |e| e[:name] } + Dir.glob(File.join(models,where,'*.xml')).map do |f|
|
133
197
|
fstage = File.read(f + '.stage').strip rescue 'draft'
|
134
|
-
{ :type => :file, :name => File.basename(f), :creator => File.read(f + '.creator'), :author => File.read(f + '.author'), :stage => fstage, :date => File.mtime(f).xmlschema } if fstage
|
198
|
+
{ :type => :file, :name => File.basename(f), :creator => File.read(f + '.creator'), :author => File.read(f + '.author'), :stage => fstage, :date => File.mtime(f).xmlschema } if stage.include?(fstage)
|
135
199
|
end.compact.uniq.sort_by{ |e| e[:name] }
|
136
200
|
|
137
201
|
Riddl::Parameter::Complex.new('list','application/json',JSON::pretty_generate(names))
|
@@ -141,14 +205,14 @@ module CPEE
|
|
141
205
|
def response
|
142
206
|
views = @a[0]
|
143
207
|
models = @a[1]
|
144
|
-
stage = @p[0]&.value || 'draft'
|
145
|
-
stage
|
208
|
+
stage = [@p[0]&.value] || ['draft']
|
209
|
+
stage << views[stage[0]] if views && views[stage[0]]
|
146
210
|
|
147
211
|
names = Dir.glob(File.join(models,'*.dir/*.xml')).map do |f|
|
148
212
|
{ :type => :file, :name => File.join(File.basename(File.dirname(f)),File.basename(f)), :creator => File.read(f + '.creator'), :date => File.mtime(f).xmlschema }
|
149
213
|
end.compact.uniq.sort_by{ |e| e[:name] } + Dir.glob(File.join(models,'*.xml')).map do |f|
|
150
214
|
fstage = File.read(f + '.stage').strip rescue 'draft'
|
151
|
-
{ :type => :file, :name => File.basename(f), :creator => File.read(f + '.creator'), :author => File.read(f + '.author'), :stage => fstage, :date => File.mtime(f).xmlschema } if fstage
|
215
|
+
{ :type => :file, :name => File.basename(f), :creator => File.read(f + '.creator'), :author => File.read(f + '.author'), :stage => fstage, :date => File.mtime(f).xmlschema } if stage.include?(fstage)
|
152
216
|
end.compact.uniq.sort_by{ |e| e[:name] }
|
153
217
|
|
154
218
|
Riddl::Parameter::Complex.new('list','application/json',JSON::pretty_generate(names))
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cpee-model-management
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juergen eTM Mangler
|
8
8
|
autorequire:
|
9
9
|
bindir: tools
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: riddl
|
@@ -51,6 +51,7 @@ files:
|
|
51
51
|
- README.md
|
52
52
|
- Rakefile
|
53
53
|
- cpee-model-management.gemspec
|
54
|
+
- lib/cpee-model-management/commit.rb
|
54
55
|
- lib/cpee-model-management/implementation.rb
|
55
56
|
- lib/cpee-model-management/moma.xml
|
56
57
|
- lib/cpee-model-management/stages
|