Module: FackUp::DB
- Defined in:
- lib/fackup/db.rb
Constant Summary collapse
- PATH =
File.join(Dir.home, '.fackup_files')
Class Method Summary collapse
- .all ⇒ Object
- .delete(path) ⇒ Object
- .each(&blk) ⇒ Object
- .path ⇒ Object
- .path=(p) ⇒ Object
- .push(path) ⇒ Object (also: <<)
Class Method Details
.all ⇒ Object
35 36 37 38 |
# File 'lib/fackup/db.rb', line 35 def all touch(DB.path) CSV.read(DB.path).map(&:first) end |
.delete(path) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/fackup/db.rb', line 56 def delete (path) path = File.realpath(path) a = all return false unless a.include?(path) CSV.open(DB.path, 'wb') {|csv| (a - [path]).each {|p| csv << [p] } } true end |
.each(&blk) ⇒ Object
40 41 42 |
# File 'lib/fackup/db.rb', line 40 def each (&blk) all.each(&blk) end |
.path ⇒ Object
31 32 33 |
# File 'lib/fackup/db.rb', line 31 def path @path ||= PATH end |
.path=(p) ⇒ Object
27 28 29 |
# File 'lib/fackup/db.rb', line 27 def path= (p) @path = File.realpath(p) end |