Class: Veewee::Provider::Core::Provider
- Inherits:
-
Object
- Object
- Veewee::Provider::Core::Provider
- Includes:
- Helper::Shell
- Defined in:
- lib/veewee/provider/core/provider.rb
Direct Known Subclasses
Kvm::Provider, Parallels::Provider, Virtualbox::Provider, Vmfusion::Provider
Instance Attribute Summary (collapse)
-
- (Object) env
Returns the value of attribute env.
-
- (Object) name
Returns the value of attribute name.
-
- (Object) options
Returns the value of attribute options.
-
- (Object) type
Returns the value of attribute type.
Class Method Summary (collapse)
Instance Method Summary (collapse)
- - (Boolean) gem_available?(gemname)
- - (Boolean) gems_available?(names)
- - (Object) get_box(name)
-
- (Provider) initialize(name, options, env)
constructor
A new instance of Provider.
Methods included from Helper::Shell
Constructor Details
- (Provider) initialize(name, options, env)
A new instance of Provider
15 16 17 18 19 20 21 22 |
# File 'lib/veewee/provider/core/provider.rb', line 15 def initialize(name,,env) @env=env @name=name @options= @type=self.class.to_s.split("::")[-2] check_requirements end |
Instance Attribute Details
- (Object) env
Returns the value of attribute env
7 8 9 |
# File 'lib/veewee/provider/core/provider.rb', line 7 def env @env end |
- (Object) name
Returns the value of attribute name
11 12 13 |
# File 'lib/veewee/provider/core/provider.rb', line 11 def name @name end |
- (Object) options
Returns the value of attribute options
8 9 10 |
# File 'lib/veewee/provider/core/provider.rb', line 8 def @options end |
- (Object) type
Returns the value of attribute type
10 11 12 |
# File 'lib/veewee/provider/core/provider.rb', line 10 def type @type end |
Class Method Details
+ (Boolean) available?
37 38 39 40 41 42 43 44 |
# File 'lib/veewee/provider/core/provider.rb', line 37 def self.available? begin self.check_requirements return true rescue Error return false end end |
Instance Method Details
- (Boolean) gem_available?(gemname)
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/veewee/provider/core/provider.rb', line 46 def gem_available?(gemname) env.logger.info "Checking for gem #{gemname}" available=false begin available=true unless Gem::Specification::find_by_name("#{gemname}").nil? rescue Gem::LoadError env.logger.info "Error loading gem #{gemname}" available=false rescue env.logger.info "Falling back to old syntax for #{gemname}" available=Gem.available?("#{gemname}") env.logger.info "Old syntax #{gemname}.available? #{available}" end return available end |
- (Boolean) gems_available?(names)
62 63 64 65 66 67 |
# File 'lib/veewee/provider/core/provider.rb', line 62 def gems_available?(names) names.each do |gemname| return false if !gem_available?(gemname) end return true end |
- (Object) get_box(name)
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/veewee/provider/core/provider.rb', line 24 def get_box(name) begin require_path='veewee/provider/'+type.to_s.downcase+"/box.rb" require require_path # Get a real box object from the Provider box=Object.const_get("Veewee").const_get("Provider").const_get(type.to_s.capitalize).const_get("Box").new(name,env) rescue Error => ex env.ui.error "Could not instante the box #{name} with provider #{type} ,#{ex}" raise end end |