Class: Gem::Sources::List
- Inherits:
-
Object
- Object
- Gem::Sources::List
show all
- Includes:
- Gem::Sources
- Defined in:
- lib/gem_check_sources/sources.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#currently_loaded_sources
Constructor Details
#initialize(sources = {}) ⇒ List
Returns a new instance of List.
19
20
21
22
23
|
# File 'lib/gem_check_sources/sources.rb', line 19
def initialize(sources = {})
self.active = sources[:active] || []
self.inactive = sources[:inactive] || []
self.unchecked = sources[:unchecked] || []
end
|
Instance Attribute Details
#active ⇒ Object
Returns the value of attribute active.
13
14
15
|
# File 'lib/gem_check_sources/sources.rb', line 13
def active
@active
end
|
#inactive ⇒ Object
Returns the value of attribute inactive.
13
14
15
|
# File 'lib/gem_check_sources/sources.rb', line 13
def inactive
@inactive
end
|
#unchecked ⇒ Object
Returns the value of attribute unchecked.
13
14
15
|
# File 'lib/gem_check_sources/sources.rb', line 13
def unchecked
@unchecked
end
|
Class Method Details
.load_file(file_name) ⇒ Object
15
16
17
|
# File 'lib/gem_check_sources/sources.rb', line 15
def self.load_file(file_name)
List.new(YAML.load_file(file_name))
end
|
Instance Method Details
#add(source) ⇒ Object
35
36
37
38
39
40
41
42
43
|
# File 'lib/gem_check_sources/sources.rb', line 35
def add(source)
available = source_available?(source)
if available
self.active << source
else
self.inactive << source
end
available
end
|
#all ⇒ Object
49
50
51
|
# File 'lib/gem_check_sources/sources.rb', line 49
def all
(active + inactive + unchecked).uniq
end
|
#dump(file_name) ⇒ Object
57
58
59
60
61
|
# File 'lib/gem_check_sources/sources.rb', line 57
def dump(file_name)
File.open(file_name, 'w') do |sources_file|
YAML.dump(to_h, sources_file)
end
end
|
#remove(source) ⇒ Object
45
46
47
|
# File 'lib/gem_check_sources/sources.rb', line 45
def remove(source)
[@active, @unchecked, @inactive].each { |list| list.delete(source) }
end
|
#size ⇒ Object
63
64
65
|
# File 'lib/gem_check_sources/sources.rb', line 63
def size
all.size
end
|
#sync ⇒ Object
29
30
31
32
33
|
# File 'lib/gem_check_sources/sources.rb', line 29
def sync
current_sources = currently_loaded_sources
(active - current_sources).each { |source| add_system_source(source) }
(inactive & current_sources).each { |source| remove_system_source(source) }
end
|
#to_h ⇒ Object
53
54
55
|
# File 'lib/gem_check_sources/sources.rb', line 53
def to_h
{:active => active, :inactive => inactive}
end
|
#verify ⇒ Object
25
26
27
|
# File 'lib/gem_check_sources/sources.rb', line 25
def verify
@active, @inactive = all.partition { |source| source_available?(source) }
end
|