Class: Lolcommits::Plugin::TermOutput

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

Instance Attribute Summary

Attributes inherited from Base

#config, #options, #runner

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#configuration, #configured?, #configured_and_enabled?, #debug, #enabled?, #execute_capture_ready, #execute_post_capture, #execute_pre_capture, #initialize, #log_error, #parse_user_input, #print, #puts, #run_post_capture, #run_pre_capture, #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
  :capture_ready
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_capture_readyObject



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

def run_capture_ready
  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