dirb 0.1.0 → 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.
- data/README.md +26 -7
- data/Rakefile +0 -15
- data/VERSION +1 -1
- data/dirb.gemspec +44 -0
- data/lib/dirb.rb +4 -4
- data/spec/dirb_spec.rb +12 -10
- metadata +6 -24
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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/Rakefile
CHANGED
|
@@ -32,21 +32,6 @@ begin
|
|
|
32
32
|
s.require_paths = ["lib"]
|
|
33
33
|
s.summary = %q{A convenient way to diff string in ruby}
|
|
34
34
|
|
|
35
|
-
if s.respond_to? :specification_version then
|
|
36
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
|
37
|
-
s.specification_version = 2
|
|
38
|
-
|
|
39
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
|
40
|
-
s.add_runtime_dependency(%q<mime-types>, [">= 1.16"])
|
|
41
|
-
s.add_runtime_dependency(%q<diff-lcs>, [">= 1.1.2"])
|
|
42
|
-
else
|
|
43
|
-
s.add_dependency(%q<mime-types>, [">= 1.16"])
|
|
44
|
-
s.add_dependency(%q<diff-lcs>, [">= 1.1.2"])
|
|
45
|
-
end
|
|
46
|
-
else
|
|
47
|
-
s.add_dependency(%q<mime-types>, [">= 1.16"])
|
|
48
|
-
s.add_dependency(%q<diff-lcs>, [">= 1.1.2"])
|
|
49
|
-
end
|
|
50
35
|
end
|
|
51
36
|
rescue LoadError
|
|
52
37
|
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
1.0.0
|
data/dirb.gemspec
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Generated by jeweler
|
|
2
|
+
# DO NOT EDIT THIS FILE
|
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
|
4
|
+
# -*- encoding: utf-8 -*-
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |s|
|
|
7
|
+
s.name = %q{dirb}
|
|
8
|
+
s.version = "1.0.0"
|
|
9
|
+
|
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
|
+
s.authors = ["Sam Goldstein"]
|
|
12
|
+
s.date = %q{2010-06-29}
|
|
13
|
+
s.description = %q{Convenient diffing in ruby}
|
|
14
|
+
s.email = %q{sgrock@gmail.com}
|
|
15
|
+
s.extra_rdoc_files = [
|
|
16
|
+
"README.md"
|
|
17
|
+
]
|
|
18
|
+
s.files = [
|
|
19
|
+
"README.md",
|
|
20
|
+
"Rakefile",
|
|
21
|
+
"VERSION",
|
|
22
|
+
"dirb.gemspec",
|
|
23
|
+
"lib/dirb.rb",
|
|
24
|
+
"spec/dirb_spec.rb"
|
|
25
|
+
]
|
|
26
|
+
s.homepage = %q{http://github.com/samg/dirb/tree/master}
|
|
27
|
+
s.rdoc_options = ["--inline-source", "--charset=UTF-8"]
|
|
28
|
+
s.require_paths = ["lib"]
|
|
29
|
+
s.rubygems_version = %q{1.3.5}
|
|
30
|
+
s.summary = %q{A convenient way to diff string in ruby}
|
|
31
|
+
s.test_files = [
|
|
32
|
+
"spec/dirb_spec.rb"
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
if s.respond_to? :specification_version then
|
|
36
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
|
37
|
+
s.specification_version = 3
|
|
38
|
+
|
|
39
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
|
40
|
+
else
|
|
41
|
+
end
|
|
42
|
+
else
|
|
43
|
+
end
|
|
44
|
+
end
|
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
|
-
'
|
|
82
|
+
' <li class="ins"><ins>' + line.gsub(/^./, '').chomp + '</ins></li>'
|
|
83
83
|
when /^-/
|
|
84
|
-
'
|
|
84
|
+
' <li class="del"><del>' + line.gsub(/^./, '').chomp + '</del></li>'
|
|
85
85
|
when /^ /
|
|
86
|
-
'
|
|
86
|
+
' <li class="unchanged"><span>' + line.gsub(/^./, '').chomp + '</span></li>'
|
|
87
87
|
end
|
|
88
88
|
end
|
|
89
|
-
%'<
|
|
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
|
-
<
|
|
110
|
-
<
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
</
|
|
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:
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sam Goldstein
|
|
@@ -9,29 +9,10 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2010-06-
|
|
12
|
+
date: 2010-06-29 00:00:00 -07:00
|
|
13
13
|
default_executable:
|
|
14
|
-
dependencies:
|
|
15
|
-
|
|
16
|
-
name: mime-types
|
|
17
|
-
type: :runtime
|
|
18
|
-
version_requirement:
|
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
20
|
-
requirements:
|
|
21
|
-
- - ">="
|
|
22
|
-
- !ruby/object:Gem::Version
|
|
23
|
-
version: "1.16"
|
|
24
|
-
version:
|
|
25
|
-
- !ruby/object:Gem::Dependency
|
|
26
|
-
name: diff-lcs
|
|
27
|
-
type: :runtime
|
|
28
|
-
version_requirement:
|
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - ">="
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: 1.1.2
|
|
34
|
-
version:
|
|
14
|
+
dependencies: []
|
|
15
|
+
|
|
35
16
|
description: Convenient diffing in ruby
|
|
36
17
|
email: sgrock@gmail.com
|
|
37
18
|
executables: []
|
|
@@ -44,6 +25,7 @@ files:
|
|
|
44
25
|
- README.md
|
|
45
26
|
- Rakefile
|
|
46
27
|
- VERSION
|
|
28
|
+
- dirb.gemspec
|
|
47
29
|
- lib/dirb.rb
|
|
48
30
|
- spec/dirb_spec.rb
|
|
49
31
|
has_rdoc: true
|
|
@@ -73,7 +55,7 @@ requirements: []
|
|
|
73
55
|
rubyforge_project:
|
|
74
56
|
rubygems_version: 1.3.5
|
|
75
57
|
signing_key:
|
|
76
|
-
specification_version:
|
|
58
|
+
specification_version: 3
|
|
77
59
|
summary: A convenient way to diff string in ruby
|
|
78
60
|
test_files:
|
|
79
61
|
- spec/dirb_spec.rb
|