Module: Diffident
- Defined in:
- lib/diffident.rb,
lib/diffident/diff.rb,
lib/diffident/change.rb,
lib/diffident/string.rb,
lib/diffident/version.rb,
lib/diffident/tokenizer.rb,
lib/diffident/format/html.rb,
lib/diffident/format/ascii.rb,
lib/diffident/format/color.rb
Defined Under Namespace
Modules: Format, StringDiffident
Classes: Change, Diff, Tokenizer
Constant Summary
collapse
- VERSION =
"0.1.0"
Class Method Summary
collapse
Class Method Details
.diff(this, base, new_sep = "\n") ⇒ Object
19
20
21
22
23
24
25
26
27
|
# File 'lib/diffident.rb', line 19
def diff(this, base, new_sep = "\n")
old_sep = self.separator
self.separator = new_sep
tokenizer = Diffident::Tokenizer.new(this, base, new_sep)
tokenizer.run
ensure
self.separator = old_sep
end
|
.diff_by_char(to, from) ⇒ Object
29
30
31
|
# File 'lib/diffident.rb', line 29
def diff_by_char(to, from)
diff(to, from, '')
end
|
.diff_by_line(to, from) ⇒ Object
37
38
39
|
# File 'lib/diffident.rb', line 37
def diff_by_line(to, from)
diff(to, from, "\n")
end
|
.diff_by_word(to, from) ⇒ Object
33
34
35
|
# File 'lib/diffident.rb', line 33
def diff_by_word(to, from)
diff(to, from, /\b/)
end
|
45
46
47
|
# File 'lib/diffident.rb', line 45
def format
return @format || Format::Ascii
end
|
41
42
43
|
# File 'lib/diffident.rb', line 41
def format=(f)
@format = format_for(f)
end
|
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/diffident.rb', line 49
def format_for(f)
if f.respond_to? :call
f
else
case f
when :ascii then Format::Ascii
when :color then Format::Color
when :html then Format::HTML
when nil then nil
else raise "Unknown format type #{f.inspect}"
end
end
end
|
.separator ⇒ Object
15
16
17
|
# File 'lib/diffident.rb', line 15
def separator
@@separator
end
|
.separator=(separator) ⇒ Object
11
12
13
|
# File 'lib/diffident.rb', line 11
def separator=(separator)
@@separator = separator
end
|