Sha256: c34b740a1f21b5152d5d0290bbf16be2abdf38341902c3b882edf242d2ed35a8

Contents?: true

Size: 1001 Bytes

Versions: 2

Compression:

Stored size: 1001 Bytes

Contents

module Ore
  #
  # Provides transparent access to {Ore::Specification}.
  #
  # @param [Symbol] name
  #   The constant name.
  #
  # @return [Object]
  #   The constant.
  #
  # @raise [NameError]
  #   The constant could not be found.
  #
  def self.const_missing(name)
    if name == :Specification
      begin
        # attempt to load 'ore/specification' from the $LOAD_PATH
        require 'ore/specification'
      rescue ::LoadError
        # find our `lib/` directory
        lib_dir = File.expand_path(File.dirname(__FILE__))

        # modify the $LOAD_PATH is 'ore/specification' is not available
        $LOAD_PATH << ORE_LIB_DIR unless $LOAD_PATH.include?(ORE_LIB_DIR)

        begin
          # attempt loading 'ore/specification' again
          require 'ore/specification'
        rescue ::LoadError
          # ore is probably not installed, so raise a NameError
          return super(name)
        end
      end

      return Ore.const_get(name)
    end

    super(name)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ore-0.1.3 lib/rubygems_plugin.rb
ore-0.1.2 lib/rubygems_plugin.rb