Permalink
Browse files

Load plugins in ~/.textbringer/plugins/.

  • Loading branch information...
shugo committed Apr 6, 2017
1 parent cab5407 commit 66f8ee50adc3c53d5d6588d6700f8df6e3a6f4a2
Showing with 7 additions and 4 deletions.
  1. +7 −4 lib/textbringer/plugin.rb
View
@@ -2,20 +2,23 @@
module Textbringer
module Plugin
def self.directory
File.expand_path("~/.textbringer/plugins")
end
def self.load_plugins
files = Gem.find_files("textbringer_plugin.rb")
files.group_by { |file|
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
}.each do |file|
} + Dir.glob(File.join(directory, "*/**/textbringer_plugin.rb"))
files.each do |file|
load(file)
end
end
end
end

0 comments on commit 66f8ee5

Please sign in to comment.