bytemapper 1.0.13 → 1.0.15

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bytemapper/registry.rb +12 -8
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b7915e2b8be3bcd3f677ed08c5a82e8fd135ab941ff9ab8b04c2148cfc7b8441
4
- data.tar.gz: c44bf0499a0d15dc77728770edf55a995a12b00987e76ea651eb249c09f0d2e7
3
+ metadata.gz: f1d4ba07f15d00f65f605f6d0672bb50c176fc74de04ce5781579230d40817ee
4
+ data.tar.gz: fe2edc55e90307d8d57413d11f4181077b5b192c36cf639510cda1a0fbeabf31
5
5
  SHA512:
6
- metadata.gz: ea2aa731fde9ad3ef8f22a08d1b0abfa4de8803e7d7849af1ad1c0aebc9c865640e9e62f1ebc91293025c1b76b21cb5bd1b469d510005dead3a6723a6b4ef314
7
- data.tar.gz: 9cbb50a69eea518d210ac6fb7bcaeeb9a74ff8b0e6ad3a9ade5f68988d6839c7d2464e9c276781d45fac856704de011352463c60a3b03d563ff90fec16ccf488
6
+ metadata.gz: efea6646d4cccd9faa324ce225ec3420d3aa0c1961c207d3037cc79f992bdc086a1f2a22da77aa95483fe3cf17c97ac3eaef4d241e02adeec3223556daaa212c
7
+ data.tar.gz: f9c991fff0d53084add4d9084bf5094d0072f8e6b9e3b97274d35b4cefdeea802499f00a8825b3079c16676065e6840f74e60cf4a525f5f2195054c9e695280a
@@ -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
- name = obj
45
- key = @names[obj]
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
- @objects[key]
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.13
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-26 00:00:00.000000000 Z
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