dz 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 +7 -0
- data/LICENCE +18 -0
- data/README.md +77 -0
- data/bin/dz +24 -0
- data/dz.gemspec +30 -0
- data/lib/dz.rb +17 -0
- data/tests/dz2bin_tests.rb +8 -0
- data/tests/tests.rb +28 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c7ca5ebb875c148f54bc13e4dba563cb290862e3
|
4
|
+
data.tar.gz: dc3a04282cd03f484da1417d0ab51729dfa01f14
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 658937378fb216c585aceae01747f3acf7f2df9556d121923cbd0e1756945c6ced922355309045e04073aaf86402daa117ebcd3bb1b0e08ba53aae8b2137503c
|
7
|
+
data.tar.gz: bc8c93ce528f9366cdfddba5d708cd6d4bede6be924c89899c0df4616392e916696746559bb1ff6371a41eb51250ee6d170a797d491a53622a9691f1721704f0
|
data/LICENCE
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Copyright © 2013 – Baptiste Fontaine
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
5
|
+
the Software without restriction, including without limitation the rights to
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
7
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
8
|
+
subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
15
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
16
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
17
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
18
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# dz
|
2
|
+
|
3
|
+
[](https://travis-ci.org/bfontaine/dz)
|
4
|
+
|
5
|
+
**dz** is a dead simple hexadecimal-to-binary tool. It’s used to create binaries
|
6
|
+
by hand.
|
7
|
+
|
8
|
+
## Install
|
9
|
+
|
10
|
+
```
|
11
|
+
gem install dz
|
12
|
+
```
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
```
|
17
|
+
$ dz input.dz output
|
18
|
+
```
|
19
|
+
|
20
|
+
Give it two filenames. It’ll read the first one and write binary data into the
|
21
|
+
second one. That’s it!
|
22
|
+
|
23
|
+
### Syntax
|
24
|
+
|
25
|
+
I use `.dz` for input files but you can use what you want, they are plain text
|
26
|
+
files.
|
27
|
+
|
28
|
+
Each byte is written as an hexadecimal number. Two bytes must be separated by
|
29
|
+
one or more spaces and/or newlines. Comments start with a `#` and take the whole
|
30
|
+
line. Non-hexadecimal chars (outside of comments) are ignored.
|
31
|
+
|
32
|
+
#### Example
|
33
|
+
|
34
|
+
```
|
35
|
+
# file header
|
36
|
+
34 | 00 | 0A 0A
|
37
|
+
|
38
|
+
# first part
|
39
|
+
01 | 00 | 00 00 02 | AA AF
|
40
|
+
# second part
|
41
|
+
01 | 0F | 00 00 06 | AA CC 89 3B 01 79
|
42
|
+
```
|
43
|
+
|
44
|
+
Save this in `example.dz`, then run:
|
45
|
+
|
46
|
+
```
|
47
|
+
$ dz example.dz example
|
48
|
+
```
|
49
|
+
|
50
|
+
you can now check the binary using `hexdump`:
|
51
|
+
|
52
|
+
```
|
53
|
+
$ hexdump example
|
54
|
+
0000000 34 00 0a 0a 01 00 00 00 02 aa af 01 0f 00 00 06
|
55
|
+
0000010 aa cc 89 3b 01 79
|
56
|
+
0000016
|
57
|
+
```
|
58
|
+
|
59
|
+
## Tests
|
60
|
+
|
61
|
+
```
|
62
|
+
$ git clone https://github.com/bfontaine/dz.git
|
63
|
+
$ cd dz
|
64
|
+
$ bundle install
|
65
|
+
$ rake test
|
66
|
+
```
|
67
|
+
|
68
|
+
Set the `COVERAGE` environment variable to activate the code
|
69
|
+
coverage report, e.g.:
|
70
|
+
|
71
|
+
```
|
72
|
+
$ export COVERAGE=1; rake test
|
73
|
+
```
|
74
|
+
|
75
|
+
|
76
|
+
It’ll generate a `coverage/index.html`, which you can open in a
|
77
|
+
Web browser.
|
data/bin/dz
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# -*- coding: UTF-8 -*-
|
3
|
+
|
4
|
+
require 'dz'
|
5
|
+
|
6
|
+
if ARGV.length < 2
|
7
|
+
puts <<EOH
|
8
|
+
Usage:
|
9
|
+
dz <input> [<input> ...] <output>
|
10
|
+
EOH
|
11
|
+
exit 1
|
12
|
+
end
|
13
|
+
|
14
|
+
output = ARGV.pop
|
15
|
+
out = File.open(output, 'w')
|
16
|
+
|
17
|
+
# Trap interrupts to quit cleanly.
|
18
|
+
Signal.trap('INT') { out.close;exit 1 }
|
19
|
+
|
20
|
+
ARGF.each_line do |l|
|
21
|
+
out.write(DZ.dz2bin(l))
|
22
|
+
end
|
23
|
+
|
24
|
+
out.close
|
data/dz.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'dz'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'dz'
|
7
|
+
s.version = DZ.version
|
8
|
+
s.date = Time.now
|
9
|
+
|
10
|
+
s.summary = 'Dead simple hex-to-binary CLI tool'
|
11
|
+
s.description = 'Convert lists of hexadecimal numbers into binary files'
|
12
|
+
s.license = 'MIT'
|
13
|
+
|
14
|
+
s.author = 'Baptiste Fontaine'
|
15
|
+
s.email = 'b@ptistefontaine.fr'
|
16
|
+
s.homepage = 'https://github.com/bfontaine/dz'
|
17
|
+
|
18
|
+
s.files = %w(LICENCE README.md dz.gemspec)
|
19
|
+
s.files += Dir.glob('lib/**/*.rb')
|
20
|
+
|
21
|
+
s.test_files = Dir.glob('tests/**/*')
|
22
|
+
s.require_path = 'lib'
|
23
|
+
|
24
|
+
s.bindir = 'bin'
|
25
|
+
s.executables << 'dz'
|
26
|
+
|
27
|
+
s.add_development_dependency 'simplecov'
|
28
|
+
s.add_development_dependency 'rake'
|
29
|
+
s.add_development_dependency 'test-unit'
|
30
|
+
end
|
data/lib/dz.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# -*- coding: UTF-8 -*-
|
3
|
+
|
4
|
+
module DZ
|
5
|
+
class << self
|
6
|
+
def version
|
7
|
+
'0.1.0'
|
8
|
+
end
|
9
|
+
|
10
|
+
def dz2bin(s)
|
11
|
+
hxs = s.gsub(/^#.*?$/, ' ').split(/[^0-9A-Fa-f]/)
|
12
|
+
hxs.reject!(&:empty?)
|
13
|
+
|
14
|
+
hxs.map { |x| x.to_i(16) }.pack('C*')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/tests/tests.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# -*- coding: UTF-8 -*-
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require 'simplecov'
|
6
|
+
|
7
|
+
test_dir = File.expand_path( File.dirname(__FILE__) )
|
8
|
+
|
9
|
+
SimpleCov.start { add_filter '/tests/' } if ENV['COVERAGE']
|
10
|
+
|
11
|
+
require 'dz'
|
12
|
+
|
13
|
+
for t in Dir.glob( File.join( test_dir, '*_tests.rb' ) )
|
14
|
+
require t
|
15
|
+
end
|
16
|
+
|
17
|
+
class DZTests < Test::Unit::TestCase
|
18
|
+
|
19
|
+
# == DZ#version == #
|
20
|
+
|
21
|
+
def test_dz_version
|
22
|
+
assert(DZ.version =~ /^\d+\.\d+\.\d+/)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
exit Test::Unit::AutoRunner.run
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dz
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Baptiste Fontaine
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: simplecov
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: test-unit
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Convert lists of hexadecimal numbers into binary files
|
56
|
+
email: b@ptistefontaine.fr
|
57
|
+
executables:
|
58
|
+
- dz
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- LICENCE
|
63
|
+
- README.md
|
64
|
+
- dz.gemspec
|
65
|
+
- lib/dz.rb
|
66
|
+
- tests/dz2bin_tests.rb
|
67
|
+
- tests/tests.rb
|
68
|
+
- bin/dz
|
69
|
+
homepage: https://github.com/bfontaine/dz
|
70
|
+
licenses:
|
71
|
+
- MIT
|
72
|
+
metadata: {}
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
requirements: []
|
88
|
+
rubyforge_project:
|
89
|
+
rubygems_version: 2.1.10
|
90
|
+
signing_key:
|
91
|
+
specification_version: 4
|
92
|
+
summary: Dead simple hex-to-binary CLI tool
|
93
|
+
test_files:
|
94
|
+
- tests/dz2bin_tests.rb
|
95
|
+
- tests/tests.rb
|