fd 0.4.0 → 0.5.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 +4 -4
- data/.github/workflows/main.yml +2 -2
- data/README.md +11 -6
- data/lib/fd/version.rb +1 -1
- data/lib/fd.rb +13 -13
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4fbb1328292e9e5ebe74262b8d9c91adf2d9d71e44055e81e1ecd1fb35965768
|
|
4
|
+
data.tar.gz: 7dfc538b1293aa6b1690c74729c2a52fc0a8f5dc74bf4d04b75ebfa3aa18bceb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8dc642b1028e40559b8a868f01cf595eebd22b65678ad676abb4866865a5a43fedd46af54ede138b8bc82fdb269918580eb44779f10625ec0a86f4dde173a29b
|
|
7
|
+
data.tar.gz: b18f4270ceb80cddccad59db720be725ce9f2e91ca43c7d2de580d9d2f469dd6d24282fcfd0ded09c91174405d9afd2df4db3fef6ee28b93dcb8972d77c79712
|
data/.github/workflows/main.yml
CHANGED
|
@@ -6,11 +6,11 @@ jobs:
|
|
|
6
6
|
build:
|
|
7
7
|
runs-on: ubuntu-latest
|
|
8
8
|
steps:
|
|
9
|
-
- uses: actions/checkout@
|
|
9
|
+
- uses: actions/checkout@v3
|
|
10
10
|
- name: Set up Ruby
|
|
11
11
|
uses: ruby/setup-ruby@v1
|
|
12
12
|
with:
|
|
13
|
-
ruby-version: 3.1
|
|
13
|
+
ruby-version: 3.2.1
|
|
14
14
|
bundler-cache: true
|
|
15
15
|
- name: Run the default task
|
|
16
16
|
run: bundle exec rake
|
data/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
## TL;DR
|
|
8
8
|
|
|
9
|
-
`fd` reads files _as a sequence of (UTF-8) characters_ and dumps the content to _STDOUT_, thus the name `fd`. It does so in two columns, the left one will display the hex values of the bytes in the file, the right one will display the characters.
|
|
9
|
+
`fd` reads files (or STDIN) _as a sequence of (UTF-8) characters_ and dumps the content to _STDOUT_, thus the name `fd`. It does so in two columns, the left one will display the hex values of the bytes in the file, the right one will display the characters.
|
|
10
10
|
|
|
11
11
|
## History
|
|
12
12
|
|
|
@@ -32,18 +32,22 @@ Or install it yourself as:
|
|
|
32
32
|
|
|
33
33
|
$ gem install fd
|
|
34
34
|
|
|
35
|
+
Also see the [fd page on rubygems.org](https://rubygems.org/gems/fd)
|
|
36
|
+
|
|
35
37
|
## Usage
|
|
36
38
|
|
|
37
39
|
You can pass _file names_ on the command line:
|
|
38
40
|
|
|
39
41
|
```
|
|
40
|
-
fd [-w
|
|
42
|
+
fd [-w number] [file_names]
|
|
41
43
|
```
|
|
42
44
|
|
|
43
45
|
For example:
|
|
46
|
+
|
|
44
47
|
```bash
|
|
45
|
-
> echo "Bacon ipsum dolor amet short ribs flank irure filet mignon brisket buffalo est porchetta."
|
|
46
|
-
|
|
48
|
+
> echo "Bacon ipsum dolor amet short ribs flank irure filet mignon brisket buffalo est porchetta." > some_file
|
|
49
|
+
> fd -w 7 some_file
|
|
50
|
+
some_file
|
|
47
51
|
42 61 63 6f 6e 20 69 | B a c o n __ i
|
|
48
52
|
70 73 75 6d 20 64 6f | p s u m __ d o
|
|
49
53
|
6c 6f 72 20 61 6d 65 | l o r __ a m e
|
|
@@ -56,12 +60,13 @@ STDIN
|
|
|
56
60
|
6b 65 74 20 62 75 66 | k e t __ b u f
|
|
57
61
|
66 61 6c 6f 20 65 73 | f a l o __ e s
|
|
58
62
|
74 20 70 6f 72 63 68 | t __ p o r c h
|
|
59
|
-
65 74 74 61 2e 0a | e t t a . LF
|
|
63
|
+
65 74 74 61 2e 0a | e t t a . LF
|
|
64
|
+
```
|
|
60
65
|
|
|
61
66
|
You can also pipe input to STDIN:
|
|
62
67
|
|
|
63
68
|
```bash
|
|
64
|
-
> echo "Put something into STDIN" |
|
|
69
|
+
> echo "Put something into STDIN" | fd -w 5
|
|
65
70
|
STDIN
|
|
66
71
|
50 75 74 20 73 | P u t __ s
|
|
67
72
|
6f 6d 65 74 68 | o m e t h
|
data/lib/fd/version.rb
CHANGED
data/lib/fd.rb
CHANGED
|
@@ -31,17 +31,17 @@ class Fd
|
|
|
31
31
|
|
|
32
32
|
@line_length = line_length
|
|
33
33
|
@char_table = {}
|
|
34
|
-
@char_table[0] = '
|
|
35
|
-
@char_table[7] = '
|
|
36
|
-
@char_table[8] = '
|
|
37
|
-
@char_table[9] = '
|
|
38
|
-
@char_table[10] = '
|
|
39
|
-
@char_table[11] = '
|
|
40
|
-
@char_table[12] = '
|
|
41
|
-
@char_table[13] = '
|
|
42
|
-
@char_table[16] = '
|
|
43
|
-
@char_table[27] = '
|
|
44
|
-
@char_table[32] = '
|
|
34
|
+
@char_table[0] = '␀'
|
|
35
|
+
@char_table[7] = '␇'
|
|
36
|
+
@char_table[8] = '␈'
|
|
37
|
+
@char_table[9] = '␉'
|
|
38
|
+
@char_table[10] = '␊'
|
|
39
|
+
@char_table[11] = '␋'
|
|
40
|
+
@char_table[12] = '␌'
|
|
41
|
+
@char_table[13] = '␍'
|
|
42
|
+
@char_table[16] = '␡'
|
|
43
|
+
@char_table[27] = '␛'
|
|
44
|
+
@char_table[32] = '␠'
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
# dumps the given file _file_name_ to stdout.
|
|
@@ -95,7 +95,7 @@ class Fd
|
|
|
95
95
|
def append_to_line(bytes, char)
|
|
96
96
|
@byte_count_in_line += bytes.size
|
|
97
97
|
bytes.each { |bt| @hex_values << format('%02x', bt) }
|
|
98
|
-
@line += format('%
|
|
98
|
+
@line += format('%2s', (char_table[char.ord] || char))
|
|
99
99
|
@char_index += 1
|
|
100
100
|
end
|
|
101
101
|
|
|
@@ -104,6 +104,6 @@ class Fd
|
|
|
104
104
|
end
|
|
105
105
|
|
|
106
106
|
def print_single_line
|
|
107
|
-
puts("#{format("%#{(3 * line_length) - 1}s", hex_values.join(' '))} |#{format("%#{
|
|
107
|
+
puts("#{format("%#{(3 * line_length) - 1}s", hex_values.join(' '))} |#{format("%#{2 * line_length}s", line)}")
|
|
108
108
|
end
|
|
109
109
|
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.
|
|
4
|
+
version: 0.5.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:
|
|
11
|
+
date: 2023-09-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: guard-bundler
|
|
@@ -198,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
198
198
|
- !ruby/object:Gem::Version
|
|
199
199
|
version: '0'
|
|
200
200
|
requirements: []
|
|
201
|
-
rubygems_version: 3.
|
|
201
|
+
rubygems_version: 3.4.19
|
|
202
202
|
signing_key:
|
|
203
203
|
specification_version: 4
|
|
204
204
|
summary: fd is a simple (currently simplistic) tool to dump file contents in binary
|