Class: DiffHighlight
- Inherits:
-
Object
- Object
- DiffHighlight
- Defined in:
- lib/diff_highlight.rb,
lib/diff_highlight/version.rb
Constant Summary collapse
- EXTENSIONS =
{ %w(.py) => :python, %w(.js) => :javascript, %w(.css) => :css, %w(.xml) => :xml, %w(.php) => :php, %w(.html) => :html, %w(.diff) => :diff, %w(.java) => :java, %w(.json) => :json, %w(.c .h) => :c, %w(.rhtml) => :rhtml, %w(.yaml .yml) => :yaml, %w(.cpp .hpp .cc .h .cxx) => :cpp, %w(.rb .ru .irbrc .gemspec .pryrc .rake) => :ruby, }
- FILES =
{ %w(Gemfile Rakefile Guardfile Capfile) => :ruby }
- VERSION =
"0.1.4"
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize ⇒ DiffHighlight
constructor
A new instance of DiffHighlight.
Constructor Details
#initialize ⇒ DiffHighlight
Returns a new instance of DiffHighlight.
29 30 31 |
# File 'lib/diff_highlight.rb', line 29 def initialize @buffer = "" end |
Instance Method Details
#execute ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/diff_highlight.rb', line 33 def execute ARGF.each_line do |line| if line =~ /^diff --git/ flush_buffer @language = type_from_filename(line.split.last) end if line =~ /^\+[^\+]/ write_added_line(line) else flush_buffer write_other_line(line) end end flush_buffer end |