Sha256: c2590c740366bc099e894403f0ee96b6ff1e2c323ceaa2b9ce25a44887e9286b

Contents?: true

Size: 816 Bytes

Versions: 2

Compression:

Stored size: 816 Bytes

Contents

require "license_acceptance/strategy/base"

module LicenseAcceptance
  module Strategy

    # Look for acceptance values in the ARGV
    class Argument < Base

      attr_reader :argv

      def initialize(argv)
        @argv = argv
      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 argv.include?("--chef-license=#{sought}")
          return true
        end

        i = argv.index("--chef-license")
        unless i.nil?
          val = argv[i + 1]
          if !val.nil? && val.downcase == sought
            return true
          end
        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/argument.rb
license-acceptance-1.0.19 lib/license_acceptance/strategy/argument.rb