Sha256: f538cd6ce338e32530c8f9fb18bfde021b7aec0dfd86af499df8a018d8d7ecde

Contents?: true

Size: 933 Bytes

Versions: 1

Compression:

Stored size: 933 Bytes

Contents

require 'yaml'
require 'facet/hash/traverse'
require 'facet/string/tabto'


module ProjectInfo
  extend self

  INFO_FILES = [ 'ProjectInfo', 'ReapFile', 'projectinfo', 'reapfile' ]

  def add_info_file( f )
    INFO_FILES.unshift( f )
  end

  def info_stream
    unless @info_stream
      info_file = INFO_FILES.find{ |f| File.file?( f ) }
      if info_file
        @info_stream = File.read( info_file )
      end
    end
    @info_stream
  end

  def info
    if info_stream
      @info ||= YAML::load(info_stream).traverse{ |k,v| [k.downcase, v] }
    else
      {}
    end
  end

  # not using at the moment
  def validate
    # required main parameters
    #raise "TITLE is a required configuration field" unless info['title']
    raise "NAME is a required piece of information" unless info['name']
    raise "VERSION is a required piece of informatiomn" unless info['version']
  end

  def [](name)
    info[name]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
reap-4.0.0 lib/reap/projectinfo.rb