banis-mod_dev 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/README.md +31 -0
- data/Rakefile +15 -0
- data/db/config/database.yml +26 -0
- data/db/development.sqlite3 +0 -0
- data/db/development.sqlite3-shm +0 -0
- data/db/development.sqlite3-wal +0 -0
- data/db/migrate/20231007103746_create_members.rb +10 -0
- data/db/migrate/20231007104054_create_dev_projects.rb +12 -0
- data/db/migrate/20231008003447_create_develements.rb +13 -0
- data/db/migrate/20231008101012_create_dev_repos.rb +14 -0
- data/db/migrate/20231008101321_create_dev_repos.rb +6 -0
- data/db/model/dev_project.rb +5 -0
- data/db/model/dev_repos.rb +5 -0
- data/db/model/develement.rb +5 -0
- data/db/schema.rb +44 -0
- data/lib/banis/mod_dev/ar/config.rb +35 -0
- data/lib/banis/mod_dev/dev_project.rb +239 -0
- data/lib/banis/mod_dev/dev_repos.rb +140 -0
- data/lib/banis/mod_dev/dev_repos_repos.rb +30 -0
- data/lib/banis/mod_dev/dev_repos_workspace.rb +37 -0
- data/lib/banis/mod_dev/develement.rb +120 -0
- data/lib/banis/mod_dev/version.rb +7 -0
- data/lib/banis/mod_dev.rb +54 -0
- data/sig/banis/mod_dev.rbs +6 -0
- metadata +221 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c2b699cfc89df1b7b4880f77815e09438e1234b5a3ea2b4ca41007b927f75fb5
|
4
|
+
data.tar.gz: 5ed5cc12799bbdbeb7c179a6d5484438b69fa9ec28d146c96be718f3c0d98bfd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4ac136ae12526e8c1dc32d52e50534bd8c977295437bad59ef386b3e46e4a4992fb4d726c5b4f4c63f8a9c92237b445771801186ffc35eab5315fce3ed517b0e
|
7
|
+
data.tar.gz: 6730e43efa6c559bee8ef7eedd9db7105713730ea24a45893c69e481b295d2d3a7430617ecb84b9ea9a56d2f37106e90818ff8464676853d3fc476152687c8ac
|
data/.rspec
ADDED
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Banis::ModDev
|
2
|
+
|
3
|
+
TODO: Delete this and the text below, and describe your gem
|
4
|
+
|
5
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/banis/mod_dev`. To experiment with that code, run `bin/console` for an interactive prompt.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
|
10
|
+
|
11
|
+
Install the gem and add to the application's Gemfile by executing:
|
12
|
+
|
13
|
+
$ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
|
14
|
+
|
15
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
16
|
+
|
17
|
+
$ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Development
|
24
|
+
|
25
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
26
|
+
|
27
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/banis-mod_dev.
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rspec/core/rake_task"
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
|
8
|
+
task default: :spec
|
9
|
+
require 'release/gem'
|
10
|
+
|
11
|
+
if ENV['BANIS_MODDEV_ENV'] == "development"
|
12
|
+
require 'argem'
|
13
|
+
require_relative 'lib/banis/mod_dev'
|
14
|
+
ARConfig = Banis::ModDev::AR::Config.new
|
15
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# SQLite. Versions 3.8.0 and up are supported.
|
2
|
+
# gem install sqlite3
|
3
|
+
#
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
+
# gem "sqlite3"
|
6
|
+
#
|
7
|
+
default: &default
|
8
|
+
adapter: sqlite3
|
9
|
+
#pool: 5
|
10
|
+
pool : 5
|
11
|
+
timeout: 5000
|
12
|
+
|
13
|
+
development:
|
14
|
+
<<: *default
|
15
|
+
database: /mnt/Vault/08.Dev/01.Workspaces/banis2/banis-mod_dev/lib/banis/mod_dev/ar/../../../../db/development.sqlite3
|
16
|
+
|
17
|
+
# Warning: The database defined as "test" will be erased and
|
18
|
+
# re-generated from your development database when you run "rake".
|
19
|
+
# Do not set this db to the same as development or production.
|
20
|
+
test:
|
21
|
+
<<: *default
|
22
|
+
database: /mnt/Vault/08.Dev/01.Workspaces/banis2/banis-mod_dev/lib/banis/mod_dev/ar/../../../../db/test.sqlite3
|
23
|
+
|
24
|
+
production:
|
25
|
+
<<: *default
|
26
|
+
database: /mnt/Vault/08.Dev/01.Workspaces/banis2/banis-mod_dev/lib/banis/mod_dev/ar/../../../../db/production.sqlite3
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateDevelements < ActiveRecord::Migration[7.1]
|
2
|
+
def change
|
3
|
+
create_table :develements do |t|
|
4
|
+
t.string :did
|
5
|
+
t.string :dev_project_id
|
6
|
+
t.string :title
|
7
|
+
t.text :notes
|
8
|
+
t.string :status
|
9
|
+
t.string :parent_id
|
10
|
+
t.string :tags
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class CreateDevRepos < ActiveRecord::Migration[7.1]
|
2
|
+
def change
|
3
|
+
create_table :dev_repos do |t|
|
4
|
+
t.string :did
|
5
|
+
t.string :dev_project_id
|
6
|
+
t.string :name
|
7
|
+
t.string :vcs_engine
|
8
|
+
t.integer :vcs_type, limit: 1
|
9
|
+
t.string :vcs_path
|
10
|
+
t.text :notes
|
11
|
+
t.string :status
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/db/schema.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# This file is auto-generated from the current state of the database. Instead
|
2
|
+
# of editing this file, please use the migrations feature of Active Record to
|
3
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
4
|
+
#
|
5
|
+
# This file is the source Rails uses to define your schema when running `bin/rails
|
6
|
+
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
|
7
|
+
# be faster and is potentially less error prone than running all of your
|
8
|
+
# migrations from scratch. Old migrations may fail to apply correctly if those
|
9
|
+
# migrations use external dependencies or application code.
|
10
|
+
#
|
11
|
+
# It's strongly recommended that you check this file into your version control system.
|
12
|
+
|
13
|
+
ActiveRecord::Schema[7.1].define(version: 2023_10_08_101012) do
|
14
|
+
create_table "dev_projects", force: :cascade do |t|
|
15
|
+
t.string "did"
|
16
|
+
t.string "name"
|
17
|
+
t.text "notes"
|
18
|
+
t.string "status"
|
19
|
+
t.string "tags"
|
20
|
+
t.integer "top_level_flag", limit: 1
|
21
|
+
end
|
22
|
+
|
23
|
+
create_table "dev_repos", force: :cascade do |t|
|
24
|
+
t.string "did"
|
25
|
+
t.string "dev_project_id"
|
26
|
+
t.string "name"
|
27
|
+
t.string "vcs_engine"
|
28
|
+
t.integer "vcs_type"
|
29
|
+
t.string "vcs_path"
|
30
|
+
t.text "notes"
|
31
|
+
t.string "status"
|
32
|
+
end
|
33
|
+
|
34
|
+
create_table "develements", force: :cascade do |t|
|
35
|
+
t.string "did"
|
36
|
+
t.string "dev_project_id"
|
37
|
+
t.string "title"
|
38
|
+
t.text "notes"
|
39
|
+
t.string "status"
|
40
|
+
t.string "parent_id"
|
41
|
+
t.string "tags"
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module Banis
|
4
|
+
module ModDev
|
5
|
+
module AR
|
6
|
+
class Config
|
7
|
+
# which env to use?
|
8
|
+
def env
|
9
|
+
"development"
|
10
|
+
end
|
11
|
+
|
12
|
+
# where to write the sqlite output?
|
13
|
+
def db_root
|
14
|
+
File.join(File.dirname(__FILE__),"..","..","..","..","db")
|
15
|
+
end
|
16
|
+
|
17
|
+
# where to read/write the database.yaml
|
18
|
+
def config_root
|
19
|
+
File.join(db_root,"config")
|
20
|
+
end
|
21
|
+
|
22
|
+
# where to write/read the migration file
|
23
|
+
def migration_root
|
24
|
+
File.join(db_root,"migrate")
|
25
|
+
end
|
26
|
+
|
27
|
+
# where to put the generated model class
|
28
|
+
def model_root
|
29
|
+
File.join(db_root,"model")
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,239 @@
|
|
1
|
+
|
2
|
+
require 'state_step'
|
3
|
+
require 'model_fact'
|
4
|
+
require 'fs_attachable'
|
5
|
+
require 'securerandom'
|
6
|
+
|
7
|
+
require 'debug'
|
8
|
+
|
9
|
+
require_relative 'dev_repos'
|
10
|
+
require_relative 'develement'
|
11
|
+
|
12
|
+
#ActiveRecord::Base.logger = TeLogger::Tlogger.new("devlog.log")
|
13
|
+
#Argem.logger = TeLogger::Tlogger.new
|
14
|
+
|
15
|
+
module Banis
|
16
|
+
module ModDev
|
17
|
+
|
18
|
+
class DevProject
|
19
|
+
include TR::CondUtils
|
20
|
+
|
21
|
+
include ModelFact::ModelHelper
|
22
|
+
|
23
|
+
include FsAttachable
|
24
|
+
domain :devProj
|
25
|
+
|
26
|
+
include Entagging
|
27
|
+
req_accessor :tags
|
28
|
+
|
29
|
+
req_accessor :did, :name, :notes, :status #, :parent_id
|
30
|
+
# top level => Project name at customer level.
|
31
|
+
# Will hold other project as sub projects
|
32
|
+
# Just a flag will do
|
33
|
+
req_accessor :top_level_flag
|
34
|
+
|
35
|
+
set_model_key :dev_project
|
36
|
+
|
37
|
+
|
38
|
+
#
|
39
|
+
# Status configuration should be inside the business
|
40
|
+
# object, which is here
|
41
|
+
#
|
42
|
+
include StateStep
|
43
|
+
|
44
|
+
status_init do
|
45
|
+
|
46
|
+
status_field :status
|
47
|
+
default :not_started
|
48
|
+
|
49
|
+
state trans: { :not_started => :active }, action: "Activate" do
|
50
|
+
end
|
51
|
+
|
52
|
+
state trans: { :active => :inactive }, action: "Inactivate" do
|
53
|
+
end
|
54
|
+
|
55
|
+
state trans: { :inactive => :active }, action: "Activate" do
|
56
|
+
end
|
57
|
+
|
58
|
+
state trans: { :active => :end_of_development }, action: "EOD" do
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
# to be included into DevProject
|
65
|
+
# AFTER the record is saved
|
66
|
+
module AfterSaveHelper
|
67
|
+
|
68
|
+
# Develement integration section
|
69
|
+
def new_develement(opts = {})
|
70
|
+
opts = {} if opts.nil?
|
71
|
+
opts[:dev_project_id] = self.model.did
|
72
|
+
dev = Develement.new(opts)
|
73
|
+
_devs << dev
|
74
|
+
dev
|
75
|
+
end
|
76
|
+
|
77
|
+
def develements(opts = {}, &block)
|
78
|
+
cond = opts || {}
|
79
|
+
cond.merge!(dev_project_id: model.did)
|
80
|
+
Develement.find_record(cond, &block)
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
# Repos integration section
|
85
|
+
def new_source_code_repos(type, path, opts = {})
|
86
|
+
opts = {} if opts.nil?
|
87
|
+
opts[:dev_project_id] = self.model.did
|
88
|
+
opts[:vcs_engine] = type
|
89
|
+
opts[:vcs_path] = path
|
90
|
+
repos = DevRepos.new(opts)
|
91
|
+
repos.set_vcs_as_repos
|
92
|
+
_repos << repos
|
93
|
+
repos
|
94
|
+
end
|
95
|
+
alias_method :new_repos, :new_source_code_repos
|
96
|
+
|
97
|
+
def new_source_code_workspace(type, path, opts = {})
|
98
|
+
opts = {} if opts.nil?
|
99
|
+
opts[:dev_project_id] = self.model.did
|
100
|
+
opts[:vcs_engine] = type
|
101
|
+
opts[:vcs_path] = path
|
102
|
+
ws = DevRepos.new(opts)
|
103
|
+
ws.set_vcs_as_workspace
|
104
|
+
_repos << ws
|
105
|
+
ws
|
106
|
+
end
|
107
|
+
alias_method :new_workspace, :new_source_code_workspace
|
108
|
+
|
109
|
+
def source_code_repos(opts = {})
|
110
|
+
cond = opts || {}
|
111
|
+
cond.merge!(dev_project_id: self.model.did)
|
112
|
+
DevRepos.find_record(cond)
|
113
|
+
end
|
114
|
+
alias_method :source_repos, :source_code_repos
|
115
|
+
|
116
|
+
def workspaces
|
117
|
+
DevRepos.find_record(dev_project_id: self.model.did, vcs_type: DevRepos::VCS_WORKSPACE)
|
118
|
+
end
|
119
|
+
alias_method :workspace, :workspaces
|
120
|
+
|
121
|
+
def repositories
|
122
|
+
DevRepos.find_record(dev_project_id: self.model.did, vcs_type: DevRepos::VCS_REPOSITORY)
|
123
|
+
end
|
124
|
+
alias_method :repository, :repositories
|
125
|
+
|
126
|
+
|
127
|
+
private
|
128
|
+
def _devs
|
129
|
+
if @_devs.nil?
|
130
|
+
@_devs = []
|
131
|
+
end
|
132
|
+
@_devs
|
133
|
+
end
|
134
|
+
|
135
|
+
def save_develements
|
136
|
+
_devs.each do |d|
|
137
|
+
d.save
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def _repos
|
142
|
+
if @_repos.nil?
|
143
|
+
@_repos = []
|
144
|
+
end
|
145
|
+
@_repos
|
146
|
+
end
|
147
|
+
|
148
|
+
def save_repos
|
149
|
+
_repos.each do |r|
|
150
|
+
r.save
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
155
|
+
|
156
|
+
|
157
|
+
def self.init_model
|
158
|
+
self.record_translator do |val|
|
159
|
+
case val
|
160
|
+
when Array, ActiveRecord::Relation
|
161
|
+
val.collect { |e| DevProject.new(instance: e) }
|
162
|
+
else
|
163
|
+
if not val.nil?
|
164
|
+
DevProject.new(instance: val)
|
165
|
+
else
|
166
|
+
val
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
|
173
|
+
def initialize(opts = {})
|
174
|
+
|
175
|
+
opts = {} if opts.nil?
|
176
|
+
if not opts[:instance].nil?
|
177
|
+
_mdl = opts[:instance]
|
178
|
+
_mdl.did = SecureRandom.uuid if is_empty?(_mdl.did)
|
179
|
+
set_model_instance(_mdl)
|
180
|
+
else
|
181
|
+
_mdl = ModelFact.new_instance(_model_key)
|
182
|
+
_mdl.did = SecureRandom.uuid
|
183
|
+
_mdl.send("name=", opts[:name]) if not_empty?(opts[:name])
|
184
|
+
set_model_instance(_mdl)
|
185
|
+
init_default_status
|
186
|
+
end
|
187
|
+
|
188
|
+
self.extend(AfterSaveHelper) if not _mdl.new_record?
|
189
|
+
|
190
|
+
@_logger = opts[:logger] if not opts[:logger].nil?
|
191
|
+
|
192
|
+
ensure_attributes_defined
|
193
|
+
|
194
|
+
@subProjects = []
|
195
|
+
|
196
|
+
self.class.init_model
|
197
|
+
end
|
198
|
+
|
199
|
+
def save
|
200
|
+
|
201
|
+
recType = :existing
|
202
|
+
if model.new_record?
|
203
|
+
recType = :new
|
204
|
+
raise DuplicatedRecordDetected, "Name '#{self.name}' already taken" if self.class.find_record(name: self.name).length > 0
|
205
|
+
else
|
206
|
+
raise DuplicatedRecordDetected, "Name '#{self.name}' already taken" if self.class.find_record(name: self.name).length > 1
|
207
|
+
end
|
208
|
+
|
209
|
+
res = model.save
|
210
|
+
|
211
|
+
if res and recType == :existing
|
212
|
+
save_develements
|
213
|
+
save_repos
|
214
|
+
end
|
215
|
+
|
216
|
+
res
|
217
|
+
|
218
|
+
end
|
219
|
+
|
220
|
+
|
221
|
+
private
|
222
|
+
def self.logger
|
223
|
+
if @_logger.nil?
|
224
|
+
@_logger = ModDev.logger(:dev_proj)
|
225
|
+
end
|
226
|
+
@_logger
|
227
|
+
end
|
228
|
+
|
229
|
+
def logger
|
230
|
+
if @_logger.nil?
|
231
|
+
@_logger = ModDev.logger(:dev_proj)
|
232
|
+
end
|
233
|
+
@_logger
|
234
|
+
end
|
235
|
+
|
236
|
+
end # class DevProject
|
237
|
+
|
238
|
+
end
|
239
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
|
2
|
+
require 'securerandom'
|
3
|
+
require_relative 'dev_repos_workspace'
|
4
|
+
require_relative 'dev_repos_repos'
|
5
|
+
|
6
|
+
module Banis
|
7
|
+
module ModDev
|
8
|
+
|
9
|
+
class DevRepos
|
10
|
+
include TR::CondUtils
|
11
|
+
|
12
|
+
include ModelFact::ModelHelper
|
13
|
+
req_accessor :did, :dev_project_id, :vcs_type, :vcs_path, :notes, :name, :vcs_engine
|
14
|
+
set_model_key :dev_project_repos
|
15
|
+
|
16
|
+
VCS_REPOSITORY = 0
|
17
|
+
VCS_WORKSPACE = 1
|
18
|
+
|
19
|
+
def self.init_model
|
20
|
+
self.record_translator do |val|
|
21
|
+
case val
|
22
|
+
when Array, ActiveRecord::Relation
|
23
|
+
val.collect { |e| DevRepos.new(instance: e) }
|
24
|
+
else
|
25
|
+
if not val.nil?
|
26
|
+
DevRepos.new(instance: val)
|
27
|
+
else
|
28
|
+
val
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
def initialize(opts = {})
|
36
|
+
opts = {} if opts.nil?
|
37
|
+
if not opts[:instance].nil?
|
38
|
+
_inst = opts[:instance]
|
39
|
+
_inst.did = SecureRandom.uuid if is_empty?(_inst.did)
|
40
|
+
set_model_instance(_inst)
|
41
|
+
else
|
42
|
+
_inst = ModelFact.new_instance(_model_key)
|
43
|
+
_inst.send("dev_project_id=", opts[:dev_project_id]) if not_empty?(opts[:dev_project_id])
|
44
|
+
_inst.send("name=", opts[:name]) if not_empty?(opts[:name])
|
45
|
+
# workspace? repository?
|
46
|
+
_inst.send("vcs_type=", opts[:vcs_type]) if not_empty?(opts[:vcs_type])
|
47
|
+
# git? svn?
|
48
|
+
_inst.send("vcs_engine=", opts[:vcs_engine]) if not_empty?(opts[:vcs_engine])
|
49
|
+
_inst.send("vcs_path=", File.expand_path(opts[:vcs_path])) if not_empty?(opts[:vcs_path])
|
50
|
+
_inst.send("notes=", opts[:notes]) if not_empty?(opts[:notes])
|
51
|
+
_inst.did = SecureRandom.uuid
|
52
|
+
set_model_instance(_inst)
|
53
|
+
end
|
54
|
+
ensure_attributes_defined
|
55
|
+
|
56
|
+
self.class.init_model
|
57
|
+
|
58
|
+
if is_vcs_workspace?
|
59
|
+
self.extend(DevReposWorkspace)
|
60
|
+
elsif is_vcs_repos?
|
61
|
+
self.extend(DevReposRepos)
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
def set_vcs_as_workspace
|
67
|
+
self.vcs_type = VCS_WORKSPACE
|
68
|
+
self.extend(DevReposWorkspace) if not self.is_a?(DevReposWorkspace)
|
69
|
+
end
|
70
|
+
def is_vcs_workspace?
|
71
|
+
self.vcs_type == VCS_WORKSPACE
|
72
|
+
end
|
73
|
+
|
74
|
+
def repos_type_name(sel = nil)
|
75
|
+
key = sel || self.vcs_type.to_i
|
76
|
+
case key
|
77
|
+
when VCS_WORKSPACE
|
78
|
+
"Workspace"
|
79
|
+
when VCS_REPOSITORY
|
80
|
+
"Repository"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def set_vcs_as_repos
|
85
|
+
self.vcs_type = VCS_REPOSITORY
|
86
|
+
self.extend(DevReposRepos) if not self.is_a?(DevReposRepos)
|
87
|
+
end
|
88
|
+
def is_vcs_repos?
|
89
|
+
self.vcs_type == VCS_REPOSITORY
|
90
|
+
end
|
91
|
+
|
92
|
+
def is_vcs_engine?(vt)
|
93
|
+
model.vcs_engine.to_s == vt.to_s
|
94
|
+
end
|
95
|
+
|
96
|
+
def save
|
97
|
+
model.save
|
98
|
+
end
|
99
|
+
|
100
|
+
private
|
101
|
+
#def method_missing(mtd, *args, &block)
|
102
|
+
# @_inst.send(mtd, *args, &block)
|
103
|
+
#end
|
104
|
+
|
105
|
+
#def respond_to_missing?(mtd, priv)
|
106
|
+
# @_inst.respond_to?(mtd)
|
107
|
+
#end
|
108
|
+
|
109
|
+
#def self.method_missing(mtd, *args, &block)
|
110
|
+
# cinst.send(mtd, *args, &block)
|
111
|
+
#end
|
112
|
+
|
113
|
+
#def self.cinst
|
114
|
+
# ModelFact.instance(_model_key)
|
115
|
+
#end
|
116
|
+
|
117
|
+
#def self.mdlClsMdl
|
118
|
+
# if @_cmdl.nil?
|
119
|
+
# @_cmdl = ModelFact.instance(_model_key)
|
120
|
+
# @_cmdl.record_translator do |val|
|
121
|
+
# case val
|
122
|
+
# when Array, ActiveRecord::Relation
|
123
|
+
# val.collect { |e| DevVcs.new(instance: e) }
|
124
|
+
# else
|
125
|
+
# if not val.nil?
|
126
|
+
# DevVcs.new(instance: val)
|
127
|
+
# else
|
128
|
+
# val
|
129
|
+
# end
|
130
|
+
# end
|
131
|
+
# end
|
132
|
+
# end
|
133
|
+
# @_cmdl
|
134
|
+
#end
|
135
|
+
|
136
|
+
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
require 'git_cli'
|
3
|
+
|
4
|
+
module Banis
|
5
|
+
module ModDev
|
6
|
+
|
7
|
+
module DevReposRepos
|
8
|
+
include GitCli::Clone
|
9
|
+
include GitCli::Init
|
10
|
+
|
11
|
+
def clone_into(dest)
|
12
|
+
st, res = clone(self.model.vcs_path, dest)
|
13
|
+
raise Error, "Error cloning repository. Error was : #{res}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def exist?
|
17
|
+
File.exist?(self.model.vcs_path)
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_if_not_exist
|
21
|
+
if not exist?
|
22
|
+
st, res = init(self.model.vcs_path, true)
|
23
|
+
raise Error, "Error initialize bare repository at '#{self.model.vcs_path}'. Error was : #{res}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
|
2
|
+
require 'git_cli'
|
3
|
+
require 'gity'
|
4
|
+
|
5
|
+
module Banis
|
6
|
+
module ModDev
|
7
|
+
module DevReposWorkspace
|
8
|
+
|
9
|
+
def has_changes?
|
10
|
+
not ws.is_clean?
|
11
|
+
end
|
12
|
+
|
13
|
+
def gity
|
14
|
+
Gity::Landing.new.run(model.vcs_path, no_exit: true) do |ops, *val|
|
15
|
+
# can listen to various operations feedback here to perform system specific
|
16
|
+
# functions such as to map the commit with develement issue... Can prompt too
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
def ws
|
22
|
+
if @_ws.nil?
|
23
|
+
@_ws = GitCli::Workspace.new(model.vcs_path)
|
24
|
+
raise Error, "Given path '#{model.vcs_path}' is not a git workspace." if not @_ws.is_workspace?
|
25
|
+
end
|
26
|
+
@_ws
|
27
|
+
end
|
28
|
+
|
29
|
+
def method_missing(mtd, *args, &block)
|
30
|
+
if ws.respond_to?(mtd)
|
31
|
+
ws.send(mtd, *args, &block)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
|
2
|
+
require 'entagging'
|
3
|
+
require 'securerandom'
|
4
|
+
|
5
|
+
module Banis
|
6
|
+
module ModDev
|
7
|
+
|
8
|
+
class Develement
|
9
|
+
include TR::CondUtils
|
10
|
+
|
11
|
+
include FsAttachable
|
12
|
+
domain :develement
|
13
|
+
|
14
|
+
include ModelFact::ModelHelper
|
15
|
+
req_accessor :did, :title, :notes, :status, :parent_id
|
16
|
+
set_model_key :develement
|
17
|
+
|
18
|
+
include Entagging
|
19
|
+
req_accessor :tags
|
20
|
+
|
21
|
+
#
|
22
|
+
# Status configuration should be inside the business
|
23
|
+
# object, which is here
|
24
|
+
#
|
25
|
+
include StateStep
|
26
|
+
status_init do
|
27
|
+
|
28
|
+
status_field :status
|
29
|
+
default :open
|
30
|
+
|
31
|
+
state trans: { :open => :in_progress }, action: "Start" do
|
32
|
+
end
|
33
|
+
|
34
|
+
state trans: { :in_progress => :done }, action: "Done" do
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.init_model
|
40
|
+
self.record_translator do |val|
|
41
|
+
case val
|
42
|
+
when Array, ActiveRecord::Relation
|
43
|
+
val.collect { |e| Develement.new(instance: e) }
|
44
|
+
else
|
45
|
+
if not val.nil?
|
46
|
+
Develement.new(instance: val)
|
47
|
+
else
|
48
|
+
val
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def initialize(opts = {})
|
55
|
+
|
56
|
+
opts = {} if opts.nil?
|
57
|
+
if not opts[:instance].nil?
|
58
|
+
_mdl = opts[:instance]
|
59
|
+
set_model_instance(_mdl)
|
60
|
+
|
61
|
+
else
|
62
|
+
_mdl = ModelFact.new_instance(_model_key)
|
63
|
+
_mdl.did = SecureRandom.uuid
|
64
|
+
_mdl.send("dev_project_id=", opts[:dev_project_id]) if not_empty?(opts[:dev_project_id])
|
65
|
+
_mdl.send("title=", opts[:title]) if not_empty?(opts[:title])
|
66
|
+
_mdl.send("notes=", opts[:notes]) if not_empty?(opts[:notes])
|
67
|
+
_mdl.send("parent_id=", opts[:parent_id]) if not_empty?(opts[:parent_id])
|
68
|
+
_mdl.send("tags=", opts[:tags]) if not_empty?(opts[:tags])
|
69
|
+
set_model_instance(_mdl)
|
70
|
+
|
71
|
+
init_default_status
|
72
|
+
end
|
73
|
+
|
74
|
+
ensure_attributes_defined
|
75
|
+
|
76
|
+
self.class.init_model
|
77
|
+
|
78
|
+
@children = []
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
def add_sub_develement(opts = {})
|
83
|
+
opts = {} if opts.nil?
|
84
|
+
opts[:parent_id] = model.did
|
85
|
+
d = Develement.new(opts)
|
86
|
+
@children << d
|
87
|
+
d
|
88
|
+
end
|
89
|
+
|
90
|
+
def sub_develements
|
91
|
+
if model.new_record?
|
92
|
+
@children
|
93
|
+
else
|
94
|
+
ModelFact.instance(Develement._model_key).find_record(parent_id: model.did)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def save
|
99
|
+
|
100
|
+
model.save
|
101
|
+
|
102
|
+
@children.each do |c|
|
103
|
+
c.parent_id = model.did if is_empty?(c.parent_id)
|
104
|
+
c.save
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
#def delete
|
110
|
+
# model.delete
|
111
|
+
#end
|
112
|
+
|
113
|
+
private
|
114
|
+
|
115
|
+
end # clas Develement
|
116
|
+
|
117
|
+
end # module ModDev
|
118
|
+
end # module Banis
|
119
|
+
|
120
|
+
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'teLogger'
|
4
|
+
require 'toolrack'
|
5
|
+
|
6
|
+
require 'state_step'
|
7
|
+
require 'model_fact'
|
8
|
+
|
9
|
+
if ENV['BANIS_MODDEV_ENV'] == "development"
|
10
|
+
require 'argem'
|
11
|
+
end
|
12
|
+
|
13
|
+
require_relative "mod_dev/version"
|
14
|
+
|
15
|
+
require_relative 'mod_dev/dev_project'
|
16
|
+
require_relative 'mod_dev/dev_repos'
|
17
|
+
require_relative 'mod_dev/develement'
|
18
|
+
|
19
|
+
require_relative 'mod_dev/ar/config'
|
20
|
+
|
21
|
+
module Banis
|
22
|
+
module ModDev
|
23
|
+
include TR::CondUtils
|
24
|
+
|
25
|
+
class Error < StandardError; end
|
26
|
+
class DuplicatedRecordDetected < Error; end
|
27
|
+
# Your code goes here...
|
28
|
+
|
29
|
+
def self.logger(tag = nil, &block)
|
30
|
+
if @_logger.nil?
|
31
|
+
@_logger = TeLogger::Tlogger.new("mod_dev.log",5, 5*1024*1024)
|
32
|
+
end
|
33
|
+
|
34
|
+
if block
|
35
|
+
if not_empty?(tag)
|
36
|
+
@_logger.with_tag(tag, &block)
|
37
|
+
else
|
38
|
+
@_logger.with_tag(@_logger.tag, &block)
|
39
|
+
end
|
40
|
+
else
|
41
|
+
if is_empty?(tag)
|
42
|
+
@_logger.tag = :mod_dev
|
43
|
+
@_logger
|
44
|
+
else
|
45
|
+
# no block but tag is given? hmm
|
46
|
+
@_logger.tag = tag
|
47
|
+
@_logger
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
metadata
ADDED
@@ -0,0 +1,221 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: banis-mod_dev
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-10-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: teLogger
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: toolrack
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.23'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.23'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: debug
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: release-gem
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: state_step
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.1.1
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.1.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: model_fact
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.1.1
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.1.1
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: fs_attachable
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.1.1
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.1.1
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: entagging
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.1.1
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.1.1
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: git_cli
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.13.7
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 0.13.7
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: gity
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - '='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 0.1.1
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - '='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 0.1.1
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: argem
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - '='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 0.1.0
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - '='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 0.1.0
|
167
|
+
description: ''
|
168
|
+
email:
|
169
|
+
- chris@antrapol.com
|
170
|
+
executables: []
|
171
|
+
extensions: []
|
172
|
+
extra_rdoc_files: []
|
173
|
+
files:
|
174
|
+
- ".rspec"
|
175
|
+
- README.md
|
176
|
+
- Rakefile
|
177
|
+
- db/config/database.yml
|
178
|
+
- db/development.sqlite3
|
179
|
+
- db/development.sqlite3-shm
|
180
|
+
- db/development.sqlite3-wal
|
181
|
+
- db/migrate/20231007103746_create_members.rb
|
182
|
+
- db/migrate/20231007104054_create_dev_projects.rb
|
183
|
+
- db/migrate/20231008003447_create_develements.rb
|
184
|
+
- db/migrate/20231008101012_create_dev_repos.rb
|
185
|
+
- db/migrate/20231008101321_create_dev_repos.rb
|
186
|
+
- db/model/dev_project.rb
|
187
|
+
- db/model/dev_repos.rb
|
188
|
+
- db/model/develement.rb
|
189
|
+
- db/schema.rb
|
190
|
+
- lib/banis/mod_dev.rb
|
191
|
+
- lib/banis/mod_dev/ar/config.rb
|
192
|
+
- lib/banis/mod_dev/dev_project.rb
|
193
|
+
- lib/banis/mod_dev/dev_repos.rb
|
194
|
+
- lib/banis/mod_dev/dev_repos_repos.rb
|
195
|
+
- lib/banis/mod_dev/dev_repos_workspace.rb
|
196
|
+
- lib/banis/mod_dev/develement.rb
|
197
|
+
- lib/banis/mod_dev/version.rb
|
198
|
+
- sig/banis/mod_dev.rbs
|
199
|
+
homepage: ''
|
200
|
+
licenses: []
|
201
|
+
metadata: {}
|
202
|
+
post_install_message:
|
203
|
+
rdoc_options: []
|
204
|
+
require_paths:
|
205
|
+
- lib
|
206
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
207
|
+
requirements:
|
208
|
+
- - ">="
|
209
|
+
- !ruby/object:Gem::Version
|
210
|
+
version: 2.6.0
|
211
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
requirements: []
|
217
|
+
rubygems_version: 3.4.6
|
218
|
+
signing_key:
|
219
|
+
specification_version: 4
|
220
|
+
summary: ''
|
221
|
+
test_files: []
|