fd 0.5.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4fbb1328292e9e5ebe74262b8d9c91adf2d9d71e44055e81e1ecd1fb35965768
4
- data.tar.gz: 7dfc538b1293aa6b1690c74729c2a52fc0a8f5dc74bf4d04b75ebfa3aa18bceb
3
+ metadata.gz: 867ca2b5b5c93216fffa4486285d16f53a066f1b98359c18781c954abdc42071
4
+ data.tar.gz: f56557d88d4e1ff44cc5702e6fa2dc7f24c518f7035b3e1ed677c378b678e98a
5
5
  SHA512:
6
- metadata.gz: 8dc642b1028e40559b8a868f01cf595eebd22b65678ad676abb4866865a5a43fedd46af54ede138b8bc82fdb269918580eb44779f10625ec0a86f4dde173a29b
7
- data.tar.gz: b18f4270ceb80cddccad59db720be725ce9f2e91ca43c7d2de580d9d2f469dd6d24282fcfd0ded09c91174405d9afd2df4db3fef6ee28b93dcb8972d77c79712
6
+ metadata.gz: 0ee0824ce6e7b1cefa11dba4ffbd06b514e8f3f7f82d56d0f77c5aa0003dc85df293c5dbd04bbb0d9c67f03db4e2d00f89e8466c1a67a45a4560fb76ab808462
7
+ data.tar.gz: f8a1ac2e48b72124faa67d9667ba37694b1e26e480a1a278c7f2f95d0aa9f10c2bd788475a7849f7794a87a3b2c76210a118023b9ba55a39e33550307e80c408
@@ -10,7 +10,7 @@ jobs:
10
10
  - name: Set up Ruby
11
11
  uses: ruby/setup-ruby@v1
12
12
  with:
13
- ruby-version: 3.2.1
13
+ ruby-version: 3.3
14
14
  bundler-cache: true
15
15
  - name: Run the default task
16
16
  run: bundle exec rake
data/README.md CHANGED
@@ -42,37 +42,41 @@ You can pass _file names_ on the command line:
42
42
  fd [-w number] [file_names]
43
43
  ```
44
44
 
45
- For example:
45
+ For example (without colour highlighting of invisible characters):
46
46
 
47
47
  ```bash
48
48
  > echo "Bacon ipsum dolor amet short ribs flank irure filet mignon brisket buffalo est porchetta." > some_file
49
- > fd -w 7 some_file
49
+ > ~/dev/fd ᚠ main > fd -w 7 some_file
50
50
  some_file
51
- 42 61 63 6f 6e 20 69 | B a c o n __ i
52
- 70 73 75 6d 20 64 6f | p s u m __ d o
53
- 6c 6f 72 20 61 6d 65 | l o r __ a m e
54
- 74 20 73 68 6f 72 74 | t __ s h o r t
55
- 20 72 69 62 73 20 66 | __ r i b s __ f
56
- 6c 61 6e 6b 20 69 72 | l a n k __ i r
57
- 75 72 65 20 66 69 6c | u r e __ f i l
58
- 65 74 20 6d 69 67 6e | e t __ m i g n
59
- 6f 6e 20 62 72 69 73 | o n __ b r i s
60
- 6b 65 74 20 62 75 66 | k e t __ b u f
61
- 66 61 6c 6f 20 65 73 | f a l o __ e s
62
- 74 20 70 6f 72 63 68 | t __ p o r c h
63
- 65 74 74 61 2e 0a | e t t a . LF
51
+ 42 61 63 6f 6e 20 69 | B a c o ni
52
+ 70 73 75 6d 20 64 6f | p s u md o
53
+ 6c 6f 72 20 61 6d 65 | l o ra m e
54
+ 74 20 73 68 6f 72 74 | ts h o r t
55
+ 20 72 69 62 73 20 66 |r i b sf
56
+ 6c 61 6e 6b 20 69 72 | l a n ki r
57
+ 75 72 65 20 66 69 6c | u r ef i l
58
+ 65 74 20 6d 69 67 6e | e tm i g n
59
+ 6f 6e 20 62 72 69 73 | o nb r i s
60
+ 6b 65 74 20 62 75 66 | k e tb u f
61
+ 66 61 6c 6f 20 65 73 | f a l oe s
62
+ 74 20 70 6f 72 63 68 | tp o r c h
63
+ 65 74 74 61 2e 0a | e t t a .
64
64
  ```
65
65
 
66
- You can also pipe input to STDIN:
66
+ Here's a screenshot of a zsh session that shows the highlighting:
67
+
68
+ ![](images/usage_example.png)
69
+
70
+ You can also pipe input from STDIN:
67
71
 
68
72
  ```bash
69
73
  > echo "Put something into STDIN" | fd -w 5
70
74
  STDIN
71
- 50 75 74 20 73 | P u t __ s
72
- 6f 6d 65 74 68 | o m e t h
73
- 69 6e 67 20 69 | i n g __ i
74
- 6e 74 6f 20 53 | n t o __ S
75
- 54 44 49 4e 0a | T D I N LF
75
+ 50 75 74 20 73 | P u ts
76
+ 6f 6d 65 74 68 | o m e t h
77
+ 69 6e 67 20 69 | i n gi
78
+ 6e 74 6f 20 53 | n t oS
79
+ 54 44 49 4e 0a | T D I N
76
80
  ```
77
81
 
78
82
  ## Development
data/fd.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ['Stephan Kämper']
9
9
  spec.email = ['the.tester@seasidetesting.com']
10
10
 
11
- spec.summary = 'fd is a simple (currently simplistic) tool to dump file contents in binary & text format - side by side'
11
+ spec.summary = 'fd is a simple tool to dump file contents in binary & text format side by side'
12
12
  spec.description = 'fd prints the given file in two columns: Hex values in the left column and the textual representations in the right column.'
13
13
  spec.homepage = 'https://github.com/s2k/fd'
14
14
  spec.license = 'MIT'
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency 'simplecov'
31
31
  spec.add_development_dependency 'terminal-notifier'
32
32
  spec.add_development_dependency 'terminal-notifier-guard'
33
+ spec.add_development_dependency 'mutex_m'
33
34
 
34
35
  # Specify which files should be added to the gem when it is released.
35
36
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
Binary file
data/lib/fd/version.rb CHANGED
@@ -4,7 +4,7 @@
4
4
  # All other code is in lib/fd.rb
5
5
  #
6
6
  class Fd
7
- VERSION = '0.5.0'
7
+ VERSION = '1.0.0'
8
8
 
9
9
  def self.version
10
10
  VERSION
data/lib/fd.rb CHANGED
@@ -7,6 +7,8 @@ require_relative 'fd/version'
7
7
  class Fd
8
8
  class Error < StandardError; end
9
9
 
10
+ ESCAPE_CHARACTERS = %w[␀ ␇ ␈ ␉ ␊ ␋ ␌ ␍ ␡ ␛ ␠]
11
+
10
12
  attr_reader :line_length, :char_table
11
13
 
12
14
  # _line_length_ sets how many characters are displayed per @line.
@@ -44,6 +46,10 @@ class Fd
44
46
  @char_table[32] = '␠'
45
47
  end
46
48
 
49
+ def add_esc_sequence(chr)
50
+ "\e[31m#{chr}\e[0m"
51
+ end
52
+
47
53
  # dumps the given file _file_name_ to stdout.
48
54
  def dump(content)
49
55
  raise "Not the expected encoding of UFT-8, got #{content.encoding}" unless content.encoding == Encoding::UTF_8
@@ -104,6 +110,8 @@ class Fd
104
110
  end
105
111
 
106
112
  def print_single_line
107
- puts("#{format("%#{(3 * line_length) - 1}s", hex_values.join(' '))} |#{format("%#{2 * line_length}s", line)}")
113
+ puts("#{format("%#{(3 * line_length) - 1}s", hex_values.join(' '))} |#{format("%#{2 * line_length}s", line)}".
114
+ gsub(/([#{ESCAPE_CHARACTERS.join('')}])/, add_esc_sequence('\1'))
115
+ )
108
116
  end
109
117
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephan Kämper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-13 00:00:00.000000000 Z
11
+ date: 2023-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard-bundler
@@ -150,6 +150,20 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: mutex_m
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
153
167
  description: 'fd prints the given file in two columns: Hex values in the left column
154
168
  and the textual representations in the right column.'
155
169
  email:
@@ -173,6 +187,7 @@ files:
173
187
  - bin/fd
174
188
  - bin/setup
175
189
  - fd.gemspec
190
+ - images/usage_example.png
176
191
  - lib/fd.rb
177
192
  - lib/fd/version.rb
178
193
  homepage: https://github.com/s2k/fd
@@ -198,9 +213,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
198
213
  - !ruby/object:Gem::Version
199
214
  version: '0'
200
215
  requirements: []
201
- rubygems_version: 3.4.19
216
+ rubygems_version: 3.5.3
202
217
  signing_key:
203
218
  specification_version: 4
204
- summary: fd is a simple (currently simplistic) tool to dump file contents in binary
205
- & text format - side by side
219
+ summary: fd is a simple tool to dump file contents in binary & text format side by
220
+ side
206
221
  test_files: []