Class: Lolcommits::LolProtonet

Inherits:
Plugin
  • Object
show all
Defined in:
lib/lolcommits/plugins/lol_protonet.rb

Instance Attribute Summary

Attributes inherited from Plugin

#options, #runner

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Plugin

#configuration, #configure_options!, #debug, #enabled?, #execute_postcapture, #execute_precapture, #log_error, #parse_user_input, #puts, #run_precapture, #valid_configuration?

Constructor Details

#initialize(runner) ⇒ LolProtonet

Returns a new instance of LolProtonet.



6
7
8
9
# File 'lib/lolcommits/plugins/lol_protonet.rb', line 6

def initialize(runner)
  super
  options.concat(%w(api_token api_endpoint))
end

Class Method Details

.nameObject



60
61
62
# File 'lib/lolcommits/plugins/lol_protonet.rb', line 60

def self.name
  'lolprotonet'
end

.runner_orderObject



64
65
66
# File 'lib/lolcommits/plugins/lol_protonet.rb', line 64

def self.runner_order
  :postcapture
end

Instance Method Details

#api_urlObject



25
26
27
# File 'lib/lolcommits/plugins/lol_protonet.rb', line 25

def api_url
  configuration['api_endpoint']
end

#configured?Boolean

Returns:

  • (Boolean)


54
55
56
57
58
# File 'lib/lolcommits/plugins/lol_protonet.rb', line 54

def configured?
  !configuration['enabled'].nil? &&
    configuration['api_token'] &&
    configuration['api_endpoint']
end

#messageObject



29
30
31
# File 'lib/lolcommits/plugins/lol_protonet.rb', line 29

def message
  "commited some #{random_adjective} #{random_object} to #{runner.git_info.repo}@#{runner.sha} (#{runner.git_info.branch}) "
end

#random_adjectiveObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/lolcommits/plugins/lol_protonet.rb', line 39

def random_adjective
  adjectives = ['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'
               ]
  adjectives.sample
end

#random_objectObject



33
34
35
36
37
# File 'lib/lolcommits/plugins/lol_protonet.rb', line 33

def random_object
  objects = %w(screws bolts exceptions errors cookies)

  objects.sample
end

#run_postcaptureObject



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/lolcommits/plugins/lol_protonet.rb', line 11

def run_postcapture
  return unless valid_configuration?

  debug "Posting capture to #{configuration['endpoint']}"
  RestClient.post(
    api_url,
    {
      :files        => [File.new(runner.main_image)],
      :message      => message
    },
    'X-Protonet-Token' => configuration['api_token']
  )
end