class Lolcommits::Plugin::Protonet

Public Class Methods

new(runner: nil, config: nil, name: nil) click to toggle source

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

Calls superclass method
# File lib/lolcommits/plugin/protonet.rb, line 13
def initialize(runner: nil, config: nil, name: nil)
  super
  options.concat([:api_endpoint, :api_token])
end

Public Instance Methods

configure_options!() click to toggle source

Prompts the user to configure plugin options.

@return [Hash] a hash of configured plugin options

Calls superclass method
# 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_ready() click to toggle source

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”

@return [RestClient::Response] response object from POST request @return [Nil] if any error occurs

# 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

Private Instance Methods

message() click to toggle source

Returns a randomly generated message describing the lolcommit, with repo info, commit sha and branch name.

@return [String]

# File lib/lolcommits/plugin/protonet.rb, line 67
def message
  "commited some #{random_adjective} #{random_noun} to #{runner.vcs_info.repo}@#{runner.sha} (#{runner.vcs_info.branch})"
end
random_adjective() click to toggle source

Returns a randomly chosen adjective to describe the lolcommit.

@return [String]

# File lib/lolcommits/plugin/protonet.rb, line 85
def random_adjective
  [
    'awesome', 'great', 'interesting', 'cool', 'EPIC', 'gut', 'good', 'pansy',
    'powerful', 'boring', 'quirky', 'untested', 'german', 'iranian', 'neutral', 'crazy', 'well tested',
    'jimmy style', 'nasty', 'bibliographical (we received complaints about the original wording)',
    'bombdiggidy', 'narly', 'spiffy', 'smashing', 'xing style',
    'leo apotheker style', 'black', 'white', 'yellow', 'shaggy', 'tasty', 'mind bending', 'JAY-Z',
    'Kanye (the best ever)', '* Toby Keith was here *', 'splendid', 'stupendulous',
    '(freedom fries!)', '[vote RON PAUL]', '- these are not my glasses -', 'typical pansy',
    '- ze goggles zey do nothing! -', 'almost working', 'legen- wait for it -', '-dairy!',
    ' - Tavonius would be proud of this - ', 'Meg FAILMAN!', '- very brofessional of you -',
    'heartbleeding', 'juciy', 'supercalifragilisticexpialidocious', 'failing', 'loving'
  ].sample
end
random_noun() click to toggle source

Returns a randomly chosen noun to describe the lolcommit.

@return [String]

# File lib/lolcommits/plugin/protonet.rb, line 76
def random_noun
  %w(screws bolts exceptions errors cookies).sample
end