Added projects. Part 1
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
30
classes/projects.rb
Normal 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
|
||||
Reference in New Issue
Block a user