Sha256: 87fccfaefb831d4daf0e140dda2da69f87d0638ced881e82e3200023015c7b68

Contents?: true

Size: 1.4 KB

Versions: 8

Compression:

Stored size: 1.4 KB

Contents

# frozen_string_literal: true

module Headdesk
  module Checks
    #
    # Module for Teak checks
    #
    module Teak
      #
      # Module for Teak APK checks
      #
      module APK
        def self.included(klass)
          klass.include(Check::APK)
          klass.extend(ClassMethods)
          klass.include(InstanceMethods)
        end

        #
        # Class methods for Teak based checks
        #
        module ClassMethods
          def check_name(cname = nil)
            cname = "teak/#{cname}" if cname
            super(cname)
          end
        end

        #
        # Instance methods for Teak based checks
        #
        module InstanceMethods
          def preconditions?
            begin
              major, minor, revision = apk.find_class('io.teak.sdk.Teak')
                                          .field('SDKVersion')
                                          .value
                                          .to_version
              @teak_sdk = OpenStruct.new(
                version: "#{major}.#{minor}.#{revision}",
                major: major, minor: minor, revision: revision
              )
            rescue NoMethodError => _e
              return false
            end
            true
          end

          def teak_sdk
            @teak_sdk
          end
        end
      end
    end
  end
end

Dir[File.dirname(__FILE__) + '/teak/*.rb'].each { |file| require file }

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
headdesk-0.17.0 lib/headdesk/checks/teak.rb
headdesk-0.16.2 lib/headdesk/checks/teak.rb
headdesk-0.16.1 lib/headdesk/checks/teak.rb
headdesk-0.16.0 lib/headdesk/checks/teak.rb
headdesk-0.15.1 lib/headdesk/checks/teak.rb
headdesk-0.15.0 lib/headdesk/checks/teak.rb
headdesk-0.14.0 lib/headdesk/checks/teak.rb
headdesk-0.13.0 lib/headdesk/checks/teak.rb