Added projects. Part 1

This commit is contained in:
alexey
2025-02-23 23:59:45 +03:00
parent d278cda22d
commit e68e781759
7 changed files with 106 additions and 5 deletions

View File

@@ -54,4 +54,12 @@ class IniConfig
[]
end
end
def get_projects_path()
unless @config["projects"]["path"].nil?
@config["projects"]["path"].to_s
else
"projects"
end
end
end

View File

@@ -12,6 +12,12 @@ end
class RepocRecips < Sequel::Model(:repos_recips)
end
class Projects < Sequel::Model(:projects)
end
class ReposProjects < Sequel::Model(:repos_projects)
end
class DBase
attr :error, :last_id
@@ -108,4 +114,8 @@ class DBase
RepocRecips.where(recip_id: id.to_i).delete
Recips.where(id: id.to_i).delete
end
def proj_list
Projects.order(:id).all
end
end

30
classes/projects.rb Normal file
View File

@@ -0,0 +1,30 @@
require_relative "db"
class ProjectsActions
attr :path, :error, :db
def initialize(path, db)
@path = nil
@error = nil
@db = db
if File.absolute_path?(path)
if File.exist?(path)
@path = path
end
else
apath = File.realpath(path)
if File.exist?(apath)
@path = apath
end
end
end
def get_projects
prj = []
File.open("locks/prjcreate", "r") do |f|
f.flock(File::LOCK_SH)
prj = @db.proj_list
end
prj
end
end