Class: LetsCert::IOPlugin
- Inherits:
-
Object
- Object
- LetsCert::IOPlugin
- Includes:
- Loggable
- Defined in:
- lib/letscert/io_plugin.rb
Overview
Input/output plugin
Direct Known Subclasses
Constant Summary collapse
- ALLOWED_PLUGINS =
Allowed plugin names
%w(account_key.json cert.der cert.pem chain.pem full.pem) + %w(fullchain.pem key.der key.pem)
- @@registered =
Registered plugins
{}
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
Plugin name.
Class Method Summary collapse
-
.empty_data ⇒ Hash
Get empty data.
-
.register(klass, *args) ⇒ IOPlugin
Register a plugin.
-
.registered ⇒ Hash
Get registered plugins.
Instance Method Summary collapse
-
#initialize(name) ⇒ IOPlugin
constructor
A new instance of IOPlugin.
- #load ⇒ Object abstract
- #save ⇒ Object abstract
Methods included from Loggable
Constructor Details
#initialize(name) ⇒ IOPlugin
Returns a new instance of IOPlugin.
72 73 74 |
# File 'lib/letscert/io_plugin.rb', line 72 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ String (readonly)
Plugin name
34 35 36 |
# File 'lib/letscert/io_plugin.rb', line 34 def name @name end |
Class Method Details
.empty_data ⇒ Hash
Get empty data
46 47 48 |
# File 'lib/letscert/io_plugin.rb', line 46 def self.empty_data { account_key: nil, key: nil, cert: nil, chain: nil } end |
.register(klass, *args) ⇒ IOPlugin
Register a plugin
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/letscert/io_plugin.rb', line 54 def self.register(klass, *args) plugin = klass.new(*args) if plugin.name =~ /[\/\\]/ or ['.', '..'].include?(plugin.name) raise Error, "plugin name should just be a file name, without path" end @@registered[plugin.name] = plugin klass end |
.registered ⇒ Hash
Get registered plugins
67 68 69 |
# File 'lib/letscert/io_plugin.rb', line 67 def self.registered @@registered end |
Instance Method Details
#load ⇒ Object
This method is abstract.
This method must be overriden in subclasses
77 78 79 |
# File 'lib/letscert/io_plugin.rb', line 77 def load raise NotImplementedError end |
#save ⇒ Object
This method is abstract.
This method must be overriden in subclasses
82 83 84 |
# File 'lib/letscert/io_plugin.rb', line 82 def save raise NotImplementedError end |