Sha256: 90da1c46e27ad687c7b12721598188e492ab16b6a37429145ab2da055ef9cb79

Contents?: true

Size: 1.14 KB

Versions: 52

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

require 'active_support/inflector/methods'

module AppMap
  # Specific hook handler classes and general related utilities.
  module Handler
    TEMPLATE_RENDER_FORMAT = 'appmap.handler.template.return_value_format'
    TEMPLATE_RENDER_VALUE = 'appmap.handler.template.return_value'

    # Try to find handler module with a given name.
    #
    # If the module is not loaded, tries to require the appropriate file
    # using the usual conventions, eg. `Acme::Handler::AppMap` will try
    # to require `acme/handler/app_map`, then `acme/handler` and
    # finally `acme`. Raises NameError if the module could not be loaded
    # this way.
    def self.find(name)
      begin
        return Object.const_get name
      rescue NameError
        try_load ActiveSupport::Inflector.underscore name
      end
      Object.const_get name
    end

    def self.try_load(fname)
      fname = fname.sub %r{^app_map/}, 'appmap/'
      fname = fname.split '/'
      until fname.empty?
        begin
          require fname.join '/'
          return
        rescue LoadError
          # pass
        end
        fname.pop
      end
    end
  end
end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
appmap-1.1.1 lib/appmap/handler.rb
appmap-1.0.1 lib/appmap/handler.rb
appmap-1.0.0 lib/appmap/handler.rb
appmap-0.103.0 lib/appmap/handler.rb
appmap-0.102.2 lib/appmap/handler.rb
appmap-0.102.1 lib/appmap/handler.rb
appmap-0.102.0 lib/appmap/handler.rb
appmap-0.101.0 lib/appmap/handler.rb
appmap-0.100.0 lib/appmap/handler.rb
appmap-0.99.4 lib/appmap/handler.rb
appmap-0.99.2 lib/appmap/handler.rb
appmap-0.99.1 lib/appmap/handler.rb
appmap-0.99.0 lib/appmap/handler.rb
appmap-0.98.1 lib/appmap/handler.rb
appmap-0.98.0 lib/appmap/handler.rb
appmap-0.97.0 lib/appmap/handler.rb
appmap-0.96.0 lib/appmap/handler.rb
appmap-0.95.2 lib/appmap/handler.rb
appmap-0.95.1 lib/appmap/handler.rb
appmap-0.95.0 lib/appmap/handler.rb