Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add plugin check option

  • Loading branch information...
commit 1a38b75e76a4c1739b98942ea2d55b71da3215c0 1 parent 7b4c627
@geraldb geraldb authored
View
2  Manifest.txt
@@ -10,6 +10,7 @@ lib/slideshow/cli/commands/fetch.rb
lib/slideshow/cli/commands/gen.rb
lib/slideshow/cli/commands/gen_templates.rb
lib/slideshow/cli/commands/list.rb
+lib/slideshow/cli/commands/plugins.rb
lib/slideshow/cli/commands/quick.rb
lib/slideshow/cli/opts.rb
lib/slideshow/cli/runner.rb
@@ -35,6 +36,7 @@ lib/slideshow/manifest_helpers.rb
lib/slideshow/markup/markdown.rb
lib/slideshow/markup/rest.rb
lib/slideshow/markup/textile.rb
+lib/slideshow/plugin_helpers.rb
lib/slideshow/slide.rb
lib/slideshow/version.rb
templates/s6.txt
View
2  lib/slideshow.rb
@@ -43,6 +43,7 @@ def self.slideshowopt
require 'slideshow/headers'
require 'slideshow/config'
require 'slideshow/manifest_helpers'
+require 'slideshow/plugin_helpers'
require 'slideshow/slide'
require 'slideshow/cli/opts'
@@ -51,6 +52,7 @@ def self.slideshowopt
require 'slideshow/cli/commands/gen'
require 'slideshow/cli/commands/gen_templates'
require 'slideshow/cli/commands/list'
+require 'slideshow/cli/commands/plugins'
require 'slideshow/cli/commands/quick'
View
37 lib/slideshow/cli/commands/plugins.rb
@@ -0,0 +1,37 @@
+module Slideshow
+
+class Plugins
+
+ include PluginHelper
+
+### fix: remove opts, use config (wrapped!!)
+
+ def initialize( logger, opts, config )
+ @logger = logger
+ @opts = opts
+ @config = config
+ end
+
+ attr_reader :logger, :opts, :config
+
+ def run
+ puts ''
+ puts 'Plugin scripts on the load path'
+
+ find_plugin_patterns.each_with_index do |pattern,i|
+ puts " [#{i+1}] #{pattern}"
+ end
+ puts ' include:'
+
+ plugins = find_plugins
+ if plugins.empty?
+ puts " -- none --"
+ else
+ plugins.each do |plugin|
+ puts " #{plugin}"
+ end
+ end
+ end
+
+end # class Plugins
+end # module Slideshow
View
10 lib/slideshow/cli/opts.rb
@@ -22,6 +22,16 @@ def quick?
end
+ def plugins=(boolean)
+ @plugins = boolean
+ end
+
+ def plugins?
+ return false if @plugins.nil? # default generate flag is false
+ @plugins == true
+ end
+
+
def generate=(boolean)
@generate = boolean
end
View
24 lib/slideshow/cli/runner.rb
@@ -2,6 +2,8 @@ module Slideshow
class Runner
+ include PluginHelper
+
def initialize
@logger = Logger.new(STDOUT)
@logger.level = Logger::INFO
@@ -14,25 +16,6 @@ def initialize
attr_reader :logger, :opts, :config, :headers
- def load_plugins
- patterns = []
- patterns << "#{config.config_dir}/lib/**/*.rb"
- patterns << 'lib/**/*.rb' unless Slideshow.root == File.expand_path( '.' ) # don't include lib if we are in repo (don't include slideshow/lib)
-
- patterns.each do |pattern|
- pattern.gsub!( '\\', '/') # normalize path; make sure all path use / only
- Dir.glob( pattern ) do |plugin|
- begin
- puts "Loading plugins in '#{plugin}'..."
- require( plugin )
- rescue Exception => e
- puts "** error: failed loading plugins in '#{plugin}': #{e}"
- end
- end
- end
- end # method load_plugins
-
-
def find_file_with_known_extension( fn )
dirname = File.dirname( fn )
basename = File.basename( fn, '.*' )
@@ -117,6 +100,7 @@ def run( args )
## fix:/todo: add generator for quickstart
cmd.on( '-q', '--quick', 'Generate Quickstart Slide Show Sample') { opts.quick = true }
+ cmd.on( '-p', '--plugins', '(Debug) List Plugin Scripts in Load Path' ) { opts.plugins = true }
cmd.on( '-v', '--version', "Show version" ) do
puts Slideshow.generator
@@ -165,6 +149,8 @@ def run( args )
if opts.list?
List.new( logger, opts, config ).run ### todo: remove opts (merge access into config)
+ elsif opts.plugins?
+ Plugins.new( logger, opts, config ).run ### todo: remove opts (merge access into config)
elsif opts.generate?
GenTemplates.new( logger, opts, config ).run ### todo: remove opts
elsif opts.quick?
View
43 lib/slideshow/plugin_helpers.rb
@@ -0,0 +1,43 @@
+module Slideshow
+
+module PluginHelper
+
+ def find_plugin_patterns
+ patterns = []
+ patterns << "#{config.config_dir}/lib/**/*.rb"
+ patterns << 'lib/**/*.rb' unless Slideshow.root == File.expand_path( '.' ) # don't include lib if we are in repo (don't include slideshow/lib)
+ patterns
+ end
+
+ def find_plugins
+ patterns = find_plugin_patterns
+
+ plugins=[]
+ patterns.each do |pattern|
+ pattern.gsub!( '\\', '/') # normalize path; make sure all path use / only
+ Dir.glob( pattern ) do |plugin|
+ plugins << plugin
+ end
+ end
+ plugins
+ end
+
+ def load_plugins
+ patterns = find_plugin_patterns
+
+ patterns.each do |pattern|
+ pattern.gsub!( '\\', '/') # normalize path; make sure all path use / only
+ Dir.glob( pattern ) do |plugin|
+ begin
+ puts "Loading plugins in '#{plugin}'..."
+ require( plugin )
+ rescue Exception => e
+ puts "** error: failed loading plugins in '#{plugin}': #{e}"
+ end
+ end
+ end
+ end # method load_plugins
+
+
+end # module PluginHelper
+end # module Slideshow
Please sign in to comment.
Something went wrong with that request. Please try again.