Class: RepoMate::Suite
- Inherits:
-
Object
- Object
- RepoMate::Suite
- Defined in:
- lib/repomate/suite.rb
Overview
Class for the suite layer of the directory structure
Class Method Summary collapse
-
.all ⇒ Object
Returns all directories without @rootdir.
-
.allowed ⇒ Object
Gets all configured architectures.
-
.dataset(category = nil) ⇒ Object
Returns a dataset including the name of the suite, the fullpath recursive through all lower layers.
Instance Method Summary collapse
-
#create ⇒ Object
Creates the directory strcuture of the suite including all lower layers.
-
#destroy ⇒ Object
Deletes the suites directory including all lower layers.
-
#directory ⇒ Object
Returns the directory strcuture of the suite including all lower layers.
-
#exist? ⇒ Boolean
Checks if the suite directory exists.
-
#initialize(suitename, category) ⇒ Suite
constructor
Init.
-
#is_allowed? ⇒ Boolean
Checks if the suite is allowed (See: configurationfile).
-
#is_unused?(dir) ⇒ Boolean
Checks if directory is unused.
-
#name ⇒ Object
Returns the given suite name (eg. lenny, squeeze).
Constructor Details
#initialize(suitename, category) ⇒ Suite
Init
8 9 10 11 |
# File 'lib/repomate/suite.rb', line 8 def initialize(suitename, category) @suitename = suitename @category = category end |
Class Method Details
.all ⇒ Object
Returns all directories without @rootdir
76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/repomate/suite.rb', line 76 def self.all categories = Category.all dirs = [] rootdir = Cfg.rootdir categories.each do |category| suites = Dir.glob(File.join(rootdir, category, "*")) suites.each do |suite| dirs.push suite.gsub(/#{rootdir}\//, '') if File.directory? suite end end return dirs end |
.allowed ⇒ Object
Gets all configured architectures
90 91 92 |
# File 'lib/repomate/suite.rb', line 90 def self.allowed Cfg.suites.uniq end |
.dataset(category = nil) ⇒ Object
Returns a dataset including the name of the suite, the fullpath recursive through all lower layers
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/repomate/suite.rb', line 57 def self.dataset(category=nil) data = [] self.all.each do |entry| # p entry parts = entry.split(/\//) unless parts.length < 2 next unless parts[0].eql?(category) || category.eql?("all") data << { :category => parts[0], :suitename => parts[1], :fullpath => File.join(Cfg.rootdir, entry), } end end data end |
Instance Method Details
#create ⇒ Object
Creates the directory strcuture of the suite including all lower layers
47 48 49 |
# File 'lib/repomate/suite.rb', line 47 def create FileUtils.mkdir_p(directory) unless exist? end |
#destroy ⇒ Object
Deletes the suites directory including all lower layers
52 53 54 |
# File 'lib/repomate/suite.rb', line 52 def destroy FileUtils.rm_r(directory) if exist? end |
#directory ⇒ Object
Returns the directory strcuture of the suite including all lower layers
19 20 21 |
# File 'lib/repomate/suite.rb', line 19 def directory File.join(Cfg.rootdir, @category, @suitename) end |
#exist? ⇒ Boolean
Checks if the suite directory exists
24 25 26 |
# File 'lib/repomate/suite.rb', line 24 def exist? Dir.exist?(directory) end |
#is_allowed? ⇒ Boolean
Checks if the suite is allowed (See: configurationfile)
29 30 31 |
# File 'lib/repomate/suite.rb', line 29 def is_allowed? self.allowed.include?(@suitename) end |
#is_unused?(dir) ⇒ Boolean
Checks if directory is unused
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/repomate/suite.rb', line 34 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 ⇒ Object
Returns the given suite name (eg. lenny, squeeze)
14 15 16 |
# File 'lib/repomate/suite.rb', line 14 def name @suitename end |