Class: Vmpooler::Providers
- Inherits:
-
Object
- Object
- Vmpooler::Providers
- Defined in:
- lib/vmpooler/providers.rb
Class Method Summary collapse
-
.installed_providers ⇒ Array
-
returns an array of gem names that contain a provider.
-
-
.load_all_providers ⇒ Array
ie.
-
.load_by_name(names) ⇒ Array
ie.
Instance Method Summary collapse
-
#load_from_gems(name = nil) ⇒ Array[String]
Internal: Find any gems containing vmpooler provider plugins and load the main file in them.
-
#vmpooler_provider_gem_list ⇒ Array
Returns a list of vmpooler providers gem plugin specs.
Class Method Details
.installed_providers ⇒ Array
Returns - returns an array of gem names that contain a provider.
23 24 25 |
# File 'lib/vmpooler/providers.rb', line 23 def self.installed_providers self.new.vmpooler_provider_gem_list.map(&:name) end |
.load_all_providers ⇒ Array
ie. [“lib/vmpooler/providers/base.rb”, “lib/vmpooler/providers/dummy.rb”, “lib/vmpooler/providers/vsphere.rb”] although these files can come from any gem
18 19 20 |
# File 'lib/vmpooler/providers.rb', line 18 def self.load_all_providers self.new.load_from_gems end |
.load_by_name(names) ⇒ Array
ie. [“lib/vmpooler/providers/base.rb”, “lib/vmpooler/providers/dummy.rb”, “lib/vmpooler/providers/vsphere.rb”]
9 10 11 12 13 |
# File 'lib/vmpooler/providers.rb', line 9 def self.load_by_name(names) names = Array(names) instance = self.new names.map {|name| instance.load_from_gems(name)}.flatten end |
Instance Method Details
#load_from_gems(name = nil) ⇒ Array[String]
Internal: Find any gems containing vmpooler provider plugins and load the main file in them.
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/vmpooler/providers.rb', line 36 def load_from_gems(name = nil) paths = gem_directories.map do |gem_path| # we don't exactly know if the provider name matches the main file name that should be loaded # so we use globs to get everything like the name # this could mean that vsphere5 and vsphere6 are loaded when only vsphere5 is used Dir.glob(File.join(gem_path, "*#{name}*.rb")).each do |file| require file end end paths.flatten end |
#vmpooler_provider_gem_list ⇒ Array
Returns a list of vmpooler providers gem plugin specs
28 29 30 |
# File 'lib/vmpooler/providers.rb', line 28 def vmpooler_provider_gem_list gemspecs.find_all { |spec| File.directory?(File.join(spec.full_gem_path, provider_path)) } + included_lib_dirs end |