Class: Lolcommits::Uploldz

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

Instance Attribute Summary collapse

Attributes inherited from Plugin

#options, #runner

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Plugin

#configuration, #configure_options!, #debug, #enabled?, #execute, #puts, #valid_configuration?

Constructor Details

#initialize(runner) ⇒ Uploldz

Returns a new instance of Uploldz.



8
9
10
11
# File 'lib/lolcommits/plugins/uploldz.rb', line 8

def initialize(runner)
  super
  self.options.concat(['endpoint', 'optional_key'])
end

Instance Attribute Details

#endpointObject

Returns the value of attribute endpoint.



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

def endpoint
  @endpoint
end

Class Method Details

.nameObject



32
33
34
# File 'lib/lolcommits/plugins/uploldz.rb', line 32

def self.name
  'uploldz'
end

Instance Method Details

#configured?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/lolcommits/plugins/uploldz.rb', line 28

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

#runObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/lolcommits/plugins/uploldz.rb', line 13

def run
  return unless valid_configuration?

  repo = self.runner.repo.to_s
  if repo.empty?
    puts 'Repo is empty, skipping upload'
  else
    debug 'Calling ' + configuration['endpoint'] + ' with repo ' + repo
    RestClient.post(configuration['endpoint'],
                    :file => File.new(self.runner.main_image),
                    :repo => repo,
                    :key => configuration['optional_key'])
  end
end