def self.read_from file_name, options = {}, &block
raise ArgumentError, "File to read from not found or not a file: #{file_name}" if !File.file? file_name
content = File.read file_name
if options[:before]
begin
regexp = options[:before].to_regexp
index = content.match(regexp).offset_before
content = content[0..index]
rescue
raise ArgumentError, ":before option must be a string or regular expression, was : #{options[:before]}"
end
end
if options[:after]
begin
regexp = options[:after].to_regexp
index = content.match(regexp).offset_after
content = content[index..-1]
rescue
raise ArgumentError, ":after option must be a string or regular expression, was : #{options[:after]}"
end
end
yield content if block
content
end