Sha256: 56c8bfc4f68589b865d46d67f674d9454914965bf38438041bcba7a3d5e962dc

Contents?: true

Size: 993 Bytes

Versions: 17

Compression:

Stored size: 993 Bytes

Contents

module Specinfra
  class HostInventory
    class Base
      private

      def create_parser_class(resource_type)
        os_info = backend.os
        family = os_info[:family]
        version = os_info[:release] ? "V#{os_info[:release].to_i}" : nil
        common_class = Specinfra::HostInventory::Parser
        base_class = common_class.const_get('Base')
        os_class = family.nil? ? base_class : common_class.const_get(family.capitalize)

        if family && version
          begin
            version_class = os_class.const_get(version)
          rescue
            version_class = os_class.const_get('Base')
          end
        elsif family.nil?
          version_class = os_class
        elsif family != 'base' && version.nil?
          version_class = os_class.const_get('Base')
        end

        begin
          parser_class = version_class.const_get(resource_type.to_camel_case)
        rescue
        end

        parser_class.create(backend)
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
koma-0.14.0 lib/koma/ext/specinfra/host_inventory/base.rb
koma-0.13.0 lib/koma/ext/specinfra/host_inventory/base.rb
koma-0.12.0 lib/koma/ext/specinfra/host_inventory/base.rb
koma-0.11.0 lib/koma/ext/specinfra/host_inventory/base.rb
koma-0.10.1 lib/koma/ext/specinfra/host_inventory/base.rb
koma-0.10.0 lib/koma/ext/specinfra/host_inventory/base.rb
koma-0.9.0 lib/koma/ext/specinfra/host_inventory/base.rb
koma-0.8.0 lib/koma/ext/specinfra/host_inventory/base.rb
koma-0.7.3 lib/koma/ext/specinfra/host_inventory/base.rb
koma-0.7.2 lib/koma/ext/specinfra/host_inventory/base.rb
koma-0.7.1 lib/koma/ext/specinfra/host_inventory/base.rb
koma-0.7.0 lib/koma/ext/specinfra/host_inventory/base.rb
koma-0.6.0 lib/koma/ext/specinfra/host_inventory/base.rb
koma-0.5.0 lib/koma/ext/specinfra/host_inventory/base.rb
koma-0.4.0 lib/koma/ext/specinfra/host_inventory/base.rb
koma-0.3.1 lib/koma/ext/specinfra/host_inventory/base.rb
koma-0.3.0 lib/koma/ext/specinfra/host_inventory/base.rb