Sha256: 9b74d253036de68723d86065512899e421c5e35a8162c8d002e1af0bb5d355fd

Contents?: true

Size: 1.65 KB

Versions: 3

Compression:

Stored size: 1.65 KB

Contents

module Indexer
  # Name of this program.
  NAME = 'indexer'

  # Current stable revision of the specification (by year).
  REVISION = 2013

  # File name of locked metadata file.
  LOCK_FILE = '.index'

  # Default metadata file name for use by end-developer.
  USER_FILES = '{Indexfile,Indexfile.rb,Metadata,Metadata.yml,Metadata.yaml}'

  # Indexer library directory.
  LIBDIR = File.dirname(__FILE__) + '/indexer'

  # Indexer library directory.
  DATADIR = File.dirname(__FILE__) + '/../data/indexer'

  # Metadata from the project's `indexer.yml` index file.
  # This is used as a fallback for #const_missing.
  #
  # Returns [Hash] of metadata.
  def self.index
    @index ||= (
      require 'yaml'
      dir  = File.dirname(__FILE__)
      file = Dir[File.join(dir, "{#{NAME}.yml,../.index}")].first
      file ? YAML.load_file(file) : {}
    )
  end

  # Project metadata via RubyGems, fallback to index file.
  #
  # TODO: The #to_s on the gemspec return value is a bit too simplistic. But how to fix?
  #       The goal is reduce the value to a basic type (String, Hash, Array, Numeric).
  #
  def self.const_missing(const_name)
    name = const_name.to_s.downcase
    begin
      Gem.loaded_specs[NAME].send(name).to_s
    rescue StandardError
      index[name] || super(const_name)
    end
  end
end

require 'yaml'
require 'time'

require 'indexer/version/exceptions'
require 'indexer/version/number'
require 'indexer/version/constraint'

require 'indexer/core_ext'
require 'indexer/command'
require 'indexer/error'
require 'indexer/valid'
require 'indexer/revision'

require 'indexer/model'
require 'indexer/components'
require 'indexer/metadata'
require 'indexer/importer'

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
indexer-0.3.0 lib/indexer.rb
indexer-0.2.0 lib/indexer.rb
indexer-0.1.0 lib/indexer.rb