Sha256: 7ba451f4e5e4dca36e7338d63ed5648000818632d6ffd2e7a66138c283fa8458

Contents?: true

Size: 993 Bytes

Versions: 6

Compression:

Stored size: 993 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 << lib_dir unless $LOAD_PATH.include?(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

6 entries across 6 versions & 2 rubygems

Version Path
ore-core-0.1.0 lib/rubygems_plugin.rb
ore-0.2.3 lib/rubygems_plugin.rb
ore-0.2.2 lib/rubygems_plugin.rb
ore-0.2.1 lib/rubygems_plugin.rb
ore-0.2.0 lib/rubygems_plugin.rb
ore-0.1.4 lib/rubygems_plugin.rb