Empact-roxml 2.5.1 → 2.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/History.txt +25 -0
  2. data/Manifest.txt +0 -4
  3. data/README.rdoc +12 -2
  4. data/examples/posts.rb +1 -1
  5. data/examples/twitter.rb +1 -1
  6. data/lib/roxml.rb +59 -149
  7. data/lib/roxml/definition.rb +60 -150
  8. data/lib/roxml/extensions.rb +4 -1
  9. data/lib/roxml/extensions/array/conversions.rb +0 -23
  10. data/lib/roxml/extensions/deprecation.rb +1 -1
  11. data/lib/roxml/extensions/string.rb +0 -15
  12. data/lib/roxml/extensions/string/conversions.rb +0 -38
  13. data/lib/roxml/hash_definition.rb +5 -40
  14. data/lib/roxml/xml/references.rb +20 -8
  15. data/roxml.gemspec +4 -4
  16. data/spec/definition_spec.rb +120 -193
  17. data/spec/examples/library_spec.rb +8 -3
  18. data/spec/examples/post_spec.rb +1 -1
  19. data/spec/roxml_spec.rb +14 -14
  20. data/test/bugs/rexml_bugs.rb +1 -1
  21. data/test/mocks/dictionaries.rb +8 -7
  22. data/test/mocks/mocks.rb +19 -19
  23. data/test/test_helper.rb +1 -0
  24. data/test/unit/definition_test.rb +22 -96
  25. data/test/unit/deprecations_test.rb +1 -74
  26. data/test/unit/to_xml_test.rb +6 -6
  27. data/test/unit/xml_attribute_test.rb +1 -1
  28. data/test/unit/xml_block_test.rb +3 -3
  29. data/test/unit/xml_bool_test.rb +4 -4
  30. data/test/unit/xml_convention_test.rb +3 -3
  31. data/test/unit/xml_hash_test.rb +5 -14
  32. data/test/unit/xml_initialize_test.rb +2 -6
  33. data/test/unit/xml_name_test.rb +5 -24
  34. data/test/unit/xml_namespace_test.rb +2 -2
  35. data/test/unit/xml_object_test.rb +5 -5
  36. data/test/unit/xml_required_test.rb +1 -1
  37. data/test/unit/xml_text_test.rb +2 -2
  38. metadata +12 -17
  39. data/lib/roxml/extensions/active_support.rb +0 -54
  40. data/spec/string_spec.rb +0 -15
  41. data/test/release/dependencies_test.rb +0 -32
  42. data/test/unit/xml_construct_test.rb +0 -77
@@ -1,54 +0,0 @@
1
- require 'rubygems'
2
- require 'active_support/core_ext/symbol'
3
- require 'active_support/core_ext/blank'
4
- require 'active_support/core_ext/duplicable'
5
- require 'active_support/core_ext/array/extract_options'
6
-
7
- class Array #:nodoc:
8
- include ActiveSupport::CoreExtensions::Array::ExtractOptions
9
- end
10
-
11
- require 'active_support/core_ext/hash/reverse_merge'
12
- require 'active_support/core_ext/module/delegation'
13
- require 'active_support/core_ext/module/aliasing'
14
- require 'active_support/core_ext/module/attribute_accessors'
15
- require 'active_support/core_ext/object/misc' # returning
16
- require 'active_support/inflector'
17
- require 'active_support/multibyte'
18
- require 'active_support/core_ext/string'
19
- class String
20
- # This conflicts with builder, unless builder is required first, which we don't want to force on people
21
- undef_method :to_xs if method_defined?(:to_xs)
22
- end
23
-
24
- class Module #:nodoc:
25
- include ActiveSupport::CoreExtensions::Module if ActiveSupport::CoreExtensions.const_defined? :Module
26
- end
27
-
28
- class Hash #:nodoc:
29
- include ActiveSupport::CoreExtensions::Hash::ReverseMerge
30
- end
31
-
32
- class Object #:nodoc:
33
- unless method_defined?(:try)
34
- # Taken from the upcoming ActiveSupport 2.3
35
- #
36
- # Tries to send the method only if object responds to it. Return +nil+ otherwise.
37
- # It will also forward any arguments and/or block like Object#send does.
38
- #
39
- # ==== Example :
40
- #
41
- # # Without try
42
- # @person ? @person.name : nil
43
- #
44
- # With try
45
- # @person.try(:name)
46
- #
47
- # # try also accepts arguments/blocks for the method it is trying
48
- # Person.try(:find, 1)
49
- # @people.try(:map) {|p| p.name}
50
- def try(method, *args, &block)
51
- send(method, *args, &block) if respond_to?(method, true)
52
- end
53
- end
54
- end
data/spec/string_spec.rb DELETED
@@ -1,15 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- describe String do
4
- describe "#to_latin" do
5
- it "should be accessible" do
6
- "".should respond_to(:to_latin)
7
- end
8
- end
9
-
10
- describe "#to_utf" do
11
- it "should be accessible" do
12
- "".should respond_to(:to_utf)
13
- end
14
- end
15
- end
@@ -1,32 +0,0 @@
1
- require 'test/unit'
2
-
3
- class TestDependencies < Test::Unit::TestCase
4
- def assert_dependency_included(*args)
5
- # assert methods are removed
6
- args.each do |type, method, source|
7
- type.send(:remove_method, method) if type.instance_methods.include?(method.to_s)
8
- assert !type.instance_methods.include?(method.to_s)
9
- end
10
-
11
- load File.join(File.dirname(__FILE__), '../../lib/roxml.rb')
12
-
13
- # assert_instance_methods returned to their rightful positions
14
- args.each do |type, method, source|
15
- assert type.instance_methods.include?(method.to_s)
16
- end
17
-
18
- #assert ROXML has what it needs
19
- assert_nothing_raised do
20
- Class.new do
21
- include ROXML
22
-
23
- xml_reader :deps
24
- end
25
- end
26
- end
27
-
28
- def test_symbol_to_proc_is_added_by_roxml
29
- assert_dependency_included([Symbol, :to_proc, 'active_support/core_ext/symbol.rb'],
30
- [Enumerable, :one?, 'extensions/enumerable.rb'])
31
- end
32
- end
@@ -1,77 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', 'test_helper')
2
-
3
- class MeasurementWithXmlConstruct
4
- include ROXML
5
-
6
- xml_reader :units, :from => :attr
7
- xml_reader :value, :from => :content
8
-
9
- xml_construct_without_deprecation :value, :units
10
-
11
- def initialize(value, units = 'pixels')
12
- @value = Float(value)
13
- @units = units.to_s
14
- if @units.starts_with? 'hundredths-'
15
- @value /= 100
16
- @units = @units.split('hundredths-')[1]
17
- end
18
- end
19
-
20
- def ==(other)
21
- other.units == @units && other.value == @value
22
- end
23
- end
24
-
25
- class BookWithDepthWithXmlConstruct
26
- include ROXML
27
-
28
- xml_reader :isbn, :from => '@ISBN'
29
- xml_reader :title
30
- xml_reader :description, :cdata => true
31
- xml_reader :author
32
- xml_reader :depth, MeasurementWithXmlConstruct
33
- end
34
-
35
- class InheritedBookWithDepthWithXmlConstruct < Book
36
- xml_reader :depth, MeasurementWithXmlConstruct
37
- end
38
-
39
- class TestXMLConstruct < Test::Unit::TestCase
40
- def test_is_deprecated
41
- assert_deprecated do
42
- MeasurementWithXmlConstruct.xml_construction_args
43
- end
44
- end
45
-
46
- def test_initialize_is_run
47
- m = MeasurementWithXmlConstruct.from_xml('<measurement units="hundredths-meters">1130</measurement>')
48
- assert_equal 11.3, m.value
49
- assert_equal 'meters', m.units
50
- end
51
-
52
- def test_initialize_is_run_for_nested_type
53
- b = BookWithDepthWithXmlConstruct.from_xml(fixture(:book_with_depth))
54
- assert_equal Measurement.new(11.3, 'meters'), b.depth
55
- end
56
-
57
- def test_initialize_is_run_for_nested_type_with_inheritance
58
- b = InheritedBookWithDepthWithXmlConstruct.from_xml(fixture(:book_with_depth))
59
- assert_equal Measurement.new(11.3, 'meters'), b.depth
60
- end
61
-
62
- def test_xml_name_uses_accessor_not_name
63
- assert_nothing_raised do
64
- Class.new do
65
- include ROXML
66
-
67
- xml_reader :bar, :from => '@Foo'
68
- xml_reader :foo, :text => 'Foo'
69
- xml_reader :baz, :from => '@Bar'
70
-
71
- xml_construct_without_deprecation :baz, :bar, :foo
72
- def initialize(baz, bar, foo)
73
- end
74
- end
75
- end
76
- end
77
- end