Class: Savon::FaradayMigrationHint

Inherits:
Object
  • Object
show all
Defined in:
lib/savon/faraday_migration_hint.rb

Overview

Formats the replacement Faraday setup for one HTTPI-only option.

Constant Summary collapse

VALUE_AWARE_OPTIONS =
%i[
  proxy
  open_timeout
  read_timeout
  write_timeout
  ssl_version
  ssl_min_version
  ssl_max_version
  ssl_verify_mode
  ssl_cert_key_file
  ssl_cert_file
  ssl_ca_cert_file
  ssl_ciphers
  ssl_ca_cert_path
  adapter
].freeze
STATIC_HINTS =
{
  ssl_cert_key: "client.faraday.ssl.client_key = key",
  ssl_cert_key_password: [
    "key = OpenSSL::PKey.read(File.read(key_path), password)",
    "client.faraday.ssl.client_key = key"
  ],
  ssl_cert: "client.faraday.ssl.client_cert = cert",
  ssl_ca_cert: [
    "store = OpenSSL::X509::Store.new",
    "store.set_default_paths",
    "store.add_cert(cert)",
    "client.faraday.ssl.cert_store = store"
  ],
  ssl_cert_store: "client.faraday.ssl.cert_store = store",
  basic_auth: "client.faraday.request :authorization, :basic, user, pass",
  digest_auth: [
    "gem 'faraday-digestauth'",
    "require 'faraday/digestauth'",
    "client.faraday.request :digest, user, pass"
  ],
  ntlm: [
    "gem 'faraday-ntlm_auth'",
    "require 'faraday/ntlm_auth'",
    "client.faraday.adapter :net_http_persistent",
    "client.faraday.request :ntlm_auth, auth: [user, pass, domain]"
  ],
  follow_redirects: [
    "gem 'faraday-follow_redirects'",
    "require 'faraday/follow_redirects'",
    "client.faraday.response :follow_redirects"
  ]
}.freeze
OPTIONS =
(VALUE_AWARE_OPTIONS + STATIC_HINTS.keys).freeze

Instance Method Summary collapse

Constructor Details

#initialize(option, value) ⇒ FaradayMigrationHint

Returns a new instance of FaradayMigrationHint.



60
61
62
63
# File 'lib/savon/faraday_migration_hint.rb', line 60

def initialize(option, value)
  @option = option
  @value = value
end

Instance Method Details

#messageObject



65
66
67
68
69
70
# File 'lib/savon/faraday_migration_hint.rb', line 65

def message
  hint = hint_lines
  return "  #{option} - Use: #{hint}" unless hint.is_a?(Array)

  "  #{option} - Use:\n#{hint.map { |line| "    #{line}" }.join("\n")}"
end