diffy 2.0.10 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of diffy might be problematic. Click here for more details.

data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ == 2.1.0 ==
2
+ Windows support
3
+
1
4
  == 2.0.10 ==
2
5
  Close tempfile after it's been written to to avoid too many open file handles
3
6
 
@@ -2,3 +2,4 @@
2
2
  * joelash
3
3
  * chaffeqa
4
4
  * Lincoln Ritter
5
+ * Bernhard Weichel
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- Diffy - Easy Diffing With Ruby
1
+ Diffy - Easy Diffing With Ruby [![Build Status](https://secure.travis-ci.org/samg/diffy.png)](http://travis-ci.org/samg/diffy)
2
2
  ============================
3
3
 
4
4
  Need diffs in your ruby app? Diffy has you covered. It provides a convenient
@@ -21,11 +21,41 @@ A default format can be set like so:
21
21
 
22
22
  Diffy::Diff.default_format = :html
23
23
 
24
+ Installation
25
+ ------------
26
+
27
+ ###on Unix
28
+
29
+ gem install diffy
30
+
31
+ ###on Windows:
32
+
33
+ 1. ensure that you have a working `which` and `diff` on your machine and on
34
+ your search path.
35
+
36
+ There are two options:
37
+
38
+ 1. install unxutils <http://sourceforge.net/projects/unxutils>
39
+
40
+ note that these tools contain diff 2.7 which has a different handling
41
+ of whitespace in the diff results. This makes diffy spec tests
42
+ yielding one fail on windows.
43
+
44
+ 2. install these two individually from the gnuwin32 project
45
+ <http://gnuwin32.sourceforge.net/>
46
+
47
+ note that this delivers diff 2.8 which makes diffy spec pass
48
+ even on windows.
49
+
50
+
51
+ 2. install the gem by
52
+
53
+ gem install diffy
54
+
55
+
24
56
  Getting Started
25
57
  ---------------
26
58
 
27
- sudo gem install diffy
28
-
29
59
  Here's an example of using Diffy to diff two strings
30
60
 
31
61
  $ irb
@@ -121,8 +151,8 @@ And even deals a bit with the formatting!
121
151
 
122
152
  ### Empty Diff Behavior
123
153
 
124
- By default diffy will return the full text of its first input if there are no
125
- differences with the second input. Sometimes it's useful to return the actual
154
+ By default diffy will return the full text of its first input if there are no
155
+ differences with the second input. Sometimes it's useful to return the actual
126
156
  diff, the empty string, in this case. To enable this behavior, simply use the
127
157
  `:allow_empty_diff => true` option when initializing.
128
158
 
@@ -203,6 +233,14 @@ If you want to use Diffy and Ruby 1.8.6 then:
203
233
 
204
234
  $ gem install diffy -v1.1.0
205
235
 
236
+ Testing
237
+ ------------
238
+
239
+ Diffy includes a full set of rspec tests. When contributing please include
240
+ tests for your changes.
241
+
242
+ [![Build Status](https://secure.travis-ci.org/samg/diffy.png)](http://travis-ci.org/samg/diffy)
243
+
206
244
  ---------------------------------------------------------------------
207
245
 
208
246
  Report bugs or request features at http://github.com/samg/diffy/issues
data/Rakefile CHANGED
@@ -1,4 +1,8 @@
1
- require 'rake/rdoctask'
1
+ begin
2
+ require 'rdoc/task'
3
+ rescue LoadError
4
+ require 'rake/rdoctask'
5
+ end
2
6
  require 'rubygems/package_task'
3
7
  require 'rspec/core/rake_task'
4
8
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.10
1
+ 2.1.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "diffy"
8
- s.version = "2.0.10"
8
+ s.version = "2.1.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 = "2012-10-27"
12
+ s.date = "2012-11-06"
13
13
  s.description = "Convenient diffing in ruby"
14
14
  s.email = "sgrock@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
18
18
  ]
19
19
  s.files = [
20
20
  ".rspec",
21
+ ".travis.yml",
21
22
  "CHANGELOG",
22
23
  "CONTRIBUTORS",
23
24
  "Gemfile",
@@ -1,5 +1,4 @@
1
1
  require 'tempfile'
2
- require 'open3'
3
2
  require 'erb'
4
3
  # 1.9 compatibility
5
4
  if defined? Enumerator and ! defined? Enumerable::Enumerator
@@ -45,7 +45,8 @@ module Diffy
45
45
  [string1, string2]
46
46
  end
47
47
  diff_opts = options[:diff].is_a?(Array) ? options[:diff] : [options[:diff]]
48
- diff = Open3.popen3(diff_bin, *(diff_opts + paths)) { |i, o, e| o.read }
48
+ cmd = "#{diff_bin} #{diff_opts.join(' ')} #{paths.join(' ')}"
49
+ diff = `#{cmd}`
49
50
  diff.force_encoding('ASCII-8BIT') if diff.respond_to?(:valid_encoding?) && !diff.valid_encoding?
50
51
  if diff =~ /\A\s*\Z/ && !options[:allow_empty_diff]
51
52
  diff = case options[:source]
@@ -116,7 +117,11 @@ module Diffy
116
117
  private
117
118
 
118
119
  def diff_bin
119
- @@bin ||= `which diff`.chomp
120
+ @@bin ||=""
121
+
122
+ @@bin = `which diff.exe`.chomp if @@bin.empty?
123
+ @@bin = `which diff`.chomp if @@bin.empty?
124
+
120
125
  if @@bin.empty?
121
126
  raise "Can't find a diff executable in PATH #{ENV['PATH']}"
122
127
  end
@@ -12,6 +12,7 @@ describe Diffy::Diff do
12
12
  @tempfiles.push(t)
13
13
  t.print(string)
14
14
  t.flush
15
+ t.close
15
16
  t.path
16
17
  end
17
18
 
@@ -487,7 +488,6 @@ baz
487
488
  line
488
489
  end.should == [" foo\n", " bar\n", "+baz\n"]
489
490
  end
490
-
491
491
  end
492
492
  end
493
493
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diffy
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.10
4
+ version: 2.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-27 00:00:00.000000000 Z
12
+ date: 2012-11-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec