Class: DevSystem::DifflcsGemShell

Inherits:
GemShell show all
Defined in:
lib/dev_system/subsystems/generator/gem_shells/difflcs_gem_shell.rb

Instance Attribute Summary

Attributes inherited from Liza::Controller

#menv

Class Method Summary collapse

Methods inherited from Shell

all, cruby?, engine, jruby?, linux?, mac?, os, ruby_version, unix?, windows?

Methods inherited from Liza::Controller

#`, `, attr_accessor, attr_reader, attr_writer, #attrs, box, #box, call, color, division, division!, division?, inherited, menv_accessor, menv_reader, menv_writer, on_connected, panel, #panel, plural, require, requirements, sh, #sh, singular, subsystem, subsystem!, subsystem?, subsystem_token, token

Methods inherited from Liza::Unit

_erbs_for, #add, add, cl, #cl, class_methods_defined, const_added, const_missing, constants_defined, define_error, descendants_select, division, erbs_available, erbs_defined, erbs_for, errors, #fetch, fetch, get, #get, instance_methods_defined, log, #log, log?, #log?, #log_array, log_array, log_hash, #log_hash, #log_level, log_level, #log_level?, log_level?, log_levels, #log_levels, #log_render_convert, #log_render_format, #log_render_in, #log_render_out, method_added, methods_defined, namespace, part, raise_error, #raise_error, reload!, #reload!, #render, #render!, #render_stack, renderable_formats_for, renderable_names, section, sections, #set, set, #settings, settings, singleton_method_added, sleep, #sleep, stick, #stick, sticks, #sticks, subclasses_select, subunits, system, #system, system?, test_class, time_diff, #time_diff

Class Method Details

.get_diffs(a, b) ⇒ Object

gem “diff-lcs”



5
6
7
8
# File 'lib/dev_system/subsystems/generator/gem_shells/difflcs_gem_shell.rb', line 5

def self.get_diffs(a, b)
  call({})
  Diff::LCS.diff(a, b)
end

.log_diff(a, b) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/dev_system/subsystems/generator/gem_shells/difflcs_gem_shell.rb', line 10

def self.log_diff(a, b)
  diffs = get_diffs(a, b)
  puts
  # Output the diff in a format similar to git diff
  diffs.each do |diff|
    diff.each do |change|
      # If it's a deletion (present in old but not in new)
      if change.action == "-"
        puts "- #{stick change.element.chomp, :light_red}"
      # If it's an addition (present in new but not in old)
      elsif change.action == "+"
        puts "+ #{stick change.element.chomp, :light_green}"
      end
    end
  end
  puts
end