Class: Dep::List
- Inherits:
-
Object
- Object
- Dep::List
- Defined in:
- lib/dep.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #add(lib) ⇒ Object
-
#initialize(path = File.join(Dir.pwd, ".gems")) ⇒ List
constructor
A new instance of List.
- #libraries ⇒ Object
- #missing_libraries ⇒ Object
- #remove(lib) ⇒ Object
- #save ⇒ Object
Constructor Details
#initialize(path = File.join(Dir.pwd, ".gems")) ⇒ List
Returns a new instance of List.
5 6 7 |
# File 'lib/dep.rb', line 5 def initialize(path = File.join(Dir.pwd, ".gems")) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/dep.rb', line 3 def path @path end |
Instance Method Details
#add(lib) ⇒ Object
9 10 11 12 |
# File 'lib/dep.rb', line 9 def add(lib) remove(lib) libraries.push(lib) end |
#libraries ⇒ Object
18 19 20 |
# File 'lib/dep.rb', line 18 def libraries @libraries ||= File.readlines(path).map { |line| Lib[line] } end |
#missing_libraries ⇒ Object
22 23 24 |
# File 'lib/dep.rb', line 22 def missing_libraries libraries.reject(&:available?) end |
#remove(lib) ⇒ Object
14 15 16 |
# File 'lib/dep.rb', line 14 def remove(lib) libraries.delete_if { |e| e.name == lib.name } end |
#save ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/dep.rb', line 26 def save File.open(path, "w") do |file| libraries.each do |lib| file.puts lib.to_s end end end |