Created
April 1, 2010 14:10
-
-
Save stormgrind/351840 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'singleton' | |
| require 'yaml' | |
| module BoxGrinder | |
| class PluginManager < Array | |
| include Singleton | |
| end | |
| class OperatingSystemPluginManager < PluginManager | |
| end | |
| class OperatingSystemPlugin | |
| def self.inherited(klass) | |
| OperatingSystemPluginManager.instance << klass.new | |
| end | |
| def name | |
| end | |
| def supported_versions | |
| [] | |
| end | |
| end | |
| class FedoraPlugin < OperatingSystemPlugin | |
| def name | |
| "fedora" | |
| end | |
| def supported_versions | |
| ['11', '12'] | |
| end | |
| end | |
| end | |
| os_plugin_manager = BoxGrinder::OperatingSystemPluginManager.instance | |
| puts "We have #{os_plugin_manager.size} plugin(s) registered." | |
| os_plugin_manager.each do |plugin| | |
| puts "Plugin for #{plugin.name} #{plugin.supported_versions.join(', ')}." | |
| end | |
| [oddthesis@lolek-f12 managers]$ ruby plugin-manager.rb | |
| We have 1 plugin(s) registered. | |
| Plugin for fedora 11, 12. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment