class Ironment::Runcom

Attributes

file[R]

Public Class Methods

new(file) click to toggle source
# File lib/ironment/runcom.rb, line 7
def initialize(file)
  @file = File.expand_path file
end

Public Instance Methods

==(other) click to toggle source
# File lib/ironment/runcom.rb, line 23
def ==(other)
  @file == other.file
end
content() click to toggle source
# File lib/ironment/runcom.rb, line 27
def content
  @content ||= File.read(file)
rescue Errno::EACCES
  raise AccessDenied, file
end
each_pair() click to toggle source
# File lib/ironment/runcom.rb, line 15
def each_pair
  if block_given?
    read_pairs.each &Proc.new
  else
    read_pairs.each
  end
end
sha1sum() click to toggle source
# File lib/ironment/runcom.rb, line 11
def sha1sum
  Digest::SHA1.hexdigest(content)
end

Private Instance Methods

read_pairs() click to toggle source
# File lib/ironment/runcom.rb, line 35
def read_pairs
  Hash[*content.split(/\n/).reject { |line|
    /^\s*#/ =~line
  }.map { |line|
    raise MalformedRuncom unless line.include? "="
    line.split(/=/)
  }.flatten]
end