Class: MediaWikiVagrant::PastePuppet

Inherits:
Object
  • Object
show all
Includes:
PluginEnvironment
Defined in:
lib/mediawiki-vagrant/paste-puppet.rb

Constant Summary collapse

URL =
URI.parse('https://dpaste.de/api/')

Class Method Summary collapse

Instance Method Summary collapse

Methods included from PluginEnvironment

#initialize, #interactive_out?

Class Method Details

.synopsisObject



12
13
14
# File 'lib/mediawiki-vagrant/paste-puppet.rb', line 12

def self.synopsis
  'uploads your puppet logs to dpaste.de pastebin'
end

Instance Method Details

#executeObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/mediawiki-vagrant/paste-puppet.rb', line 16

def execute

  res = Net::HTTP.post_form URL, content: latest_logfile.read
  raise unless res.value.nil? && res.body =~ /^"[^"]+"$/
rescue RuntimeError
  @env.ui.error "Unexpected response from #{URL}."
  1
rescue TypeError
  @env.ui.error 'No Puppet log files found.'
  1
rescue SocketError, Net::HTTPExceptions
  @env.ui.error "Unable to connect to #{URL}."
  1
else
  @env.ui.success "HTTP #{res.code} #{res.msg}"
  @env.ui.info res.body[1...-1]
  0

end