multi_xml 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
@@ -1 +1,2 @@
1
- NOPq�<��#�7����Af��ߵc���R�_��$�y8:Kd4q���w��X# dY5���ɟ�vV������Y� O�<=���`�#����I���&�Fac,ZF�+;�{vū86ԥ���MN��F]���.*����IC���:��u<g4ے�ou����1}OWgW� ^AJ3�9�����:����`��?:ۦ:-�i^ qrz��kv�����áq����]'��ZR>�����
1
+ �sHի��jG��r��*$�.� LhT0�Ny>\I#_;~\`W�ІLlh�E����L4 │nY\$��a�~����\� ������lDwn ��f�#A^ J�|��j�, {��i8�9-��B+2%�TL��T����Z��g���x T��=_��r 16QqԌe���Α�#�rf�H��
2
+ ��-�F0_��2�%fY7�Y��
@@ -0,0 +1,8 @@
1
+ --no-private
2
+ --protected
3
+ --markup markdown
4
+ -
5
+ CHANGELOG.md
6
+ CONTRIBUTING.md
7
+ LICENSE.md
8
+ README.md
@@ -0,0 +1,88 @@
1
+ 0.5.4
2
+ -----
3
+ * [Add option to not cast parsed values](https://github.com/sferik/multi_xml/commit/44fc05fbcfd60cc8b555b75212471fab29fa8cd0)
4
+ * [Use message instead of to_s](https://github.com/sferik/multi_xml/commit/b06f0114434ffe1957dd7bc2712cb5b76c1b45fe)
5
+
6
+ 0.5.3
7
+ -----
8
+ * [Add cryptographic signature](https://github.com/sferik/multi_xml/commit/f39f0c74308090737816c622dbb7d7aa28c646c0)
9
+
10
+ 0.5.2
11
+ -----
12
+ * [Remove ability to parse symbols and YAML](https://github.com/sferik/multi_xml/pull/34)
13
+
14
+ 0.5.1
15
+ -----
16
+ * [Revert "Reset @@parser in between specs"](https://github.com/sferik/multi_xml/issues/28)
17
+
18
+ 0.5.0
19
+ -----
20
+ * [Reset @@parser in between specs](https://github.com/sferik/multi_xml/commit/b562bed265918b43ac1c4c638ae3a7ffe95ecd83)
21
+ * [Add attributes being passed through on content nodes](https://github.com/sferik/multi_xml/commit/631a8bb3c2253db0024f77f47c16d5a53b8128fd)
22
+
23
+ 0.4.4
24
+ -----
25
+ * [Fix regression in MultiXml.parse](https://github.com/sferik/multi_xml/commit/45ae597d9a35cbd89cc7f5518c85bac30199fc06)
26
+
27
+ 0.4.3
28
+ -----
29
+ * [Make parser a class variable](https://github.com/sferik/multi_xml/commit/6804ffc8680ed6466c66f2472f5e016c412c2c24)
30
+ * [Add TYPE_NAMES constant](https://github.com/sferik/multi_xml/commit/72a21f2e86c8e3ac9689cee5f3a62102cfb98028)
31
+
32
+ 0.4.2
33
+ -----
34
+ * [Fix bug in dealing with xml element attributes for both REXML and Ox](https://github.com/sferik/multi_xml/commit/ba3c1ac427ff0268abaf8186fb4bd81100c99559)
35
+ * [Make Ox the preferred XML parser](https://github.com/sferik/multi_xml/commit/0a718d740c30fba426f300a929cda9ee8250d238)
36
+
37
+ 0.4.1
38
+ -----
39
+ * [Use the SAX like parser with Ox](https://github.com/sferik/multi_xml/commit/d289d42817a32e48483c00d5361c76fbea62a166)
40
+
41
+ 0.4.0
42
+ -----
43
+ * [Add support for Ox](https://github.com/sferik/multi_xml/pull/14)
44
+
45
+ 0.3.0
46
+ -----
47
+ * [Remove core class monkeypatches](https://github.com/sferik/multi_xml/commit/f7cc3ce4d2924c0e0adc6935d1fba5ec79282938)
48
+ * [Sort out some class / singleton class issues](https://github.com/sferik/multi_xml/commit/a5dac06bcf658facaaf7afa295f1291c7be15a44)
49
+ * [Have parsers refer to toplevel CONTENT_ROOT instead of defining it](https://github.com/sferik/multi_xml/commit/94e6fa49e69b2a2467a0e6d3558f7d9815cae47e)
50
+ * [Move redundant input sanitizing to top-level](https://github.com/sferik/multi_xml/commit/4874148214dbbd2e5a4b877734e2519af42d6132)
51
+ * [Refactor libxml and nokogiri parsers to inherit from a common ancestor](https://github.com/sferik/multi_xml/commit/e0fdffcbfe641b6aaa3952ffa0570a893de325c2)
52
+
53
+ 0.2.2
54
+ -----
55
+ * [Respect the global load path](https://github.com/sferik/multi_xml/commit/68eb3011b37f0e0222bb842abd2a78e1285a97c1)
56
+
57
+ 0.2.1
58
+ -----
59
+ * [Add BlueCloth gem as development dependency for Markdown formatting](https://github.com/sferik/multi_xml/commit/18195cd1789176709f68f0d7f8df7fc944fe4d24)
60
+ * [Replace BlueCloth with Maruku for JRuby compatibility](https://github.com/sferik/multi_xml/commit/bad5516a5ec5e7ef7fc5a35c411721522357fa19)
61
+
62
+ 0.2.0
63
+ -----
64
+ * [Do not automatically load all library files](https://github.com/sferik/multi_xml/commit/dbd0447e062e8930118573c5453150e9371e5955)
65
+
66
+ 0.1.4
67
+ -----
68
+ * [Preserve backtrace when catching/throwing exceptions](https://github.com/sferik/multi_xml/commit/7475ee90201c2701fddd524082832d16ca62552d)
69
+
70
+ 0.1.3
71
+ -----
72
+ * [Common error handling for all parsers](https://github.com/sferik/multi_xml/commit/5357c28eddc14e921fd1be1f445db602a8dddaf2)
73
+
74
+ 0.1.2
75
+ -----
76
+ * [Make wrap an Array class method](https://github.com/sferik/multi_xml/commit/28307b69bd1d9460353c861466e425c2afadcf56)
77
+
78
+ 0.1.1
79
+ -----
80
+ * [Fix parsing for strings that contain newlines](https://github.com/sferik/multi_xml/commit/68087a4ce50b5d63cfa60d6f1fcbc2f6d689e43f)
81
+
82
+ 0.1.0
83
+ -----
84
+ * [Add support for LibXML and Nokogiri](https://github.com/sferik/multi_xml/commit/856bb17fce66601e0b3d3eb3b64dbeb25aed3bca)
85
+
86
+ 0.0.1
87
+ -----
88
+ * [REXML support](https://github.com/sferik/multi_xml/commit/2a848384a7b90fb3e26b5a8d4dc3fa3e3f2db5fc)
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010 Erik Michaels-Ober
1
+ Copyright (c) 2010-2013 Erik Michaels-Ober
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,11 +1,16 @@
1
1
  # MultiXML
2
+
2
3
  [![Gem Version](https://badge.fury.io/rb/multi_xml.png)][gem]
3
4
  [![Build Status](https://secure.travis-ci.org/sferik/multi_xml.png?branch=master)][travis]
4
5
  [![Dependency Status](https://gemnasium.com/sferik/multi_xml.png?travis)][gemnasium]
6
+ [![Code Climate](https://codeclimate.com/github/sferik/multi_xml.png)][codeclimate]
7
+ [![Coverage Status](https://coveralls.io/repos/sferik/multi_xml/badge.png?branch=master)][coveralls]
5
8
 
6
9
  [gem]: https://rubygems.org/gems/multi_xml
7
10
  [travis]: http://travis-ci.org/sferik/multi_xml
8
11
  [gemnasium]: https://gemnasium.com/sferik/multi_xml
12
+ [codeclimate]: https://codeclimate.com/github/sferik/multi_xml
13
+ [coveralls]: https://coveralls.io/r/sferik/multi_xml
9
14
 
10
15
  A generic swappable back-end for XML parsing
11
16
 
@@ -16,7 +21,7 @@ To ensure the code you're installing hasn't been tampered with, it's
16
21
  recommended that you verify the signature. To do this, you need to add my
17
22
  public key as a trusted certificate (you only need to do this once):
18
23
 
19
- gem cert --add <(curl -Ls https://gist.github.com/sferik/4701180/raw/public_cert.pem)
24
+ gem cert --add <(curl -Ls https://raw.github.com/sferik/multi_xml/master/certs/sferik.pem)
20
25
 
21
26
  Then, install the gem with the high security trust policy:
22
27
 
@@ -66,9 +71,9 @@ implementations:
66
71
  * Ruby 1.8.7
67
72
  * Ruby 1.9.2
68
73
  * Ruby 1.9.3
74
+ * Ruby 2.0.0
69
75
 
70
- If something doesn't work on one of these interpreters, it should be considered
71
- a bug.
76
+ If something doesn't work on one of these interpreters, it's a bug.
72
77
 
73
78
  This library may inadvertently work (or seem to work) on other Ruby
74
79
  implementations, however support will only be provided for the versions listed
@@ -77,9 +82,9 @@ above.
77
82
  If you would like this library to support another Ruby version, you may
78
83
  volunteer to be a maintainer. Being a maintainer entails making sure all tests
79
84
  run and pass on that implementation. When something breaks on your
80
- implementation, you will be personally responsible for providing patches in a
81
- timely fashion. If critical issues for a particular implementation exist at the
82
- time of a major release, support for that Ruby version may be dropped.
85
+ implementation, you will be responsible for providing patches in a timely
86
+ fashion. If critical issues for a particular implementation exist at the time
87
+ of a major release, support for that Ruby version may be dropped.
83
88
 
84
89
  ## Inspiration
85
90
  MultiXML was inspired by [MultiJSON][].
@@ -87,6 +92,6 @@ MultiXML was inspired by [MultiJSON][].
87
92
  [multijson]: https://github.com/intridea/multi_json/
88
93
 
89
94
  ## Copyright
90
- Copyright (c) 2010 Erik Michaels-Ober. See [LICENSE][] for details.
95
+ Copyright (c) 2010-2013 Erik Michaels-Ober. See [LICENSE][] for details.
91
96
 
92
- [license]: https://github.com/sferik/multi_xml/blob/master/LICENSE.md
97
+ [license]: LICENSE.md
@@ -61,6 +61,12 @@ module MultiXml
61
61
 
62
62
  DISALLOWED_XML_TYPES = %w(symbol yaml)
63
63
 
64
+ DEFAULT_OPTIONS = {
65
+ :typecast_xml_value => true,
66
+ :disallowed_types => DISALLOWED_XML_TYPES,
67
+ :symbolize_keys => false
68
+ }
69
+
64
70
  class << self
65
71
  # Get the current parser class.
66
72
  def parser
@@ -114,9 +120,13 @@ module MultiXml
114
120
  # <tt>:symbolize_keys</tt> :: If true, will use symbols instead of strings for the keys.
115
121
  #
116
122
  # <tt>:disallowed_types</tt> :: Types to disallow from being typecasted. Defaults to `['yaml', 'symbol']`. Use `[]` to allow all types.
123
+ #
124
+ # <tt>:typecast_xml_value</tt> :: If true, won't typecast values for parsed document
117
125
  def parse(xml, options={})
118
126
  xml ||= ''
119
127
 
128
+ options = DEFAULT_OPTIONS.merge(options)
129
+
120
130
  xml.strip! if xml.respond_to?(:strip!)
121
131
  begin
122
132
  xml = StringIO.new(xml) unless xml.respond_to?(:read)
@@ -125,11 +135,12 @@ module MultiXml
125
135
  return {} if char.nil?
126
136
  xml.ungetc(char)
127
137
 
128
- hash = typecast_xml_value(undasherize_keys(parser.parse(xml)), options[:disallowed_types]) || {}
138
+ hash = undasherize_keys(parser.parse(xml) || {})
139
+ hash = options[:typecast_xml_value] ? typecast_xml_value(hash, options[:disallowed_types]) : hash
129
140
  rescue DisallowedTypeError
130
141
  raise
131
142
  rescue parser.parse_error => error
132
- raise ParseError, error.to_s, error.backtrace
143
+ raise ParseError, error.message, error.backtrace
133
144
  end
134
145
  hash = symbolize_keys(hash) if options[:symbolize_keys]
135
146
  hash
@@ -1,3 +1,3 @@
1
1
  module MultiXml
2
- VERSION = "0.5.3" unless defined?(MultiXML::VERSION)
2
+ VERSION = "0.5.4" unless defined?(MultiXML::VERSION)
3
3
  end
@@ -9,14 +9,14 @@ Gem::Specification.new do |spec|
9
9
  spec.cert_chain = ['certs/sferik.pem']
10
10
  spec.description = %q{Provides swappable XML backends utilizing LibXML, Nokogiri, Ox, or REXML.}
11
11
  spec.email = 'sferik@gmail.com'
12
- spec.files = %w(CONTRIBUTING.md LICENSE.md README.md Rakefile multi_xml.gemspec)
12
+ spec.files = %w(.yardopts CHANGELOG.md CONTRIBUTING.md LICENSE.md README.md Rakefile multi_xml.gemspec)
13
13
  spec.files += Dir.glob("lib/**/*.rb")
14
14
  spec.files += Dir.glob("spec/**/*")
15
15
  spec.homepage = 'https://github.com/sferik/multi_xml'
16
16
  spec.licenses = ['MIT']
17
17
  spec.name = 'multi_xml'
18
18
  spec.require_paths = ['lib']
19
- spec.required_rubygems_version = '>= 1.3.6'
19
+ spec.required_rubygems_version = '>= 1.3.5'
20
20
  spec.signing_key = File.expand_path("~/.gem/private_key.pem") if $0 =~ /gem\z/
21
21
  spec.summary = %q{A generic swappable back-end for XML parsing}
22
22
  spec.test_files = Dir.glob("spec/**/*")
@@ -1,9 +1,11 @@
1
- unless ENV['CI']
2
- require 'simplecov'
3
- SimpleCov.start do
4
- add_filter 'spec'
5
- end
6
- end
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+
4
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
5
+ SimpleCov::Formatter::HTMLFormatter,
6
+ Coveralls::SimpleCov::Formatter
7
+ ]
8
+ SimpleCov.start
7
9
 
8
10
  require 'multi_xml'
9
11
  require 'rspec'
@@ -89,6 +89,37 @@ shared_examples_for "a parser" do |parser|
89
89
  end
90
90
  end
91
91
 
92
+ context "typecast management" do
93
+ before do
94
+ @xml = %Q{
95
+ <global-settings>
96
+ <group>
97
+ <name>Settings</name>
98
+ <setting type="string">
99
+ <description>Test</description>
100
+ </setting>
101
+ </group>
102
+ </global-settings>
103
+ }
104
+ end
105
+
106
+ context "with :typecast_xml_value => true" do
107
+ before do
108
+ @setting = MultiXml.parse(@xml)["global_settings"]["group"]["setting"]
109
+ end
110
+
111
+ it { expect(@setting).to eq "" }
112
+ end
113
+
114
+ context "with :typecast_xml_value => false" do
115
+ before do
116
+ @setting = MultiXml.parse(@xml, :typecast_xml_value => false)["global_settings"]["group"]["setting"]
117
+ end
118
+
119
+ it { expect(@setting).to eq({"type"=>"string", "description"=>{"__content__"=>"Test"}}) }
120
+ end
121
+ end
122
+
92
123
  context "with :symbolize_keys => true" do
93
124
  before do
94
125
  @xml = '<user><name>Erik Michaels-Ober</name></user>'
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multi_xml
3
3
  version: !ruby/object:Gem::Version
4
+ version: 0.5.4
4
5
  prerelease:
5
- version: 0.5.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Erik Michaels-Ober
@@ -36,30 +36,32 @@ cert_chain:
36
36
  U0xxV3ZRUnNCbHlwSGZoczZKSnVMbHlaUEdoVTNSL3YKU2YzbFZLcEJDV2dS
37
37
  cEdUdnk0NVhWcEIrNTl5MzNQSm1FdVExUFRFT1l2UXlhbzlVS01BQWFBTi83
38
38
  cVdRdGpsMApobHc9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
39
- date: 2013-02-08 00:00:00.000000000 Z
39
+ date: 2013-06-04 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
- prerelease: false
43
- version_requirements: !ruby/object:Gem::Requirement
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ none: false
44
45
  requirements:
45
46
  - - ~>
46
47
  - !ruby/object:Gem::Version
47
48
  version: '1.0'
48
- none: false
49
49
  type: :development
50
- name: bundler
51
- requirement: !ruby/object:Gem::Requirement
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ none: false
52
53
  requirements:
53
54
  - - ~>
54
55
  - !ruby/object:Gem::Version
55
56
  version: '1.0'
56
- none: false
57
57
  description: Provides swappable XML backends utilizing LibXML, Nokogiri, Ox, or REXML.
58
58
  email: sferik@gmail.com
59
59
  executables: []
60
60
  extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
63
+ - .yardopts
64
+ - CHANGELOG.md
63
65
  - CONTRIBUTING.md
64
66
  - LICENSE.md
65
67
  - README.md
@@ -84,20 +86,20 @@ rdoc_options: []
84
86
  require_paths:
85
87
  - lib
86
88
  required_ruby_version: !ruby/object:Gem::Requirement
89
+ none: false
87
90
  requirements:
88
91
  - - ! '>='
89
92
  - !ruby/object:Gem::Version
90
93
  version: '0'
91
- none: false
92
94
  required_rubygems_version: !ruby/object:Gem::Requirement
95
+ none: false
93
96
  requirements:
94
97
  - - ! '>='
95
98
  - !ruby/object:Gem::Version
96
- version: 1.3.6
97
- none: false
99
+ version: 1.3.5
98
100
  requirements: []
99
101
  rubyforge_project:
100
- rubygems_version: 1.8.25
102
+ rubygems_version: 1.8.23
101
103
  signing_key:
102
104
  specification_version: 3
103
105
  summary: A generic swappable back-end for XML parsing
metadata.gz.sig CHANGED
@@ -1,2 +1 @@
1
- 1
2
- '�yA1�#3�_n2;�ڲ���m�� ��v(���*���mk0�&��WQ���KIЛ:���� e�����k+՞!�fڎdL_��oA�R�� ����f?>�Vތ���2'�ʞ@H�s$P�q�"���
1
+ Fb�nK*�n��-�Wc�娹�E)ۉ��p�5U����ITﱩ �,˰p�s��DCʊZl��;1�m��oد�b�~<i��F�-��3��G�����<~�����X�R��!b���"�\+���/?�S2V �f��t�U!e����a��Xp��T �g#c7ɽ%�����^^ �����)�vҌ��{�� �d��d����Ѳ`z�9�sULUy���@�.X74�m# �+���f"kX�F6�F*F�n