Class: LetsencryptHeroku::CLI

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

Constant Summary collapse

CONFIG_FILE =
'config/letsencrypt_heroku.yml'

Class Method Summary collapse

Class Method Details

.limit_entries(entries, limit) ⇒ Object



29
30
31
32
33
# File 'lib/letsencrypt_heroku.rb', line 29

def self.limit_entries(entries, limit)
  return entries if limit.nil?
  puts "Restrict to domains including: #{Rainbow(limit).yellow}"
  entries.select { |c| c.domains.include?(limit) }
end

.read_config_file(file) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/letsencrypt_heroku.rb', line 35

def self.read_config_file(file)
  if File.exist?(file)
    Array(YAML.load(File.read(file))).map { |c| OpenStruct.new(c) }
  else
    abort "Config file not found: #{Rainbow(file).red}"
  end
end

.run(opts) ⇒ Object



23
24
25
26
27
# File 'lib/letsencrypt_heroku.rb', line 23

def self.run(opts)
  entries = read_config_file(opts[:config])
  entries = limit_entries(entries, opts[:limit])
  entries.each { |entry| Process.new(entry).perform }
end