class RepoMate::Category
Class for the category layer of the directory structure
Public Class Methods
all()
click to toggle source
Returns all directories
# File lib/repomate/category.rb, line 53 def self.all dirs = Dir.glob(File.join(Cfg.rootdir, "*")) dirs.map{ |dir| File.basename(dir) unless dirs.include?(File.basename(dir)) } end
dataset(category=nil)
click to toggle source
Returns a dataset including the name of the category and the fullpath
# File lib/repomate/category.rb, line 38 def self.dataset(category=nil) data = [] self.all.each do |entry| unless entry.nil? next unless entry.eql?(category) || category.eql?("all") data << { :category => entry, :fullpath => File.join(Cfg.rootdir, entry) } end end data end
new(category)
click to toggle source
Init
# File lib/repomate/category.rb, line 8 def initialize(category) @category = category end
Public Instance Methods
create()
click to toggle source
Creates the directory strcuture of the category
# File lib/repomate/category.rb, line 28 def create FileUtils.mkdir_p(directory) unless exist? end
destroy()
click to toggle source
Deletes a categories directory
# File lib/repomate/category.rb, line 33 def destroy FileUtils.rm_r(directory) if exist? end
directory()
click to toggle source
Returns the full path of the categories directory
# File lib/repomate/category.rb, line 18 def directory File.join(Cfg.rootdir, @category) end
exist?()
click to toggle source
Checks if the category directory exists
# File lib/repomate/category.rb, line 23 def exist? Dir.exist?(directory) end
name()
click to toggle source
Returns the name of the category (eg. pool, dists)
# File lib/repomate/category.rb, line 13 def name @category end