binp 3.0.0 → 4.0.1
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/.gitignore +0 -0
- data/.travis.yml +0 -0
- data/Gemfile +0 -0
- data/Gemfile.lock +9 -7
- data/LICENSE +0 -0
- data/README.md +0 -0
- data/Rakefile +0 -0
- data/bin/console +0 -0
- data/bin/setup +0 -0
- data/binp.gemspec +0 -0
- data/example/example.bin +0 -0
- data/example/example.yaml +0 -0
- data/example/example_01.bin +0 -0
- data/example/example_01.yaml +2 -0
- data/lib/binp/cli/main.rb +22 -1
- data/lib/binp/version.rb +1 -1
- data/lib/binp.rb +7 -3
- 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: 3e5aa8bf9a77550ad7541f17e1f958f5f6d9c23a763dc555770cd16c528462d7
|
|
4
|
+
data.tar.gz: 05f9f4429177401d63115fb14320e33bc77f9c1554023213d7e4997b49dff0dc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8e6e4087c112da72860488d20008946b3955fc87cf0d350c85dc3ce746d3d28e0155a82821b6e0b67c6ace98b06a981bc222cc1a71737a55bac477a4c197e447
|
|
7
|
+
data.tar.gz: '0514328a067f495fdad35ecd88587ba142fc0d7b7178a6a420db00eafcb253de7c67b01bc1151cbe5e1c84b9f514ffdeb42a8d1e4502a38fe3948bf9e0f574e1'
|
data/.gitignore
CHANGED
|
File without changes
|
data/.travis.yml
CHANGED
|
File without changes
|
data/Gemfile
CHANGED
|
File without changes
|
data/Gemfile.lock
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
binp (
|
|
4
|
+
binp (4.0.1)
|
|
5
5
|
formatador
|
|
6
6
|
|
|
7
7
|
GEM
|
|
8
8
|
remote: https://rubygems.org/
|
|
9
9
|
specs:
|
|
10
|
-
docile (1.
|
|
11
|
-
formatador (
|
|
12
|
-
power_assert (
|
|
10
|
+
docile (1.4.0)
|
|
11
|
+
formatador (1.1.0)
|
|
12
|
+
power_assert (2.0.3)
|
|
13
13
|
rake (12.3.3)
|
|
14
|
-
simplecov (0.
|
|
14
|
+
simplecov (0.22.0)
|
|
15
15
|
docile (~> 1.1)
|
|
16
16
|
simplecov-html (~> 0.11)
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
simplecov_json_formatter (~> 0.1)
|
|
18
|
+
simplecov-html (0.12.3)
|
|
19
|
+
simplecov_json_formatter (0.1.4)
|
|
20
|
+
test-unit (3.6.1)
|
|
19
21
|
power_assert
|
|
20
22
|
|
|
21
23
|
PLATFORMS
|
data/LICENSE
CHANGED
|
File without changes
|
data/README.md
CHANGED
|
File without changes
|
data/Rakefile
CHANGED
|
File without changes
|
data/bin/console
CHANGED
|
File without changes
|
data/bin/setup
CHANGED
|
File without changes
|
data/binp.gemspec
CHANGED
|
File without changes
|
data/example/example.bin
CHANGED
|
File without changes
|
data/example/example.yaml
CHANGED
|
File without changes
|
data/example/example_01.bin
CHANGED
|
File without changes
|
data/example/example_01.yaml
CHANGED
data/lib/binp/cli/main.rb
CHANGED
|
@@ -42,10 +42,31 @@ class Main
|
|
|
42
42
|
all: false
|
|
43
43
|
}
|
|
44
44
|
op = OptionParser.new
|
|
45
|
+
op.banner = 'Usage: binp [options] FILE'
|
|
45
46
|
|
|
46
47
|
op.on('-c VALUE', '--config VALUE', '設定ファイルパス') { |v| options[:config] = v }
|
|
47
48
|
op.on('-a', '--all', 'name, value 以外のすべての項目(endianness, offset, size, type)を表示する') { |v| options[:all] = true }
|
|
48
|
-
|
|
49
|
+
begin
|
|
50
|
+
op.parse!(argv)
|
|
51
|
+
rescue OptionParser::InvalidOption => e
|
|
52
|
+
STDERR.puts 'ERROR: オプションのパースに失敗しました。'
|
|
53
|
+
STDERR.puts op.to_s
|
|
54
|
+
exit(1);
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# 必須オプション `-c` のチェック
|
|
58
|
+
unless options[:config]
|
|
59
|
+
STDERR.puts 'ERROR: 必須オプション `-c, --config` が指定されていません。'
|
|
60
|
+
STDERR.puts op.to_s
|
|
61
|
+
exit(1);
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# ファイル指定があるかのチェック
|
|
65
|
+
if argv.size == 0
|
|
66
|
+
STDERR.puts 'ERROR: FILE が指定されていません。'
|
|
67
|
+
STDERR.puts op.to_s
|
|
68
|
+
exit(1);
|
|
69
|
+
end
|
|
49
70
|
|
|
50
71
|
[options, argv]
|
|
51
72
|
end
|
data/lib/binp/version.rb
CHANGED
data/lib/binp.rb
CHANGED
|
@@ -8,7 +8,7 @@ class BinParser
|
|
|
8
8
|
if e['type'] == BinParserElement::Type::FLAGS
|
|
9
9
|
e = BinParserElement.get_flags(uint8_array, e)
|
|
10
10
|
else
|
|
11
|
-
e['value'] = BinParserElement.get_value(uint8_array, e['offset'], e['size'], e['type'], e['endianness'])
|
|
11
|
+
e['value'] = BinParserElement.get_value(uint8_array, e['offset'], e['size'], e['type'], e['endianness'], e['value_label'])
|
|
12
12
|
end
|
|
13
13
|
e
|
|
14
14
|
}
|
|
@@ -79,11 +79,15 @@ class BinParserElement
|
|
|
79
79
|
'C' * size
|
|
80
80
|
end
|
|
81
81
|
|
|
82
|
-
def self.get_value(uint8_array, offset, size, type, endianness)
|
|
82
|
+
def self.get_value(uint8_array, offset, size, type, endianness, value_labels={})
|
|
83
83
|
target = uint8_array.slice(offset, size)
|
|
84
84
|
pack_template_string = calculate_pack_template_string(size)
|
|
85
85
|
unpack_template_string = calculate_unpack_template_string(type, endianness)
|
|
86
|
-
target.pack(pack_template_string).unpack(unpack_template_string)[0]
|
|
86
|
+
value = target.pack(pack_template_string).unpack(unpack_template_string)[0]
|
|
87
|
+
|
|
88
|
+
# value_label が設定されている数値であれば、それに置き換える
|
|
89
|
+
value_labels ||= {}
|
|
90
|
+
value_labels.fetch(value, value)
|
|
87
91
|
end
|
|
88
92
|
|
|
89
93
|
def self.get_flags(uint8_array, config)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: binp
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 4.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- mikoto2000
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2023-08-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: formatador
|
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
100
100
|
- !ruby/object:Gem::Version
|
|
101
101
|
version: '0'
|
|
102
102
|
requirements: []
|
|
103
|
-
rubygems_version: 3.
|
|
103
|
+
rubygems_version: 3.4.10
|
|
104
104
|
signing_key:
|
|
105
105
|
specification_version: 4
|
|
106
106
|
summary: binary file parser.
|