xml-simple 1.1.4 → 1.1.5

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/xmlsimple.rb +16 -9
  3. metadata +5 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 068e3be25c5a9565cee2d420a9c396c851fb66e4
4
- data.tar.gz: 21523e733014986f92569c8a2e0e32e0617945c1
3
+ metadata.gz: b2673ebe343b5f04ba6870687867461f21ade3b9
4
+ data.tar.gz: 1e0f37f2fc6d72365f9b0b36a18849cb17eba27e
5
5
  SHA512:
6
- metadata.gz: e4fd65ac9b33e3723968f59030366b0400ff14c61c290eecc6cd7d24e06a6768279a64ff514c3f4111c8cd89a06d8a5373e976c7e97fce2eba03d5631527d4bb
7
- data.tar.gz: 9fede257f59b389c890003c9995762c1714f6e70d6c9e0067f200c4dfb7d90fe3a69f068f24229265c8f483d274393f123a89ff7fda9117cf41c824d0c86acb3
6
+ metadata.gz: 5ac3b4367a95d29ccecad806a0484658cdb36a87edc71bb2dec1ca90c0f29ae63f0fcac1cb6f3c87d5503b50224728e2a2506d0d516ddda46b639091a5d37180
7
+ data.tar.gz: ed5a721d68e38fb6551d1a1c99c3c66c8094b37752f7cfe371a1b92867dcb37f309dc7a7fa3d2e985f03dd5583869bb3d36b27c42b45eca04c66b3251c62b19a
@@ -11,7 +11,7 @@ require 'stringio'
11
11
  class XmlSimple
12
12
  include REXML
13
13
 
14
- @@VERSION = '1.1.4'
14
+ @@VERSION = '1.1.5'
15
15
 
16
16
  # A simple cache for XML documents that were already transformed
17
17
  # by xml_in.
@@ -121,7 +121,7 @@ class XmlSimple
121
121
  # Create a "global" cache.
122
122
  @@cache = Cache.new
123
123
 
124
- # Creates and intializes a new XmlSimple object.
124
+ # Creates and initializes a new XmlSimple object.
125
125
  #
126
126
  # defaults::
127
127
  # Default values for options.
@@ -264,10 +264,10 @@ class XmlSimple
264
264
  # Declare options that are valid for xml_in and xml_out.
265
265
  KNOWN_OPTIONS = {
266
266
  'in' => %w(
267
- keyattr keeproot forcecontent contentkey noattr
268
- searchpath forcearray suppressempty anonymoustag
269
- cache grouptags normalisespace normalizespace
270
- variables varattr keytosymbol attrprefix conversions
267
+ keyattr keeproot forcecontent contentkey noattr searchpath
268
+ forcearray suppressempty anonymoustag cache grouptags
269
+ normalisespace normalizespace variables varattr keytosymbol
270
+ attrtosymbol attrprefix conversions
271
271
  ),
272
272
  'out' => %w(
273
273
  keyattr keeproot contentkey noattr rootname
@@ -285,11 +285,12 @@ class XmlSimple
285
285
  DEF_FORCE_ARRAY = true
286
286
  DEF_INDENTATION = ' '
287
287
  DEF_KEY_TO_SYMBOL = false
288
+ DEF_ATTR_TO_SYMBOL = false
288
289
 
289
290
  # Normalizes option names in a hash, i.e., turns all
290
291
  # characters to lower case and removes all underscores.
291
- # Additionally, this method checks, if an unknown option
292
- # was used and raises an according exception.
292
+ # Additionally, this method checks if an unknown option
293
+ # was used, and raises an according exception.
293
294
  #
294
295
  # options::
295
296
  # Hash to be normalized.
@@ -301,7 +302,7 @@ class XmlSimple
301
302
  options.each { |key, value|
302
303
  lkey = key.to_s.downcase.gsub(/_/, '')
303
304
  if !known_options.member?(lkey)
304
- raise ArgumentError, "Unrecognised option: #{lkey}."
305
+ raise ArgumentError, "Unrecognized option: #{lkey}."
305
306
  end
306
307
  result[lkey] = value
307
308
  }
@@ -353,6 +354,8 @@ class XmlSimple
353
354
 
354
355
  @options['keytosymbol'] = DEF_KEY_TO_SYMBOL unless @options.has_key?('keytosymbol')
355
356
 
357
+ @options['attrtosymbol'] = DEF_ATTR_TO_SYMBOL unless @options.has_key?('attrtosymbol')
358
+
356
359
  if @options.has_key?('contentkey')
357
360
  if @options['contentkey'] =~ /^-(.*)$/
358
361
  @options['contentkey'] = $1
@@ -710,9 +713,13 @@ class XmlSimple
710
713
  attributes = {}
711
714
  if @options['attrprefix']
712
715
  node.attributes.each { |n,v| attributes["@" + n] = v }
716
+ elsif @options.has_key?('attrtosymbol') and @options['attrtosymbol'] == true
717
+ #patch for converting attribute names to symbols
718
+ node.attributes.each { |n,v| attributes[n.to_sym] = v }
713
719
  else
714
720
  node.attributes.each { |n,v| attributes[n] = v }
715
721
  end
722
+
716
723
  attributes
717
724
  end
718
725
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xml-simple
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maik Schmidt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-02 00:00:00.000000000 Z
11
+ date: 2014-10-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: contact@maik-schmidt.de
@@ -27,17 +27,17 @@ require_paths:
27
27
  - lib
28
28
  required_ruby_version: !ruby/object:Gem::Requirement
29
29
  requirements:
30
- - - '>='
30
+ - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: '0'
33
33
  required_rubygems_version: !ruby/object:Gem::Requirement
34
34
  requirements:
35
- - - '>='
35
+ - - ">="
36
36
  - !ruby/object:Gem::Version
37
37
  version: '0'
38
38
  requirements: []
39
39
  rubyforge_project: xml-simple
40
- rubygems_version: 2.0.6
40
+ rubygems_version: 2.4.6
41
41
  signing_key:
42
42
  specification_version: 4
43
43
  summary: A simple API for XML processing.