Sha256: 1cc7bacb7d587b8cee44eece323c3669c07c6a6d98239de54b7d2d17a1e70e1f

Contents?: true

Size: 1.11 KB

Versions: 6934

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,934 entries across 6,924 versions & 63 rubygems

Version Path
logstash-output-scalyr-0.1.12 vendor/bundle/jruby/2.5.0/gems/coderay-1.1.2/lib/coderay/helpers/plugin.rb
logstash-output-scalyr-0.1.11.beta vendor/bundle/jruby/2.5.0/gems/coderay-1.1.2/lib/coderay/helpers/plugin.rb
logstash-output-scalyr-0.1.10.beta vendor/bundle/jruby/2.5.0/gems/coderay-1.1.2/lib/coderay/helpers/plugin.rb
logstash-output-scalyr-0.1.9 vendor/bundle/jruby/2.5.0/gems/coderay-1.1.2/lib/coderay/helpers/plugin.rb
logstash-output-scalyr-0.1.8 vendor/bundle/jruby/2.5.0/gems/coderay-1.1.2/lib/coderay/helpers/plugin.rb
logstash-output-scalyr-0.1.7 vendor/bundle/jruby/2.5.0/gems/coderay-1.1.2/lib/coderay/helpers/plugin.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb
logstash-output-scalyr-0.1.6 vendor/bundle/jruby/2.5.0/gems/coderay-1.1.2/lib/coderay/helpers/plugin.rb
mfk_openapi_ruby_client-1.0.0 vendor/bundle/ruby/2.7.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb
logstash-output-newrelic-1.2.0 vendor/bundle/jruby/2.5.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb
qiita_org-0.1.35 gems/ruby/2.7.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb
qiita_org-0.1.34 gems/ruby/2.7.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb
qiita_org-0.1.33 gems/ruby/2.7.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb
qiita_org-0.1.32 gems/ruby/2.7.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb
qiita_org-0.1.31 gems/ruby/2.7.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb
qiita_org-0.1.30 gems/ruby/2.7.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb
qiita_org-0.1.29 gems/ruby/2.7.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb
passbase-1.2.0 vendor/bundle/ruby/2.7.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb