Sha256: 57442fa323a1568f4bb364ef387125b579eb74657f2bc894f5fdb124fbeda247

Contents?: true

Size: 644 Bytes

Versions: 2

Compression:

Stored size: 644 Bytes

Contents

module ProxyPacRb
  # Validator for commandline options
  class CliValidator
    private

    attr_reader :options

    public

    def initialize(options)
      @options = options
    end

    def validate
      exit_with_message 'You need to provide at least one url. Multiple urls need to be separated by a space.' if empty_url?
      exit_with_message 'You need to provide a proxy pac file.' if empty_pac_file?
    end

    private

    def empty_url?
      options[:urls].blank?
    end

    def empty_pac_file?
      options[:proxy_pac].blank?
    end

    def exit_with_message(msg)
      $stderr.puts msg
      exit 1
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
proxy_pac_rb-0.3.8 lib/proxy_pac_rb/cli_validator.rb
proxy_pac_rb-0.3.7 lib/proxy_pac_rb/cli_validator.rb