hrr_rb_relaxed_xml 0.1.0 → 0.1.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 +4 -4
- data/README.md +3 -1
- data/hrr_rb_relaxed_xml.gemspec +2 -2
- data/lib/hrr_rb_relaxed_xml/document.rb +7 -4
- data/lib/hrr_rb_relaxed_xml/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8c8633661432b59a4cba504fa05746c96d56eab0e980715dcc991ff0e83b14d
|
4
|
+
data.tar.gz: a196b679723aefb614f048524d58785184ac1f9f219ab72f3c9169cb9f6bf1c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97d6d2872a9d9ab549e37a755cde9fededa52c5ca29b95e7909584f5d8f8cf9ea6871e947592fd7a855f383f392e0ffcb76a1ba3d06e6727d95dd361cd36769d
|
7
|
+
data.tar.gz: 3334c62aafb400b30da5b1c74bd77b00317d16dfebd88067780439719ef312a2bdc45e1d4e16ed18d04feef15fe1790bd19057c3fa1b7270d077d15800598e79
|
data/README.md
CHANGED
@@ -86,11 +86,13 @@ The output of the `#write` method is the below.
|
|
86
86
|
</root2>
|
87
87
|
```
|
88
88
|
|
89
|
-
With using `#elements`, `#root`, `#add_element`, or `#add` methods, the XML document can be manipulated.
|
89
|
+
With using `#elements`, `#clone`, `#deep_clone`, `#root`, `#add_element`, or `#add` methods, the XML document can be manipulated.
|
90
90
|
|
91
91
|
```ruby
|
92
92
|
xml_doc.elements.to_a # => [<root1> ... </>, <root2> ... </>]
|
93
93
|
|
94
|
+
xml_doc.deep_clone.elements.to_a # => [<root1> ... </>, <root2> ... </>]
|
95
|
+
|
94
96
|
xml_doc.elements[1] # => <root1> ... </>
|
95
97
|
xml_doc.elements['root1'].elements['child1'] # => <child1> ... </>
|
96
98
|
xml_doc.elements['root1'].elements['child1'].root # => <root1> ... </>
|
data/hrr_rb_relaxed_xml.gemspec
CHANGED
@@ -11,8 +11,8 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.authors = ["hirura"]
|
12
12
|
spec.email = ["hirura@gmail.com"]
|
13
13
|
|
14
|
-
spec.summary = %q{
|
15
|
-
spec.description = %q{
|
14
|
+
spec.summary = %q{An REXML-based XML toolkit that can have multiple root elements}
|
15
|
+
spec.description = %q{An REXML-based XML toolkit that can have multiple root elements}
|
16
16
|
spec.homepage = "https://github.com/hirura/hrr_rb_relaxed_xml"
|
17
17
|
spec.license = "MIT"
|
18
18
|
|
@@ -5,6 +5,10 @@ require 'rexml/document'
|
|
5
5
|
|
6
6
|
module HrrRbRelaxedXML
|
7
7
|
class Document < REXML::Document
|
8
|
+
def clone
|
9
|
+
self.class.new self
|
10
|
+
end
|
11
|
+
|
8
12
|
def add child
|
9
13
|
case child
|
10
14
|
when REXML::XMLDecl, REXML::DocType
|
@@ -18,13 +22,12 @@ module HrrRbRelaxedXML
|
|
18
22
|
alias :<< :add
|
19
23
|
|
20
24
|
def add_element element, attrs={}
|
21
|
-
|
25
|
+
case element
|
26
|
+
when nil
|
22
27
|
super
|
23
28
|
else
|
24
29
|
child_e = @elements.add element
|
25
|
-
|
26
|
-
child_e.attributes[k] = v
|
27
|
-
end
|
30
|
+
child_e.add_attributes attrs
|
28
31
|
child_e
|
29
32
|
end
|
30
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hrr_rb_relaxed_xml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hirura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-06-
|
11
|
+
date: 2019-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rexml
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
description:
|
69
|
+
description: An REXML-based XML toolkit that can have multiple root elements
|
70
70
|
email:
|
71
71
|
- hirura@gmail.com
|
72
72
|
executables: []
|
@@ -108,5 +108,5 @@ requirements: []
|
|
108
108
|
rubygems_version: 3.0.3
|
109
109
|
signing_key:
|
110
110
|
specification_version: 4
|
111
|
-
summary:
|
111
|
+
summary: An REXML-based XML toolkit that can have multiple root elements
|
112
112
|
test_files: []
|