Class: Lolcommits::Plugin::Protonet

Inherits:
Base
  • Object
show all
Defined in:
lib/lolcommits/plugin/protonet.rb

Instance Method Summary collapse

Constructor Details

#initialize(runner: nil, config: nil, name: nil) ⇒ Protonet

Initialize plugin with runner, config and set all configurable options.



13
14
15
16
# File 'lib/lolcommits/plugin/protonet.rb', line 13

def initialize(runner: nil, config: nil, name: nil)
  super
  options.concat([:api_endpoint, :api_token])
end

Instance Method Details

#configure_options!Hash

Prompts the user to configure plugin options.

Returns:

  • (Hash)

    a hash of configured plugin options



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/lolcommits/plugin/protonet.rb', line 23

def configure_options!
  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

#run_capture_readyRestClient::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”

Returns:

  • (RestClient::Response)

    response object from POST request

  • (Nil)

    if any error occurs



43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/lolcommits/plugin/protonet.rb', line 43

def run_capture_ready
  debug "Posting image (and message) to #{configuration[:api_endpoint]}"
  RestClient.post(
    configuration[:api_endpoint],
    {
      files: [File.new(runner.lolcommit_path)],
      message: message
    },
    'X-Protonet-Token' => configuration[:api_token]
  )
rescue => e
  log_error(e, "ERROR: RestClient POST FAILED #{e.class} - #{e.message}")
  nil
end