Sha256: 138a48575fec2ec3c1749f4ca201a3682b5dbb162a4256616211c3b9742b9cfe

Contents?: true

Size: 821 Bytes

Versions: 14

Compression:

Stored size: 821 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
        return false
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
license-acceptance-1.0.18 lib/license_acceptance/strategy/argument.rb
license-acceptance-1.0.13 lib/license_acceptance/strategy/argument.rb
license-acceptance-1.0.12 lib/license_acceptance/strategy/argument.rb
license-acceptance-1.0.11 lib/license_acceptance/strategy/argument.rb
license-acceptance-1.0.8 lib/license_acceptance/strategy/argument.rb
license-acceptance-1.0.7 lib/license_acceptance/strategy/argument.rb
license-acceptance-1.0.6 lib/license_acceptance/strategy/argument.rb
license-acceptance-1.0.5 lib/license_acceptance/strategy/argument.rb
license-acceptance-1.0.3 lib/license_acceptance/strategy/argument.rb
license-acceptance-1.0.2 lib/license_acceptance/strategy/argument.rb
license-acceptance-1.0.0 lib/license_acceptance/strategy/argument.rb
license-acceptance-0.2.16 lib/license_acceptance/strategy/argument.rb
license-acceptance-0.2.15 lib/license_acceptance/strategy/argument.rb
license-acceptance-0.2.13 lib/license_acceptance/strategy/argument.rb