xml2json-rb 0.2.1 → 0.3.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 894ff6fe88c1e4a0e7bbb426419954f98413f568f8ac361784e60537074033fd
4
- data.tar.gz: face561e86ac59fb767535689377e361f171574b77722ba55a55056c96630767
3
+ metadata.gz: 929c9024b54d50ca7dc4d457c75cd69ddb02d0f4394d25eb2d3b6c5e8573fd25
4
+ data.tar.gz: 6e80dac62fb5f67fa6f19641cd0c0a62c91110d190a4ec38e6a461d166d3074b
5
5
  SHA512:
6
- metadata.gz: 2d3917434cd6824082cb8256ef752e10af0153d29da3b00365f0ed5ceebcef5626e422998b52a7f1a3c63b44ab2b49586f079557e1cb4888a08cf2d4f128c9bc
7
- data.tar.gz: 36cf6993a5ca3f586357b8d46b9a038ad53cab83eae759fa1506ab58989cdd3c97dad69fe15a44f3ecea49eb3ac7287f35a75a01582e3bd13d493e58029a523a
6
+ metadata.gz: dcd614a2cbfd953cc2ae8adcf123a1723a0143f2754ca0ff3e42509cb385b283794d8090bd5808ed117c8e0e6f65bc630791052941848e2f46cb626e26599593
7
+ data.tar.gz: 28e43cbfaaa8987a1f7fbb1ef348055e742886dc3b629874c0f04d67bd74789751dc1e288d93358ee4c8e0b0fe7a2a6fa0c88393cc426dfe7731c0056e146383
data/Cargo.lock CHANGED
@@ -13,9 +13,9 @@ dependencies = [
13
13
 
14
14
  [[package]]
15
15
  name = "bindgen"
16
- version = "0.62.0"
16
+ version = "0.66.1"
17
17
  source = "registry+https://github.com/rust-lang/crates.io-index"
18
- checksum = "c6720a8b7b2d39dd533285ed438d458f65b31b5c257e6ac7bb3d7e82844dd722"
18
+ checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7"
19
19
  dependencies = [
20
20
  "bitflags",
21
21
  "cexpr",
@@ -28,14 +28,14 @@ dependencies = [
28
28
  "regex",
29
29
  "rustc-hash",
30
30
  "shlex",
31
- "syn",
31
+ "syn 2.0.32",
32
32
  ]
33
33
 
34
34
  [[package]]
35
35
  name = "bitflags"
36
- version = "1.3.2"
36
+ version = "2.4.1"
37
37
  source = "registry+https://github.com/rust-lang/crates.io-index"
38
- checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
38
+ checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
39
39
 
40
40
  [[package]]
41
41
  name = "cexpr"
@@ -127,9 +127,9 @@ dependencies = [
127
127
 
128
128
  [[package]]
129
129
  name = "magnus"
130
- version = "0.4.4"
130
+ version = "0.5.5"
131
131
  source = "registry+https://github.com/rust-lang/crates.io-index"
132
- checksum = "fc87660cd7daa49fddbfd524c836de54d5c927d520cd163f43700c5087c57d6c"
132
+ checksum = "5b7a37670bc433d081ef5846d5589381fabd8d3410ad3b59faa6b1b4c9c3cbce"
133
133
  dependencies = [
134
134
  "magnus-macros",
135
135
  "rb-sys",
@@ -138,13 +138,13 @@ dependencies = [
138
138
 
139
139
  [[package]]
140
140
  name = "magnus-macros"
141
- version = "0.3.0"
141
+ version = "0.4.1"
142
142
  source = "registry+https://github.com/rust-lang/crates.io-index"
143
- checksum = "206cb23bfeea05180c97522ef6a3e52a4eb17b0ed2f30ee3ca9c4f994d2378ae"
143
+ checksum = "6cc17af1d45442c011aa579d727ec6cff8a69aea8a6bbad26736e7112d749bfb"
144
144
  dependencies = [
145
145
  "proc-macro2",
146
146
  "quote",
147
- "syn",
147
+ "syn 1.0.109",
148
148
  ]
149
149
 
150
150
  [[package]]
@@ -204,18 +204,18 @@ dependencies = [
204
204
 
205
205
  [[package]]
206
206
  name = "rb-sys"
207
- version = "0.9.79"
207
+ version = "0.9.82"
208
208
  source = "registry+https://github.com/rust-lang/crates.io-index"
209
- checksum = "939fb78db3e4f26665c1d4c7b91ca66d3578335a19aba552d4a6445811d07072"
209
+ checksum = "a3e6bf79bf4c711917cacfaf46dfab4314dbfdd89a8ee3ec4b98336cd23f1ebf"
210
210
  dependencies = [
211
211
  "rb-sys-build",
212
212
  ]
213
213
 
214
214
  [[package]]
215
215
  name = "rb-sys-build"
216
- version = "0.9.79"
216
+ version = "0.9.82"
217
217
  source = "registry+https://github.com/rust-lang/crates.io-index"
218
- checksum = "335a95eb0420d52fa94ef12019df3c2c250c6b19cbb3c60bd05cb7e9c362072c"
218
+ checksum = "5482a1ed4cde58dddaf162b6aebcb5c25645822547832b8be101f2acd40bcdd6"
219
219
  dependencies = [
220
220
  "bindgen",
221
221
  "lazy_static",
@@ -223,7 +223,7 @@ dependencies = [
223
223
  "quote",
224
224
  "regex",
225
225
  "shell-words",
226
- "syn",
226
+ "syn 2.0.32",
227
227
  ]
228
228
 
229
229
  [[package]]
@@ -314,6 +314,17 @@ dependencies = [
314
314
  "unicode-ident",
315
315
  ]
316
316
 
317
+ [[package]]
318
+ name = "syn"
319
+ version = "2.0.32"
320
+ source = "registry+https://github.com/rust-lang/crates.io-index"
321
+ checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2"
322
+ dependencies = [
323
+ "proc-macro2",
324
+ "quote",
325
+ "unicode-ident",
326
+ ]
327
+
317
328
  [[package]]
318
329
  name = "unicode-ident"
319
330
  version = "1.0.10"
@@ -344,9 +355,10 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
344
355
 
345
356
  [[package]]
346
357
  name = "xml2json"
347
- version = "0.2.1"
358
+ version = "0.3.1"
348
359
  dependencies = [
349
360
  "magnus",
361
+ "rb-sys",
350
362
  "xml2json-rs",
351
363
  ]
352
364
 
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "xml2json"
3
- version = "0.2.1"
3
+ version = "0.3.1"
4
4
  edition = "2021"
5
5
  authors = ["uvlad7 <uvlad7@gmail.com>"]
6
6
  license = "MIT"
@@ -10,5 +10,8 @@ publish = false
10
10
  crate-type = ["cdylib"]
11
11
 
12
12
  [dependencies]
13
- magnus = { version = "0.4" }
13
+ magnus = { version = "0.5.5", features = ["rb-sys-interop"] }
14
+ rb-sys = { version = "*", default-features = false, features = [
15
+ "stable-api-compiled-fallback",
16
+ ] }
14
17
  xml2json-rs = "1.0.1"
@@ -2,16 +2,12 @@ use magnus::{define_module, function, prelude::*, Error, Value};
2
2
  use magnus::scan_args::{scan_args};
3
3
  use xml2json_rs::{XmlBuilder, JsonBuilder, JsonConfig, XmlConfig, Declaration, Version, Encoding, Indentation};
4
4
 
5
- // fn hello(subject: String) -> String {
6
- // format!("Hello from Rust, {}!", subject)
7
- // }
8
-
9
5
  #[macro_export]
10
6
  macro_rules! set_arg {
11
7
  ($config:expr, $opts_hash:expr, $arg:ident, $arg_type:ident) => (
12
8
  let arg_value = $opts_hash.lookup::<_, Option<$arg_type>>(magnus::Symbol::new(stringify!($arg)))?;
13
- if arg_value.is_some() {
14
- $config.$arg(arg_value.unwrap());
9
+ if let Some(value) = arg_value {
10
+ $config.$arg(value);
15
11
  }
16
12
  );
17
13
  }
@@ -21,15 +17,21 @@ fn map_xml2json_err(error: xml2json_rs::X2JError) -> Error {
21
17
  }
22
18
 
23
19
  fn build_xml(args: &[Value]) -> Result<String, Error> {
24
- let args = scan_args::<_, _, (), (), _, ()>(args)?;
20
+ build_xml_impl(args, false)
21
+ }
22
+
23
+ fn build_pretty_xml(args: &[Value]) -> Result<String, Error> {
24
+ build_xml_impl(args, true)
25
+ }
26
+
27
+ fn build_xml_impl(args: &[Value], build_pretty: bool) -> Result<String, Error> {
28
+ let args = scan_args::<_, _, (), (), (), ()>(args)?;
25
29
  let (json_s, ): (String, ) = args.required;
26
30
  let (opts, ): (Option<magnus::RHash>, ) = args.optional;
27
- let _: () = args.keywords;
28
31
 
29
32
  let mut xml_builder: XmlBuilder;
30
- if opts.is_some() { // yep, even if it's an empty hash
33
+ if let Some(opts_hash) = opts { // yep, even if it's an empty hash
31
34
  // println!("{}", opts.unwrap().to_string());
32
- let opts_hash = opts.unwrap();
33
35
  let mut config = XmlConfig::new();
34
36
  set_arg!(config, opts_hash, root_name, String);
35
37
  set_arg!(config, opts_hash, attrkey, String);
@@ -43,18 +45,16 @@ fn build_xml(args: &[Value]) -> Result<String, Error> {
43
45
  || decl_standalone.is_some()
44
46
  { // something is specified
45
47
  // I didn't find a way to get defaults without copying them
46
- let decl_version_val;
47
- if decl_version.is_some() {
48
+ let decl_version_val = if decl_version.is_some() {
48
49
  let decl_version_str = unsafe { decl_version.unwrap().to_s() }?.into_owned();
49
- decl_version_val = Version::try_from(decl_version_str.as_str())
50
- .map_err(map_xml2json_err)?;
51
- } else { decl_version_val = Version::XML10; }
52
- let decl_encoding_val;
53
- if decl_encoding.is_some() {
50
+ Version::try_from(decl_version_str.as_str())
51
+ .map_err(map_xml2json_err)?
52
+ } else { Version::XML10 };
53
+ let decl_encoding_val = if decl_encoding.is_some() {
54
54
  let decl_encoding_str = unsafe { decl_encoding.unwrap().to_s() }?.into_owned();
55
- decl_encoding_val = Some(Encoding::try_from(decl_encoding_str.as_str())
56
- .map_err(map_xml2json_err)?);
57
- } else { decl_encoding_val = None; }
55
+ Some(Encoding::try_from(decl_encoding_str.as_str())
56
+ .map_err(map_xml2json_err)?)
57
+ } else { None };
58
58
 
59
59
  let decl = Declaration::new(
60
60
  decl_version_val,
@@ -71,95 +71,44 @@ fn build_xml(args: &[Value]) -> Result<String, Error> {
71
71
  if indent_char.is_some()
72
72
  || indent_size.is_some()
73
73
  {
74
- let indent_char_val: u8;
75
- if indent_char.is_some() {
76
- indent_char_val = u8::try_from(indent_char.unwrap()).map_err(|error| Error::new(magnus::exception::type_error(), error.to_string()))?;
77
- } else { indent_char_val = b' '; }
78
-
79
- let intent = Indentation::new(
74
+ let indent_char_val: u8 = if indent_char.is_some() {
75
+ u8::try_from(indent_char.unwrap()).map_err(|error| Error::new(magnus::exception::type_error(), error.to_string()))?
76
+ } else { b' ' };
77
+ config.rendering(Indentation::new(
80
78
  indent_char_val,
81
79
  indent_size.unwrap_or(2),
82
- );
83
- config.rendering(intent);
84
- } else if indent.unwrap_or(false) {
80
+ ));
81
+ } else if indent.unwrap_or(build_pretty) {
85
82
  // because Indentation::default is not the same as not calling config.rendering at all;
86
83
  config.rendering(Indentation::default());
87
84
  }
88
85
  }
89
86
  xml_builder = config.finalize();
87
+ } else if build_pretty {
88
+ xml_builder = XmlConfig::new().rendering(Indentation::default()).finalize();
90
89
  } else { xml_builder = XmlBuilder::default(); }
91
90
 
92
- xml_builder.build_from_json_string(&json_s).or_else(|error| {
93
- Err(map_xml2json_err(error))
91
+ xml_builder.build_from_json_string(&json_s).map_err(|error| {
92
+ map_xml2json_err(error)
94
93
  })
95
94
  }
96
95
 
97
96
  fn build_json(args: &[Value]) -> Result<String, Error> {
97
+ build_json_impl(args, false)
98
+ }
99
+
100
+ fn build_pretty_json(args: &[Value]) -> Result<String, Error> {
101
+ build_json_impl(args, true)
102
+ }
103
+
104
+ fn build_json_impl(args: &[Value], mut build_pretty: bool) -> Result<String, Error> {
98
105
  // https://docs.rs/magnus/latest/magnus/scan_args/fn.scan_args.html
99
- let args = scan_args::<_, _, (), (), _, ()>(args)?;
106
+ let args = scan_args::<_, _, (), (), (), ()>(args)?;
100
107
  let (xml, ): (String, ) = args.required;
101
108
  let (opts, ): (Option<magnus::RHash>, ) = args.optional;
102
- // let _: () = args.optional;
103
- let _: () = args.keywords;
104
-
105
- // Impossible, too long
106
- // let kw = get_kwargs::<_, (), (
107
- // Option<String>, // charkey
108
- // Option<String>, // attrkey
109
- // Option<String>, // empty_tag
110
- // Option<bool>, // explicit_root
111
- // Option<bool>, // trim
112
- // Option<bool>, // ignore_attrs
113
- // Option<bool>, // merge_attrs
114
- // Option<bool>, // normalize_text
115
- // Option<bool>, // lowercase_tags
116
- // Option<bool>, // explicit_array
117
- // Option<bool>, // explicit_charkey
118
- // ), ()>(args.keywords, &[], &[
119
- // "charkey",
120
- // "attrkey",
121
- // "empty_tag",
122
- // "explicit_root",
123
- // "trim",
124
- // "ignore_attrs",
125
- // "merge_attrs",
126
- // "normalize_text",
127
- // "lowercase_tags",
128
- // "explicit_array",
129
- // "explicit_charkey",
130
- // ])?;
131
- // let (
132
- // charkey,
133
- // attrkey,
134
- // empty_tag,
135
- // explicit_root,
136
- // trim,
137
- // ignore_attrs,
138
- // merge_attrs,
139
- // normalize_text,
140
- // lowercase_tags,
141
- // explicit_array,
142
- // explicit_charkey,
143
- // ) = kw.optional;
144
- // if charkey.is_some()
145
- // || attrkey.is_some()
146
- // || empty_tag.is_some()
147
- // || explicit_root.is_some()
148
- // || trim.is_some()
149
- // || ignore_attrs.is_some()
150
- // || merge_attrs.is_some()
151
- // || normalize_text.is_some()
152
- // || lowercase_tags.is_some()
153
- // || explicit_array.is_some()
154
- // || explicit_charkey.is_some()
155
- // {
156
- // println!("any")
157
- // } else { println!("none") }
158
109
 
159
110
  let json_builder: JsonBuilder;
160
- if opts.is_some() { // yep, even if it's an empty hash
161
- // println!("{}", opts.unwrap().to_string());
162
- let opts_hash = opts.unwrap();
111
+ if let Some(opts_hash) = opts { // yep, even if it's an empty hash
163
112
  let mut config = JsonConfig::new();
164
113
  set_arg!(config, opts_hash, charkey, String);
165
114
  set_arg!(config, opts_hash, attrkey, String);
@@ -173,18 +122,25 @@ fn build_json(args: &[Value]) -> Result<String, Error> {
173
122
  set_arg!(config, opts_hash, explicit_array, bool);
174
123
  set_arg!(config, opts_hash, explicit_charkey, bool);
175
124
  json_builder = config.finalize();
125
+
126
+ let indent = opts_hash.lookup::<_, Option<bool>>(magnus::Symbol::new("indent"))?;
127
+ if let Some(indent_value) = indent {
128
+ build_pretty = indent_value;
129
+ }
176
130
  } else { json_builder = JsonBuilder::default(); }
177
131
 
178
- json_builder.build_string_from_xml(&xml).or_else(|error| {
179
- Err(map_xml2json_err(error))
132
+ if build_pretty {
133
+ json_builder.build_pretty_string_from_xml(&xml)
134
+ } else {
135
+ json_builder.build_string_from_xml(&xml)
136
+ }.map_err(|error| {
137
+ map_xml2json_err(error)
180
138
  })
181
139
  }
182
140
 
183
141
  #[magnus::init]
184
142
  fn init() -> Result<(), Error> {
185
143
  let module = define_module("Xml2Json")?;
186
- // module.define_singleton_method("hello", function!(hello, 1))?;
187
- // It's not possible to wrap XmlBuilder
188
144
  let xml = module.define_module("Xml")?;
189
145
  let xml_version = xml.define_module("Version")?;
190
146
  xml_version.const_set("XML10", Version::XML10.to_string())?;
@@ -192,7 +148,9 @@ fn init() -> Result<(), Error> {
192
148
  let xml_encoding = xml.define_module("Encoding")?;
193
149
  xml_encoding.const_set("UTF8", Encoding::UTF8.to_string())?;
194
150
  xml.define_singleton_method("build", function!(build_xml, -1))?;
151
+ xml.define_singleton_method("build_pretty", function!(build_pretty_xml, -1))?;
195
152
  let json = module.define_module("Json")?;
196
153
  json.define_singleton_method("build", function!(build_json, -1))?;
154
+ json.define_singleton_method("build_pretty", function!(build_pretty_json, -1))?;
197
155
  Ok(())
198
156
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Xml2Json
4
- VERSION = "0.2.1"
4
+ VERSION = "0.3.1"
5
5
  end
data/lib/xml2json.rb CHANGED
@@ -1,9 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "xml2json/version"
4
- require_relative "xml2json/xml2json"
4
+ begin
5
+ require_relative "xml2json/#{RUBY_VERSION[/(\d+\.\d+)/, 1]}/xml2json"
6
+ rescue LoadError
7
+ require_relative "xml2json/xml2json"
8
+ end
5
9
 
6
- # @see https://github.com/novcn/xml2json-rs docs for the wrapped library
10
+ # @see https://docs.rs/xml2json-rs/1.0.1/xml2json_rs/index.html docs for the wrapped library
7
11
  module Xml2Json
8
12
  # @!parse [ruby]
9
13
  # module Xml
@@ -17,18 +21,66 @@ module Xml2Json
17
21
  #
18
22
  # # @param json_s [String, #to_str] JSON string
19
23
  # # @param opts [Hash<Symbol, Object>] config params
20
- # # @see https://docs.rs/xml2json-rs/1.0.1/xml2json_rs/struct.XmlConfig.html rust doc
24
+ # # @note Default values are provided by xml2json-rs
25
+ # # @see https://docs.rs/xml2json-rs/1.0.1/xml2json_rs/struct.XmlConfig.html Docs for xml2json-rs XmlConfig
26
+ # # @option opts [String, #to_str] root_name ("root") Root key name to contain produced JSON object
27
+ # # @option opts [String, #to_str] attrkey ("$") The value of the JSON key used to store XML attributes under
28
+ # # @option opts [String, #to_str] charkey ("_") The value of the JSON key used to store XML character data under
29
+ # # @option opts [nil, "1.0", "1.1", #to_s] version (Xml2Json::Version::XML10) XML Declaration 'version' field,
30
+ # # default if nil
31
+ # # @raise [RuntimeError] if +version.to_s+ returns unsupported string,
32
+ # # for now only +"1.0"+ and +"1.1"+ are supported
33
+ # # @option opts [nil, "UTF-8", #to_s] encoding (nil) XML Declaration 'encoding' field, empty if nil
34
+ # # @raise [RuntimeError] if +encoding.to_s+ returns unsupported string, for now only +"UTF-8"+ is supported
35
+ # # @option opts [bool, nil] standalone (nil) XML Declaration 'standalone' field, empty if nil
36
+ # # @option opts [bool] indent (false) Output XML with line-breaks and indentations
37
+ # # @option opts [String, #to_str] indent_char (" ") Character used for indentation. This option will be ignored
38
+ # # if +indent+ is false
39
+ # # @raise [TypeError] If +indent_char+ is more than one character or can not be encoded as UTF-8
40
+ # # @note It's not enough for the Ruby +indent_char+ string to be UTF-8 encoded, not sure
41
+ # # if that's a bug or a feature of Magnus
42
+ # # @option opts [Integer, #to_int] indent_size (2) Number of characters used for indentation.
43
+ # # This option will be ignored if +indent+ is false
44
+ # # @raise [RangeError] if +indent_size+ cannot be converted into +unsigned long long+
21
45
  # # @return [String] XML string
22
- # # @raise [RuntimeError] if the input string is invalid
46
+ # # @raise [RuntimeError] if +json_s+ is not valid JSON
47
+ # # @raise [TypeError] if +opts+ contain invalid value
23
48
  # def self.build(json_s, opts: nil); end
49
+ # # @option opts [bool] indent (true)
50
+ # # @note Check +Xml2Json::Xml.build+ for other details, the only difference is that +indent+ is true by default
51
+ # # @see .build
52
+ # def self.build_pretty(json_s, opts: nil); end
24
53
  # end
25
54
  #
26
55
  # module Json
27
56
  # # @param xml [String, #to_str] XML string
28
57
  # # @param opts [Hash<Symbol, Object>] config params
29
- # # @see https://docs.rs/xml2json-rs/1.0.1/xml2json_rs/struct.JsonConfig.html rust doc
58
+ # # @note Default values are provided by xml2json-rs
59
+ # # @see https://docs.rs/xml2json-rs/1.0.1/xml2json_rs/struct.JsonConfig.html Docs for xml2json-rs JsonConfig
60
+ # # @option opts [String, #to_str] attrkey ("$") Key to outer object containing tag attributes
61
+ # # @option opts [String, #to_str] charkey ("_") Key to store character content under
62
+ # # @option opts [String, #to_str] empty_tag ("") The value of empty nodes
63
+ # # @option opts [bool] indent (false) Output JSON with line-breaks and indentations
64
+ # # @option opts [bool] explicit_root (true) Sets the root node inside the resulting object
65
+ # # @option opts [bool] trim (false) Trim whitespace at the beginning and end of text nodes
66
+ # # @option opts [bool] ignore_attrs (false) Setting this to true will skip adding element attributes
67
+ # # and create text nodes
68
+ # # @option opts [bool] merge_attrs (false) Merge all XML attributes and child elements as properties of
69
+ # # the parent, instead of keying attributes off of the child attribute object. This option will be
70
+ # # ignored if +ignore_attrs+ is true
71
+ # # @option opts [bool] normalize_text (false) Removes whitespace character data in text nodes
72
+ # # @option opts [bool] lowercase_tags (false) Normalize all tags by converting them to lowercase
73
+ # # @option opts [bool] explicit_array (true) Always put the child nodes in an array, otherwise an array is only
74
+ # # created if there is more than one child
75
+ # # @option opts [bool] explicit_charkey (false) Always store character data under +charkey+ even if there are
76
+ # # no other text elements stored inside the tag
30
77
  # # @return [String] JSON string
31
- # # @raise [RuntimeError] if the input string is invalid
78
+ # # @raise [RuntimeError] if +xml+ is not valid XML
79
+ # # @raise [TypeError] if +opts+ contain invalid value
32
80
  # def self.build(xml, opts: nil); end
81
+ # # @option opts [bool] indent (true)
82
+ # # @note Check +Xml2Json::Json.build+ for other details, the only difference is that +indent+ is true by default
83
+ # # @see .build
84
+ # def self.build_pretty(xml, opts: nil); end
33
85
  # end
34
86
  end
@@ -1,5 +1,6 @@
1
1
  module Xml2Json
2
2
  module Json
3
3
  def self.build: (xml: String, opts: Hash[Symbol, Object]?) -> String
4
+ def self.build_pretty: (xml: String, opts: Hash[Symbol, Object]?) -> String
4
5
  end
5
6
  end
@@ -1,5 +1,6 @@
1
1
  module Xml2Json
2
2
  module Xml
3
3
  def self.build: (json_s: String, opts: Hash[Symbol, Object]?) -> String
4
+ def self.build_pretty: (json_s: String, opts: Hash[Symbol, Object]?) -> String
4
5
  end
5
6
  end
metadata CHANGED
@@ -1,17 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xml2json-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - uvlad7
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-12 00:00:00.000000000 Z
11
+ date: 2023-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: yard-rustdoc
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '13.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '13.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake-compiler
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - ">="
@@ -24,6 +38,48 @@ dependencies:
24
38
  - - ">="
25
39
  - !ruby/object:Gem::Version
26
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rb_sys
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.9.63
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.9.63
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.21'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.21'
27
83
  - !ruby/object:Gem::Dependency
28
84
  name: pry
29
85
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +164,20 @@ dependencies:
108
164
  - - ">="
109
165
  - !ruby/object:Gem::Version
110
166
  version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: toml-rb
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
111
181
  description: This gem helps to convert xml strings to json and vise versa
112
182
  email:
113
183
  - uvlad7@gmail.com
@@ -123,7 +193,6 @@ files:
123
193
  - ext/xml2json/src/lib.rs
124
194
  - lib/xml2json.rb
125
195
  - lib/xml2json/version.rb
126
- - lib/xml2json/xml2json.so
127
196
  - sig/xml2_json/json.rbs
128
197
  - sig/xml2_json/xml.rbs
129
198
  - sig/xml2_json/xml/encoding.rbs
@@ -136,8 +205,9 @@ metadata:
136
205
  homepage_uri: https://github.com/uvlad7/xml2json-rb
137
206
  source_code_uri: https://github.com/uvlad7/xml2json-rb
138
207
  changelog_uri: https://github.com/uvlad7/xml2json-rb/blob/main/CHANGELOG.md
139
- documentation_uri: https://rubydoc.info/gems/xml2json-rb/0.2.1
140
- post_install_message:
208
+ documentation_uri: https://rubydoc.info/gems/xml2json-rb/0.3.1
209
+ rubygems_mfa_required: 'true'
210
+ post_install_message:
141
211
  rdoc_options: []
142
212
  require_paths:
143
213
  - lib
@@ -152,8 +222,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
222
  - !ruby/object:Gem::Version
153
223
  version: 3.3.11
154
224
  requirements: []
155
- rubygems_version: 3.4.10
156
- signing_key:
225
+ rubygems_version: 3.4.20
226
+ signing_key:
157
227
  specification_version: 4
158
228
  summary: Ruby wrapper for xml2json-rs
159
229
  test_files: []
Binary file