Révision | 1ac0fbfb9caf931bc2db9dd1158bd5e00a1b44db (tree) |
---|---|
l'heure | 2009-09-22 22:49:08 |
Auteur | soutaro <soutaro@f836...> |
Commiter | soutaro |
for case if config.yaml is empty
git-svn-id: http://dev.ikejima.org/src/svn/pragger/trunk@415 f8368ae4-1e99-dc11-9799-0018f35ab5fa
@@ -10,7 +10,7 @@ $plugins = {} | ||
10 | 10 | class Plugin |
11 | 11 | attr_reader :source |
12 | 12 | def initialize(file) |
13 | - instance_eval( @source = File.read(file).toutf8, file , 1) | |
13 | + instance_eval( @source = File.read(file).toutf8, file.to_s , 1) | |
14 | 14 | end |
15 | 15 | def self.load_plugins(folder = (Pathname(__FILE__).parent + "plugin")) |
16 | 16 | Pathname.glob(folder.to_s + "**/*.rb").sort.each do |file| |
@@ -23,7 +23,7 @@ class Plugin | ||
23 | 23 | end |
24 | 24 | |
25 | 25 | def eval_pragger(command_array,data) |
26 | - command_array.inject(data) do |data, command| | |
26 | + (command_array || []).inject(data) do |data, command| | |
27 | 27 | $plugins[command["module"]].send(command["module"].sub(/.*::/,""), command["config"] || {}, data.clone) |
28 | 28 | end |
29 | 29 | end |
@@ -36,6 +36,7 @@ opt.on("-p", "--plugindir PLUGINDIR") {|v| Plugin.load_plugins(Pathname(v)) } | ||
36 | 36 | opt.on("-u", "--pluginusage PLUGINNAME") {|v| $plugins[v].source.gsub(/^## ?(.*)/){ puts $1 }; exit } |
37 | 37 | opt.on("-l", "--listplugin") { $plugins.keys.sort.each{|k| puts k }; exit } |
38 | 38 | opt.on("-w", "--where") { puts(Pathname(__FILE__).parent + "plugin"); exit } |
39 | +opt.on("-v", "--verbose") { $verbose = true } | |
39 | 40 | opt.parse! |
40 | 41 | |
41 | 42 | eval_pragger(YAML.load(File.read(configFile).toutf8.gsub(/base64::([\w+\/]+=*)/){ Base64.decode64($1) }),[]) |