edouard-htmldiff 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README.md +14 -0
  2. data/lib/htmldiff.rb +5 -1
  3. data/spec/htmldiff_spec.rb +4 -8
  4. metadata +9 -6
  5. data/README +0 -15
data/README.md ADDED
@@ -0,0 +1,14 @@
1
+ A diff library that uses html tags to show differences
2
+
3
+ Inline diff:
4
+
5
+ HTMLDiff.diff('a word is here', 'a nother word is there')
6
+ # => "a<ins class=\"diffins\"> nother</ins> word is <del class=\"diffmod\">here</del><ins class=\"diffmod\">there</ins>"
7
+
8
+ Separated diff:
9
+
10
+ HTMLDiff.diff('a word is here', 'a nother word is there', true)
11
+ # => ["a word is <del class=\"diffmod\">here</del>", "a<ins class=\"diffins\"> nother</ins> word is <ins class=\"diffmod\">there</ins>"]
12
+
13
+
14
+ Checkout the crappy specs for good examples.
data/lib/htmldiff.rb CHANGED
@@ -1,4 +1,4 @@
1
- module HTMLDiff
1
+ class HTMLDiff
2
2
 
3
3
  Match = Struct.new(:start_in_old, :start_in_new, :size)
4
4
  class Match
@@ -333,6 +333,10 @@ module HTMLDiff
333
333
  end
334
334
 
335
335
  end # of class Diff Builder
336
+
337
+ def HTMLDiff.diff(a, b, dual = false)
338
+ HTMLDiff.new.diff(a, b, dual)
339
+ end
336
340
 
337
341
  def diff(a, b, dual = false)
338
342
  DiffBuilder.new(a, b, dual).build
@@ -1,31 +1,27 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
2
  require 'htmldiff'
3
3
 
4
- class TestDiff
5
- extend HTMLDiff
6
- end
7
-
8
4
  describe "htmldiff" do
9
5
 
10
6
  it "should diff text" do
11
7
 
12
- diff = TestDiff.diff('a word is here', 'a nother word is there')
8
+ diff = HTMLDiff.diff('a word is here', 'a nother word is there')
13
9
  diff.should == "a<ins class=\"diffins\"> nother</ins> word is <del class=\"diffmod\">here</del><ins class=\"diffmod\">there</ins>"
14
10
 
15
11
  end
16
12
 
17
13
  it "should insert a letter and a space" do
18
- diff = TestDiff.diff('a c', 'a b c')
14
+ diff = HTMLDiff.diff('a c', 'a b c')
19
15
  diff.should == "a <ins class=\"diffins\">b </ins>c"
20
16
  end
21
17
 
22
18
  it "should remove a letter and a space" do
23
- diff = TestDiff.diff('a b c', 'a c')
19
+ diff = HTMLDiff.diff('a b c', 'a c')
24
20
  diff.should == "a <del class=\"diffdel\">b </del>c"
25
21
  end
26
22
 
27
23
  it "should change a letter" do
28
- diff = TestDiff.diff('a b c', 'a d c')
24
+ diff = HTMLDiff.diff('a b c', 'a d c')
29
25
  diff.should == "a <del class=\"diffmod\">b</del><ins class=\"diffmod\">d</ins> c"
30
26
  end
31
27
 
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: edouard-htmldiff
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 23
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 2
9
- version: 0.0.2
9
+ - 4
10
+ version: 0.0.4
10
11
  platform: ruby
11
12
  authors:
12
13
  - Nathan Herald
@@ -25,12 +26,12 @@ executables: []
25
26
  extensions: []
26
27
 
27
28
  extra_rdoc_files:
28
- - README
29
+ - README.md
29
30
  - LICENSE
30
31
  - TODO
31
32
  files:
32
33
  - LICENSE
33
- - README
34
+ - README.md
34
35
  - Rakefile
35
36
  - TODO
36
37
  - lib/htmldiff.rb
@@ -50,6 +51,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
50
51
  requirements:
51
52
  - - ">="
52
53
  - !ruby/object:Gem::Version
54
+ hash: 3
53
55
  segments:
54
56
  - 0
55
57
  version: "0"
@@ -58,13 +60,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
60
  requirements:
59
61
  - - ">="
60
62
  - !ruby/object:Gem::Version
63
+ hash: 3
61
64
  segments:
62
65
  - 0
63
66
  version: "0"
64
67
  requirements: []
65
68
 
66
69
  rubyforge_project:
67
- rubygems_version: 1.3.7
70
+ rubygems_version: 1.5.0
68
71
  signing_key:
69
72
  specification_version: 3
70
73
  summary: HTML diffs of text
data/README DELETED
@@ -1,15 +0,0 @@
1
- class Stuff
2
-
3
- class << self
4
- include HTMLDiff
5
- end
6
-
7
- # or extend HTMLDiff ?
8
-
9
- end
10
-
11
- Stuff.diff('a word is here', 'a nother word is there')
12
-
13
- # => 'a<ins class=\"diffins\"> nother</ins> word is <del class=\"diffmod\">here</del><ins class=\"diffmod\">there</ins>'
14
-
15
- Checkout the crappy specs for good examples.