Sha256: 41e0611b2eaa44de695e68c9f73551232e5bc6bee6fc2ed32a337e7e92c81c7c

Contents?: true

Size: 724 Bytes

Versions: 1

Compression:

Stored size: 724 Bytes

Contents

# frozen_string_literal: true

module Textbringer
  module Plugin
    class << self
      attr_accessor :directory
    end

    @directory = File.expand_path("~/.textbringer/plugins")

    def self.load_plugins
      files = Gem.find_files("textbringer_plugin.rb").group_by { |file|
        file.slice(/([^\/]+)-[\w.]+\/lib\/textbringer_plugin\.rb\z/, 1)
      }.map { |gem, versions|
        versions.sort_by { |version|
          v = version.slice(/[^\/]+-([\w.]+)\/lib\/textbringer_plugin\.rb\z/,
                            1)
          Gem::Version.create(v)
        }.last
      } + Dir.glob(File.join(directory, "*/**/textbringer_plugin.rb"))
      files.each do |file|
        load(file)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
textbringer-0.2.2 lib/textbringer/plugin.rb