Class: Rodbot::Plugins

Inherits:
Object
  • Object
show all
Defined in:
lib/rodbot/plugins.rb,
lib/rodbot/plugins/hal/app.rb,
lib/rodbot/plugins/otp/app.rb,
lib/rodbot/plugins/slack/relay.rb,
lib/rodbot/plugins/matrix/relay.rb,
lib/rodbot/plugins/github_webhook/app.rb,
lib/rodbot/plugins/gitlab_webhook/app.rb,
lib/rodbot/plugins/word_of_the_day/schedule.rb

Overview

Interface for bundled and gemified plugins

Defined Under Namespace

Classes: GithubWebhook, GitlabWebhook, Hal, Matrix, Otp, Slack, WordOfTheDay

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePlugins

Returns a new instance of Plugins.



16
17
18
# File 'lib/rodbot/plugins.rb', line 16

def initialize
  @extensions = {}
end

Instance Attribute Details

#extensionsHash (readonly)

Required service extensions from plugins

Returns:

  • (Hash)

    map from extension name (Symbol) to module or class path (String)



14
15
16
# File 'lib/rodbot/plugins.rb', line 14

def extensions
  @extensions
end

Instance Method Details

#extend_appObject

Extend app service with app components provided by all active plugins



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rodbot/plugins.rb', line 21

def extend_app
  require_extensions(:app) do |name, path|
    begin
      ::App.run(name, "#{path}/routes".constantize)
    rescue NameError
    end
    begin
      Roda::RodaPlugins.register_plugin(name, path.constantize)
    rescue NameError
    end
  end
end

#extend_relayObject

Extend relay service with relay components provided by all active plugins



35
36
37
38
# File 'lib/rodbot/plugins.rb', line 35

def extend_relay
  return if extensions.key? :relay
  require_extensions(:relay)
end

#extend_scheduleObject

Extend schedule service with schedule components provided by all active plugins



42
43
44
45
46
47
# File 'lib/rodbot/plugins.rb', line 42

def extend_schedule
  return if extensions.key? :schedule
  require_extensions(:schedule) do |name, path|
    path.constantize.new
  end
end