Class: Photostat::Plugins::Base
- Inherits:
-
Object
- Object
- Photostat::Plugins::Base
- Defined in:
- lib/photostat/plugins/00_base.rb
Class Method Summary collapse
- .exposes(name = nil, help_text = nil) ⇒ Object
- .exposes_help ⇒ Object
- .extended(sub) ⇒ Object
- .help_text(msg = nil) ⇒ Object
- .included(sub) ⇒ Object
- .inherited(sub) ⇒ Object
- .plugin_name ⇒ Object
- .register_plugin(sub) ⇒ Object
Instance Method Summary collapse
Class Method Details
.exposes(name = nil, help_text = nil) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/photostat/plugins/00_base.rb', line 38 def self.exposes(name=nil, help_text=nil) @exposes_names ||= [] @exposes_help ||= {} if name @exposes_names << name @exposes_help[name] = help_text if help_text end @exposes_names end |
.exposes_help ⇒ Object
34 35 36 |
# File 'lib/photostat/plugins/00_base.rb', line 34 def self.exposes_help @exposes_help end |
.extended(sub) ⇒ Object
75 76 77 |
# File 'lib/photostat/plugins/00_base.rb', line 75 def self.extended(sub) register_plugin sub end |
.help_text(msg = nil) ⇒ Object
29 30 31 32 |
# File 'lib/photostat/plugins/00_base.rb', line 29 def self.help_text(msg=nil) @help_text = msg if msg @help_text end |
.included(sub) ⇒ Object
71 72 73 |
# File 'lib/photostat/plugins/00_base.rb', line 71 def self.included(sub) register_plugin sub end |
.inherited(sub) ⇒ Object
67 68 69 |
# File 'lib/photostat/plugins/00_base.rb', line 67 def self.inherited(sub) register_plugin sub end |
.plugin_name ⇒ Object
79 80 81 |
# File 'lib/photostat/plugins/00_base.rb', line 79 def self.plugin_name @plugin_name end |
.register_plugin(sub) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/photostat/plugins/00_base.rb', line 49 def self.register_plugin(sub) sub.name =~ /Photostat[:]{2}(\w+)/ name = $1 new_name = '' name.each_char do |ch| if ch != ch.downcase ch = ch.downcase ch = "_" + ch if new_name.length > 0 end new_name += ch end sub.instance_variable_set :@plugin_name, new_name ::Photostat::Plugins.all[new_name] = sub ::Photostat::Plugins.all_in_order << sub end |
Instance Method Details
#activate! ⇒ Object
83 84 85 |
# File 'lib/photostat/plugins/00_base.rb', line 83 def activate! # blank end |
#config ⇒ Object
105 106 107 |
# File 'lib/photostat/plugins/00_base.rb', line 105 def config # blank end |
#help ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/photostat/plugins/00_base.rb', line 87 def help puts "Photostat version #{Photostat::VERSION}" puts "Plugin: " + self.class.plugin_name.upcase puts puts "Usage: photostat <command> [options]*" puts "For help on each individual command: photostat <command> --help" puts puts "Where command is one of the following:" self.class.exposes.each do |name| msg = " #{self.class.plugin_name}:#{name}" if self.class.exposes_help[name] msg += "\t- " + self.class.exposes_help[name] end puts msg end puts end |