Sha256: 1cc7bacb7d587b8cee44eece323c3669c07c6a6d98239de54b7d2d17a1e70e1f

Contents?: true

Size: 1.11 KB

Versions: 6606

Compression:

Stored size: 1.11 KB

Contents

module CodeRay
  
  # = Plugin
  #
  #  Plugins have to include this module.
  #
  #  IMPORTANT: Use extend for this module.
  #
  #  See CodeRay::PluginHost for examples.
  module Plugin
    
    attr_reader :plugin_id
    
    # Register this class for the given +id+.
    # 
    # Example:
    #   class MyPlugin < PluginHost::BaseClass
    #     register_for :my_id
    #     ...
    #   end
    #
    # See PluginHost.register.
    def register_for id
      @plugin_id = id
      plugin_host.register self, id
    end
    
    # Returns the title of the plugin, or sets it to the
    # optional argument +title+.
    def title title = nil
      if title
        @title = title.to_s
      else
        @title ||= name[/([^:]+)$/, 1]
      end
    end
    
    # The PluginHost for this Plugin class.
    def plugin_host host = nil
      if host.is_a? PluginHost
        const_set :PLUGIN_HOST, host
      end
      self::PLUGIN_HOST
    end
    
    def aliases
      plugin_host.plugin_hash.inject [] do |aliases, (key, _)|
        aliases << key if plugin_host[key] == self
        aliases
      end
    end
    
  end
  
end

Version data entries

6,606 entries across 6,597 versions & 60 rubygems

Version Path
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/coderay-1.1.2/lib/coderay/helpers/plugin.rb
dadapush_client-1.0.1 vendor/bundle/ruby/2.3.0/gems/coderay-1.1.2/lib/coderay/helpers/plugin.rb
chess_engine-0.0.2 vendor/bundle/gems/coderay-1.1.2/lib/coderay/helpers/plugin.rb
chess_engine-0.0.1 vendor/bundle/gems/coderay-1.1.2/lib/coderay/helpers/plugin.rb
xaiml-0.1.3 vendor/bundle/ruby/2.5.0/gems/coderay-1.1.2/lib/coderay/helpers/plugin.rb
alimentos-alu0100945645-0.1.0 vendor/bundle/ruby/2.3.0/gems/coderay-1.1.2/lib/coderay/helpers/plugin.rb
alimentos-alu0100945645-1.0.0 vendor/bundle/ruby/2.3.0/gems/coderay-1.1.2/lib/coderay/helpers/plugin.rb
xaiml-0.1.2 vendor/bundle/ruby/2.5.0/gems/coderay-1.1.2/lib/coderay/helpers/plugin.rb
xaiml-0.1.1 vendor/bundle/ruby/2.5.0/gems/coderay-1.1.2/lib/coderay/helpers/plugin.rb
xaiml-0.1.0 vendor/bundle/ruby/2.5.0/gems/coderay-1.1.2/lib/coderay/helpers/plugin.rb
logstash-filter-device_detection-1.0.7-java vendor/bundle/jruby/1.9/gems/coderay-1.1.2/lib/coderay/helpers/plugin.rb
mrcooper-logstash-output-azuresearch-0.2.2 vendor/jruby/2.5.0/gems/coderay-1.1.2/lib/coderay/helpers/plugin.rb
monero_wallet_gen-0.1.0 vendor/bundle/ruby/2.3.0/gems/coderay-1.1.2/lib/coderay/helpers/plugin.rb
sb_prime_table-0.1.1 vendor/bundle/ruby/2.4.0/gems/coderay-1.1.2/lib/coderay/helpers/plugin.rb
sb_prime_table-0.1.0 vendor/bundle/ruby/2.4.0/gems/coderay-1.1.2/lib/coderay/helpers/plugin.rb
comiditaULL-0.1.1 vendor/bundle/ruby/2.3.0/gems/coderay-1.1.2/lib/coderay/helpers/plugin.rb
comidita_ull-0.1.1 vendor/bundle/ruby/2.3.0/gems/coderay-1.1.2/lib/coderay/helpers/plugin.rb
comidita_ull-0.1.0 vendor/bundle/ruby/2.3.0/gems/coderay-1.1.2/lib/coderay/helpers/plugin.rb
logstash-output-icinga-1.1.0 vendor/jruby/1.9/gems/coderay-1.1.1/lib/coderay/helpers/plugin.rb
logstash-output-icinga-1.1.0 vendor/jruby/2.3.0/gems/coderay-1.1.1/lib/coderay/helpers/plugin.rb