Class: Lolcommits::Plugin::Protonet
- Inherits:
-
Base
- Object
- Base
- Lolcommits::Plugin::Protonet
- Defined in:
- lib/lolcommits/plugin/protonet.rb
Class Method Summary collapse
-
.name ⇒ String
Returns the name of the plugin to identify the plugin to lolcommits.
-
.runner_order ⇒ Array
Returns position(s) of when this plugin should run during the capture process.
Instance Method Summary collapse
-
#configure_options! ⇒ Hash
Prompts the user to configure plugin options.
-
#configured? ⇒ Boolean
Returns true if the plugin has been configured.
-
#initialize(runner: nil, config: nil) ⇒ Protonet
constructor
Initialize plugin with runner, config and set all configurable options.
-
#run_capture_ready ⇒ RestClient::Response, Nil
Post-capture hook, runs after lolcommits captures a snapshot.
Constructor Details
#initialize(runner: nil, config: nil) ⇒ Protonet
Initialize plugin with runner, config and set all configurable options.
11 12 13 14 |
# File 'lib/lolcommits/plugin/protonet.rb', line 11 def initialize(runner: nil, config: nil) super .concat() end |
Class Method Details
.name ⇒ String
Returns the name of the plugin to identify the plugin to lolcommits.
21 22 23 |
# File 'lib/lolcommits/plugin/protonet.rb', line 21 def self.name 'protonet' end |
.runner_order ⇒ Array
Returns position(s) of when this plugin should run during the capture process. Posting to a Protonet box happens when a new capture is ready.
31 32 33 |
# File 'lib/lolcommits/plugin/protonet.rb', line 31 def self.runner_order [:capture_ready] end |
Instance Method Details
#configure_options! ⇒ Hash
Prompts the user to configure plugin options.
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/lolcommits/plugin/protonet.rb', line 40 def puts "-----------------------------------------------------------------" puts " Lolcommits Protonet Plugin Config" puts "-----------------------------------------------------------------" puts "\n" puts "We'll need an API endpoint & token. Find API info on your box at " puts "Help/Protonet Rest API. Visit https://protonet.com for more info." puts "-----------------------------------------------------------------" puts "\n" super end |
#configured? ⇒ Boolean
Returns true if the plugin has been configured.
token and endpoint are required.
58 59 60 61 62 |
# File 'lib/lolcommits/plugin/protonet.rb', line 58 def configured? !!(configuration['enabled'] && configuration['api_token'] && configuration['api_endpoint']) end |
#run_capture_ready ⇒ RestClient::Response, Nil
Post-capture hook, runs after lolcommits captures a snapshot. Posts the lolcommit image with a message to the Protonet box. API Documentation can be found on the Protonet box under Help/“Protonet REST API”
72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/lolcommits/plugin/protonet.rb', line 72 def run_capture_ready debug "Posting image (and message) to #{configuration['api_endpoint']}" RestClient.post( configuration['api_endpoint'], { files: [File.new(runner.main_image)], message: }, 'X-Protonet-Token' => configuration['api_token'] ) rescue => e log_error(e, "ERROR: RestClient POST FAILED #{e.class} - #{e.message}") nil end |