Class: Veewee::Provider::Core::Provider

Inherits:
Object
  • Object
show all
Includes:
Helper::Shell
Defined in:
lib/veewee/provider/core/provider.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helper::Shell

#shell_exec

Constructor Details

#initialize(name, options, env) ⇒ Provider

Returns 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,options,env)

  @env=env
  @name=name
  @options=options
  @type=self.class.to_s.split("::")[-2]
  check_requirements
end

Instance Attribute Details

#envObject

Returns the value of attribute env



7
8
9
# File 'lib/veewee/provider/core/provider.rb', line 7

def env
  @env
end

#nameObject

Returns the value of attribute name



11
12
13
# File 'lib/veewee/provider/core/provider.rb', line 11

def name
  @name
end

#optionsObject

Returns the value of attribute options



8
9
10
# File 'lib/veewee/provider/core/provider.rb', line 8

def options
  @options
end

#typeObject

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

.available?Boolean

Returns:

  • (Boolean)


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

#gem_available?(gemname) ⇒ Boolean

Returns:

  • (Boolean)


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

#gems_available?(names) ⇒ Boolean

Returns:

  • (Boolean)


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

#get_box(name) ⇒ Object



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