difftastic 0.6.0 → 0.7.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 40aeed4803e810a76a8a9b0ffcce1c86869a114cfbeda8209ac5beaa756b2b54
4
- data.tar.gz: 01f9e9243363960e7a50872fe1841161c5546e795e4ad3730a11d8fe3b6517aa
3
+ metadata.gz: '015263482aed42c09cdd11125be618178500445bba4859aca854f03333317318'
4
+ data.tar.gz: 1b11a29cf5da9928740f07ba52a13befc0328c9ebc2d346d03fee639a4994100
5
5
  SHA512:
6
- metadata.gz: fba70383aa09e3cf75edb2560fd719ac5f0fcda6e6df67f7cab21063502c912b83217aee4cc7667e6a76562de55f3299a3f2e256b397ea9172643d0af66d6dfe
7
- data.tar.gz: a49384365ed1dc54853645353e8f23d99e9fcefe83caf02fc6eddd72ffa4892c63a67fc0fec0b89217aeebe2f5387894903b7bb14c09de1255533845c1abcb76
6
+ metadata.gz: c50ca1ffeb1b87730c16b92cd039456a0aca25b9769de9c8524d2cdfa28d88988e57b819c20f6392d3e1174752e11aa07068fb5912d41cfaddc9ff050798134b
7
+ data.tar.gz: 4904bc8fb6ba4cb628f9a6fd1d2b0e8974c864ce4772d2ed8dd1444aeba534b9b90997fd1ed417cffbf084ba5fffbbf91fcdd523537937265ae115ee6b56c7bf
@@ -289,8 +289,8 @@ class Difftastic::Differ
289
289
 
290
290
  def diff_files(old_file, new_file)
291
291
  options = [
292
- (old_file.path),
293
- (new_file.path),
292
+ (file_to_path(old_file)),
293
+ (file_to_path(new_file)),
294
294
  ("--color=#{@color}" if @color),
295
295
  ("--context=#{@context}" if @context),
296
296
  ("--background=#{@background}" if @background),
@@ -303,7 +303,7 @@ class Difftastic::Differ
303
303
  result = Difftastic.execute(options.join(" ")).lstrip.sub(/\n{2}\z/, "")
304
304
 
305
305
  unless @show_paths
306
- new_line_index = result.index("\n") + 1
306
+ new_line_index = (result.index("\n") || 0) + 1
307
307
  result = result.byteslice(new_line_index, result.bytesize - new_line_index)
308
308
  end
309
309
 
@@ -362,4 +362,13 @@ class Difftastic::Differ
362
362
 
363
363
  [minimum_offset, offset].max
364
364
  end
365
+
366
+ def file_to_path(file)
367
+ return file if file.is_a?(String)
368
+ return file.path if file.is_a?(File)
369
+ return file.path if file.is_a?(Tempfile)
370
+ return file.to_s if file.is_a?(Pathname) # just to be explicit
371
+
372
+ file.to_s
373
+ end
365
374
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Difftastic
4
- VERSION = "0.6.0"
4
+ VERSION = "0.7.0"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: difftastic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Drapper
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-02-11 00:00:00.000000000 Z
10
+ date: 2025-05-24 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: pretty_please