Roll  Roll::Locals

Parent

  • Object

Included Modules

[Validate]
Generated with WebRI Redfish 1.2.1

Locals

Constants

DIR

Public Class Methods

list() click to toggle source

List of available environments.

    # File lib/roll/locals.rb, line 17
17:     def self.list
18:       Dir[File.join(DIR, '*')].map do |file|
19:         File.basename(file)
20:       end
21:     end
new(name=nil) click to toggle source
    # File lib/roll/locals.rb, line 24
24:     def initialize(name=nil)
25:       @name = name || self.class.current
26:       reload
27:     end

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
name() click to toggle source
    # File lib/roll/locals.rb, line 30
30:     def name
31:       @name
32:     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
size() click to toggle source
    # File lib/roll/locals.rb, line 64
64:     def size
65:       @table.size
66:     end

Disabled; run with --debug to generate this.