roxml 3.2.2 → 4.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +13 -0
- data/Gemfile +9 -6
- data/Gemfile.lock +98 -40
- data/History.txt +15 -0
- data/README.rdoc +3 -2
- data/Rakefile +9 -21
- data/VERSION +1 -1
- data/examples/search_query.rb +17 -0
- data/lib/roxml.rb +9 -3
- data/lib/roxml/definition.rb +4 -9
- data/lib/roxml/xml/parsers/libxml.rb +11 -27
- data/lib/roxml/xml/parsers/nokogiri.rb +13 -26
- data/lib/roxml/xml/references.rb +33 -21
- data/roxml.gemspec +40 -40
- data/spec/definition_spec.rb +85 -104
- data/spec/examples/active_record_spec.rb +13 -13
- data/spec/examples/amazon_spec.rb +13 -13
- data/spec/examples/current_weather_spec.rb +6 -6
- data/spec/examples/dashed_elements_spec.rb +3 -3
- data/spec/examples/library_spec.rb +3 -3
- data/spec/examples/library_with_fines_spec.rb +7 -7
- data/spec/examples/person_spec.rb +27 -27
- data/spec/examples/post_spec.rb +4 -4
- data/spec/examples/search_query_spec.rb +26 -0
- data/spec/examples/twitter_spec.rb +4 -4
- data/spec/reference_spec.rb +2 -2
- data/spec/regression_spec.rb +13 -8
- data/spec/roxml_spec.rb +56 -61
- data/spec/shared_specs.rb +2 -2
- data/spec/spec_helper.rb +2 -0
- data/spec/xml/array_spec.rb +2 -2
- data/spec/xml/attributes_spec.rb +7 -7
- data/spec/xml/encoding_spec.rb +9 -9
- data/spec/xml/namespace_spec.rb +40 -21
- data/spec/xml/namespaces_spec.rb +3 -3
- data/spec/xml/object_spec.rb +7 -7
- data/spec/xml/parser_spec.rb +2 -8
- data/spec/xml/text_spec.rb +6 -6
- data/test/fixtures/book_with_octal_pages.xml +2 -3
- data/test/test_helper.rb +1 -2
- data/test/unit/definition_test.rb +26 -27
- data/test/unit/deprecations_test.rb +23 -2
- data/test/unit/to_xml_test.rb +9 -9
- data/test/unit/xml_attribute_test.rb +3 -2
- data/test/unit/xml_block_test.rb +3 -2
- data/test/unit/xml_bool_test.rb +7 -8
- data/test/unit/xml_convention_test.rb +4 -3
- data/test/unit/xml_hash_test.rb +5 -13
- data/test/unit/xml_initialize_test.rb +4 -3
- data/test/unit/xml_name_test.rb +3 -2
- data/test/unit/xml_namespace_test.rb +4 -3
- data/test/unit/xml_object_test.rb +8 -7
- data/test/unit/xml_required_test.rb +7 -6
- data/test/unit/xml_text_test.rb +3 -2
- data/website/index.html +11 -11
- metadata +114 -61
- data/test/load_test.rb +0 -6
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 27c567c0681f6d38e5b3741668cde44eee9b32f150d9a11d52ea5d0c1c8a4551
|
4
|
+
data.tar.gz: 8f964263300741e8973287b94a7496050e2432a436bab8064b41ac2b07050860
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 77d2448797f6c7055531b4ced3df08bf0012dbcc3d93042583aaaad4b593a46bbd765cfeb0738c6e5630b78528058f60d35fe9f7d4ce6bd6ce65355961c916bc
|
7
|
+
data.tar.gz: '08e0090edc8a2090a39d0f3675e363ae92983581cdfe9449a7c12eb9228b178ef750a56addcfb6bcd1a90c07d924b5faa73a6bb8b60729ba14f87ca5fef366a4'
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
|
-
gem 'activesupport', '>=
|
3
|
+
gem 'activesupport', '>= 4.0'
|
4
4
|
gem 'nokogiri', '>= 1.3.3'
|
5
5
|
|
6
6
|
group :development, :test do
|
7
|
-
gem 'rake'
|
8
|
-
gem '
|
9
|
-
gem
|
10
|
-
gem
|
11
|
-
gem
|
7
|
+
gem 'rake', '~> 0.9'
|
8
|
+
gem 'juwelier'
|
9
|
+
gem 'minitest'
|
10
|
+
gem 'rspec', '~> 3.7.0'
|
11
|
+
gem 'sqlite3', '>= 1.2.4'
|
12
|
+
gem 'activerecord', '>= 4.0'
|
13
|
+
gem 'rack', '< 2.0.0'
|
14
|
+
gem 'equivalent-xml', '>= 0.6.0'
|
12
15
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,50 +1,108 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activemodel (3.1
|
5
|
-
activesupport (= 3.1
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
4
|
+
activemodel (6.0.3.1)
|
5
|
+
activesupport (= 6.0.3.1)
|
6
|
+
activerecord (6.0.3.1)
|
7
|
+
activemodel (= 6.0.3.1)
|
8
|
+
activesupport (= 6.0.3.1)
|
9
|
+
activesupport (6.0.3.1)
|
10
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
11
|
+
i18n (>= 0.7, < 2)
|
12
|
+
minitest (~> 5.1)
|
13
|
+
tzinfo (~> 1.1)
|
14
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
15
|
+
addressable (2.7.0)
|
16
|
+
public_suffix (>= 2.0.2, < 5.0)
|
17
|
+
builder (3.2.4)
|
18
|
+
concurrent-ruby (1.1.6)
|
19
|
+
descendants_tracker (0.0.4)
|
20
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
21
|
+
diff-lcs (1.3)
|
22
|
+
equivalent-xml (0.6.0)
|
23
|
+
nokogiri (>= 1.4.3)
|
24
|
+
faraday (0.17.3)
|
25
|
+
multipart-post (>= 1.2, < 3)
|
26
|
+
git (1.7.0)
|
27
|
+
rchardet (~> 1.8)
|
28
|
+
github_api (0.18.2)
|
29
|
+
addressable (~> 2.4)
|
30
|
+
descendants_tracker (~> 0.0.4)
|
31
|
+
faraday (~> 0.8)
|
32
|
+
hashie (~> 3.5, >= 3.5.2)
|
33
|
+
oauth2 (~> 1.0)
|
34
|
+
hashie (3.6.0)
|
35
|
+
highline (2.0.3)
|
36
|
+
i18n (1.8.3)
|
37
|
+
concurrent-ruby (~> 1.0)
|
38
|
+
juwelier (2.4.9)
|
39
|
+
builder
|
40
|
+
bundler
|
41
|
+
git
|
42
|
+
github_api
|
43
|
+
highline
|
44
|
+
kamelcase (~> 0)
|
45
|
+
nokogiri
|
46
|
+
psych
|
23
47
|
rake
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
48
|
+
rdoc
|
49
|
+
semver2
|
50
|
+
jwt (2.2.1)
|
51
|
+
kamelcase (0.0.2)
|
52
|
+
semver2 (~> 3)
|
53
|
+
mini_portile2 (2.4.0)
|
54
|
+
minitest (5.14.1)
|
55
|
+
multi_json (1.14.1)
|
56
|
+
multi_xml (0.6.0)
|
57
|
+
multipart-post (2.1.1)
|
58
|
+
nokogiri (1.10.9)
|
59
|
+
mini_portile2 (~> 2.4.0)
|
60
|
+
oauth2 (1.4.4)
|
61
|
+
faraday (>= 0.8, < 2.0)
|
62
|
+
jwt (>= 1.0, < 3.0)
|
63
|
+
multi_json (~> 1.3)
|
64
|
+
multi_xml (~> 0.5)
|
65
|
+
rack (>= 1.2, < 3)
|
66
|
+
psych (3.1.0)
|
67
|
+
public_suffix (4.0.5)
|
68
|
+
rack (1.6.13)
|
69
|
+
rake (0.9.6)
|
70
|
+
rchardet (1.8.0)
|
71
|
+
rdoc (6.2.1)
|
72
|
+
rspec (3.7.0)
|
73
|
+
rspec-core (~> 3.7.0)
|
74
|
+
rspec-expectations (~> 3.7.0)
|
75
|
+
rspec-mocks (~> 3.7.0)
|
76
|
+
rspec-core (3.7.1)
|
77
|
+
rspec-support (~> 3.7.0)
|
78
|
+
rspec-expectations (3.7.0)
|
79
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
80
|
+
rspec-support (~> 3.7.0)
|
81
|
+
rspec-mocks (3.7.0)
|
82
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
83
|
+
rspec-support (~> 3.7.0)
|
84
|
+
rspec-support (3.7.1)
|
85
|
+
semver2 (3.4.2)
|
86
|
+
sqlite3 (1.4.2)
|
87
|
+
thread_safe (0.3.6)
|
88
|
+
tzinfo (1.2.7)
|
89
|
+
thread_safe (~> 0.1)
|
90
|
+
zeitwerk (2.3.0)
|
39
91
|
|
40
92
|
PLATFORMS
|
41
93
|
ruby
|
42
94
|
|
43
95
|
DEPENDENCIES
|
44
|
-
activerecord (>=
|
45
|
-
activesupport (>=
|
46
|
-
|
96
|
+
activerecord (>= 4.0)
|
97
|
+
activesupport (>= 4.0)
|
98
|
+
equivalent-xml (>= 0.6.0)
|
99
|
+
juwelier
|
100
|
+
minitest
|
47
101
|
nokogiri (>= 1.3.3)
|
48
|
-
|
49
|
-
|
50
|
-
|
102
|
+
rack (< 2.0.0)
|
103
|
+
rake (~> 0.9)
|
104
|
+
rspec (~> 3.7.0)
|
105
|
+
sqlite3 (>= 1.2.4)
|
106
|
+
|
107
|
+
BUNDLED WITH
|
108
|
+
1.17.3
|
data/History.txt
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
See github releases for versions > 3.3.1
|
2
|
+
https://github.com/Empact/roxml/releases
|
3
|
+
|
4
|
+
== 3.3.1 (February 10, 2012)
|
5
|
+
|
6
|
+
* bug fix
|
7
|
+
|
8
|
+
* Fix reading of VERSION file - Jari Bakken (jarib)
|
9
|
+
|
10
|
+
== 3.3.0 (February 9, 2012)
|
11
|
+
|
12
|
+
* major enhancement
|
13
|
+
|
14
|
+
* Don't extend/modify the XML parser
|
15
|
+
|
1
16
|
== 3.1.6 (September 9, 2010)
|
2
17
|
|
3
18
|
* bug fix
|
data/README.rdoc
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
ROXML Ruby Object to XML mapping library.
|
2
2
|
|
3
|
+
{<img src="https://travis-ci.org/Empact/roxml.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/Empact/roxml]
|
4
|
+
|
3
5
|
For more information visit:
|
4
6
|
|
5
7
|
http://rdoc.info/projects/Empact/roxml
|
6
8
|
http://empact.github.com/roxml/
|
7
|
-
http://rubyforge.org/projects/roxml/
|
8
9
|
|
9
10
|
Please submit bugs here:
|
10
11
|
|
@@ -171,7 +172,7 @@ explicitly require one or the other, you may do the following:
|
|
171
172
|
For more information on available annotations, see ROXML::ClassMethods::Declarations
|
172
173
|
|
173
174
|
== Note on Patches/Pull Requests
|
174
|
-
|
175
|
+
|
175
176
|
* Fork the project.
|
176
177
|
* Make your feature addition or bug fix.
|
177
178
|
* Add specs for it. This is important so I don't break it in a
|
data/Rakefile
CHANGED
@@ -4,10 +4,9 @@ ENV['RUBY_FLAGS'] = '-W1'
|
|
4
4
|
|
5
5
|
# Generate all the Rake tasks
|
6
6
|
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
7
|
-
require '
|
8
|
-
|
7
|
+
require 'juwelier'
|
8
|
+
Juwelier::Tasks.new do |gem|
|
9
9
|
gem.name = 'roxml'
|
10
|
-
gem.rubyforge_project = "roxml"
|
11
10
|
gem.summary = "Ruby Object to XML mapping library"
|
12
11
|
gem.description = <<EOF
|
13
12
|
ROXML is a Ruby library designed to make it easier for Ruby developers to work with XML.
|
@@ -17,28 +16,24 @@ building first-class Ruby classes. As a result, ROXML simplifies the development
|
|
17
16
|
RESTful applications, Web Services, and XML-RPC.
|
18
17
|
EOF
|
19
18
|
gem.email = "ben.woosley@gmail.com"
|
20
|
-
gem.homepage = "
|
19
|
+
gem.homepage = "https://github.com/Empact/roxml"
|
21
20
|
gem.authors = ["Ben Woosley", "Zak Mandhro", "Anders Engstrom", "Russ Olsen"]
|
22
21
|
|
23
22
|
gem.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.rdoc"]
|
24
23
|
end
|
25
|
-
|
24
|
+
Juwelier::GemcutterTasks.new
|
26
25
|
|
27
26
|
Dir['tasks/**/*.rake'].each { |t| load t }
|
28
27
|
|
29
|
-
task :default => [:test, :spec
|
30
|
-
task :all => [:libxml, :nokogiri
|
28
|
+
task :default => [:test, :spec]
|
29
|
+
task :all => [:libxml, :nokogiri]
|
31
30
|
task :libxml => ['test:libxml', 'spec:libxml']
|
32
31
|
task :nokogiri => ['test:nokogiri', 'spec:nokogiri']
|
33
32
|
|
34
33
|
|
35
34
|
require 'rdoc/task'
|
36
35
|
RDoc::Task.new do |rdoc|
|
37
|
-
|
38
|
-
version = File.read('VERSION')
|
39
|
-
else
|
40
|
-
version = ""
|
41
|
-
end
|
36
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
42
37
|
|
43
38
|
rdoc.rdoc_dir = 'rdoc'
|
44
39
|
rdoc.title = "roxml #{version}"
|
@@ -72,10 +67,8 @@ end
|
|
72
67
|
|
73
68
|
require 'rake/testtask'
|
74
69
|
desc "Test ROXML using the default parser selection behavior"
|
75
|
-
|
76
|
-
|
77
|
-
$LOAD_PATH << '.'
|
78
|
-
Rake.run_tests 'test/unit/*_test.rb'
|
70
|
+
Rake::TestTask.new do |t|
|
71
|
+
t.test_files = FileList['test/**/*_test.rb']
|
79
72
|
end
|
80
73
|
|
81
74
|
namespace :test do
|
@@ -93,11 +86,6 @@ namespace :test do
|
|
93
86
|
Rake::Task["test"].invoke
|
94
87
|
end
|
95
88
|
|
96
|
-
task :load do
|
97
|
-
`ruby test/load_test.rb`
|
98
|
-
puts "Load Success!" if $?.success?
|
99
|
-
end
|
100
|
-
|
101
89
|
desc "Runs tests under RCOV"
|
102
90
|
task :rcov do
|
103
91
|
system "rcov -T --no-html -x '^/' #{FileList['test/unit/*_test.rb']}"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
4.1.1
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require_relative './../spec/spec_helper'
|
3
|
+
|
4
|
+
class SearchQuery
|
5
|
+
include ROXML
|
6
|
+
xml_accessor :query
|
7
|
+
xml_accessor :max_results, :else => 20, :as => Integer
|
8
|
+
xml_accessor :language, :else => 'EN'
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
unless defined?(RSpec)
|
13
|
+
q = SearchQuery.new
|
14
|
+
q.query = "Some random query string."
|
15
|
+
puts q.to_xml.to_s
|
16
|
+
end
|
17
|
+
|
data/lib/roxml.rb
CHANGED
@@ -14,7 +14,7 @@ require 'roxml/definition'
|
|
14
14
|
require 'roxml/xml'
|
15
15
|
|
16
16
|
module ROXML # :nodoc:
|
17
|
-
VERSION =
|
17
|
+
VERSION = File.read(File.expand_path("../../VERSION", __FILE__))
|
18
18
|
|
19
19
|
def self.included(base) # :nodoc:
|
20
20
|
base.class_eval do
|
@@ -42,6 +42,9 @@ module ROXML # :nodoc:
|
|
42
42
|
ref.update_xml(root, value)
|
43
43
|
end
|
44
44
|
end
|
45
|
+
if params[:namespaces]
|
46
|
+
params[:namespaces].each { |prefix, url| root.add_namespace_definition(prefix, url) }
|
47
|
+
end
|
45
48
|
end
|
46
49
|
end
|
47
50
|
end
|
@@ -260,7 +263,7 @@ module ROXML # :nodoc:
|
|
260
263
|
#
|
261
264
|
# xml_reader(:count) {|val| Integer(val) unless val.empty? }
|
262
265
|
#
|
263
|
-
# Such block shorthands for Integer, Float,
|
266
|
+
# Such block shorthands for Integer, Float, BigDecimal, Date, Time, and DateTime
|
264
267
|
# are currently available, but only for non-Hash declarations.
|
265
268
|
#
|
266
269
|
# To reference many elements, put the desired type in a literal array. e.g.:
|
@@ -434,7 +437,7 @@ module ROXML # :nodoc:
|
|
434
437
|
# === Other Options
|
435
438
|
# [:in] An optional name of a wrapping tag for this XML accessor.
|
436
439
|
# This can include other xpath values, which will be joined with :from with a '/'
|
437
|
-
# [:else] Default value for attribute, if missing from the xml on .from_xml
|
440
|
+
# [:else] Default value for attribute, if missing from the xml (or it's there but its contents are blank) on .from_xml
|
438
441
|
# [:required] If true, throws RequiredElementMissing when the element isn't present
|
439
442
|
# [:frozen] If true, all results are frozen (using #freeze) at parse-time.
|
440
443
|
# [:cdata] true for values which should be input from or output as cdata elements
|
@@ -479,6 +482,9 @@ module ROXML # :nodoc:
|
|
479
482
|
private
|
480
483
|
def add_reader(attr)
|
481
484
|
define_method(attr.accessor) do
|
485
|
+
if instance_variable_get(attr.instance_variable_name).nil?
|
486
|
+
instance_variable_set(attr.instance_variable_name, attr.default)
|
487
|
+
end
|
482
488
|
instance_variable_get(attr.instance_variable_name)
|
483
489
|
end
|
484
490
|
end
|
data/lib/roxml/definition.rb
CHANGED
@@ -60,7 +60,7 @@ module ROXML
|
|
60
60
|
@sought_type = :namespace
|
61
61
|
elsif opts[:from].to_s.starts_with?('@')
|
62
62
|
@sought_type = :attr
|
63
|
-
opts[:from].sub
|
63
|
+
opts[:from] = opts[:from].sub('@', '')
|
64
64
|
end
|
65
65
|
|
66
66
|
@name = @attr_name = accessor.to_s.chomp('?')
|
@@ -140,12 +140,12 @@ module ROXML
|
|
140
140
|
default
|
141
141
|
end
|
142
142
|
end
|
143
|
-
|
143
|
+
|
144
144
|
CORE_BLOCK_SHORTHANDS = {
|
145
145
|
# Core Shorthands
|
146
146
|
Integer => lambda do |val|
|
147
147
|
all(val) do |v|
|
148
|
-
|
148
|
+
v.to_i unless v.blank?
|
149
149
|
end
|
150
150
|
end,
|
151
151
|
Float => lambda do |val|
|
@@ -153,11 +153,6 @@ module ROXML
|
|
153
153
|
Float(v) unless v.blank?
|
154
154
|
end
|
155
155
|
end,
|
156
|
-
Fixnum => lambda do |val|
|
157
|
-
all(val) do |v|
|
158
|
-
v.to_i unless v.blank?
|
159
|
-
end
|
160
|
-
end,
|
161
156
|
Time => lambda do |val|
|
162
157
|
all(val) {|v| Time.parse(v) unless v.blank? }
|
163
158
|
end,
|
@@ -181,7 +176,7 @@ module ROXML
|
|
181
176
|
CORE_BLOCK_SHORTHANDS.tap do |blocks|
|
182
177
|
blocks.reverse_merge!(BigDecimal => lambda do |val|
|
183
178
|
all(val) do |v|
|
184
|
-
BigDecimal
|
179
|
+
BigDecimal(v) unless v.blank?
|
185
180
|
end
|
186
181
|
end) if defined?(BigDecimal)
|
187
182
|
|
@@ -44,42 +44,26 @@ module ROXML
|
|
44
44
|
def save_doc(doc, path)
|
45
45
|
doc.save(path)
|
46
46
|
end
|
47
|
-
end
|
48
47
|
|
49
|
-
|
50
|
-
|
48
|
+
def default_namespace(doc)
|
49
|
+
doc = doc.doc if doc.respond_to?(:doc)
|
50
|
+
default = doc.root.namespaces.default
|
51
|
+
default.prefix || 'xmlns' if default
|
52
|
+
end
|
51
53
|
|
52
|
-
|
53
|
-
|
54
|
-
if namespaces.default
|
54
|
+
def search(xml, xpath, roxml_namespaces = {})
|
55
|
+
if xml.namespaces.default
|
55
56
|
roxml_namespaces = {:xmlns => namespaces.default.href}.merge(roxml_namespaces)
|
56
57
|
end
|
57
58
|
if roxml_namespaces.present?
|
58
|
-
find(xpath, roxml_namespaces.map {|prefix, href| [prefix, href].join(':') })
|
59
|
+
xml.find(xpath, roxml_namespaces.map {|prefix, href| [prefix, href].join(':') })
|
59
60
|
else
|
60
|
-
find(xpath)
|
61
|
+
xml.find(xpath)
|
61
62
|
end
|
62
63
|
end
|
63
64
|
end
|
64
65
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
def default_namespace
|
69
|
-
default = namespaces.default
|
70
|
-
default.prefix || 'xmlns' if default
|
71
|
-
end
|
72
|
-
|
73
|
-
private
|
74
|
-
delegate :namespaces, :to => :root
|
75
|
-
end
|
76
|
-
|
77
|
-
class Node
|
78
|
-
include NamespacedSearch
|
79
|
-
|
80
|
-
def default_namespace
|
81
|
-
doc.default_namespace
|
82
|
-
end
|
83
|
-
end
|
66
|
+
Document = LibXML::XML::Document
|
67
|
+
Node = LibXML::XML::Node
|
84
68
|
end
|
85
69
|
end
|