Class: Lolcommits::Lolzinary

Inherits:
Plugin
  • Object
show all
Defined in:
lib/lolzinary_plugin.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(runner) ⇒ Lolzinary

Returns a new instance of Lolzinary.



8
9
10
11
12
13
14
15
# File 'lib/lolzinary_plugin.rb', line 8

def initialize(runner)
  super
  options.concat(%w(
    cloud_name
    api_key
    secret
  ))
end

Class Method Details

.nameObject



48
49
50
# File 'lib/lolzinary_plugin.rb', line 48

def self.name
  'lolzinary'
end

.runner_orderObject



52
53
54
# File 'lib/lolzinary_plugin.rb', line 52

def self.runner_order
  :postcapture
end

Instance Method Details

#auth_detailsObject



33
34
35
36
37
38
39
# File 'lib/lolzinary_plugin.rb', line 33

def auth_details
  {
      cloud_name: "#{configuration['cloud_name']}",
      api_key: "#{configuration['api_key']}",
      api_secret: "#{configuration['secret']}"
  }
end

#run_postcaptureObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/lolzinary_plugin.rb', line 17

def run_postcapture
  return unless valid_configuration?

  if runner.git_info.repo.empty?
    puts 'Repo is empty, skipping upload'
  else
    debug "Posting capture to Cloudinary!"
    upload = Cloudinary::Uploader.upload(runner.main_image, )
    if upload.present?
      puts "Upload complete! view me at #{upload["secure_url"]}"
    else
      puts "Upload failed. :-("
    end
  end
end

#upload_metadataObject



41
42
43
44
45
46
# File 'lib/lolzinary_plugin.rb', line 41

def 
  auth_details.merge!(tags: ["lolcommits", "#{runner.git_info.repo}"],
                      context: {caption: "Uploaded by #{runner.git_info.author_name} while working on #{runner.git_info.repo}"},
                      folder: "lolcommits/#{runner.git_info.repo}",
                      public_id: "#{runner.sha}")
end