class HeartInspector
Constants
- DEFAULTS
Attributes
existing_settings[R]
result[R]
Public Class Methods
new()
click to toggle source
# File lib/tdd_heart.rb, line 10 def initialize @existing_settings = load_existing_settings end
Public Instance Methods
load_existing_settings(setting: nil, file_path: nil)
click to toggle source
# File lib/tdd_heart.rb, line 14 def load_existing_settings(setting: nil, file_path: nil) setting ||= DEFAULTS[:target_setting] file_path ||= DEFAULTS[:tmux_location] file = File.open file_path config = nil file.each { |line| config = line if /#{setting}/ =~ line } file.close config.chomp.split('"').last end
new_status()
click to toggle source
# File lib/tdd_heart.rb, line 43 def new_status return existing_settings if result.nil? output(result_color) + ' ' + existing_settings end
output(color)
click to toggle source
# File lib/tdd_heart.rb, line 56 def output(color) "#[fg=#{color}]♥" end
read_test_status(file_path = nil)
click to toggle source
# File lib/tdd_heart.rb, line 32 def read_test_status(file_path = nil) file_path ||= Dir.pwd + DEFAULTS[:result_file] return unless File.exist? file_path @result = File.read(file_path).chomp end
refresh_status()
click to toggle source
# File lib/tdd_heart.rb, line 27 def refresh_status read_test_status system(update_status_command) end
result_color()
click to toggle source
# File lib/tdd_heart.rb, line 48 def result_color case result when /success/ then 'green' when /fail/ then 'red' when /pending/ then 'yellow' end end
update_status_command()
click to toggle source
# File lib/tdd_heart.rb, line 39 def update_status_command "tmux set -g status-right '#{new_status}'" end