bin_struct 0.2.0 → 0.2.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/CHANGELOG.md +10 -0
- data/README.md +7 -1
- data/lib/bin_struct/cstring.rb +2 -1
- data/lib/bin_struct/int_string.rb +2 -2
- data/lib/bin_struct/string.rb +2 -1
- data/lib/bin_struct/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df710325cf6aa4414fc997d77033b8bea34d4dc80e571ceb184462b2aa047eb3
|
4
|
+
data.tar.gz: aa372402e27bc5b254b7e4e82cb7d9b2178823c84adc3c1bda17bba7806ff05e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ef8207d1fc62509bda66a0caa779ec2b6b95e2a7805fb10199423bcf1300a7f05dd5c5b595f33f8b6605b93277e485a5a18f80a83b7c6954339eea0541f6073
|
7
|
+
data.tar.gz: b47f00bd2497c5330eeb6a01721b3cbd4a305d624e6df7dce2fd13b8f996c61e287ab92df393ea0fcb67fece0396497354220e9a56cb50bf617fa0d9b3ccdaff
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,16 @@
|
|
3
3
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
4
4
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
5
5
|
|
6
|
+
## 0.2.1 - 2024-11-25
|
7
|
+
|
8
|
+
### Added
|
9
|
+
|
10
|
+
- `CString` and `String` initializers now accepts `:value` option to set string initial value.
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
|
14
|
+
- `IntString` initializer option `:string` is renamed into `:value`.
|
15
|
+
|
6
16
|
## 0.2.0 - 2024-07-21
|
7
17
|
|
8
18
|
### Changed
|
data/README.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
[](https://badge.fury.io/rb/bin_struct)
|
2
|
+
[](https://github.com/lemontree55/bin_struct/actions/workflows/main.yml)
|
3
|
+
|
1
4
|
# BinStruct
|
2
5
|
|
3
6
|
BinStruct provides a simple way to create and dissect binary data. It is an extraction from [PacketGen](https://github.com/lemontree55/packetgen) 3.x Fields.
|
@@ -6,9 +9,12 @@ BinStruct provides a simple way to create and dissect binary data. It is an extr
|
|
6
9
|
|
7
10
|
Installation using RubyGems is easy:
|
8
11
|
|
9
|
-
|
12
|
+
```shell
|
13
|
+
gem install bin_struct
|
14
|
+
```
|
10
15
|
|
11
16
|
Or add it to a Gemfile:
|
17
|
+
|
12
18
|
```ruby
|
13
19
|
gem 'bin_struct'
|
14
20
|
```
|
data/lib/bin_struct/cstring.rb
CHANGED
@@ -76,8 +76,9 @@ module BinStruct
|
|
76
76
|
|
77
77
|
# @param [Hash] options
|
78
78
|
# @option options [Integer] :static_length set a static length for this string
|
79
|
+
# @option options [::String] :value string value (default to +''+)
|
79
80
|
def initialize(options = {})
|
80
|
-
register_internal_string(+'')
|
81
|
+
register_internal_string(options[:value] || +'')
|
81
82
|
@static_length = options[:static_length]
|
82
83
|
end
|
83
84
|
|
@@ -20,9 +20,9 @@ module BinStruct
|
|
20
20
|
|
21
21
|
# @param [Hash] options
|
22
22
|
# @option options [Class] :length_type should be a {Int} subclass. Default to {Int8}.
|
23
|
-
# @option options [::String] :
|
23
|
+
# @option options [::String] :value String value. Default to +""+
|
24
24
|
def initialize(options = {})
|
25
|
-
@string = BinStruct::String.new.read(options[:
|
25
|
+
@string = BinStruct::String.new.read(options[:value] || +'')
|
26
26
|
@length = (options[:length_type] || Int8).new
|
27
27
|
calc_length
|
28
28
|
end
|
data/lib/bin_struct/string.rb
CHANGED
@@ -32,8 +32,9 @@ module BinStruct
|
|
32
32
|
# @option options [Int,Proc] :length_from object or proc from which
|
33
33
|
# takes length when reading
|
34
34
|
# @option options [Integer] :static_length set a static length for this string
|
35
|
+
# @option options [::String] :value string value (default to +''+)
|
35
36
|
def initialize(options = {})
|
36
|
-
register_internal_string(+'')
|
37
|
+
register_internal_string(options[:value] || +'')
|
37
38
|
initialize_length_from(options)
|
38
39
|
@static_length = options[:static_length]
|
39
40
|
end
|
data/lib/bin_struct/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bin_struct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LemonTree55
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: 'BinStruct is a binary dissector and generator. It eases manipulating
|
14
14
|
complex binary data.
|