class LetsencryptWebfaction::Options::Certificate
Constants
- SUPPORTED_VALIDATION_METHODS
- VALID_CERT_NAME
- VALID_KEY_SIZES
Public Class Methods
new(args)
click to toggle source
# File lib/letsencrypt_webfaction/options/certificate.rb, line 10 def initialize(args) @args = args end
Public Instance Methods
cert_name()
click to toggle source
# File lib/letsencrypt_webfaction/options/certificate.rb, line 30 def cert_name if @args['name'].nil? && domains.any? domains[0].gsub(VALID_CERT_NAME, '_') else @args['name'] end end
domains()
click to toggle source
# File lib/letsencrypt_webfaction/options/certificate.rb, line 14 def domains return [] if @args['domains'].nil? || @args['domains'] == '' Array(@args['domains']) end
errors()
click to toggle source
# File lib/letsencrypt_webfaction/options/certificate.rb, line 42 def errors # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity {}.tap do |e| e[:domains] = "can't be empty" if domains.none? e[:method] = 'must be "http01"' unless SUPPORTED_VALIDATION_METHODS.include?(validation_method) e[:public] = "can't be empty" if public_dirs.none? e[:name] = "can't be blank" if cert_name.nil? || cert_name == '' e[:name] = 'can only include letters, numbers, and underscores' if VALID_CERT_NAME.match?(cert_name) e[:key_size] = "must be one of #{VALID_KEY_SIZES.join(', ')}" unless VALID_KEY_SIZES.include?(key_size) end end
key_size()
click to toggle source
# File lib/letsencrypt_webfaction/options/certificate.rb, line 38 def key_size @args['key_size'] || 4096 end
public_dirs()
click to toggle source
# File lib/letsencrypt_webfaction/options/certificate.rb, line 24 def public_dirs return [] if @args['public'].nil? || @args['public'] == '' Array(@args['public']) end
validation_method()
click to toggle source
# File lib/letsencrypt_webfaction/options/certificate.rb, line 20 def validation_method @args['method'] || 'http01' end