Class: RepoMate::Suite

Inherits:
Object
  • Object
show all
Defined in:
lib/repomate/suite.rb

Overview

Class for the suite layer of the directory structure

Class Method Summary collapse

Instance Method Summary collapse

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

.allObject

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

.allowedObject

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

#createObject

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

#destroyObject

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

#directoryObject

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

Returns:

  • (Boolean)


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)

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


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

#nameObject

Returns the given suite name (eg. lenny, squeeze)



14
15
16
# File 'lib/repomate/suite.rb', line 14

def name
  @suitename
end