Class: Lolcommits::Plugin::TermOutput

Inherits:
Base
  • Object
show all
Defined in:
lib/lolcommits/plugin/term_output.rb

Instance Attribute Summary

Attributes inherited from Base

#options, #runner

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#configuration, #configured?, #debug, #enabled?, #execute_postcapture, #execute_precapture, #initialize, #log_error, #parse_user_input, #puts, #run_precapture, #valid_configuration?

Constructor Details

This class inherits a constructor from Lolcommits::Plugin::Base

Class Method Details

.nameObject



19
20
21
# File 'lib/lolcommits/plugin/term_output.rb', line 19

def self.name
  'term_output'
end

.runner_orderObject



23
24
25
# File 'lib/lolcommits/plugin/term_output.rb', line 23

def self.runner_order
  :postcapture
end

Instance Method Details

#configure_options!Object



27
28
29
30
31
32
33
# File 'lib/lolcommits/plugin/term_output.rb', line 27

def configure_options!
  if terminal_supported?
    super
  else
    puts "Sorry, your terminal does not support the #{self.class.name} plugin (requires iTerm2)"
  end
end

#run_postcaptureObject



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/lolcommits/plugin/term_output.rb', line 6

def run_postcapture
  if terminal_supported?
    if !runner.vcs_info || runner.vcs_info.repo.empty?
      debug 'repo is empty, skipping term output'
    else
      base64 = Base64.encode64(open(runner.main_image, &:read))
      puts "#{begin_escape}1337;File=inline=1:#{base64};alt=#{runner.message};#{end_escape}\n"
    end
  else
    debug 'Disabled, your terminal is not supported (requires iTerm2)'
  end
end