Class: Repository

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, url, siglevel) ⇒ Repository

Returns a new instance of Repository.



26
27
28
29
30
# File 'lib/repman.rb', line 26

def initialize(name, url, siglevel)
    @name = name
    @url = url
    @siglevel = siglevel
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



50
51
52
# File 'lib/repman.rb', line 50

def name
  @name
end

#siglevelObject

Returns the value of attribute siglevel.



52
53
54
# File 'lib/repman.rb', line 52

def siglevel
  @siglevel
end

#urlObject

Returns the value of attribute url.



51
52
53
# File 'lib/repman.rb', line 51

def url
  @url
end

Class Method Details

.all(config) ⇒ Object



45
46
47
48
49
# File 'lib/repman.rb', line 45

def self.all(config)
    config.sections.map do |name|
        Repository.load(config, name)
    end
end

.load(config, name) ⇒ Object



39
40
41
42
43
44
# File 'lib/repman.rb', line 39

def self.load(config, name)
    return nil unless config.has_section?(name)
    siglevel = config[name]['SigLevel']
    url = config[name]['Server']
    self.new(name, url, siglevel)
end

Instance Method Details

#remove(config) ⇒ Object



35
36
37
38
# File 'lib/repman.rb', line 35

def remove(config)
    config.delete_section(@name)
    config.write
end

#save(config) ⇒ Object



31
32
33
34
# File 'lib/repman.rb', line 31

def save(config)
    config[@name] = { 'Server' => @url, 'SigLevel' => @siglevel }
    config.write
end