Module: CertFileMaker
- Defined in:
- lib/version.rb,
lib/generator.rb,
lib/cert_file_maker.rb,
lib/cert_file_maker/railtie.rb
Defined Under Namespace
Classes: Generator, Railtie
Constant Summary
collapse
- VERSION =
'0.0.7'.freeze
- @@cert_names =
[]
Class Method Summary
collapse
Class Method Details
.cert_names ⇒ Object
22
23
24
|
# File 'lib/cert_file_maker.rb', line 22
def self.cert_names
@@cert_names
end
|
.generate ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/cert_file_maker.rb', line 26
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
File.chmod(0400, "#{cert.downcase}.pem")
puts "=> CertFileMaker => Created: #{cert.downcase}.pem"
end
puts '=== CertFileMaker loaded ==='
rescue KeyError => e
puts "=> CertFileMaker Requires Environment variable exists => #{e}"
raise KeyError
end
end
|
.validate ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/cert_file_maker.rb', line 4
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
|