Sha256: 72ec9f0183ac5c25b65546680442b847472168de443efd03581e4f1ee90ac277

Contents?: true

Size: 1.74 KB

Versions: 1

Compression:

Stored size: 1.74 KB

Contents

require 'fog/core/credentials'

module Fog
  class << self

    def available_providers
      @providers.select {|provider| Kernel.const_get(provider).available?}
    end

  end

  class Bin
    class << self

      def available?
        availability = true
        for service in services
          begin
            service = self.class_for(service)
            availability &&= service.requirements.all? { |requirement| Fog.credentials.include?(requirement) }
          rescue ArgumentError => e
            warning = "[yellow][WARN] #{e.message}[/]"
            Formatador.display_line(warning)
            availability = false
          rescue => e
            availability = false
          end
        end

        if availability
          for service in services
            for collection in self.class_for(service).collections
              unless self.respond_to?(collection)
                self.class_eval <<-EOS, __FILE__, __LINE__
                  def self.#{collection}
                    self[:#{service}].#{collection}
                  end
                EOS
              end
            end
          end
        end

        availability
      end

      def collections
        services.map {|service| self[service].collections}.flatten.sort_by {|service| service.to_s}
      end

    end
  end

end

require 'fog/bin/aws'
require 'fog/bin/bluebox'
require 'fog/bin/brightbox'
require 'fog/bin/dnsimple'
require 'fog/bin/ecloud'
require 'fog/bin/go_grid'
require 'fog/bin/google'
require 'fog/bin/linode'
require 'fog/bin/local'
require 'fog/bin/new_servers'
require 'fog/bin/rackspace'
require 'fog/bin/slicehost'
require 'fog/bin/stormondemand'
require 'fog/bin/terremark'
require 'fog/bin/virtual_box'
require 'fog/bin/voxel'
require 'fog/bin/zerigo'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fog-0.8.2 lib/fog/bin.rb