cpee-model-management 1.0.0 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 28a4708fee10b56828b2e1cc17ee2bc7387765132991cf5c615f81fcea9e7006
4
- data.tar.gz: d4b7307f3e0a31dd18f3538b48c2a6e79e3611ba2ecca20ae4acfce351e6d22e
3
+ metadata.gz: 2301d22c5a02dcace2fa736c3b41b88d02866c2cb2f3b68b2554e0766224486e
4
+ data.tar.gz: d8f20b6c8c5c620dab0f582566a3445f6b48498cecd36ea7670096d80319166c
5
5
  SHA512:
6
- metadata.gz: ed03d2f9904eee9563f75ef01145bbfcee94eb84daeb5c09244df7cbcaf8db9a9f3bc7b87883bf304ccbdf7cb523097edf7c4bf902d28bda2dd1f3a7be6203ba
7
- data.tar.gz: b64f5f194e8657b8110131c703b846ec1a78709f1d4ad77f0321a11fd752cee9aa89bc50d766405c0d87a617fe081b28c3ce416395230258e686532218765a6e
6
+ metadata.gz: c8de486ecdffc9c0cf93a7ca043e0d1363210d679223528270f9aa02e97aa2106386bb9a0240237f0c115321ea58127e13d0c24e33e414695ee1896676e88fa7
7
+ data.tar.gz: 711f92a0d044bd8bfc77cb56cd899df56343fd9fe80f9bc92170f4d86b0c5cced06edfd95f273879dbc59f59a27deaa7be4a25b5e572668621c062df7b9d82bd
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cpee-model-management"
3
- s.version = "1.0.0"
3
+ s.version = "1.0.5"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.license = "LGPL-3.0"
6
6
  s.summary = "(Lifecycle) manage your process models in a directory or git repo."
@@ -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
- if File.exists?(File.join(models,'.git'))
33
- cdir = Dir.pwd
34
- Dir.chdir(models)
35
- case op
36
- when 'mv'
37
- fname = old
38
- fnname = new
39
- `git mv "#{fname}" "#{fnname}" 2>/dev/null`
40
- `git rm -rf "#{fname + '.active'}" "#{fnname + '.active'}" 2>/dev/null`
41
- `git rm -rf "#{fname + '.active-uuid'}" "#{fnname + '.active-uuid'}" 2>/dev/null`
42
- `git mv "#{fname + '.author'}" "#{fnname + '.author'}" 2>/dev/null`
43
- `git mv "#{fname + '.creator'}" "#{fnname + '.creator'}" 2>/dev/null`
44
- `git mv "#{fname + '.stage'}" "#{fnname + '.stage'}" 2>/dev/null`
45
- when 'rm'
46
- fname = new
47
- `git rm -rf "#{fname}" 2>/dev/null`
48
- FileUtils.rm_rf(fname)
49
- `git rm -rf "#{fname}.active" 2>/dev/null`
50
- `git rm -rf "#{fname}.active-uuid" 2>/dev/null`
51
- `git rm -rf "#{fname}.author" 2>/dev/null`
52
- `git rm -rf "#{fname}.creator" 2>/dev/null`
53
- `git rm -rf "#{fname}.stage" 2>/dev/null`
54
- when 'shift'
55
- fname = new
56
- `git rm -rf "#{fname}.active" 2>/dev/null`
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
- fname = new
60
- `git add "#{fname}" 2>/dev/null`
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
- fname = File.join(models,old)
72
- fnname = File.join(models,new)
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 #}}}
data/server/moma CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/ruby
2
2
  require 'rubygems'
3
- require_relative '../lib/cpee-model-management/implementation'
3
+ require 'cpee-model-management/implementation'
4
4
 
5
5
  options = {
6
6
  :host => 'localhost',
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.0
4
+ version: 1.0.5
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-03-25 00:00:00.000000000 Z
11
+ date: 2021-03-27 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