bytemapper 1.0.13 → 1.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bytemapper/registry.rb +12 -8
- 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: f1d4ba07f15d00f65f605f6d0672bb50c176fc74de04ce5781579230d40817ee
|
4
|
+
data.tar.gz: fe2edc55e90307d8d57413d11f4181077b5b192c36cf639510cda1a0fbeabf31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efea6646d4cccd9faa324ce225ec3420d3aa0c1961c207d3037cc79f992bdc086a1f2a22da77aa95483fe3cf17c97ac3eaef4d241e02adeec3223556daaa212c
|
7
|
+
data.tar.gz: f9c991fff0d53084add4d9084bf5094d0072f8e6b9e3b97274d35b4cefdeea802499f00a8825b3079c16676065e6840f74e60cf4a525f5f2195054c9e695280a
|
data/lib/bytemapper/registry.rb
CHANGED
@@ -5,14 +5,15 @@
|
|
5
5
|
# the terms of the GNU Affero General Public License as published by the Free
|
6
6
|
# Software Foundation, either version 3 of the License, or (at your option) any
|
7
7
|
# later version.
|
8
|
-
|
8
|
+
#
|
9
9
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
10
10
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
11
11
|
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
12
12
|
# details.
|
13
|
-
|
13
|
+
#
|
14
14
|
# You should have received a copy of the GNU Affero General Public License
|
15
15
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
16
|
+
|
16
17
|
module Bytemapper
|
17
18
|
class Registry
|
18
19
|
require 'bytemapper/nameable'
|
@@ -41,15 +42,15 @@ module Bytemapper
|
|
41
42
|
|
42
43
|
def get(obj, name = nil)
|
43
44
|
if (obj.is_a?(String) || obj.is_a?(Symbol))
|
44
|
-
|
45
|
-
|
45
|
+
# Object assumed to be a registered name
|
46
|
+
obj = @objects.fetch(@names[obj])
|
47
|
+
register_alias(obj, name) unless name.nil?
|
46
48
|
elsif (obj.is_a?(Array) || obj.is_a?(Hash))
|
47
|
-
put(obj, name)
|
48
|
-
key = obj.hash
|
49
|
+
obj = put(obj, name)
|
49
50
|
else
|
50
51
|
raise ArgumentError "Invalid obj"
|
51
52
|
end
|
52
|
-
|
53
|
+
obj
|
53
54
|
end
|
54
55
|
|
55
56
|
def put(obj, name = nil)
|
@@ -86,6 +87,7 @@ module Bytemapper
|
|
86
87
|
end
|
87
88
|
obj
|
88
89
|
end
|
90
|
+
alias :register_alias :register_name
|
89
91
|
|
90
92
|
def print
|
91
93
|
puts to_s
|
@@ -134,7 +136,7 @@ module Bytemapper
|
|
134
136
|
" #{obj.class.to_s} ",
|
135
137
|
" #{obj.to_s} "
|
136
138
|
]
|
137
|
-
|
139
|
+
|
138
140
|
# Calculate padding for each column.
|
139
141
|
pads = widths.zip(values).map { |a,b| a - b.size }
|
140
142
|
|
@@ -162,6 +164,8 @@ module Bytemapper
|
|
162
164
|
private
|
163
165
|
def register_basic_types
|
164
166
|
[
|
167
|
+
[:char, [8,'c']],
|
168
|
+
[:uchar, [8,'C']],
|
165
169
|
[:uint8_t, [8,'C']],
|
166
170
|
[:bool, [8,'C']],
|
167
171
|
[:uint16_t, [16,'S']],
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bytemapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jefferson Hudson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Model and interact with bytestrings using Ruby objects.
|
14
14
|
email: jefferson.hudson@gmail.com
|