Sha256: 2b3a07086c45f1d5fcc44a9430617f7759856efc22966ce1a8a461923ed7bc5f

Contents?: true

Size: 653 Bytes

Versions: 2

Compression:

Stored size: 653 Bytes

Contents

require "license_acceptance/strategy/base"

module LicenseAcceptance
  module Strategy

    # Look for acceptance values in the environment
    class Environment < Base

      attr_reader :env

      def initialize(env)
        @env = env
      end

      def accepted?
        look_for_value(ACCEPT)
      end

      def silent?
        look_for_value(ACCEPT_SILENT)
      end

      def no_persist?
        look_for_value(ACCEPT_NO_PERSIST)
      end

      private

      def look_for_value(sought)
        if env["CHEF_LICENSE"] && env["CHEF_LICENSE"].downcase == sought
          return true
        end

        false
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
license-acceptance-2.0.0 lib/license_acceptance/strategy/environment.rb
license-acceptance-1.0.19 lib/license_acceptance/strategy/environment.rb