
# Reads in a file, removes blank lines and remarks
# (lines starting with '#') and then returns
# an array of all the remaining lines.
#
def File.read_list(filepath, chomp_string='')
  farr = nil
  farr = File.read(filepath).split("\n")
  farr.collect! { |line|
    l = line.strip.chomp(chomp_string)
    (l.empty? or l[0,1] == '#') ? nil : l
  }
  farr.compact
end



#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
=begin test

  require 'test/unit'

  # mock behavior for file access

  class File
    def self.mock_read( content )
      @content = content
    end
    def self.read( fpath )
      @content
    end
  end

  class TC_READ_LIST < Test::Unit::TestCase

    def test_read_list
      f = File.mock_read("A\nB\nC")
      s = File.read_list( f )
      r = ['A','B','C']
      assert_equal( r, s )
    end

  end

=end

