class LetsencryptWebfaction::Options
Constants
- NON_BLANK_FIELDS
- WEBFACTION_API_URL
Public Class Methods
default_config_path()
click to toggle source
# File lib/letsencrypt_webfaction/options.rb, line 28 def self.default_config_path Pathname.new(Dir.home).join('.config', 'letsencrypt_webfaction') end
default_options_path()
click to toggle source
# File lib/letsencrypt_webfaction/options.rb, line 24 def self.default_options_path Pathname.new(Dir.home).join('letsencrypt_webfaction.toml') end
from_toml(path)
click to toggle source
# File lib/letsencrypt_webfaction/options.rb, line 20 def self.from_toml(path) new TomlRB.parse(path.read) end
new(args)
click to toggle source
# File lib/letsencrypt_webfaction/options.rb, line 14 def initialize(args) @config = args # Fetch options # Validate options end
Public Instance Methods
api_url()
click to toggle source
# File lib/letsencrypt_webfaction/options.rb, line 48 def api_url @config['api_url'] || WEBFACTION_API_URL end
certificates()
click to toggle source
# File lib/letsencrypt_webfaction/options.rb, line 56 def certificates @_certs ||= @config['certificate'].map { |cert| Certificate.new(cert) } end
directory()
click to toggle source
# File lib/letsencrypt_webfaction/options.rb, line 44 def directory @config['directory'] end
errors()
click to toggle source
# File lib/letsencrypt_webfaction/options.rb, line 60 def errors {}.tap do |e| e[:endpoint] = 'needs to be updated to directory. See upgrade documentation.' if @config.key?('endpoint') NON_BLANK_FIELDS.each do |field| e[field] = "can't be blank" if public_send(field).nil? || public_send(field) == '' end cert_errors = certificates.map(&:errors).reject(&:empty?) e[:certificate] = cert_errors if cert_errors.any? end end
letsencrypt_account_email()
click to toggle source
# File lib/letsencrypt_webfaction/options.rb, line 40 def letsencrypt_account_email @config['letsencrypt_account_email'] end
password()
click to toggle source
# File lib/letsencrypt_webfaction/options.rb, line 36 def password @config['password'] end
servername()
click to toggle source
# File lib/letsencrypt_webfaction/options.rb, line 52 def servername @config['servername'] || Socket.gethostname.split('.')[0].sub(/^./, &:upcase) end
username()
click to toggle source
# File lib/letsencrypt_webfaction/options.rb, line 32 def username @config['username'] end
valid?()
click to toggle source
# File lib/letsencrypt_webfaction/options.rb, line 71 def valid? errors.none? end