module LogCabin::Modules::Grep
Pull state from a local file
Public Instance Methods
load!()
click to toggle source
# File lib/prospectus/modules/grep.rb, line 8 def load! raise('No file specified') unless @file @find ||= '.*' line = read_file @state.value = regex_helper(line) end
Private Instance Methods
file(value)
click to toggle source
# File lib/prospectus/modules/grep.rb, line 25 def file(value) @file = value end
read_file()
click to toggle source
# File lib/prospectus/modules/grep.rb, line 17 def read_file File.read(@file).each_line do |line| line = line.chomp return line if line.match(@find) end raise("No lines in #{@file} matched #{@find}") end