class RepoMate::Component
Class for the component layer of the directory structure
Public Class Methods
all()
click to toggle source
Returns all directories without @rootdir
# File lib/repomate/component.rb, line 81 def self.all config = Configuration.new suites = Suite.all dirs = [] rootdir = Cfg.rootdir suites.each do |suite| components = Dir.glob(File.join(rootdir, suite, "*")) components.each do |component| dirs.push component.gsub(/#{rootdir}\//, '') if File.directory? component end end return dirs end
allowed()
click to toggle source
Gets all configured architectures
# File lib/repomate/component.rb, line 96 def self.allowed Cfg.components.uniq end
dataset(category=nil)
click to toggle source
Returns a dataset including the name of the component, the fullpath recursive through all lower layers
# File lib/repomate/component.rb, line 63 def self.dataset(category=nil) data = [] self.all.each do |entry| parts = entry.split(/\//) unless parts.length < 3 next unless parts[0].eql?(category) || category.eql?("all") data << { :category => parts[0], :suitename => parts[1], :component => parts[2], :fullpath => File.join(Cfg.rootdir, entry) } end end data end
new(component, suitename, category)
click to toggle source
Init
# File lib/repomate/component.rb, line 8 def initialize(component, suitename, category) @component = component @suitename = suitename @category = category end
Public Instance Methods
create()
click to toggle source
Creates the directory strcuture of the component including all lower layers
# File lib/repomate/component.rb, line 48 def create FileUtils.mkdir_p(directory) unless exist? end
destroy()
click to toggle source
Deletes the components directory including all lower layers
# File lib/repomate/component.rb, line 53 def destroy FileUtils.rm_r(directory) if exist? end
directory()
click to toggle source
Returns the directory strcuture of the component including all lower layers
# File lib/repomate/component.rb, line 20 def directory File.join(Cfg.rootdir, @category, @suitename, @component) end
exist?()
click to toggle source
Checks if the component directory exists
# File lib/repomate/component.rb, line 25 def exist? Dir.exist?(directory) end
files()
click to toggle source
Returns a list of all debian files in the component directory
# File lib/repomate/component.rb, line 58 def files Dir.glob(File.join(directory, "*.deb")) end
is_allowed?()
click to toggle source
Checks if the component is allowed (See: configurationfile)
# File lib/repomate/component.rb, line 30 def is_allowed? self.allowed.include?(@component) end
is_unused?(dir)
click to toggle source
Checks if directory is unused
# File lib/repomate/component.rb, line 35 def is_unused?(dir) status = true path = Dir.glob(File.join(dir, "*")) path.each do |dirorfile| status = false if File.directory?(dirorfile) status = false if File.basename(dirorfile) =~ /\.deb$/ end status end
name()
click to toggle source
Returns the given architecture name (eg. main, contrib, non-free)
# File lib/repomate/component.rb, line 15 def name @component end