dirb 0.1.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (6) hide show
  1. data/README.md +26 -7
  2. data/VERSION +1 -1
  3. data/dirb.gemspec +2 -2
  4. data/lib/dirb.rb +4 -4
  5. data/spec/dirb_spec.rb +12 -10
  6. metadata +2 -2
data/README.md CHANGED
@@ -10,10 +10,14 @@ It provides several built in format options. Pass `:text`, `:color`, or
10
10
  `:html` to `Dirb::Diff#to_s` to force that format, or set
11
11
  `Dirb::Diff.default_format`
12
12
 
13
+ Getting Started
14
+ ---------------
15
+
16
+ sudo gem install dirb
17
+
18
+ Here's an example of using Dirb to diff two strings
19
+
13
20
  $ irb
14
- >> require 'rubygems'
15
- >> require 'dirb'
16
- => true
17
21
  >> string1 = <<-TXT
18
22
  >" Hello how are you
19
23
  >" I'm fine
@@ -32,7 +36,9 @@ It provides several built in format options. Pass `:text`, `:color`, or
32
36
  I'm fine
33
37
  -That's great
34
38
  +That's swell
35
- => nil
39
+
40
+ Outputing the diff as html is easy too.
41
+
36
42
  >> puts Dirb::Diff.new(string1, string2).to_s(:html)
37
43
  <ul class="diff">
38
44
  <li class="del"><del>Hello how are you</del></li>
@@ -41,16 +47,29 @@ It provides several built in format options. Pass `:text`, `:color`, or
41
47
  <li class="del"><del>That's great</del></li>
42
48
  <li class="ins"><ins>That's swell</ins></li>
43
49
  </ul>
44
- => nil
50
+
51
+ Then try adding this css to your stylesheets:
52
+
53
+ .diff{overflow:auto;}
54
+ .diff ul{background:#fff;overflow:auto;font-size:13px;list-style:none;margin:0;padding:0;display:table;width:100%;}
55
+ .diff del, .diff ins{display:block;text-decoration:none;}
56
+ .diff li{padding:0; display:table-row;margin: 0;}
57
+ .diff li.ins{background:#9f9;}
58
+ .diff li.del{background:#ccf;}
59
+ .diff li:hover{background:#ffc}
60
+ .diff del, .diff ins, .diff span{white-space:pre;font-family:courier;}
61
+
62
+ Dirb::Diff also alows you to set a default format. Here we set the default to
63
+ use ANSI termnial color escape sequences.
64
+
45
65
  >> Dirb::Diff.default_format = :color
46
66
  => :color
47
- irb(main):015:0> puts Dirb::Diff.new(string1, string2) # prints color in the terminal
67
+ >> puts Dirb::Diff.new(string1, string2) # prints color in the terminal
48
68
  -Hello how are you
49
69
  +Hello how are you?
50
70
  I'm fine
51
71
  -That's great
52
72
  +That's swell
53
- => nil
54
73
 
55
74
 
56
75
  Creating custom formatted output is easy too. `Dirb::Diff` provides an
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 1.0.0
data/dirb.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{dirb}
8
- s.version = "0.1.1"
8
+ s.version = "1.0.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Sam Goldstein"]
12
- s.date = %q{2010-06-28}
12
+ s.date = %q{2010-06-29}
13
13
  s.description = %q{Convenient diffing in ruby}
14
14
  s.email = %q{sgrock@gmail.com}
15
15
  s.extra_rdoc_files = [
data/lib/dirb.rb CHANGED
@@ -79,14 +79,14 @@ module Dirb
79
79
  lines = map do |line|
80
80
  case line
81
81
  when /^\+/
82
- ' <li class="ins"><ins>' + line.gsub(/^./, '').chomp + '</ins></li>'
82
+ ' <li class="ins"><ins>' + line.gsub(/^./, '').chomp + '</ins></li>'
83
83
  when /^-/
84
- ' <li class="del"><del>' + line.gsub(/^./, '').chomp + '</del></li>'
84
+ ' <li class="del"><del>' + line.gsub(/^./, '').chomp + '</del></li>'
85
85
  when /^ /
86
- ' <li class="unchanged"><span>' + line.gsub(/^./, '').chomp + '</span></li>'
86
+ ' <li class="unchanged"><span>' + line.gsub(/^./, '').chomp + '</span></li>'
87
87
  end
88
88
  end
89
- %'<ul class="diff">\n#{lines.join("\n")}\n</ul>\n'
89
+ %'<div class="diff">\n <ul>\n#{lines.join("\n")}\n </ul>\n</div>\n'
90
90
  end
91
91
  end
92
92
  end
data/spec/dirb_spec.rb CHANGED
@@ -106,16 +106,18 @@ describe Dirb::Diff do
106
106
 
107
107
  it "should make an awesome html diff" do
108
108
  @diff.to_s(:html).should == <<-HTML
109
- <ul class="diff">
110
- <li class="del"><del>foo</del></li>
111
- <li class="ins"><ins>one</ins></li>
112
- <li class="ins"><ins>two</ins></li>
113
- <li class="ins"><ins>three</ins></li>
114
- <li class="unchanged"><span>bar</span></li>
115
- <li class="unchanged"><span>bang</span></li>
116
- <li class="del"><del>woot</del></li>
117
- <li class="ins"><ins>baz</ins></li>
118
- </ul>
109
+ <div class="diff">
110
+ <ul>
111
+ <li class="del"><del>foo</del></li>
112
+ <li class="ins"><ins>one</ins></li>
113
+ <li class="ins"><ins>two</ins></li>
114
+ <li class="ins"><ins>three</ins></li>
115
+ <li class="unchanged"><span>bar</span></li>
116
+ <li class="unchanged"><span>bang</span></li>
117
+ <li class="del"><del>woot</del></li>
118
+ <li class="ins"><ins>baz</ins></li>
119
+ </ul>
120
+ </div>
119
121
  HTML
120
122
  end
121
123
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dirb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Goldstein
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-06-28 00:00:00 -07:00
12
+ date: 2010-06-29 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15