Class: Card::Content::Diff
- Inherits:
-
Object
- Object
- Card::Content::Diff
- Defined in:
- lib/card/content/diff.rb,
lib/card/content/diff/l_c_s.rb,
lib/card/content/diff/result.rb,
lib/card/content/diff/l_c_s/processor.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Class Method Summary collapse
- .complete(a, b, opts = {}) ⇒ Object
- .render_added_chunk(text) ⇒ Object
- .render_deleted_chunk(text, _count = true) ⇒ Object
- .summary(a, b, opts = {}) ⇒ Object
Instance Method Summary collapse
- #green? ⇒ Boolean
-
#initialize(old_version, new_version, opts = {}) ⇒ Diff
constructor
diff options :format => :html|:text|:pointer|:raw :html = maintain html structure, but compare only content :text = remove all html tags; compare plain text :pointer = remove all double square brackets :raw = escape html tags and compare everything.
- #red? ⇒ Boolean
Constructor Details
#initialize(old_version, new_version, opts = {}) ⇒ Diff
diff options :format => :html|:text|:pointer|:raw :html = maintain html structure, but compare only content :text = remove all html tags; compare plain text :pointer = remove all double square brackets :raw = escape html tags and compare everything
summary: {length:
35 36 37 38 39 40 41 |
# File 'lib/card/content/diff.rb', line 35 def initialize old_version, new_version, opts={} @result = Result.new opts[:summary] return unless new_version lcs_opts = lcs_opts_for_format opts[:diff_format] LCS.new(lcs_opts).run(old_version, new_version, @result) end |
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
24 25 26 |
# File 'lib/card/content/diff.rb', line 24 def result @result end |
Class Method Details
.complete(a, b, opts = {}) ⇒ Object
7 8 9 |
# File 'lib/card/content/diff.rb', line 7 def complete a, b, opts={} Card::Content::Diff.new(a, b, opts).complete end |
.render_added_chunk(text) ⇒ Object
15 16 17 |
# File 'lib/card/content/diff.rb', line 15 def render_added_chunk text "<ins class='diffins diff-added'>#{text}</ins>" end |
.render_deleted_chunk(text, _count = true) ⇒ Object
19 20 21 |
# File 'lib/card/content/diff.rb', line 19 def render_deleted_chunk text, _count=true "<del class='diffdel diff-deleted'>#{text}</del>" end |
Instance Method Details
#green? ⇒ Boolean
47 48 49 |
# File 'lib/card/content/diff.rb', line 47 def green? @result.adds_cnt > 0 end |
#red? ⇒ Boolean
43 44 45 |
# File 'lib/card/content/diff.rb', line 43 def red? @result.dels_cnt > 0 end |