difftastic 0.0.1 → 0.1.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: 9f48cc3ea22f59316452fccc1b08d2bd389dea4191c72bef3e949143fb1f8b5c
4
- data.tar.gz: 764cd134a19239e277d8dd80f743198b64b98d1cbe07a3a43d38066934915afc
3
+ metadata.gz: 36d2eb85b5edd94a6c73be35dfaab7186f035f06a861c82c60106bddfe605282
4
+ data.tar.gz: ac58b149f7fe539c818d99e3572865759d0c67e22f8da3da63e4078d68351ac1
5
5
  SHA512:
6
- metadata.gz: 85636d73d69e4301fa31e2b4a22d2abbd5ff6178e2905bb9ede00139a07f2df3a99f89f5bfbfaa6751c21694ee65a47472021f3a800e862ad730254729b5167f
7
- data.tar.gz: 69332e462ac67ea40ab46b921d89ef7e4a4838cc70c6c2560853418cc2c8aec4378861ae1cb861ad7cb2ab9cc6d51954f7d793f7b5cdd6ccbf3782c532792fe5
6
+ metadata.gz: 35d914cd69bbfd754521ae5508951b4b67a1cdabc8d8100086b785ce28ce2e8dbe95de72792895c9493022738c7cba8c6248cf78fe8e594ce9770886efcfa874
7
+ data.tar.gz: 903e1e8432a8fecd05e3a6f39c8c100497ad745db1678c8dd720a60af9c0e817d141ca85b61a8e5d839387b4aa8ad819f45f3560cccd529aa12d05544856c9f5
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Joel Drapper
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1 +1 @@
1
- # Difftastic
1
+ # Difftastic Ruby
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Difftastic::Differ
4
- def initialize(background: nil, color: nil, syntax_highlight: nil, context: nil, tab_width: nil, parse_error_limit: nil)
4
+ def initialize(background: nil, color: nil, syntax_highlight: nil, context: nil, tab_width: nil, parse_error_limit: nil, underline_highlights: true)
5
5
  @show_paths = false
6
6
  @background = background => :dark | :light | nil
7
7
  @color = color => :always | :never | :auto | nil
@@ -9,6 +9,7 @@ class Difftastic::Differ
9
9
  @context = context => Integer | nil
10
10
  @tab_width = tab_width => Integer | nil
11
11
  @parse_error_limit = parse_error_limit => Integer | nil
12
+ @underline_highlights = underline_highlights => true | false
12
13
  end
13
14
 
14
15
  def diff_objects(old, new)
@@ -291,11 +292,22 @@ class Difftastic::Differ
291
292
 
292
293
  result = Difftastic.execute(options.join(" "))
293
294
 
294
- if @show_paths
295
- result
296
- else
295
+ unless @show_paths
297
296
  new_line_index = result.index("\n") + 1
298
- result.byteslice(new_line_index, result.bytesize - new_line_index)
297
+ result = result.byteslice(new_line_index, result.bytesize - new_line_index)
299
298
  end
299
+
300
+ if @underline_highlights
301
+ result.gsub!(/\e\[([0-9;]*)m/) {
302
+ codes = $1
303
+ if codes =~ /9[12]/ # Matches 91 or 92
304
+ "\e[#{codes};4m"
305
+ else
306
+ "\e[#{codes}m"
307
+ end
308
+ }
309
+ end
310
+
311
+ result
300
312
  end
301
313
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Difftastic
4
- VERSION = "0.0.1"
4
+ VERSION = "0.1.0"
5
5
  end
data/lib/difftastic.rb CHANGED
@@ -99,7 +99,7 @@ module Difftastic
99
99
  when Set
100
100
  buffer << "Set[\n"
101
101
  indent += 1
102
- object.each do |value|
102
+ object.to_a.sort!.each do |value|
103
103
  buffer << (" " * indent)
104
104
  pretty(value, buffer:, indent:)
105
105
  buffer << ",\n"
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.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Drapper
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-01-21 00:00:00.000000000 Z
10
+ date: 2025-01-22 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  email:
13
13
  - joel@drapper.me
@@ -16,6 +16,7 @@ executables:
16
16
  extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
+ - LICENSE.txt
19
20
  - README.md
20
21
  - exe/difft
21
22
  - lib/difftastic.rb