In Files
Parent
- Object
Included Modules
- Enumerable
Information
Locals
Constants
Public Class Methods
Public Instance Methods
append(path, depth=3)
click to toggle source
# File lib/roll/locals.rb, line 69
69: def append(path, depth=3)
70: path = File.expand_path(path)
71: depth = (depth || 3).to_i
72: @table = @table.reject{ |(p, d)| path == p }
73: @table.push([path, depth])
74: end
delete(path)
click to toggle source
# File lib/roll/locals.rb, line 77
77: def delete(path)
78: @table.reject!{ |p,d| path == p }
79: end
each(&block)
click to toggle source
# File lib/roll/locals.rb, line 59
59: def each(&block)
60: @table.each(&block)
61: end
file()
click to toggle source
# File lib/roll/locals.rb, line 35
35: def file
36: @file ||= File.join(DIR, name)
37: end
reload()
click to toggle source
# File lib/roll/locals.rb, line 40
40: def reload
41: t = []
42: if File.exist?(file)
43: lines = File.readlines(file)
44: lines.each do |line|
45: line = line.strip
46: path, depth = *line.split(/\s+/)
47: next if line =~ /^\s*$/ # blank
48: next if line =~ /^\#/ # comment
49: dir, depth = *line.split(/\s+/)
50: t << [path, (depth || 3).to_i]
51: end
52: else
53: t = []
54: end
55: @table = t
56: end
save()
click to toggle source
# File lib/roll/locals.rb, line 82
82: def save
83: out = @table.map do |(path, depth)|
84: "#{path} #{depth}"
85: end
86: dir = File.dirname(file)
87: FileUtils.mkdir_p(dir) unless File.exist?(dir)
88: File.open(file, 'w') do |f|
89: f << out.join("\n")
90: end
91: end
Disabled; run with --debug to generate this.