Method: Usage.scan

Defined in:
lib/right_agent/scripts/usage.rb

.scan(file) ⇒ Object

Scans the given file from its usage (the top comment block) and returns it

Parameters

file(String)

path to file to read

Return

String

the usage as found in the file



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/right_agent/scripts/usage.rb', line 41

def self.scan(file)

  lines = File.readlines(file)  # Display usage from the given file
  result = []

  while line = lines.shift
    if m = line.match(/^ *#(.*)$/)
      result << m[1]
    else
      break unless result.empty?
    end
  end

  result.join("\n")
end