bin2hex 0.0.1 → 0.0.2
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.
- data/bin/bin2hex +1 -1
- data/lib/bin2hex.rb +13 -14
- data/lib/bin2hex/version.rb +3 -0
- metadata +4 -3
data/bin/bin2hex
CHANGED
|
@@ -44,7 +44,7 @@ def parse_args(args)
|
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
options = parse_args(ARGV)
|
|
47
|
-
b2h = BinaryToHexFileConverter.new({ :format => options.format })
|
|
47
|
+
b2h = Bin2Hex::BinaryToHexFileConverter.new({ :format => options.format })
|
|
48
48
|
b2h.process_file(options.input_file, options.output_file)
|
|
49
49
|
|
|
50
50
|
|
data/lib/bin2hex.rb
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
|
+
module Bin2Hex
|
|
2
|
+
class BinaryToHexFileConverter
|
|
1
3
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
def initialize(options)
|
|
6
|
-
@options = options
|
|
7
|
-
end
|
|
4
|
+
def initialize(options)
|
|
5
|
+
@options = options
|
|
6
|
+
end
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
def process_file(input, output)
|
|
9
|
+
begin
|
|
10
|
+
File.open(sprintf(output, input), "w") do |out_file|
|
|
11
|
+
File.open(input, "rb").each_byte do |b|
|
|
12
|
+
out_file.write(sprintf(@options[:format], b))
|
|
13
|
+
end
|
|
14
14
|
end
|
|
15
|
+
rescue Errno::ENOENT => e
|
|
16
|
+
puts "Error: #{e.message}"
|
|
15
17
|
end
|
|
16
|
-
rescue Errno::ENOENT => e
|
|
17
|
-
puts "Error: #{e.message}"
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
|
-
|
|
21
20
|
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bin2hex
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 27
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 0
|
|
9
|
-
-
|
|
10
|
-
version: 0.0.
|
|
9
|
+
- 2
|
|
10
|
+
version: 0.0.2
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Dextrey
|
|
@@ -27,6 +27,7 @@ extensions: []
|
|
|
27
27
|
extra_rdoc_files: []
|
|
28
28
|
|
|
29
29
|
files:
|
|
30
|
+
- lib/bin2hex/version.rb
|
|
30
31
|
- lib/bin2hex.rb
|
|
31
32
|
- bin/bin2hex
|
|
32
33
|
homepage:
|