Class: Ve::Manager
- Inherits:
-
Object
- Object
- Ve::Manager
- Defined in:
- lib/ve.rb
Constant Summary collapse
- @@config_for =
{}
Class Method Summary collapse
- .functions_for_language(language) ⇒ Object
- .languages ⇒ Object
- .provider_for(language, function) ⇒ Object
-
.register(klass, language) ⇒ Object
TODO: Make a difference between what features are available locally and what requires contacting external Ves.
- .set_default_config_for(klass, config = {}) ⇒ Object
Class Method Details
.functions_for_language(language) ⇒ Object
32 33 34 |
# File 'lib/ve.rb', line 32 def self.functions_for_language(language) @@provider_for[language.to_sym].keys end |
.languages ⇒ Object
28 29 30 |
# File 'lib/ve.rb', line 28 def self.languages @@provider_for.keys end |
.provider_for(language, function) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/ve.rb', line 18 def self.provider_for(language, function) provider = @@provider_for[language.to_sym][function.to_sym] if provider.is_a?(Class) config = @@config_for[provider] || {} provider = @@provider_for[language.to_sym][function.to_sym].new(config) @@provider_for[language.to_sym][function.to_sym] = provider end provider end |
.register(klass, language) ⇒ Object
TODO: Make a difference between what features are available locally and what requires contacting external Ves
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/ve.rb', line 38 def self.register(klass, language) @@provider_for ||= {} # This won't work if people start monkey patching the providers with public methods that arent abilities # It's also not pretty, but kinda nifty provider_name = klass.to_s.split('::').last parse_class = Kernel.class_eval("Ve::Parse::#{provider_name}") abilities = parse_class.public_instance_methods - Object.public_instance_methods abilities.each do |a| @@provider_for[language.to_sym] ||= {} @@provider_for[language.to_sym][a] = klass end end |
.set_default_config_for(klass, config = {}) ⇒ Object
14 15 16 |
# File 'lib/ve.rb', line 14 def self.set_default_config_for(klass, config = {}) @@config_for[klass] = config end |