vault_coh 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e398c4277d3f495c8d75bd7a878fbba0a92c4f509caab4b782afeae21707ac30
4
+ data.tar.gz: 0d8a47ac15efb8513b5e71f52c3ba34b782ff75fba9cbccecc6f72095ab2a618
5
+ SHA512:
6
+ metadata.gz: d7a5a45c518ba83d4ba6e911f6c251eee18f8606baab1b30b893657a50f859e2abda98c641cc8d6c7d29d500cb4cd1f5766aeea5bf184d48c2a0a37215984c58
7
+ data.tar.gz: 726566f51cd8a59df7f44952899862c68482bbbe7f8ae3516ecf161d1791e092a29f169b30db0e82609fbe3f09330722482475831e2e60e507262db7e161ac57
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,3 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.1
3
+ NewCops: enable
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-02-28
4
+
5
+ - Initial release
data/Cargo.lock ADDED
@@ -0,0 +1,334 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 3
4
+
5
+ [[package]]
6
+ name = "aho-corasick"
7
+ version = "1.0.1"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04"
10
+ dependencies = [
11
+ "memchr",
12
+ ]
13
+
14
+ [[package]]
15
+ name = "bindgen"
16
+ version = "0.60.1"
17
+ source = "registry+https://github.com/rust-lang/crates.io-index"
18
+ checksum = "062dddbc1ba4aca46de6338e2bf87771414c335f7b2f2036e8f3e9befebf88e6"
19
+ dependencies = [
20
+ "bitflags",
21
+ "cexpr",
22
+ "clang-sys",
23
+ "lazy_static",
24
+ "lazycell",
25
+ "peeking_take_while",
26
+ "proc-macro2",
27
+ "quote",
28
+ "regex",
29
+ "rustc-hash",
30
+ "shlex",
31
+ ]
32
+
33
+ [[package]]
34
+ name = "bitflags"
35
+ version = "1.3.2"
36
+ source = "registry+https://github.com/rust-lang/crates.io-index"
37
+ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
38
+
39
+ [[package]]
40
+ name = "bytecount"
41
+ version = "0.6.3"
42
+ source = "registry+https://github.com/rust-lang/crates.io-index"
43
+ checksum = "2c676a478f63e9fa2dd5368a42f28bba0d6c560b775f38583c8bbaa7fcd67c9c"
44
+
45
+ [[package]]
46
+ name = "byteorder"
47
+ version = "1.4.3"
48
+ source = "registry+https://github.com/rust-lang/crates.io-index"
49
+ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
50
+
51
+ [[package]]
52
+ name = "cexpr"
53
+ version = "0.6.0"
54
+ source = "registry+https://github.com/rust-lang/crates.io-index"
55
+ checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
56
+ dependencies = [
57
+ "nom",
58
+ ]
59
+
60
+ [[package]]
61
+ name = "cfg-if"
62
+ version = "1.0.0"
63
+ source = "registry+https://github.com/rust-lang/crates.io-index"
64
+ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
65
+
66
+ [[package]]
67
+ name = "clang-sys"
68
+ version = "1.6.1"
69
+ source = "registry+https://github.com/rust-lang/crates.io-index"
70
+ checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f"
71
+ dependencies = [
72
+ "glob",
73
+ "libc",
74
+ "libloading",
75
+ ]
76
+
77
+ [[package]]
78
+ name = "glob"
79
+ version = "0.3.1"
80
+ source = "registry+https://github.com/rust-lang/crates.io-index"
81
+ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
82
+
83
+ [[package]]
84
+ name = "lazy_static"
85
+ version = "1.4.0"
86
+ source = "registry+https://github.com/rust-lang/crates.io-index"
87
+ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
88
+
89
+ [[package]]
90
+ name = "lazycell"
91
+ version = "1.3.0"
92
+ source = "registry+https://github.com/rust-lang/crates.io-index"
93
+ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
94
+
95
+ [[package]]
96
+ name = "libc"
97
+ version = "0.2.143"
98
+ source = "registry+https://github.com/rust-lang/crates.io-index"
99
+ checksum = "edc207893e85c5d6be840e969b496b53d94cec8be2d501b214f50daa97fa8024"
100
+
101
+ [[package]]
102
+ name = "libloading"
103
+ version = "0.7.4"
104
+ source = "registry+https://github.com/rust-lang/crates.io-index"
105
+ checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
106
+ dependencies = [
107
+ "cfg-if",
108
+ "winapi",
109
+ ]
110
+
111
+ [[package]]
112
+ name = "magnus"
113
+ version = "0.5.3"
114
+ source = "registry+https://github.com/rust-lang/crates.io-index"
115
+ checksum = "c8dc14463c2552e753ef562961f486ca76f17a857c121db40e9f3ade3f35ab81"
116
+ dependencies = [
117
+ "magnus-macros",
118
+ "rb-sys",
119
+ "rb-sys-env",
120
+ ]
121
+
122
+ [[package]]
123
+ name = "magnus-macros"
124
+ version = "0.4.1"
125
+ source = "registry+https://github.com/rust-lang/crates.io-index"
126
+ checksum = "6cc17af1d45442c011aa579d727ec6cff8a69aea8a6bbad26736e7112d749bfb"
127
+ dependencies = [
128
+ "proc-macro2",
129
+ "quote",
130
+ "syn",
131
+ ]
132
+
133
+ [[package]]
134
+ name = "memchr"
135
+ version = "2.5.0"
136
+ source = "registry+https://github.com/rust-lang/crates.io-index"
137
+ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
138
+
139
+ [[package]]
140
+ name = "minimal-lexical"
141
+ version = "0.2.1"
142
+ source = "registry+https://github.com/rust-lang/crates.io-index"
143
+ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
144
+
145
+ [[package]]
146
+ name = "nom"
147
+ version = "7.1.3"
148
+ source = "registry+https://github.com/rust-lang/crates.io-index"
149
+ checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
150
+ dependencies = [
151
+ "memchr",
152
+ "minimal-lexical",
153
+ ]
154
+
155
+ [[package]]
156
+ name = "nom-tracable"
157
+ version = "0.9.0"
158
+ source = "registry+https://github.com/rust-lang/crates.io-index"
159
+ checksum = "160767ce1eed2cdadc2256015a6dc51d9632226ea02e0f0ce4590b904e1d80e2"
160
+ dependencies = [
161
+ "nom",
162
+ "nom-tracable-macros",
163
+ "nom_locate",
164
+ ]
165
+
166
+ [[package]]
167
+ name = "nom-tracable-macros"
168
+ version = "0.9.0"
169
+ source = "registry+https://github.com/rust-lang/crates.io-index"
170
+ checksum = "a7ac681ea0c3d468b003bdebe3a65d1632e340302452f95c3ffadf515704c48d"
171
+ dependencies = [
172
+ "quote",
173
+ "syn",
174
+ ]
175
+
176
+ [[package]]
177
+ name = "nom_locate"
178
+ version = "4.1.0"
179
+ source = "registry+https://github.com/rust-lang/crates.io-index"
180
+ checksum = "b1e299bf5ea7b212e811e71174c5d1a5d065c4c0ad0c8691ecb1f97e3e66025e"
181
+ dependencies = [
182
+ "bytecount",
183
+ "memchr",
184
+ "nom",
185
+ ]
186
+
187
+ [[package]]
188
+ name = "peeking_take_while"
189
+ version = "0.1.2"
190
+ source = "registry+https://github.com/rust-lang/crates.io-index"
191
+ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
192
+
193
+ [[package]]
194
+ name = "proc-macro2"
195
+ version = "1.0.56"
196
+ source = "registry+https://github.com/rust-lang/crates.io-index"
197
+ checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435"
198
+ dependencies = [
199
+ "unicode-ident",
200
+ ]
201
+
202
+ [[package]]
203
+ name = "quote"
204
+ version = "1.0.26"
205
+ source = "registry+https://github.com/rust-lang/crates.io-index"
206
+ checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc"
207
+ dependencies = [
208
+ "proc-macro2",
209
+ ]
210
+
211
+ [[package]]
212
+ name = "rb-sys"
213
+ version = "0.9.75"
214
+ source = "registry+https://github.com/rust-lang/crates.io-index"
215
+ checksum = "32ffbc5146796cb118f5a68196fabf1bccfff94c4830dea18aac0690cb29bb87"
216
+ dependencies = [
217
+ "rb-sys-build",
218
+ ]
219
+
220
+ [[package]]
221
+ name = "rb-sys-build"
222
+ version = "0.9.75"
223
+ source = "registry+https://github.com/rust-lang/crates.io-index"
224
+ checksum = "55edd49608668f9d45b7b1d619e6dab24ce8e591bcb912975936314aad94be40"
225
+ dependencies = [
226
+ "bindgen",
227
+ "lazy_static",
228
+ "proc-macro2",
229
+ "quote",
230
+ "regex",
231
+ "shell-words",
232
+ "syn",
233
+ ]
234
+
235
+ [[package]]
236
+ name = "rb-sys-env"
237
+ version = "0.1.2"
238
+ source = "registry+https://github.com/rust-lang/crates.io-index"
239
+ checksum = "a35802679f07360454b418a5d1735c89716bde01d35b1560fc953c1415a0b3bb"
240
+
241
+ [[package]]
242
+ name = "regex"
243
+ version = "1.8.1"
244
+ source = "registry+https://github.com/rust-lang/crates.io-index"
245
+ checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370"
246
+ dependencies = [
247
+ "aho-corasick",
248
+ "memchr",
249
+ "regex-syntax",
250
+ ]
251
+
252
+ [[package]]
253
+ name = "regex-syntax"
254
+ version = "0.7.1"
255
+ source = "registry+https://github.com/rust-lang/crates.io-index"
256
+ checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c"
257
+
258
+ [[package]]
259
+ name = "rustc-hash"
260
+ version = "1.1.0"
261
+ source = "registry+https://github.com/rust-lang/crates.io-index"
262
+ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
263
+
264
+ [[package]]
265
+ name = "shell-words"
266
+ version = "1.1.0"
267
+ source = "registry+https://github.com/rust-lang/crates.io-index"
268
+ checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
269
+
270
+ [[package]]
271
+ name = "shlex"
272
+ version = "1.1.0"
273
+ source = "registry+https://github.com/rust-lang/crates.io-index"
274
+ checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
275
+
276
+ [[package]]
277
+ name = "syn"
278
+ version = "1.0.109"
279
+ source = "registry+https://github.com/rust-lang/crates.io-index"
280
+ checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
281
+ dependencies = [
282
+ "proc-macro2",
283
+ "quote",
284
+ "unicode-ident",
285
+ ]
286
+
287
+ [[package]]
288
+ name = "unicode-ident"
289
+ version = "1.0.8"
290
+ source = "registry+https://github.com/rust-lang/crates.io-index"
291
+ checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4"
292
+
293
+ [[package]]
294
+ name = "vault"
295
+ version = "3.0.0"
296
+ source = "registry+https://github.com/rust-lang/crates.io-index"
297
+ checksum = "f10e953cb5ef5a80d7bc904867faf0ba8ed5e5253093fb159818dc55a8f4ff46"
298
+ dependencies = [
299
+ "byteorder",
300
+ "magnus",
301
+ "nom",
302
+ "nom-tracable",
303
+ "nom_locate",
304
+ ]
305
+
306
+ [[package]]
307
+ name = "vault_coh"
308
+ version = "1.0.0"
309
+ dependencies = [
310
+ "magnus",
311
+ "vault",
312
+ ]
313
+
314
+ [[package]]
315
+ name = "winapi"
316
+ version = "0.3.9"
317
+ source = "registry+https://github.com/rust-lang/crates.io-index"
318
+ checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
319
+ dependencies = [
320
+ "winapi-i686-pc-windows-gnu",
321
+ "winapi-x86_64-pc-windows-gnu",
322
+ ]
323
+
324
+ [[package]]
325
+ name = "winapi-i686-pc-windows-gnu"
326
+ version = "0.4.0"
327
+ source = "registry+https://github.com/rust-lang/crates.io-index"
328
+ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
329
+
330
+ [[package]]
331
+ name = "winapi-x86_64-pc-windows-gnu"
332
+ version = "0.4.0"
333
+ source = "registry+https://github.com/rust-lang/crates.io-index"
334
+ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
data/Cargo.toml ADDED
@@ -0,0 +1,7 @@
1
+ # This Cargo.toml is here to let externals tools (IDEs, etc.) know that this is
2
+ # a Rust project. Your extensions dependencies should be added to the Cargo.toml
3
+ # in the ext/ directory.
4
+
5
+ [workspace]
6
+ members = ["ext/vault_coh"]
7
+ resolver = "2"
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in vault_coh.gemspec
6
+ gemspec
7
+
8
+ gem 'rake', '~> 13.0'
9
+
10
+ gem 'rake-compiler'
11
+ gem 'rb_sys'
12
+
13
+ gem 'rspec', '~> 3.0'
14
+
15
+ gem 'rubocop', '~> 1.21'
data/Gemfile.lock ADDED
@@ -0,0 +1,62 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ vault_coh (1.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ diff-lcs (1.5.0)
11
+ json (2.6.3)
12
+ parallel (1.22.1)
13
+ parser (3.2.1.0)
14
+ ast (~> 2.4.1)
15
+ rainbow (3.1.1)
16
+ rake (13.0.6)
17
+ rake-compiler (1.2.1)
18
+ rake
19
+ rb_sys (0.9.65)
20
+ regexp_parser (2.7.0)
21
+ rexml (3.2.5)
22
+ rspec (3.12.0)
23
+ rspec-core (~> 3.12.0)
24
+ rspec-expectations (~> 3.12.0)
25
+ rspec-mocks (~> 3.12.0)
26
+ rspec-core (3.12.1)
27
+ rspec-support (~> 3.12.0)
28
+ rspec-expectations (3.12.2)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.12.0)
31
+ rspec-mocks (3.12.3)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (~> 3.12.0)
34
+ rspec-support (3.12.0)
35
+ rubocop (1.46.0)
36
+ json (~> 2.3)
37
+ parallel (~> 1.10)
38
+ parser (>= 3.2.0.0)
39
+ rainbow (>= 2.2.2, < 4.0)
40
+ regexp_parser (>= 1.8, < 3.0)
41
+ rexml (>= 3.2.5, < 4.0)
42
+ rubocop-ast (>= 1.26.0, < 2.0)
43
+ ruby-progressbar (~> 1.7)
44
+ unicode-display_width (>= 2.4.0, < 3.0)
45
+ rubocop-ast (1.27.0)
46
+ parser (>= 3.2.1.0)
47
+ ruby-progressbar (1.11.0)
48
+ unicode-display_width (2.4.2)
49
+
50
+ PLATFORMS
51
+ arm64-darwin-21
52
+
53
+ DEPENDENCIES
54
+ rake (~> 13.0)
55
+ rake-compiler
56
+ rb_sys
57
+ rspec (~> 3.0)
58
+ rubocop (~> 1.21)
59
+ vault_coh!
60
+
61
+ BUNDLED WITH
62
+ 2.4.7
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 ryantaylor
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # Vault
2
+
3
+ [![Documentation](https://img.shields.io/badge/View-Documentation-blue.svg)](https://rubydoc.info/github/ryantaylor/vault-rb/v0.1.0)
4
+
5
+ A native Ruby client wrapper for the [vault](https://github.com/ryantaylor/vault) Company of Heroes replay parser, integrated via a Rust native extension.
6
+
7
+ ## Installation
8
+
9
+ First, make sure you have a relatively recent version of the Rust toolchain installed (minimum supported Rust version for `vault` is 1.61.0). You can install Rust easily using [rustup](https://rustup.rs/).
10
+
11
+ Then you can add to Gemfile:
12
+ ```
13
+ gem 'vault_coh'
14
+ ```
15
+ And run `bundle install`.
16
+
17
+ ## Usage
18
+
19
+ Currently `vault` accepts a byte array and parses it as a Company of Heroes 3 replay file, returning a parsed object when successful or an error on failure:
20
+ ```ruby
21
+ require 'vault_coh'
22
+
23
+ bytes = File.read('/path/to/replay.rec').unpack('C*')
24
+ replay = VaultCoh::Replay.from_bytes(bytes)
25
+ puts replay.version
26
+ ```
27
+ All information available from parsing can be found in the [documentation](https://rubydoc.info/github/ryantaylor/vault-rb/v0.1.0).
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ryantaylor/vault-rb.
32
+
33
+ If you need to make changes to the Rust code, you can compile the extension by running `rake compile` or run tests with `cargo test`.
34
+
35
+ ## License
36
+
37
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require 'rubocop/rake_task'
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ require 'rake/extensiontask'
13
+
14
+ task build: :compile
15
+
16
+ Rake::ExtensionTask.new('vault_coh') do |ext|
17
+ ext.lib_dir = 'lib/vault_coh'
18
+ end
19
+
20
+ task default: %i[compile spec rubocop]
@@ -0,0 +1,14 @@
1
+ [package]
2
+ name = "vault_coh"
3
+ version = "1.0.0"
4
+ edition = "2021"
5
+ authors = ["ryantaylor <2320507+ryantaylor@users.noreply.github.com>"]
6
+ license = "MIT"
7
+ publish = false
8
+
9
+ [lib]
10
+ crate-type = ["cdylib"]
11
+
12
+ [dependencies]
13
+ magnus = { version = "0.5" }
14
+ vault = { version = "3", features = ["magnus"] }
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'mkmf'
4
+ require 'rb_sys/mkmf'
5
+
6
+ create_rust_makefile('vault_coh/vault_coh')
@@ -0,0 +1,58 @@
1
+ use magnus::{class, define_module, exception, function, method, prelude::*, Error};
2
+ use vault::{Faction, Map, Message, Player, Replay, Team};
3
+
4
+ #[magnus::init]
5
+ fn init() -> Result<(), Error> {
6
+ let module = define_module("VaultCoh")?;
7
+
8
+ let replay = module.define_class("Replay", class::object())?;
9
+ replay.define_singleton_method("from_bytes", function!(from_bytes, 1))?;
10
+ replay.define_method("version", method!(Replay::version, 0))?;
11
+ replay.define_method("timestamp", method!(Replay::timestamp, 0))?;
12
+ replay.define_method("matchhistory_id", method!(Replay::matchhistory_id, 0))?;
13
+ replay.define_method("map", method!(Replay::map, 0))?;
14
+ replay.define_method("map_filename", method!(Replay::map_filename, 0))?;
15
+ replay.define_method(
16
+ "map_localized_name_id",
17
+ method!(Replay::map_localized_name_id, 0),
18
+ )?;
19
+ replay.define_method(
20
+ "map_localized_description_id",
21
+ method!(Replay::map_localized_description_id, 0),
22
+ )?;
23
+ replay.define_method("players", method!(Replay::players, 0))?;
24
+ replay.define_method("length", method!(Replay::length, 0))?;
25
+
26
+ let map = module.define_class("Map", class::object())?;
27
+ map.define_method("filename", method!(Map::filename, 0))?;
28
+ map.define_method("localized_name_id", method!(Map::localized_name_id, 0))?;
29
+ map.define_method(
30
+ "localized_description_id",
31
+ method!(Map::localized_description_id, 0),
32
+ )?;
33
+
34
+ let player = module.define_class("Player", class::object())?;
35
+ player.define_method("name", method!(Player::name, 0))?;
36
+ player.define_method("faction", method!(Player::faction, 0))?;
37
+ player.define_method("team", method!(Player::team, 0))?;
38
+ player.define_method("steam_id", method!(Player::steam_id, 0))?;
39
+ player.define_method("profile_id", method!(Player::profile_id, 0))?;
40
+ player.define_method("messages", method!(Player::messages, 0))?;
41
+
42
+ let message = module.define_class("Message", class::object())?;
43
+ message.define_method("tick", method!(Message::tick, 0))?;
44
+ message.define_method("message", method!(Message::message, 0))?;
45
+
46
+ let faction = module.define_class("Faction", class::object())?;
47
+ faction.define_method("value", method!(Faction::to_string, 0))?;
48
+
49
+ let team = module.define_class("Team", class::object())?;
50
+ team.define_method("value", method!(Team::value, 0))?;
51
+
52
+ Ok(())
53
+ }
54
+
55
+ fn from_bytes(input: Vec<u8>) -> Result<Replay, Error> {
56
+ Replay::from_bytes(&input)
57
+ .map_err(|err| Error::new(exception::runtime_error(), err.to_string()))
58
+ }
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module VaultCoh
4
+ # Identifiers for the Company of Heroes 3 factions.
5
+ class Faction
6
+ AMERICANS = 'Americans'
7
+ BRITISH = 'British'
8
+ WEHRMACHT = 'Wehrmacht'
9
+ AFRIKAKORPS = 'AfrikaKorps'
10
+
11
+ # String identifier of the given faction.
12
+ #
13
+ # @see https://docs.rs/vault/3.0.0/vault/enum.Faction.html
14
+ #
15
+ # @return [AMERICANS|BRITISH|WEHRMACHT|AFRIKAKORPS]
16
+ def value; end
17
+ end
18
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module VaultCoh
4
+ # Representation of all map-related information that can be parsed
5
+ # from a Company of Heroes 3 replay.
6
+ class Map
7
+ # This is a “filename” in the sense that its structure resembles
8
+ # one, but it doesn’t actually point to any file on the file
9
+ # system. The final “token” in this string (if you split by slash)
10
+ # generally corresponds to the map name returned by the CoH3 stats
11
+ # API. The string is UTF-8 encoded.
12
+ #
13
+ # @return [String]
14
+ def filename; end
15
+
16
+ # Entity ID that corresponds to a localization string that
17
+ # represents the localized name of the map. Conventionally these
18
+ # IDs do not change between patches, but that isn’t guaranteed.
19
+ # The string is UTF-16 encoded.
20
+ #
21
+ # @return [String]
22
+ def localized_name_id; end
23
+
24
+ # Entity ID that corresponds to a localization string that
25
+ # represents the localized description of the map. Conventionally
26
+ # these IDs do not change between patches, but that isn’t
27
+ # guaranteed. The string is UTF-16 encoded.
28
+ #
29
+ # @return [String]
30
+ def localized_description_id; end
31
+ end
32
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module VaultCoh
4
+ # Representation of a user-sent chat message in a Company of Heroes
5
+ # 3 replay. Messages are collected during command parsing and then
6
+ # associated with the {Player} instance that sent them. To access,
7
+ # see {Player#messages}.
8
+ class Message
9
+ # This value is the tick at which the message was found while
10
+ # parsing the replay, which represents the time in the replay at
11
+ # which it was sent. Because CoH3’s engine runs at 8 ticks per
12
+ # second, you can divide this value by 8 to get the number of
13
+ # seconds since the replay began, which will tell you when this
14
+ # message was sent.
15
+ #
16
+ # @return [Integer] unsigned, 32 bits
17
+ def tick; end
18
+
19
+ # UTF-16 encoded representation of the message sent by the player.
20
+ #
21
+ # @return [String]
22
+ def message; end
23
+ end
24
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module VaultCoh
4
+ # Game-specific player representation. Includes generally immutable
5
+ # information alongside data specific to the replay being parsed.
6
+ class Player
7
+ # Name of the player at the time the replay was recorded. Note
8
+ # that the player may have changed their name since time of
9
+ # recording. If attempting to uniquely identify players across
10
+ # replay files, look at {#steam_id} and {#profile_id} instead.
11
+ # The string is UTF-16 encoded.
12
+ #
13
+ # @return [String]
14
+ def name; end
15
+
16
+ # The faction selected by the player in this match.
17
+ #
18
+ # @return [Faction]
19
+ def faction; end
20
+
21
+ # The team the player was assigned to. Currently only head-to-head
22
+ # matchups are supported (max two teams).
23
+ #
24
+ # @return [Team]
25
+ def team; end
26
+
27
+ # The Steam ID of the player. This ID can be used to uniquely
28
+ # identify a player between replays, and connect them to their
29
+ # Steam profile.
30
+ #
31
+ # @return [Integer] unsigned, 64 bits
32
+ def steam_id; end
33
+
34
+ # The Relic profile ID of the player. This ID can be used to
35
+ # uniquely identify a player between replays, and can be used to
36
+ # query statistical information about the player from Relic’s
37
+ # stats API.
38
+ #
39
+ # @return [Integer] unsigned, 64 bits
40
+ def profile_id; end
41
+
42
+ # A list of all messages sent by the player in the match. Sorted
43
+ # chronologically from first to last.
44
+ #
45
+ # @return [Array<Message>]
46
+ def messages; end
47
+ end
48
+ end
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true
2
+
3
+ module VaultCoh
4
+ # A complete representation of all information able to be parsed from a
5
+ # Company of Heroes 3 replay. Note that parsing is not yet exhaustive,
6
+ # and iterative improvements will be made to pull more information from
7
+ # replay files over time.
8
+ class Replay
9
+ # Takes a byte slice, parses it as a CoH3 replay, and returns a
10
+ # representation of the parsed information. Any failures during parsing
11
+ # or conversion will return an error.
12
+ #
13
+ # @param bytes [Array<Byte>] Byte array representation of a CoH3 replay file (required).
14
+ #
15
+ # @return [Replay]
16
+ #
17
+ # @example
18
+ # require 'vault_coh'
19
+ #
20
+ # bytes = File.read('/path/to/replay.rec').unpack('C*')
21
+ # replay = VaultCoh::Replay.from_bytes(bytes)
22
+ # puts replay.version
23
+ def self.from_bytes(bytes); end
24
+
25
+ # The Company of Heroes 3 game version this replay was recorded on.
26
+ # Note that this is probably more accurately described as the build
27
+ # version, and represents the final segment of digits you see in the
28
+ # game version on the game’s main menu. Every time the game is patched,
29
+ # this version will change, and replays are generally only viewable on
30
+ # the same game version they were recorded on.
31
+ #
32
+ # @return [Integer] unsigned, 16 bits
33
+ def version; end
34
+
35
+ # A UTF-16 representation of the recording user’s local time when the
36
+ # replay was recorded. Note that value may contain non-standard
37
+ # characters and is not guaranteed to be parsable into an accurate
38
+ # date/time format.
39
+ #
40
+ # @return [String]
41
+ def timestamp; end
42
+
43
+ # The ID used by Relic to track this match on their internal servers.
44
+ # This ID can be matched with an ID of the same name returned by
45
+ # Relic’s CoH3 stats API, enabling linkage between replay files and
46
+ # statistical information for a match.
47
+ #
48
+ # @return [Integer] unsigned, 64 bits
49
+ def matchhistory_id; end
50
+
51
+ # Map information for this match.
52
+ #
53
+ # @return [Map]
54
+ def map; end
55
+
56
+ # Filename of the map this match was played on. See {Map#filename}
57
+ # for more information.
58
+ #
59
+ # @return [String]
60
+ def map_filename; end
61
+
62
+ # Localization ID of the map’s name. See {Map#localized_name_id}
63
+ # for more information.
64
+ #
65
+ # @return [String]
66
+ def map_localized_name_id; end
67
+
68
+ # Localization ID of the map’s description. See
69
+ # {Map#localized_description_id} for more information.
70
+ #
71
+ # @return [String]
72
+ def map_localized_description_id; end
73
+
74
+ # A list of all players who participated in this match.
75
+ #
76
+ # @return [Array<Player>]
77
+ def players; end
78
+
79
+ # A simple count of the number of ticks that were executed in this
80
+ # match. Because CoH3’s engine runs at 8 ticks per second, you can
81
+ # divide this value by 8 to get the duration of the match in seconds.
82
+ #
83
+ # @return [Integer]
84
+ def length; end
85
+ end
86
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module VaultCoh
4
+ # Identifiers for a player's team membership.
5
+ class Team
6
+ FIRST = 0
7
+ SECOND = 1
8
+
9
+ # Integer representation of the assigned team.
10
+ #
11
+ # @see https://docs.rs/vault/3.0.0/vault/enum.Team.html
12
+ #
13
+ # @return [FIRST|SECOND]
14
+ def value; end
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module VaultCoh
4
+ VERSION = '0.1.0'
5
+ end
data/lib/vault_coh.rb ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'vault_coh/version'
4
+ require_relative 'vault_coh/vault_coh'
5
+
6
+ # Company of Heroes 3 replay parsing powered by
7
+ # {https://github.com/ryantaylor/vault vault}. For usage details
8
+ # see {Replay.from_bytes}.
9
+ module VaultCoh
10
+ end
data/vault_coh.gemspec ADDED
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/vault_coh/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'vault_coh'
7
+ spec.version = VaultCoh::VERSION
8
+ spec.authors = ['ryantaylor']
9
+ spec.email = ['2320507+ryantaylor@users.noreply.github.com']
10
+
11
+ spec.summary = 'CoH3 replay parsing in Ruby with Rust'
12
+ spec.description = 'Company of Heroes replay parsing in Ruby using the vault parsing library via a Rust native extension.'
13
+ spec.homepage = 'https://github.com/ryantaylor/vault-rb'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = '>= 3.1.0'
16
+ spec.required_rubygems_version = '>= 3.3.11'
17
+
18
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
19
+
20
+ spec.metadata['homepage_uri'] = spec.homepage
21
+ spec.metadata['source_code_uri'] = spec.homepage
22
+ spec.metadata['changelog_uri'] = spec.homepage
23
+
24
+ # Specify which files should be added to the gem when it is released.
25
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
26
+ spec.files = Dir.chdir(__dir__) do
27
+ `git ls-files -z`.split("\x0").reject do |f|
28
+ (File.expand_path(f) == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
29
+ end
30
+ end
31
+ spec.bindir = 'exe'
32
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
33
+ spec.require_paths = ['lib']
34
+ spec.extensions = ['ext/vault_coh/Cargo.toml']
35
+ spec.metadata['rubygems_mfa_required'] = 'true'
36
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vault_coh
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - ryantaylor
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-05-09 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Company of Heroes replay parsing in Ruby using the vault parsing library
14
+ via a Rust native extension.
15
+ email:
16
+ - 2320507+ryantaylor@users.noreply.github.com
17
+ executables: []
18
+ extensions:
19
+ - ext/vault_coh/Cargo.toml
20
+ extra_rdoc_files: []
21
+ files:
22
+ - ".rspec"
23
+ - ".rubocop.yml"
24
+ - CHANGELOG.md
25
+ - Cargo.lock
26
+ - Cargo.toml
27
+ - Gemfile
28
+ - Gemfile.lock
29
+ - LICENSE.txt
30
+ - README.md
31
+ - Rakefile
32
+ - ext/vault_coh/Cargo.toml
33
+ - ext/vault_coh/extconf.rb
34
+ - ext/vault_coh/src/lib.rs
35
+ - lib/vault_coh.rb
36
+ - lib/vault_coh/faction.rb
37
+ - lib/vault_coh/map.rb
38
+ - lib/vault_coh/message.rb
39
+ - lib/vault_coh/player.rb
40
+ - lib/vault_coh/replay.rb
41
+ - lib/vault_coh/team.rb
42
+ - lib/vault_coh/version.rb
43
+ - vault_coh.gemspec
44
+ homepage: https://github.com/ryantaylor/vault-rb
45
+ licenses:
46
+ - MIT
47
+ metadata:
48
+ allowed_push_host: https://rubygems.org
49
+ homepage_uri: https://github.com/ryantaylor/vault-rb
50
+ source_code_uri: https://github.com/ryantaylor/vault-rb
51
+ changelog_uri: https://github.com/ryantaylor/vault-rb
52
+ rubygems_mfa_required: 'true'
53
+ post_install_message:
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 3.1.0
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 3.3.11
67
+ requirements: []
68
+ rubygems_version: 3.4.12
69
+ signing_key:
70
+ specification_version: 4
71
+ summary: CoH3 replay parsing in Ruby with Rust
72
+ test_files: []