Sha256: 7c2fcfa07f3236fb3348c8d4a7071d08799557fcd347197a430008eef13a14c3

Contents?: true

Size: 550 Bytes

Versions: 1

Compression:

Stored size: 550 Bytes

Contents

# from comment at http://devender.wordpress.com/2006/05/01/reading-and-writing-java-property-files-with-ruby/

module PgMigrate
  class Properties < Hash
    def initialize(filename = nil)
      if (filename) then
        File.open(filename).select { |line| not line=~/^[ \t]*(#.+)*$/ }.# ignore comments and blank lines
        each { |line|
          (k, v) = line.chomp.split('=', 2)
          self[k.strip] = v.strip
        }
      end
    end

    def to_s
      self.map { |k, v| " #{k}=#{v}" }.join("\n")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pg_migrate-0.1.11 lib/pg_migrate/props.rb