Module: Inspec::Backend
- Defined in:
- lib/inspec/backend.rb
Class Method Summary collapse
-
.create(config) ⇒ TransportBackend
Create the transport backend with aggregated resources.
Class Method Details
.create(config) ⇒ TransportBackend
Create the transport backend with aggregated resources.
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 |
# File 'lib/inspec/backend.rb', line 15 def self.create(config) conf = Train.target_config(config) name = conf[:backend] || :local transport = Train.create(name, conf) if transport.nil? fail "Can't find transport backend '#{name}'." end connection = transport.connection if connection.nil? fail "Can't connect to transport backend '#{name}'." end cls = Class.new do define_method :backend do connection end Inspec::Resource.registry.each do |id, r| define_method id.to_sym do |*args| r.new(self, id.to_s, *args) end end end cls.new rescue Train::ClientError => e raise "Client error, can't connect to '#{name}' backend: #{e.}" rescue Train::TransportError => e raise "Transport error, can't connect to '#{name}' backend: #{e.}" end |