Sha256: 4540f55d58ad6fcf6b860001adb7acabbe2f3c7950443c063499d1bc5dc33841
Contents?: true
Size: 1.28 KB
Versions: 2
Compression:
Stored size: 1.28 KB
Contents
require 'yaml' module CertFileMaker @@cert_names = [] def self.validate begin configuration = {} file = 'config/cert_file_maker.yml' raise StandardError unless File.exists?(file) yfile = ::YAML.load_file(file) configuration = yfile if yfile names = configuration.fetch('cert_names') @@cert_names = names.split(',').map(&:strip) if names rescue KeyError => e puts "=> CertFileMaker: config/cert_file_maker.yml #{e}" raise KeyError rescue StandardError => e puts "=> CertFileMaker: #{e} => Please create config/cert_file_maker.yml file with cert_names key" raise StandardError end end def self.cert_names @@cert_names end def self.generate begin puts '=> CertFileMaker loading' cert_names.each do |cert| next if File.exists?("#{cert.downcase}.pem") cert_file = ENV.fetch(cert) File.open("#{cert.downcase}.pem", 'w+') do |f| f.write cert_file end puts "=> CertFileMaker => Created: #{cert.downcase}.pem" end puts '=== CertFileMaker loaded ===' rescue KeyError => e puts "=> CertFileMaker Requires Environment variable exists => #{e}" raise KeyError end end end require 'cert_file_maker/railtie' if defined?(Rails)
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cert_file_maker-0.0.6 | lib/cert_file_maker.rb |
cert_file_maker-0.0.5 | lib/cert_file_maker.rb |