Class: Anchor::PemBundle
- Inherits:
-
Object
- Object
- Anchor::PemBundle
- Defined in:
- lib/anchor/pem_bundle.rb
Overview
PEMBundle is a collection of PEM encoded certificates. It can be written to a temporarly file on disk as a bundle if needed.
This temp file to disk is needed for some other libraries that require a path to a pem file, and not a string of pem encoded certificates.
Constant Summary collapse
- DEFAULT_BASENAME =
'bundle.pem'
Instance Method Summary collapse
- #add_cert(cert) ⇒ Object
- #clear ⇒ Object
-
#initialize(pems: []) ⇒ PemBundle
constructor
A new instance of PemBundle.
- #path ⇒ Object
- #pems ⇒ Object
- #to_s ⇒ Object
- #with_path ⇒ Object
Constructor Details
#initialize(pems: []) ⇒ PemBundle
Returns a new instance of PemBundle.
15 16 17 18 19 20 |
# File 'lib/anchor/pem_bundle.rb', line 15 def initialize(pems: []) @pems = pems || [] @path = nil @temp_dir = nil @basename = DEFAULT_BASENAME end |
Instance Method Details
#add_cert(cert) ⇒ Object
37 38 39 40 |
# File 'lib/anchor/pem_bundle.rb', line 37 def add_cert(cert) @pems << cert remove_path end |
#clear ⇒ Object
46 47 48 49 |
# File 'lib/anchor/pem_bundle.rb', line 46 def clear @pems.clear remove_path end |
#path ⇒ Object
26 27 28 29 |
# File 'lib/anchor/pem_bundle.rb', line 26 def path write @path end |
#pems ⇒ Object
22 23 24 |
# File 'lib/anchor/pem_bundle.rb', line 22 def pems @pems.dup end |
#to_s ⇒ Object
42 43 44 |
# File 'lib/anchor/pem_bundle.rb', line 42 def to_s @pems.join("\n") end |
#with_path ⇒ Object
31 32 33 34 35 |
# File 'lib/anchor/pem_bundle.rb', line 31 def with_path yield(path) ensure remove_path end |