xml-smart 0.4.4 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0082580453384e4fc3faf5b355f6aa8ce68d77e620fc520b4712659190e900b1'
4
- data.tar.gz: 6e690294fe78c3d3a28f7be10a147f498ec0775a324ae63c02e786ed35972e55
3
+ metadata.gz: cfe8c2fc13f2a69f5070626a391bb93a3767a19c25326569e92611ade77d77d7
4
+ data.tar.gz: fc5f83de13c78e2092a3b0d8c802522e79e5f55c81b1b81acda018b0cff7d515
5
5
  SHA512:
6
- metadata.gz: a009c08c31957a69772a05764ab7334ce878d6d009f779c248715fb4cd40595f034b4cba04d03fb656d20cb31ceaa690e65f265d98a7cba54f7af625b78b1ba2
7
- data.tar.gz: 94475b9125ff888bf800e6e466b99892833de16d99f0b5417f995853454c66e7987f5070f5650983f02f468a3154a20b90a35f7e578b80dda42827a33cb10b9e
6
+ metadata.gz: 32851327e59702b2f7664706cdcb5148e91aa260543810312a6a42572a0496c4d96a84ef14b7e649b94645b6a31c3686752f706f34fd8cd5a56637c4342373d6
7
+ data.tar.gz: 719e57fcc9d636eece10acb376db47119eff7ef1a577605f793da3dd14f5c15129a6fbf10234826dd7fc5da6de172efe89193f7373814675a297d9b6977e69b9
data/AUTHORS CHANGED
@@ -2,3 +2,4 @@ Jürgen Mangler <juergen.mangler@univie.ac.at>
2
2
  Christian Neukirchen <chneukirchen@gmail.com>
3
3
  Jonathan Paisley <jp#{spidermonkey}dcs#{dot}gla#{dot}ac#{dot}uk>
4
4
  Emmanuel Touzery <emmanuel#{dot}touzery#{spidermonkey}wanadoo#{dot}fr>
5
+ Heinrich Fenkart <hnrch02@gmail.com>
@@ -1,4 +1,4 @@
1
- == XML::Smart - A Ruby class for fast and simple XML access
1
+ ## XML::Smart - A Ruby class for fast and simple XML access
2
2
 
3
3
  Copyright (C) 2004-2012 Jürgen Mangler <juergen.mangler@univie.ac.at>
4
4
 
@@ -6,74 +6,84 @@ Ruby/XML/Smart is freely distributable according to the terms of the GNU Lesser
6
6
 
7
7
  This program is distributed without any warranty. See the file 'COPYING' for details.
8
8
 
9
- == Installation
9
+ ## Installation
10
10
 
11
11
  - Based on Nokogiri 1.5.5
12
12
  - Thus works for MRI ruby 1.8.7, 1.9.x, JRuby (basically everything that is Nokogiri ready)
13
13
  - Works on Linux, OSX, Windows
14
14
 
15
- == Features
15
+ ## Features
16
16
 
17
- === Principle of least surprise
17
+ ### Principle of least surprise
18
18
 
19
19
  - Nokogiri is messy - violence always is
20
20
  - libxml smells like old-school C-Binding ;-)
21
21
  - rex is ... strange
22
22
 
23
- === Inherits Nokogiris GREAT compatibility for platforms and Ruby interpreters
23
+ ### Inherits Nokogiris GREAT compatibility for platforms and Ruby interpreters
24
24
 
25
- === XML only
25
+ ### XML only
26
26
 
27
27
  Sorry, no css selectors, html, ... go to Nokogiri if you look for these.
28
28
 
29
- === Great and convenient namespace support, compared to everything else out there
29
+ ### Great and convenient namespace support, compared to everything else out there
30
30
 
31
31
  Use namespaces in xpaths without any additional work:
32
32
 
33
+ ```ruby
33
34
  doc = XML::Smart.string('<test xmlns:aaa="uri:aaa"><aaa:test/></test>')
34
35
  doc.find('string(aaa:test)')
35
36
  doc.close
37
+ ```
36
38
 
37
39
  Register your own shortcusts to be available in all XPaths:
38
40
 
41
+ ```ruby
39
42
  doc = XML::Smart.string('<test xmlns:aaa="uri:aaa"><aaa:test/></test>')
40
43
  doc.register_namespace :a, 'uri:aaa'
41
44
  doc.find('string(a:test)')
42
45
  doc.close
46
+ ```
43
47
 
44
- === NFS safe file locking while editing / reading from an XML file
48
+ ### NFS safe file locking while editing / reading from an XML file
45
49
 
50
+ ```ruby
46
51
  XML::Smart.modify("EXAMPLE.xml","<test><names/></test>") do |doc|
47
52
  doc.root.add "test_node"
48
53
  end
54
+ ```
49
55
 
50
- === check against relaxng and xml schema
56
+ ### check against relaxng and xml schema
51
57
 
52
58
  Libxml2, the basis for nokogiri has only partial xml-schema support, but full
53
59
  relaxng support. Thus checking against xml-schema with nokogiri may return
54
60
  positive results, although it is a lie. XML::Smart internally converts
55
61
  xml-schema to relaxng, thus allowing for seamless schema usage:
56
62
 
63
+ ```ruby
57
64
  doc = XML::Smart.string('<test xmlns:aaa="uri:aaa"><aaa:test/></test>')
58
65
  doc.validate_against(XML::Smart.open_unprotected('xmlschema.xml'))
59
66
  doc.validate_against(XML::Smart.open_unprotected('xmlschema.xml'))
60
67
  doc.find('string(a:test)')
61
68
  doc.close
69
+ ```
62
70
 
63
- === xinclude
71
+ ### xinclude
64
72
 
65
- Libxml2, the basis for nokogiri does not support https xincludes. Nokogiri may
66
- impelement this in the future (issue
67
- https://github.com/sparklemotion/nokogiri/issues/1321), but for now we do
68
- support it:
73
+ Libxml2, the basis for nokogiri does not support https xincludes. Nokogiri may impelement this in the future (issue
74
+ https://github.com/sparklemotion/nokogiri/issues/1321), but for now we do support it:
69
75
 
76
+ ```ruby
70
77
  doc.xinclude!
78
+ ```
71
79
 
72
80
  or
73
-
81
+
82
+ ```ruby
74
83
  doc.find('//someelement').first.xinclude!
84
+ ```
75
85
 
76
- == Changes since 0.2.x (see Changelog)
86
+ ## Changes since 0.2.x (see Changelog)
77
87
 
78
88
  - qname instead of name
79
89
  - #register_namespace instead of #namespaces= to register shortcuts
@@ -81,6 +91,6 @@ or
81
91
  - signals removed
82
92
  - pull parser removed
83
93
 
84
- == Documentation
94
+ ## Documentation
85
95
 
86
96
  Sorry, no inline code documentation yet. We have an extensive test suite, look for examples there for now.
data/example/xpath_visual CHANGED
@@ -40,7 +40,7 @@ if ARGV.length < 2
40
40
  else
41
41
  # xpath expression that should be visualised
42
42
  xpath = ARGV[1..-1].join(' ') || "/"
43
- unless File.exists?(ARGV[0])
43
+ unless File.exist?(ARGV[0])
44
44
  help
45
45
  end
46
46
  doc = XML::Smart.open_unprotected(ARGV[0])
data/lib/xml/smart.rb CHANGED
@@ -102,8 +102,9 @@ module Nokogiri
102
102
  ctx.register_namespaces "xi"=>"http://www.w3.org/2001/XInclude"
103
103
  ctx.evaluate('.//xi:include').each do |ele|
104
104
  name = ele.attributes['href'].value
105
- name = path + name if name !~ /^(https?:|ftp:|\/)/
106
- content = open(name,:ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE).read
105
+ is_path = name !~ %r{\A[A-Za-z][A-Za-z0-9+\-\.]*://}
106
+ name = path + name if is_path && !name.start_with?('/')
107
+ content = ::URI::open(name, is_path ? 'r' : {:ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE}).read
107
108
  insert = begin
108
109
  Nokogiri::XML::parse(content).root # {|config| config.noblanks.noent.strict }.root
109
110
  rescue
data/test/EXAMPLE.xml CHANGED
@@ -1,6 +1,6 @@
1
1
  <test xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xml:lang="de">
2
2
  <names>
3
- <name team="0" a="3">2020-06-05 23:34:48 +0200</name>
3
+ <name team="0" a="3">2023-06-11 19:39:57 +0200</name>
4
4
  <name team="1">Jürgen</name>
5
5
  <name team="1">Michel</name>
6
6
  <name team="1">Raphi</name>
data/test/tc_create.rb CHANGED
@@ -6,7 +6,7 @@ class TestCreate < Minitest::Test
6
6
  # When a string as second paramter is provided, then a empty
7
7
  # xml file is created if it not exists. A block has to be supplied
8
8
  #
9
- # XML::Smart.modify(FILE,STRING) {} ... create file if !exists?
9
+ # XML::Smart.modify(FILE,STRING) {} ... create file if !exist?
10
10
  # XML::Smart.modify(FILE) {} ... just open file change and write back (LOCKTIMEOUT defaults to 7)
11
11
 
12
12
  File.unlink ::File.dirname(__FILE__) + "/EXAMPLE.tmp.xml" rescue nil
data/xml-smart.gemspec CHANGED
@@ -1,22 +1,22 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "xml-smart"
3
- s.version = "0.4.4"
3
+ s.version = "0.5.2"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.license = "LGPL-3.0"
6
- s.summary = "An xml library that doesn't suck - since 2004."
6
+ s.summary = "An xml library that doesn't suck (for me) - since 2004."
7
7
 
8
8
  s.description = "An xml library that doesn't suck (since 2004). Based on Nokogiri since 2012. For more info check out the Documentation link below."
9
9
 
10
- s.files = Dir['{lib/**/*,example/**/*}'] + %w(COPYING Rakefile xml-smart.gemspec README.rdoc AUTHORS)
10
+ s.files = Dir['{lib/**/*,example/**/*}'] + %w(COPYING Rakefile xml-smart.gemspec README.md AUTHORS)
11
11
  s.require_path = 'lib'
12
- s.extra_rdoc_files = ['README.rdoc']
12
+ s.extra_rdoc_files = ['README.md']
13
13
  s.test_files = Dir['test/tc_*.rb','test/*.xml','test/*.rng','test/*.xsd','test/smartrunner.rb','minitest/*']
14
14
  s.bindir = 'example'
15
15
  s.executables = ['xpath_visual']
16
16
 
17
17
  s.authors = ['Juergen eTM Mangler']
18
18
  s.email = 'juergen.mangler@gmail.com'
19
- s.homepage = 'http://www.wst.univie.ac.at/~mangler/xml-smart/'
19
+ s.homepage = 'https://github.com/etm/xml-smart/'
20
20
 
21
21
  s.required_ruby_version = '>=1.9.3'
22
22
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xml-smart
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen eTM Mangler
8
8
  autorequire:
9
9
  bindir: example
10
10
  cert_chain: []
11
- date: 2021-12-08 00:00:00.000000000 Z
11
+ date: 2023-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -77,11 +77,11 @@ executables:
77
77
  - xpath_visual
78
78
  extensions: []
79
79
  extra_rdoc_files:
80
- - README.rdoc
80
+ - README.md
81
81
  files:
82
82
  - AUTHORS
83
83
  - COPYING
84
- - README.rdoc
84
+ - README.md
85
85
  - Rakefile
86
86
  - example/CARD.xml
87
87
  - example/EXAMPLE.xml
@@ -145,7 +145,7 @@ files:
145
145
  - test/tc_xpath_root.rb
146
146
  - test/tc_xsl.rb
147
147
  - xml-smart.gemspec
148
- homepage: http://www.wst.univie.ac.at/~mangler/xml-smart/
148
+ homepage: https://github.com/etm/xml-smart/
149
149
  licenses:
150
150
  - LGPL-3.0
151
151
  metadata: {}
@@ -164,10 +164,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
164
  - !ruby/object:Gem::Version
165
165
  version: '0'
166
166
  requirements: []
167
- rubygems_version: 3.2.22
167
+ rubygems_version: 3.4.10
168
168
  signing_key:
169
169
  specification_version: 4
170
- summary: An xml library that doesn't suck - since 2004.
170
+ summary: An xml library that doesn't suck (for me) - since 2004.
171
171
  test_files:
172
172
  - test/tc_add.rb
173
173
  - test/tc_basic.rb