Sha256: e6424ae61db8b57d548852c2d5bce655452391b9cb14eb328a65c85f51606659

Contents?: true

Size: 712 Bytes

Versions: 47

Compression:

Stored size: 712 Bytes

Contents

module Pliny
  module Utils
    def self.parse_env(file)
      env = {}
      File.open(file).each do |line|
        line = line.gsub(/#.*$/, '').strip
        next if line.empty?
        var, value = line.split("=", 2)
        value.gsub!(/^['"](.*)['"]$/, '\1')
        env[var] = value
      end
      env
    end

    # Requires an entire directory of source files in a stable way so that file
    # hierarchy is respected for load order.
    def self.require_glob(path)
      files = Dir[path].sort_by do |file|
        [file.count("/"), file]
      end

      files.each do |file|
        require file
      end
    end

    class << self
      alias :require_relative_glob :require_glob
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
pliny-0.1.0 lib/pliny/utils.rb
pliny-0.0.4 lib/pliny/utils.rb
pliny-0.0.3 lib/pliny/utils.rb
pliny-0.0.1 lib/pliny/utils.rb
pliny-0.0.1.pre3 lib/pliny/utils.rb
pliny-0.0.1.pre2 lib/pliny/utils.rb
pliny-0.0.1.pre lib/pliny/utils.rb