xbd 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/xbd/asi.rb +1 -1
- data/lib/xbd/version.rb +1 -1
- data/lib/xbd/xbd.rb +0 -2
- data/lib/xbd/xbd_dictionary.rb +17 -9
- data/lib/xbd/xbd_tag.rb +2 -2
- data/xbd.gemspec +1 -1
- metadata +48 -78
data/lib/xbd/asi.rb
CHANGED
data/lib/xbd/version.rb
CHANGED
data/lib/xbd/xbd.rb
CHANGED
@@ -23,8 +23,6 @@ And run:
|
|
23
23
|
require "xbd.rb"
|
24
24
|
puts Xbd.load_from_file("your_xbd_filename.xbd")
|
25
25
|
|
26
|
-
Master verison of this file lives in: imikimi_plugin_source/xbd/xbd.rb
|
27
|
-
|
28
26
|
=end
|
29
27
|
require File.join(File.dirname(__FILE__),"asi")
|
30
28
|
require File.join(File.dirname(__FILE__),"xbd_dictionary")
|
data/lib/xbd/xbd_dictionary.rb
CHANGED
@@ -12,9 +12,11 @@ module Xbd
|
|
12
12
|
def initialize(initial_values=[])
|
13
13
|
@hash={}
|
14
14
|
@array=[]
|
15
|
-
initial_values.each {|v|
|
15
|
+
initial_values.each {|v| add v, false}
|
16
16
|
end
|
17
17
|
|
18
|
+
def length; @array.length end
|
19
|
+
|
18
20
|
# return String given an ID, or ID given a String
|
19
21
|
def [](i) @hash[i] end
|
20
22
|
|
@@ -26,14 +28,7 @@ module Xbd
|
|
26
28
|
end
|
27
29
|
|
28
30
|
# add a String to the dictionary
|
29
|
-
def <<(str)
|
30
|
-
str = Dictionary.sanitize_string str
|
31
|
-
@hash[str] ||= begin
|
32
|
-
new_id = @array.length
|
33
|
-
@array << @hash[new_id] = str
|
34
|
-
new_id
|
35
|
-
end
|
36
|
-
end
|
31
|
+
def <<(str) add str end
|
37
32
|
|
38
33
|
# convert to binary string
|
39
34
|
def to_binary
|
@@ -48,5 +43,18 @@ module Xbd
|
|
48
43
|
strings = lengths.collect {|len| encoded_dictionary.read len}
|
49
44
|
[Dictionary.new(strings), index]
|
50
45
|
end
|
46
|
+
|
47
|
+
private
|
48
|
+
# enforce_unique == false during loading, since technically, and xbd dictionary COULD have duplicate entries.
|
49
|
+
# Duplicate entries only reduces efficiency. It shouldn't break anything.
|
50
|
+
# XBD files shouldn't have dupes, but the current C++ implementation DOES create them rarely (bug).
|
51
|
+
def add(str, enforce_unique = true)
|
52
|
+
str = Dictionary.sanitize_string str
|
53
|
+
return @hash[str] if @hash[str] && enforce_unique
|
54
|
+
|
55
|
+
@hash[str] = new_id = @array.length
|
56
|
+
@array << @hash[new_id] = str
|
57
|
+
end
|
58
|
+
|
51
59
|
end
|
52
60
|
end
|
data/lib/xbd/xbd_tag.rb
CHANGED
@@ -167,8 +167,8 @@ module Xbd
|
|
167
167
|
attr_byte_size-=(index-i)
|
168
168
|
n=attrsd[name_id]
|
169
169
|
v=valuesd[value_id]
|
170
|
-
raise "attribute name id(#{name_id}) not in attribute-names dictionary" if !n
|
171
|
-
raise "attribute value id(#{value_id}) not in
|
170
|
+
raise "attribute name id(#{name_id}) not in attribute-names dictionary (max value = #{attrsd.length})" if !n
|
171
|
+
raise "attribute value id(#{value_id}) not in attribute-values dictionary (max value = #{valuesd.length})" if !v
|
172
172
|
attrs_hash[n]=v
|
173
173
|
end
|
174
174
|
tag_length-=(index-tag_start_index)
|
data/xbd.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
|
-
s.add_dependency 'RubyInline', '~> 3.11.0'
|
21
|
+
# s.add_dependency 'RubyInline', '~> 3.11.0'
|
22
22
|
s.add_development_dependency 'rake'
|
23
23
|
s.add_development_dependency 'rspec', '~> 2.6.0'
|
24
24
|
end
|
metadata
CHANGED
@@ -1,78 +1,57 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: xbd
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 0
|
10
|
-
version: 0.1.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Shane Brinkman-Davis
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
21
|
-
name: RubyInline
|
22
|
-
prerelease: false
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
-
none: false
|
25
|
-
requirements:
|
26
|
-
- - ~>
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 43
|
29
|
-
segments:
|
30
|
-
- 3
|
31
|
-
- 11
|
32
|
-
- 0
|
33
|
-
version: 3.11.0
|
34
|
-
type: :runtime
|
35
|
-
version_requirements: *id001
|
36
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2014-06-25 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
37
15
|
name: rake
|
38
|
-
|
39
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
40
17
|
none: false
|
41
|
-
requirements:
|
42
|
-
- -
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
|
45
|
-
segments:
|
46
|
-
- 0
|
47
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
48
22
|
type: :development
|
49
|
-
version_requirements: *id002
|
50
|
-
- !ruby/object:Gem::Dependency
|
51
|
-
name: rspec
|
52
23
|
prerelease: false
|
53
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
25
|
none: false
|
55
|
-
requirements:
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
56
35
|
- - ~>
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
hash: 23
|
59
|
-
segments:
|
60
|
-
- 2
|
61
|
-
- 6
|
62
|
-
- 0
|
36
|
+
- !ruby/object:Gem::Version
|
63
37
|
version: 2.6.0
|
64
38
|
type: :development
|
65
|
-
|
66
|
-
|
67
|
-
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.6.0
|
46
|
+
description: The XBD gem allows you to create, load and save XBD files. XBD files
|
47
|
+
are arbitrary, self-describing, hierarchical, binary data structures consisting
|
48
|
+
of "tags", "attributes", and "sub-tags".
|
49
|
+
email:
|
68
50
|
- shanebdavis@imikimi.com
|
69
51
|
executables: []
|
70
|
-
|
71
52
|
extensions: []
|
72
|
-
|
73
53
|
extra_rdoc_files: []
|
74
|
-
|
75
|
-
files:
|
54
|
+
files:
|
76
55
|
- .gitignore
|
77
56
|
- Gemfile
|
78
57
|
- LICENSE.TXT
|
@@ -92,38 +71,29 @@ files:
|
|
92
71
|
- xbd.gemspec
|
93
72
|
homepage: https://github.com/Imikimi-LLC/xbd
|
94
73
|
licenses: []
|
95
|
-
|
96
74
|
post_install_message:
|
97
75
|
rdoc_options: []
|
98
|
-
|
99
|
-
require_paths:
|
76
|
+
require_paths:
|
100
77
|
- lib
|
101
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
79
|
none: false
|
103
|
-
requirements:
|
104
|
-
- -
|
105
|
-
- !ruby/object:Gem::Version
|
106
|
-
|
107
|
-
|
108
|
-
- 0
|
109
|
-
version: "0"
|
110
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ! '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
85
|
none: false
|
112
|
-
requirements:
|
113
|
-
- -
|
114
|
-
- !ruby/object:Gem::Version
|
115
|
-
|
116
|
-
segments:
|
117
|
-
- 0
|
118
|
-
version: "0"
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
119
90
|
requirements: []
|
120
|
-
|
121
91
|
rubyforge_project: xbd
|
122
|
-
rubygems_version: 1.8.
|
92
|
+
rubygems_version: 1.8.25
|
123
93
|
signing_key:
|
124
94
|
specification_version: 3
|
125
95
|
summary: A fast, simplified, XML-inspired binary file format.
|
126
|
-
test_files:
|
96
|
+
test_files:
|
127
97
|
- spec/xbd_asi_spec.rb
|
128
98
|
- spec/xbd_dictionary_spec.rb
|
129
99
|
- spec/xbd_tag_spec.rb
|