/usr/lib/ruby/vendor_ruby/fog/core/services_mixin.rb is in ruby-fog-core 1.45.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | module Fog
module ServicesMixin
def [](provider)
new(:provider => provider)
end
def new(attributes)
attributes = attributes.dup # Prevent delete from having side effects
provider = attributes.delete(:provider).to_s.downcase.to_sym
provider_name = Fog.providers[provider]
raise ArgumentError, "#{provider} is not a recognized provider" unless providers.include?(provider)
require_service_provider_library(service_name.downcase, provider)
spc = service_provider_constant(service_name, provider_name)
spc.new(attributes)
rescue LoadError, NameError # Only rescue errors in finding the libraries, allow connection errors through to the caller
raise Fog::Service::NotFound, "#{provider} has no #{service_name.downcase} service"
end
def providers
Fog.services[service_name.downcase.to_sym] || []
end
private
def require_service_provider_library(service, provider)
require "fog/#{provider}/#{service}"
rescue LoadError # Try to require the service provider in an alternate location
require "fog/#{service}/#{provider}"
end
def service_provider_constant(service_name, provider_name)
Fog.const_get(service_name).const_get(*const_get_args(provider_name))
rescue NameError # Try to find the constant from in an alternate location
Fog.const_get(provider_name).const_get(*const_get_args(service_name))
end
# Ruby 1.8 does not support the second 'inherit' argument to #const_get
def const_get_args(*args)
if RUBY_VERSION < '1.9'
args
else
args + [false]
end
end
def service_name
name.split("Fog::").last
end
end
end
|