xml2json-rb 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: 3136f4ff83c6e8851b4fbfcb2bc343f3cf4a453a27dc566c63f3b3d661364c84
4
+ data.tar.gz: 8a98b15dacac13a9fea305985e74325eeb173fe7d8d1ce19ce4e8114d98c15a2
5
+ SHA512:
6
+ metadata.gz: 96c29af1693eb23580ac8f42bca2627b8b46aa57d5fe776e4b7171263e17f1b92fee00bec36668816bdca5f9a24a34e5440c8ad4ca24032a737173c5bbda591a
7
+ data.tar.gz: 05d2d14fe2c6195eb8d5c00a9e5c0e4b2f875c6f4f119f0c0e12257299b8ece2dbecbaa22102474081cc3a1d18fa7ebb991f5e47781ac9b77e49b0a8d0adfba2
data/Cargo.lock ADDED
@@ -0,0 +1,364 @@
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.2"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41"
10
+ dependencies = [
11
+ "memchr",
12
+ ]
13
+
14
+ [[package]]
15
+ name = "bindgen"
16
+ version = "0.62.0"
17
+ source = "registry+https://github.com/rust-lang/crates.io-index"
18
+ checksum = "c6720a8b7b2d39dd533285ed438d458f65b31b5c257e6ac7bb3d7e82844dd722"
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
+ "syn",
32
+ ]
33
+
34
+ [[package]]
35
+ name = "bitflags"
36
+ version = "1.3.2"
37
+ source = "registry+https://github.com/rust-lang/crates.io-index"
38
+ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
39
+
40
+ [[package]]
41
+ name = "cexpr"
42
+ version = "0.6.0"
43
+ source = "registry+https://github.com/rust-lang/crates.io-index"
44
+ checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
45
+ dependencies = [
46
+ "nom",
47
+ ]
48
+
49
+ [[package]]
50
+ name = "cfg-if"
51
+ version = "1.0.0"
52
+ source = "registry+https://github.com/rust-lang/crates.io-index"
53
+ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
54
+
55
+ [[package]]
56
+ name = "clang-sys"
57
+ version = "1.6.1"
58
+ source = "registry+https://github.com/rust-lang/crates.io-index"
59
+ checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f"
60
+ dependencies = [
61
+ "glob",
62
+ "libc",
63
+ "libloading",
64
+ ]
65
+
66
+ [[package]]
67
+ name = "equivalent"
68
+ version = "1.0.0"
69
+ source = "registry+https://github.com/rust-lang/crates.io-index"
70
+ checksum = "88bffebc5d80432c9b140ee17875ff173a8ab62faad5b257da912bd2f6c1c0a1"
71
+
72
+ [[package]]
73
+ name = "glob"
74
+ version = "0.3.1"
75
+ source = "registry+https://github.com/rust-lang/crates.io-index"
76
+ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
77
+
78
+ [[package]]
79
+ name = "hashbrown"
80
+ version = "0.14.0"
81
+ source = "registry+https://github.com/rust-lang/crates.io-index"
82
+ checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a"
83
+
84
+ [[package]]
85
+ name = "indexmap"
86
+ version = "2.0.0"
87
+ source = "registry+https://github.com/rust-lang/crates.io-index"
88
+ checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d"
89
+ dependencies = [
90
+ "equivalent",
91
+ "hashbrown",
92
+ ]
93
+
94
+ [[package]]
95
+ name = "itoa"
96
+ version = "1.0.8"
97
+ source = "registry+https://github.com/rust-lang/crates.io-index"
98
+ checksum = "62b02a5381cc465bd3041d84623d0fa3b66738b52b8e2fc3bab8ad63ab032f4a"
99
+
100
+ [[package]]
101
+ name = "lazy_static"
102
+ version = "1.4.0"
103
+ source = "registry+https://github.com/rust-lang/crates.io-index"
104
+ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
105
+
106
+ [[package]]
107
+ name = "lazycell"
108
+ version = "1.3.0"
109
+ source = "registry+https://github.com/rust-lang/crates.io-index"
110
+ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
111
+
112
+ [[package]]
113
+ name = "libc"
114
+ version = "0.2.147"
115
+ source = "registry+https://github.com/rust-lang/crates.io-index"
116
+ checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
117
+
118
+ [[package]]
119
+ name = "libloading"
120
+ version = "0.7.4"
121
+ source = "registry+https://github.com/rust-lang/crates.io-index"
122
+ checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
123
+ dependencies = [
124
+ "cfg-if",
125
+ "winapi",
126
+ ]
127
+
128
+ [[package]]
129
+ name = "magnus"
130
+ version = "0.4.4"
131
+ source = "registry+https://github.com/rust-lang/crates.io-index"
132
+ checksum = "fc87660cd7daa49fddbfd524c836de54d5c927d520cd163f43700c5087c57d6c"
133
+ dependencies = [
134
+ "magnus-macros",
135
+ "rb-sys",
136
+ "rb-sys-env",
137
+ ]
138
+
139
+ [[package]]
140
+ name = "magnus-macros"
141
+ version = "0.3.0"
142
+ source = "registry+https://github.com/rust-lang/crates.io-index"
143
+ checksum = "206cb23bfeea05180c97522ef6a3e52a4eb17b0ed2f30ee3ca9c4f994d2378ae"
144
+ dependencies = [
145
+ "proc-macro2",
146
+ "quote",
147
+ "syn",
148
+ ]
149
+
150
+ [[package]]
151
+ name = "memchr"
152
+ version = "2.5.0"
153
+ source = "registry+https://github.com/rust-lang/crates.io-index"
154
+ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
155
+
156
+ [[package]]
157
+ name = "minimal-lexical"
158
+ version = "0.2.1"
159
+ source = "registry+https://github.com/rust-lang/crates.io-index"
160
+ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
161
+
162
+ [[package]]
163
+ name = "nom"
164
+ version = "7.1.3"
165
+ source = "registry+https://github.com/rust-lang/crates.io-index"
166
+ checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
167
+ dependencies = [
168
+ "memchr",
169
+ "minimal-lexical",
170
+ ]
171
+
172
+ [[package]]
173
+ name = "peeking_take_while"
174
+ version = "0.1.2"
175
+ source = "registry+https://github.com/rust-lang/crates.io-index"
176
+ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
177
+
178
+ [[package]]
179
+ name = "proc-macro2"
180
+ version = "1.0.63"
181
+ source = "registry+https://github.com/rust-lang/crates.io-index"
182
+ checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb"
183
+ dependencies = [
184
+ "unicode-ident",
185
+ ]
186
+
187
+ [[package]]
188
+ name = "quick-xml"
189
+ version = "0.23.1"
190
+ source = "registry+https://github.com/rust-lang/crates.io-index"
191
+ checksum = "11bafc859c6815fbaffbbbf4229ecb767ac913fecb27f9ad4343662e9ef099ea"
192
+ dependencies = [
193
+ "memchr",
194
+ ]
195
+
196
+ [[package]]
197
+ name = "quote"
198
+ version = "1.0.29"
199
+ source = "registry+https://github.com/rust-lang/crates.io-index"
200
+ checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105"
201
+ dependencies = [
202
+ "proc-macro2",
203
+ ]
204
+
205
+ [[package]]
206
+ name = "rb-sys"
207
+ version = "0.9.79"
208
+ source = "registry+https://github.com/rust-lang/crates.io-index"
209
+ checksum = "939fb78db3e4f26665c1d4c7b91ca66d3578335a19aba552d4a6445811d07072"
210
+ dependencies = [
211
+ "rb-sys-build",
212
+ ]
213
+
214
+ [[package]]
215
+ name = "rb-sys-build"
216
+ version = "0.9.79"
217
+ source = "registry+https://github.com/rust-lang/crates.io-index"
218
+ checksum = "335a95eb0420d52fa94ef12019df3c2c250c6b19cbb3c60bd05cb7e9c362072c"
219
+ dependencies = [
220
+ "bindgen",
221
+ "lazy_static",
222
+ "proc-macro2",
223
+ "quote",
224
+ "regex",
225
+ "shell-words",
226
+ "syn",
227
+ ]
228
+
229
+ [[package]]
230
+ name = "rb-sys-env"
231
+ version = "0.1.2"
232
+ source = "registry+https://github.com/rust-lang/crates.io-index"
233
+ checksum = "a35802679f07360454b418a5d1735c89716bde01d35b1560fc953c1415a0b3bb"
234
+
235
+ [[package]]
236
+ name = "regex"
237
+ version = "1.9.1"
238
+ source = "registry+https://github.com/rust-lang/crates.io-index"
239
+ checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575"
240
+ dependencies = [
241
+ "aho-corasick",
242
+ "memchr",
243
+ "regex-automata",
244
+ "regex-syntax",
245
+ ]
246
+
247
+ [[package]]
248
+ name = "regex-automata"
249
+ version = "0.3.2"
250
+ source = "registry+https://github.com/rust-lang/crates.io-index"
251
+ checksum = "83d3daa6976cffb758ec878f108ba0e062a45b2d6ca3a2cca965338855476caf"
252
+ dependencies = [
253
+ "aho-corasick",
254
+ "memchr",
255
+ "regex-syntax",
256
+ ]
257
+
258
+ [[package]]
259
+ name = "regex-syntax"
260
+ version = "0.7.3"
261
+ source = "registry+https://github.com/rust-lang/crates.io-index"
262
+ checksum = "2ab07dc67230e4a4718e70fd5c20055a4334b121f1f9db8fe63ef39ce9b8c846"
263
+
264
+ [[package]]
265
+ name = "rustc-hash"
266
+ version = "1.1.0"
267
+ source = "registry+https://github.com/rust-lang/crates.io-index"
268
+ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
269
+
270
+ [[package]]
271
+ name = "ryu"
272
+ version = "1.0.14"
273
+ source = "registry+https://github.com/rust-lang/crates.io-index"
274
+ checksum = "fe232bdf6be8c8de797b22184ee71118d63780ea42ac85b61d1baa6d3b782ae9"
275
+
276
+ [[package]]
277
+ name = "serde"
278
+ version = "1.0.167"
279
+ source = "registry+https://github.com/rust-lang/crates.io-index"
280
+ checksum = "7daf513456463b42aa1d94cff7e0c24d682b429f020b9afa4f5ba5c40a22b237"
281
+
282
+ [[package]]
283
+ name = "serde_json"
284
+ version = "1.0.100"
285
+ source = "registry+https://github.com/rust-lang/crates.io-index"
286
+ checksum = "0f1e14e89be7aa4c4b78bdbdc9eb5bf8517829a600ae8eaa39a6e1d960b5185c"
287
+ dependencies = [
288
+ "indexmap",
289
+ "itoa",
290
+ "ryu",
291
+ "serde",
292
+ ]
293
+
294
+ [[package]]
295
+ name = "shell-words"
296
+ version = "1.1.0"
297
+ source = "registry+https://github.com/rust-lang/crates.io-index"
298
+ checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
299
+
300
+ [[package]]
301
+ name = "shlex"
302
+ version = "1.1.0"
303
+ source = "registry+https://github.com/rust-lang/crates.io-index"
304
+ checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
305
+
306
+ [[package]]
307
+ name = "syn"
308
+ version = "1.0.109"
309
+ source = "registry+https://github.com/rust-lang/crates.io-index"
310
+ checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
311
+ dependencies = [
312
+ "proc-macro2",
313
+ "quote",
314
+ "unicode-ident",
315
+ ]
316
+
317
+ [[package]]
318
+ name = "unicode-ident"
319
+ version = "1.0.10"
320
+ source = "registry+https://github.com/rust-lang/crates.io-index"
321
+ checksum = "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73"
322
+
323
+ [[package]]
324
+ name = "winapi"
325
+ version = "0.3.9"
326
+ source = "registry+https://github.com/rust-lang/crates.io-index"
327
+ checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
328
+ dependencies = [
329
+ "winapi-i686-pc-windows-gnu",
330
+ "winapi-x86_64-pc-windows-gnu",
331
+ ]
332
+
333
+ [[package]]
334
+ name = "winapi-i686-pc-windows-gnu"
335
+ version = "0.4.0"
336
+ source = "registry+https://github.com/rust-lang/crates.io-index"
337
+ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
338
+
339
+ [[package]]
340
+ name = "winapi-x86_64-pc-windows-gnu"
341
+ version = "0.4.0"
342
+ source = "registry+https://github.com/rust-lang/crates.io-index"
343
+ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
344
+
345
+ [[package]]
346
+ name = "xml2json"
347
+ version = "0.1.0"
348
+ dependencies = [
349
+ "magnus",
350
+ "xml2json-rs",
351
+ ]
352
+
353
+ [[package]]
354
+ name = "xml2json-rs"
355
+ version = "1.0.1"
356
+ source = "registry+https://github.com/rust-lang/crates.io-index"
357
+ checksum = "c6ba4fb1256176d2eb02e25065efade8e43215a4d0743cb823991aea314077ea"
358
+ dependencies = [
359
+ "lazy_static",
360
+ "quick-xml",
361
+ "regex",
362
+ "serde",
363
+ "serde_json",
364
+ ]
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/xml2json"]
7
+ resolver = "2"
@@ -0,0 +1,14 @@
1
+ [package]
2
+ name = "xml2json"
3
+ version = "0.1.0"
4
+ edition = "2021"
5
+ authors = ["uvlad7 <uvlad7@gmail.com>"]
6
+ license = "MIT"
7
+ publish = false
8
+
9
+ [lib]
10
+ crate-type = ["cdylib"]
11
+
12
+ [dependencies]
13
+ magnus = { version = "0.4" }
14
+ xml2json-rs = "1.0.1"
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "mkmf"
4
+ require "rb_sys/mkmf"
5
+
6
+ create_rust_makefile("xml2json/xml2json")
@@ -0,0 +1,59 @@
1
+ use magnus::{define_module, function, prelude::*, Error};
2
+ use xml2json_rs::{XmlBuilder, JsonBuilder};
3
+
4
+ // fn hello(subject: String) -> String {
5
+ // format!("Hello from Rust, {}!", subject)
6
+ // }
7
+
8
+ // struct RbXmlConfig {
9
+ // val: XmlConfig,
10
+ // }
11
+
12
+ // impl RbXmlConfig {
13
+ // fn root_name(&mut self, key: Option<String>) -> &mut RbXmlConfig {
14
+ // self.val.root_name(key);
15
+ // self
16
+ // }
17
+ //
18
+ // fn build(self, json_s: String) -> Result<String, Error> {
19
+ // build_xml_impl(json_s, Some(self))
20
+ // }
21
+ // }
22
+
23
+ // fn build_xml(json_s: String) -> Result<String, Error> {
24
+ // build_xml_impl(json_s, None)
25
+ // }
26
+
27
+ // fn build_xml_impl(json_s: String, config: Option<RbXmlConfig>) -> Result<String, Error> {
28
+ // let mut xml_builder = config.map_or_else(|| XmlBuilder::default(), |conf| conf.val.finalize());
29
+ // xml_builder.build_from_json_string(&json_s).or_else(|error| {
30
+ // Err(Error::new(magnus::exception::arg_error(), error.to_string()))
31
+ // })
32
+ // }
33
+
34
+ fn build_xml(json_s: String) -> Result<String, Error> {
35
+ let mut xml_builder = XmlBuilder::default();
36
+ xml_builder.build_from_json_string(&json_s).or_else(|error| {
37
+ Err(Error::new(magnus::exception::runtime_error(), error.details()))
38
+ })
39
+ }
40
+
41
+ fn build_json(xml: String) -> Result<String, Error> {
42
+ let json_builder = JsonBuilder::default();
43
+ json_builder.build_string_from_xml(&xml).or_else(|error| {
44
+ Err(Error::new(magnus::exception::runtime_error(), error.details()))
45
+ })
46
+ }
47
+
48
+ #[magnus::init]
49
+ fn init() -> Result<(), Error> {
50
+ let module = define_module("Xml2Json")?;
51
+ // module.define_singleton_method("hello", function!(hello, 1))?;
52
+ // It's not possible to wrap XmlBuilder
53
+ let xml = module.define_module("Xml")?;
54
+ xml.define_singleton_method("build", function!(build_xml, 1))?;
55
+ // xml.define_class("Config", magnus::class::object())?;
56
+ let json = module.define_module("Json")?;
57
+ json.define_singleton_method("build", function!(build_json, 1))?;
58
+ Ok(())
59
+ }
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Xml2Json
4
+ VERSION = "0.1.0"
5
+ end
Binary file
data/lib/xml2json.rb ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "xml2json/version"
4
+ require_relative "xml2json/xml2json"
5
+
6
+ module Xml2Json
7
+ class Error < StandardError; end
8
+ # Your code goes here...
9
+ end
data/sig/xml2json.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Xml2Json
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: xml2json-rb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - uvlad7
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-07-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: yard-rustdoc
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description:
28
+ email:
29
+ - uvlad7@gmail.com
30
+ executables: []
31
+ extensions:
32
+ - ext/xml2json/Cargo.toml
33
+ extra_rdoc_files: []
34
+ files:
35
+ - Cargo.lock
36
+ - Cargo.toml
37
+ - ext/xml2json/Cargo.toml
38
+ - ext/xml2json/extconf.rb
39
+ - ext/xml2json/src/lib.rs
40
+ - lib/xml2json.rb
41
+ - lib/xml2json/version.rb
42
+ - lib/xml2json/xml2json.so
43
+ - sig/xml2json.rbs
44
+ homepage: https://github.com/uvlad7/xml2json-rb
45
+ licenses:
46
+ - MIT
47
+ metadata:
48
+ homepage_uri: https://github.com/uvlad7/xml2json-rb
49
+ source_code_uri: https://github.com/uvlad7/xml2json-rb
50
+ changelog_uri: https://github.com/uvlad7/xml2json-rb/blob/main/CHANGELOG.md
51
+ post_install_message:
52
+ rdoc_options: []
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 2.6.0
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 3.3.11
65
+ requirements: []
66
+ rubygems_version: 3.4.10
67
+ signing_key:
68
+ specification_version: 4
69
+ summary: Ruby wrapper for xml2json-rs
70
+ test_files: []