dirb 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/CHANGELOG +5 -0
- data/LICENSE +19 -0
- data/README.md +18 -16
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/dirb.gemspec +8 -4
- data/lib/dirb.rb +5 -3
- data/spec/dirb_spec.rb +9 -0
- metadata +6 -2
data/.gitignore
ADDED
data/CHANGELOG
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2010 Sam Goldstein
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
5
|
+
the Software without restriction, including without limitation the rights to
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
7
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
8
|
+
so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -40,26 +40,28 @@ Here's an example of using Dirb to diff two strings
|
|
40
40
|
Outputing the diff as html is easy too.
|
41
41
|
|
42
42
|
>> puts Dirb::Diff.new(string1, string2).to_s(:html)
|
43
|
-
<
|
44
|
-
<
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
43
|
+
<div class="diff">
|
44
|
+
<ul>
|
45
|
+
<li class="del"><del>Hello how are you</del></li>
|
46
|
+
<li class="ins"><ins>Hello how are you?</ins></li>
|
47
|
+
<li class="unchanged"><span>I'm fine</span></li>
|
48
|
+
<li class="del"><del>That's great</del></li>
|
49
|
+
<li class="ins"><ins>That's swell</ins></li>
|
50
|
+
</ul>
|
51
|
+
</div>
|
50
52
|
|
51
53
|
Then try adding this css to your stylesheets:
|
52
54
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
55
|
+
.diff{overflow:auto;}
|
56
|
+
.diff ul{background:#fff;overflow:auto;font-size:13px;list-style:none;margin:0;padding:0;display:table;width:100%;}
|
57
|
+
.diff del, .diff ins{display:block;text-decoration:none;}
|
58
|
+
.diff li{padding:0; display:table-row;margin: 0;}
|
59
|
+
.diff li.ins{background:#9f9;}
|
60
|
+
.diff li.del{background:#ccf;}
|
61
|
+
.diff li:hover{background:#ffc}
|
62
|
+
.diff del, .diff ins, .diff span{white-space:pre;font-family:courier;}
|
61
63
|
|
62
|
-
Dirb::Diff also alows you to set a default format. Here we set the default to
|
64
|
+
`Dirb::Diff` also alows you to set a default format. Here we set the default to
|
63
65
|
use ANSI termnial color escape sequences.
|
64
66
|
|
65
67
|
>> Dirb::Diff.default_format = :color
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.1
|
data/dirb.gemspec
CHANGED
@@ -5,18 +5,22 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{dirb}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.1"
|
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-
|
12
|
+
s.date = %q{2010-07-03}
|
13
13
|
s.description = %q{Convenient diffing in ruby}
|
14
14
|
s.email = %q{sgrock@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
|
-
"
|
16
|
+
"LICENSE",
|
17
|
+
"README.md"
|
17
18
|
]
|
18
19
|
s.files = [
|
19
|
-
"
|
20
|
+
".gitignore",
|
21
|
+
"CHANGELOG",
|
22
|
+
"LICENSE",
|
23
|
+
"README.md",
|
20
24
|
"Rakefile",
|
21
25
|
"VERSION",
|
22
26
|
"dirb.gemspec",
|
data/lib/dirb.rb
CHANGED
@@ -25,7 +25,9 @@ module Dirb
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def each &block
|
28
|
-
diff.
|
28
|
+
diff.split("\n").reject{|x| x =~ /^---|\+\+\+|@@/ }.each do |line|
|
29
|
+
block.call line + "\n"
|
30
|
+
end
|
29
31
|
end
|
30
32
|
|
31
33
|
def tempfile(string)
|
@@ -37,9 +39,9 @@ module Dirb
|
|
37
39
|
|
38
40
|
def to_s(format = nil)
|
39
41
|
format ||= self.class.default_format
|
40
|
-
formats = Format.instance_methods(false)
|
42
|
+
formats = Format.instance_methods(false).map{|x| x.to_s}
|
41
43
|
if formats.include? format.to_s
|
42
|
-
enum = self.
|
44
|
+
enum = self.to_a
|
43
45
|
enum.extend Format
|
44
46
|
enum.send format
|
45
47
|
else
|
data/spec/dirb_spec.rb
CHANGED
@@ -135,6 +135,15 @@ baz
|
|
135
135
|
DIFF
|
136
136
|
end
|
137
137
|
end
|
138
|
+
|
139
|
+
it "should be easy to generate custom format" do
|
140
|
+
Dirb::Diff.new("foo\nbar\n", "foo\nbar\nbaz\n").map do |line|
|
141
|
+
case line
|
142
|
+
when /^\+/ then "line #{line.chomp} added"
|
143
|
+
when /^-/ then "line #{line.chomp} removed"
|
144
|
+
end
|
145
|
+
end.compact.join.should == "line +baz added"
|
146
|
+
end
|
138
147
|
end
|
139
148
|
end
|
140
149
|
|
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: 1.0.
|
4
|
+
version: 1.0.1
|
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-
|
12
|
+
date: 2010-07-03 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -20,8 +20,12 @@ executables: []
|
|
20
20
|
extensions: []
|
21
21
|
|
22
22
|
extra_rdoc_files:
|
23
|
+
- LICENSE
|
23
24
|
- README.md
|
24
25
|
files:
|
26
|
+
- .gitignore
|
27
|
+
- CHANGELOG
|
28
|
+
- LICENSE
|
25
29
|
- README.md
|
26
30
|
- Rakefile
|
27
31
|
- VERSION
|