Class: LetsCert::IOPlugin
- Inherits:
-
Object
- Object
- LetsCert::IOPlugin
- Includes:
- Loggable
- Defined in:
- lib/letscert/io_plugin.rb
Overview
Input/output plugin
Direct Known Subclasses
Class Attribute Summary collapse
-
.registered ⇒ Hash
readonly
Get 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.
Instance Method Summary collapse
-
#initialize(name) ⇒ IOPlugin
constructor
A new instance of IOPlugin.
-
#load ⇒ Object
abstract
Load data from disk.
-
#save ⇒ Object
abstract
Save data to disk.
Methods included from Loggable
Constructor Details
#initialize(name) ⇒ IOPlugin
Returns a new instance of IOPlugin.
68 69 70 |
# File 'lib/letscert/io_plugin.rb', line 68 def initialize(name) @name = name end |
Class Attribute Details
.registered ⇒ Hash (readonly)
Get registered plugins
43 44 45 |
# File 'lib/letscert/io_plugin.rb', line 43 def registered @registered end |
Instance Attribute Details
#name ⇒ String (readonly)
Plugin name
33 34 35 |
# File 'lib/letscert/io_plugin.rb', line 33 def name @name end |
Class Method Details
.empty_data ⇒ Hash
Get empty data
47 48 49 |
# File 'lib/letscert/io_plugin.rb', line 47 def empty_data { account_key: nil, key: nil, cert: nil, chain: nil } end |
.register(klass, *args) ⇒ IOPlugin
Register a plugin
55 56 57 58 59 60 61 62 63 |
# File 'lib/letscert/io_plugin.rb', line 55 def register(klass, *args) plugin = klass.new(*args) if plugin.name =~ %r{[/\\]} or ['.', '..'].include?(plugin.name) raise Error, 'plugin name should just be a file name, without path' end @registered[plugin.name] = plugin klass end |
Instance Method Details
#load ⇒ Object
This method is abstract.
This method must be overriden in subclasses
Load data from disk
74 75 76 |
# File 'lib/letscert/io_plugin.rb', line 74 def load raise NotImplementedError end |
#save ⇒ Object
This method is abstract.
This method must be overriden in subclasses
Save data to disk
80 81 82 |
# File 'lib/letscert/io_plugin.rb', line 80 def save raise NotImplementedError end |