Sha256: 0b248f118e9e2e75923a6ea28e7b5d7b8eca88abc999b410b20cab923133d242

Contents?: true

Size: 1.39 KB

Versions: 30

Compression:

Stored size: 1.39 KB

Contents

module Vcloud
  class << self

    def services
      if Fog.credentials.has_key?(:vcloud)
        Fog.credentials[:vcloud].keys.sort { |a,b| a.to_s <=> b.to_s }
      else
        []
      end
    end

    def registered_services
      Vcloud.services.map { |service| ":" << service.to_s }.join(", ")
    end

    def complete_service_options?(service)
      if Fog.credentials.has_key?(:vcloud)
        if Fog.credentials[:vcloud].has_key?(service)
          service = Fog.credentials[:vcloud][service]
          if Fog::Vcloud.requirements.all? { |option| service.has_key?(option) }
            return true
          end
        end
      end
      false
    end

    if Vcloud.services.any? && Vcloud.services.all? { |service| Vcloud.complete_service_options?(service) }

      def initialized?
        true
      end

      def startup_notice
        puts "You have access to the following vCloud services: #{Vcloud.registered_services}."
      end

      def [](service)
        @@connections ||= Hash.new do |hash, key|
          if credentials = Fog.credentials[:vcloud][key]
            hash[key] = Fog::Vcloud.new(credentials)
          else
            raise ArgumentError.new("Unregistered service: :#{key}. Registered services are: #{Vcloud.registered_services}")
          end
        end
        @@connections[service]
      end

    else

      def initialized?
        false
      end

    end
  end
end

Version data entries

30 entries across 30 versions & 2 rubygems

Version Path
fog-0.2.30 lib/fog/vcloud/bin.rb
fog-0.2.28 lib/fog/vcloud/bin.rb
fog-0.2.27 lib/fog/vcloud/bin.rb
fog-0.2.26 lib/fog/vcloud/bin.rb
fog-0.2.25 lib/fog/vcloud/bin.rb
fog-0.2.24 lib/fog/vcloud/bin.rb
tecnh-fog-0.2.23.vpc lib/fog/vcloud/bin.rb
fog-0.2.23 lib/fog/vcloud/bin.rb
fog-0.2.22 lib/fog/vcloud/bin.rb
fog-0.2.21 lib/fog/vcloud/bin.rb
fog-0.2.20 lib/fog/vcloud/bin.rb
fog-0.2.19 lib/fog/vcloud/bin.rb
fog-0.2.18 lib/fog/vcloud/bin.rb
fog-0.2.17 lib/fog/vcloud/bin.rb
fog-0.2.16 lib/fog/vcloud/bin.rb
fog-0.2.15 lib/fog/vcloud/bin.rb
fog-0.2.14 lib/fog/vcloud/bin.rb
fog-0.2.13 lib/fog/vcloud/bin.rb
fog-0.2.12 lib/fog/vcloud/bin.rb
fog-0.2.11 lib/fog/vcloud/bin.rb