di 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/HISTORY +4 -0
- data/LICENSE +1 -1
- data/README.rdoc +1 -1
- data/Rakefile +1 -62
- data/di.gemspec +20 -42
- data/lib/di.rb +24 -3
- metadata +28 -56
data/.gitignore
ADDED
data/HISTORY
CHANGED
data/LICENSE
CHANGED
data/README.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -1,62 +1 @@
|
|
1
|
-
require
|
2
|
-
require 'rake'
|
3
|
-
|
4
|
-
load 'lib/di.rb'
|
5
|
-
|
6
|
-
begin
|
7
|
-
require 'jeweler'
|
8
|
-
Jeweler::Tasks.new do |gem|
|
9
|
-
gem.name = "di"
|
10
|
-
gem.summary = %Q{A wrapper around GNU diff(1)}
|
11
|
-
gem.description = <<EOS
|
12
|
-
The di(1) command wraps around GNU diff(1) to provide reasonable
|
13
|
-
default settings and some original features.
|
14
|
-
EOS
|
15
|
-
gem.email = "knu@idaemons.org"
|
16
|
-
gem.homepage = "https://github.com/knu/di"
|
17
|
-
gem.authors = ["Akinori MUSHA"]
|
18
|
-
gem.required_ruby_version = Gem::Requirement.new(">= 1.8.7")
|
19
|
-
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
20
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
21
|
-
gem.executables = ["di"]
|
22
|
-
|
23
|
-
gem.version = MYVERSION
|
24
|
-
end
|
25
|
-
Jeweler::GemcutterTasks.new
|
26
|
-
rescue LoadError
|
27
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
28
|
-
end
|
29
|
-
|
30
|
-
require 'rake/testtask'
|
31
|
-
Rake::TestTask.new(:test) do |test|
|
32
|
-
test.libs << 'lib' << 'test'
|
33
|
-
test.pattern = 'test/**/test_*.rb'
|
34
|
-
test.verbose = true
|
35
|
-
end
|
36
|
-
|
37
|
-
begin
|
38
|
-
require 'rcov/rcovtask'
|
39
|
-
Rcov::RcovTask.new do |test|
|
40
|
-
test.libs << 'test'
|
41
|
-
test.pattern = 'test/**/test_*.rb'
|
42
|
-
test.verbose = true
|
43
|
-
end
|
44
|
-
rescue LoadError
|
45
|
-
task :rcov do
|
46
|
-
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
task :test => :check_dependencies
|
51
|
-
|
52
|
-
task :default => :test
|
53
|
-
|
54
|
-
require 'rake/rdoctask'
|
55
|
-
Rake::RDocTask.new do |rdoc|
|
56
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
57
|
-
|
58
|
-
rdoc.rdoc_dir = 'rdoc'
|
59
|
-
rdoc.title = "di #{version}"
|
60
|
-
rdoc.rdoc_files.include('README*')
|
61
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
62
|
-
end
|
1
|
+
require "bundler/gem_tasks"
|
data/di.gemspec
CHANGED
@@ -1,50 +1,28 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'di'
|
5
5
|
|
6
|
-
Gem::Specification.new do |
|
7
|
-
|
8
|
-
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "di"
|
8
|
+
gem.version = MYVERSION
|
9
|
+
gem.authors = ["Akinori MUSHA"]
|
10
|
+
gem.email = ["knu@idaemons.org"]
|
11
|
+
gem.description = <<EOS
|
12
|
+
The di(1) command wraps around GNU diff(1) to provide reasonable
|
13
|
+
default settings and some original features.
|
14
|
+
EOS
|
15
|
+
gem.summary = %q{A wrapper around GNU diff(1)}
|
16
|
+
gem.homepage = "https://github.com/knu/di"
|
9
17
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
s.email = "knu@idaemons.org"
|
15
|
-
s.executables = ["di"]
|
16
|
-
s.extra_rdoc_files = [
|
18
|
+
gem.files = `git ls-files`.split($/)
|
19
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
20
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
21
|
+
gem.extra_rdoc_files = [
|
17
22
|
"LICENSE",
|
18
23
|
"README.rdoc"
|
19
24
|
]
|
20
|
-
|
21
|
-
".document",
|
22
|
-
"HISTORY",
|
23
|
-
"LICENSE",
|
24
|
-
"README.rdoc",
|
25
|
-
"Rakefile",
|
26
|
-
"bin/di",
|
27
|
-
"di.gemspec",
|
28
|
-
"lib/di.rb",
|
29
|
-
"test/helper.rb",
|
30
|
-
"test/test_di.rb"
|
31
|
-
]
|
32
|
-
s.homepage = "https://github.com/knu/di"
|
33
|
-
s.require_paths = ["lib"]
|
34
|
-
s.required_ruby_version = Gem::Requirement.new(">= 1.8.7")
|
35
|
-
s.rubygems_version = "1.8.23"
|
36
|
-
s.summary = "A wrapper around GNU diff(1)"
|
25
|
+
gem.require_paths = ["lib"]
|
37
26
|
|
38
|
-
|
39
|
-
s.specification_version = 3
|
40
|
-
|
41
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
42
|
-
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
43
|
-
else
|
44
|
-
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
45
|
-
end
|
46
|
-
else
|
47
|
-
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
48
|
-
end
|
27
|
+
gem.required_ruby_version = Gem::Requirement.new(">= 1.8.7")
|
49
28
|
end
|
50
|
-
|
data/lib/di.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
#
|
4
4
|
# di - a wrapper around GNU diff(1)
|
5
5
|
#
|
6
|
-
# Copyright (c) 2008, 2009, 2010, 2011, 2012 Akinori MUSHA
|
6
|
+
# Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Akinori MUSHA
|
7
7
|
#
|
8
8
|
# All rights reserved.
|
9
9
|
#
|
@@ -28,9 +28,9 @@
|
|
28
28
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
29
29
|
# SUCH DAMAGE.
|
30
30
|
|
31
|
-
MYVERSION = "0.3.
|
31
|
+
MYVERSION = "0.3.2"
|
32
32
|
MYNAME = File.basename($0)
|
33
|
-
MYCOPYRIGHT = "Copyright (c) 2008, 2009, 2010, 2011, 2012 Akinori MUSHA"
|
33
|
+
MYCOPYRIGHT = "Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Akinori MUSHA"
|
34
34
|
|
35
35
|
DIFF_CMD = ENV.fetch('DIFF', 'diff')
|
36
36
|
ENV_NAME = "#{MYNAME.tr('-a-z', '_A-Z')}_OPTIONS"
|
@@ -95,6 +95,8 @@ def setup
|
|
95
95
|
:unchanged => "",
|
96
96
|
:whitespace => "\e[41m",
|
97
97
|
:off => "\e[m",
|
98
|
+
:open_inv => "\e[7m",
|
99
|
+
:close_inv => "\e[27m",
|
98
100
|
}
|
99
101
|
$diff.reversed = false
|
100
102
|
end
|
@@ -705,6 +707,7 @@ def colorize_unified_diff(io)
|
|
705
707
|
state = :comment
|
706
708
|
hunk_left = nil
|
707
709
|
io.each_line { |line|
|
710
|
+
replace_invalid_bytes!(line)
|
708
711
|
case state
|
709
712
|
when :comment
|
710
713
|
case line
|
@@ -769,6 +772,7 @@ def colorize_context_diff(io)
|
|
769
772
|
state = :comment
|
770
773
|
hunk_part = nil
|
771
774
|
io.each_line { |line|
|
775
|
+
replace_invalid_bytes!(line)
|
772
776
|
case state
|
773
777
|
when :comment
|
774
778
|
case line
|
@@ -844,4 +848,21 @@ def colorize_context_diff(io)
|
|
844
848
|
io.close
|
845
849
|
end
|
846
850
|
|
851
|
+
def replace_invalid_bytes!(text)
|
852
|
+
colors = $diff.colors
|
853
|
+
text.replace(text.replace_invalid_bytes { |byte|
|
854
|
+
'%s<%02X>%s' % [colors[:open_inv], byte, colors[:close_inv]]
|
855
|
+
})
|
856
|
+
end
|
857
|
+
|
858
|
+
class String
|
859
|
+
def replace_invalid_bytes
|
860
|
+
return self if !defined?(Encoding) || valid_encoding?
|
861
|
+
|
862
|
+
each_char.inject('') { |s, c|
|
863
|
+
s << (c.valid_encoding? ? c : yield(*c.bytes))
|
864
|
+
}
|
865
|
+
end
|
866
|
+
end
|
867
|
+
|
847
868
|
main(ARGV) if $0 == __FILE__
|
metadata
CHANGED
@@ -1,50 +1,32 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: di
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.2
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 3
|
9
|
-
- 1
|
10
|
-
version: 0.3.1
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Akinori MUSHA
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
12
|
+
date: 2013-01-09 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: ! 'The di(1) command wraps around GNU diff(1) to provide reasonable
|
17
15
|
|
18
|
-
date: 2012-05-21 00:00:00 Z
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
21
|
-
name: thoughtbot-shoulda
|
22
|
-
prerelease: false
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
-
none: false
|
25
|
-
requirements:
|
26
|
-
- - ">="
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 3
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
version: "0"
|
32
|
-
type: :development
|
33
|
-
version_requirements: *id001
|
34
|
-
description: |
|
35
|
-
The di(1) command wraps around GNU diff(1) to provide reasonable
|
36
16
|
default settings and some original features.
|
37
17
|
|
38
|
-
|
39
|
-
|
18
|
+
'
|
19
|
+
email:
|
20
|
+
- knu@idaemons.org
|
21
|
+
executables:
|
40
22
|
- di
|
41
23
|
extensions: []
|
42
|
-
|
43
|
-
extra_rdoc_files:
|
24
|
+
extra_rdoc_files:
|
44
25
|
- LICENSE
|
45
26
|
- README.rdoc
|
46
|
-
files:
|
27
|
+
files:
|
47
28
|
- .document
|
29
|
+
- .gitignore
|
48
30
|
- HISTORY
|
49
31
|
- LICENSE
|
50
32
|
- README.rdoc
|
@@ -56,38 +38,28 @@ files:
|
|
56
38
|
- test/test_di.rb
|
57
39
|
homepage: https://github.com/knu/di
|
58
40
|
licenses: []
|
59
|
-
|
60
41
|
post_install_message:
|
61
42
|
rdoc_options: []
|
62
|
-
|
63
|
-
require_paths:
|
43
|
+
require_paths:
|
64
44
|
- lib
|
65
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
46
|
none: false
|
67
|
-
requirements:
|
68
|
-
- -
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
hash: 57
|
71
|
-
segments:
|
72
|
-
- 1
|
73
|
-
- 8
|
74
|
-
- 7
|
47
|
+
requirements:
|
48
|
+
- - ! '>='
|
49
|
+
- !ruby/object:Gem::Version
|
75
50
|
version: 1.8.7
|
76
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
52
|
none: false
|
78
|
-
requirements:
|
79
|
-
- -
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
|
82
|
-
segments:
|
83
|
-
- 0
|
84
|
-
version: "0"
|
53
|
+
requirements:
|
54
|
+
- - ! '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
85
57
|
requirements: []
|
86
|
-
|
87
58
|
rubyforge_project:
|
88
|
-
rubygems_version: 1.8.
|
59
|
+
rubygems_version: 1.8.24
|
89
60
|
signing_key:
|
90
61
|
specification_version: 3
|
91
62
|
summary: A wrapper around GNU diff(1)
|
92
|
-
test_files:
|
93
|
-
|
63
|
+
test_files:
|
64
|
+
- test/helper.rb
|
65
|
+
- test/test_di.rb
|