representable 0.0.1.alpha1 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. data/README.rdoc +58 -153
  2. data/lib/representable.rb +18 -42
  3. data/lib/representable/bindings/json_bindings.rb +69 -0
  4. data/lib/representable/bindings/xml_bindings.rb +152 -0
  5. data/lib/representable/definition.rb +1 -12
  6. data/lib/representable/json.rb +66 -0
  7. data/lib/representable/version.rb +1 -1
  8. data/lib/representable/xml.rb +32 -38
  9. data/representable.gemspec +3 -2
  10. data/test/bindings_test.rb +110 -0
  11. data/test/json_test.rb +130 -0
  12. data/test/{roxml_test.rb → representable_test.rb} +28 -9
  13. data/test/test_helper.rb +2 -0
  14. data/test/xml_test.rb +192 -0
  15. metadata +32 -105
  16. data/History.txt +0 -354
  17. data/TODO +0 -37
  18. data/VERSION +0 -1
  19. data/examples/amazon.rb +0 -35
  20. data/examples/current_weather.rb +0 -27
  21. data/examples/dashed_elements.rb +0 -20
  22. data/examples/library.rb +0 -40
  23. data/examples/posts.rb +0 -27
  24. data/examples/rails.rb +0 -70
  25. data/examples/twitter.rb +0 -37
  26. data/examples/xml/active_record.xml +0 -70
  27. data/examples/xml/amazon.xml +0 -133
  28. data/examples/xml/current_weather.xml +0 -89
  29. data/examples/xml/dashed_elements.xml +0 -52
  30. data/examples/xml/posts.xml +0 -23
  31. data/examples/xml/twitter.xml +0 -422
  32. data/lib/representable/references.rb +0 -153
  33. data/spec/definition_spec.rb +0 -495
  34. data/spec/examples/active_record_spec.rb +0 -41
  35. data/spec/examples/amazon_spec.rb +0 -54
  36. data/spec/examples/current_weather_spec.rb +0 -37
  37. data/spec/examples/dashed_elements_spec.rb +0 -20
  38. data/spec/examples/library_spec.rb +0 -46
  39. data/spec/examples/post_spec.rb +0 -24
  40. data/spec/examples/twitter_spec.rb +0 -32
  41. data/spec/roxml_integration_test.rb +0 -289
  42. data/spec/roxml_spec.rb +0 -372
  43. data/spec/shared_specs.rb +0 -15
  44. data/spec/spec_helper.rb +0 -5
  45. data/spec/support/libxml.rb +0 -3
  46. data/spec/support/nokogiri.rb +0 -3
  47. data/spec/xml/array_spec.rb +0 -36
  48. data/spec/xml/attributes_spec.rb +0 -71
  49. data/spec/xml/encoding_spec.rb +0 -53
  50. data/spec/xml/namespace_spec.rb +0 -270
  51. data/spec/xml/namespaces_spec.rb +0 -67
  52. data/spec/xml/object_spec.rb +0 -82
  53. data/spec/xml/parser_spec.rb +0 -21
  54. data/spec/xml/text_spec.rb +0 -71
  55. data/test/fixtures/book_malformed.xml +0 -5
  56. data/test/fixtures/book_pair.xml +0 -8
  57. data/test/fixtures/book_text_with_attribute.xml +0 -5
  58. data/test/fixtures/book_valid.xml +0 -5
  59. data/test/fixtures/book_with_authors.xml +0 -7
  60. data/test/fixtures/book_with_contributions.xml +0 -9
  61. data/test/fixtures/book_with_contributors.xml +0 -7
  62. data/test/fixtures/book_with_contributors_attrs.xml +0 -7
  63. data/test/fixtures/book_with_default_namespace.xml +0 -9
  64. data/test/fixtures/book_with_depth.xml +0 -6
  65. data/test/fixtures/book_with_octal_pages.xml +0 -4
  66. data/test/fixtures/book_with_publisher.xml +0 -7
  67. data/test/fixtures/book_with_wrapped_attr.xml +0 -3
  68. data/test/fixtures/dictionary_of_attr_name_clashes.xml +0 -8
  69. data/test/fixtures/dictionary_of_attrs.xml +0 -6
  70. data/test/fixtures/dictionary_of_guarded_names.xml +0 -6
  71. data/test/fixtures/dictionary_of_mixeds.xml +0 -4
  72. data/test/fixtures/dictionary_of_name_clashes.xml +0 -10
  73. data/test/fixtures/dictionary_of_names.xml +0 -4
  74. data/test/fixtures/dictionary_of_texts.xml +0 -10
  75. data/test/fixtures/library.xml +0 -30
  76. data/test/fixtures/library_uppercase.xml +0 -30
  77. data/test/fixtures/muffins.xml +0 -3
  78. data/test/fixtures/nameless_ageless_youth.xml +0 -2
  79. data/test/fixtures/node_with_attr_name_conflicts.xml +0 -1
  80. data/test/fixtures/node_with_name_conflicts.xml +0 -4
  81. data/test/fixtures/numerology.xml +0 -4
  82. data/test/fixtures/person.xml +0 -1
  83. data/test/fixtures/person_with_guarded_mothers.xml +0 -13
  84. data/test/fixtures/person_with_mothers.xml +0 -10
  85. data/test/mocks/dictionaries.rb +0 -57
  86. data/test/mocks/mocks.rb +0 -279
  87. data/test/support/fixtures.rb +0 -11
  88. data/test/unit/definition_test.rb +0 -235
  89. data/test/unit/deprecations_test.rb +0 -24
  90. data/test/unit/to_xml_test.rb +0 -81
  91. data/test/unit/xml_attribute_test.rb +0 -39
  92. data/test/unit/xml_block_test.rb +0 -81
  93. data/test/unit/xml_bool_test.rb +0 -122
  94. data/test/unit/xml_convention_test.rb +0 -150
  95. data/test/unit/xml_hash_test.rb +0 -115
  96. data/test/unit/xml_initialize_test.rb +0 -49
  97. data/test/unit/xml_name_test.rb +0 -141
  98. data/test/unit/xml_namespace_test.rb +0 -31
  99. data/test/unit/xml_object_test.rb +0 -206
  100. data/test/unit/xml_required_test.rb +0 -94
  101. data/test/unit/xml_text_test.rb +0 -71
  102. data/website/index.html +0 -98
@@ -1,354 +0,0 @@
1
- == 3.1.6 (September 9, 2010)
2
-
3
- * bug fix
4
-
5
- * load active_support in a way that is compatible with 2.x and 3.x
6
- (fixes gh issue #27)
7
- * change the way we monkey patch Nokogiri to leave the original
8
- behaviour of the search() method unchanged (fixes gh issue #16)
9
- * Unofficial release by James Healy, empact has stepped back from maintaining
10
- roxml
11
-
12
- == 3.1.5 (December 18, 2009)
13
-
14
- * bug fix
15
-
16
- * don't use tasks/ because those rake files are picked up by those vendoring roxml
17
-
18
- == 3.1.4 (December 18, 2009)
19
-
20
- * bug fix
21
-
22
- * require the necessary version of active support (#tap wasn't introduced until 2.3)
23
-
24
- == 3.1.3 (October 30, 2009)
25
-
26
- * minor enhancements
27
-
28
- * Add support for local-name() reference reading via :namespace => '*'
29
- (ala http://techrageo.us/2008/11/01/wildcard-namespaces-in-xpath/)
30
-
31
- * bug fixes
32
-
33
- * attributes collected :as => [] were previously output improperly,
34
- as a single attribute on a single node
35
- * don't output crazy, context-less namespaces and local-name xpaths
36
- when trying to output namespaced attributes
37
-
38
- == 3.1.2 (October 18, 2009)
39
-
40
- * minor enhancements
41
-
42
- * Retain whitespace in element contents, but still default on blank (rather than entirely empty) elements
43
-
44
- * bug fixes
45
-
46
- * Include namespaces in xml output
47
- * Fix that auto-wrapped collections weren't output with their wrappers
48
- (which requires introducing the roxml_references accessor on the instance)
49
-
50
- == 3.1.1 (October 17, 2009)
51
-
52
- * bug fix
53
-
54
- * Fix bad load paths
55
-
56
- == 3.1 (October 16, 2009)
57
-
58
- * major enhancements
59
-
60
- * Add support for registering XML namespace prefixes via the xml_namespaces method
61
-
62
- * bug fix
63
-
64
- * References to arrays of attributes were only returning the first. No more.
65
-
66
- == 3.0 (October 14, 2009)
67
-
68
- * major enhancements
69
-
70
- * Add Nokogiri support
71
- * Remove previously deprecated functionality
72
- * Remove REXML support
73
- * Error on any unrecognized options
74
- * Normalize hash declaration syntax:
75
- * for :key => '@string', string is taken to be the :from argument
76
- * for :key => {:from => '@string', :as => Type}, the arguments are just the same as a regular declaration
77
-
78
- * minor enhancements
79
-
80
- * Include 't' and 'f' in the list of possible boolean values, since rails uses them
81
- * Remove :attrs hash syntax. Not particularly helpful & somewhat obfuscatory. Use :key, :value instead.
82
- * Default attrs ending in '_at' to DateTime. This can be overriden via :as
83
- * Default attrs ending in '_on' to Date. This can be overriden via :as
84
- * Don't require rubygems within the library
85
- * Don't mess with the load path
86
-
87
- == 2.5.4 (October 4, 2009)
88
-
89
- * bug fix
90
-
91
- * Rely on REXML's #add_child and LibXML's <<, rather than #child_add which had been removed from REXML and deprecated from LibXML
92
-
93
- == 2.5.3 (March 22, 2009)
94
-
95
- * minor enhancement
96
-
97
- * Work around apparently unintentional breaking change in libxml-ruby 1.1.3
98
-
99
- == 2.5.2 (March 12, 2009)
100
-
101
- * minor enhancements
102
-
103
- * Remove dependency on an Object#try which conflicted with ActiveSupport 2.3's version
104
- * Document the :to_xml option for attr references
105
- * Require active_support directly, as it's less brittle and plays nicer with other libraries
106
-
107
- == 2.5.1 (March 2, 2009)
108
-
109
- * minor enhancements
110
-
111
- * Add Document#save to REXML support, complete with XMLDecl output
112
-
113
- * bug fixes
114
-
115
- * rexml support has been fixed
116
- * the first example in the readme was broken and has been fixed
117
-
118
- == 2.5.0 (February 24, 2009)
119
-
120
- * major enhancements
121
-
122
- * support for mapping ActiveRecord classes. See examples/rails.rb.
123
- * .from_xml will now use the setter for the declared variable, if one is available,
124
- rather than directly setting the instance variable
125
- * All declaration type arguments are now supported via the :as parameter, e.g. :as => [MyType]. Other uses are deprecated.
126
- * All xml source path arguments are now supported via the :from and :in parameters, e.g. :from => :attr or :from => '@MyAttr'. Other uses are deprecated.
127
- * All other options are presented separately, e.g. :cdata => true rather than :as => :cdata. Other uses are deprecated.
128
-
129
- * minor enhancements
130
-
131
- * .xml_attr declaration declares neither a reader nor a writer. With it you're left to your own devices.
132
- * You can use literal [] for the [:text] object type declaration,
133
- though they should be used in the :as parameter: :as => []
134
- * You can use [] with your :as declarations. e.g. :as => [Float] is
135
- equivalent to the old :as => [Float, :array]
136
- * Show the actual call point of a deprecation, rather than some internal path
137
- * Add support for BigDecimal and Fixnum as block shorthands [James Healy]
138
- * Update libxml support to 0.9.6, and add it as a dependency, to ensure correct versioning, and
139
- as it's an order of magnitude faster than rexml
140
-
141
- * breaking changes
142
-
143
- * :else option only applies to instances created via .from_xml
144
- * On .from_xml, #initialize is now called with the *initialization_args before extracting attributes from the xml.
145
- * #xml_initialize has been replaced with the #after_parse callback, which takes no arguments.
146
- * .xml_accessor will overwrite the setter for this variable if it has already been defined. Use .xml_reader or .xml_attr,
147
- or define your writer later, if this is not the behavior you want.
148
-
149
- * deprecations
150
-
151
- * Use :cdata => true rather than :as => :cdata
152
- * Use literal [] around your regular object type, rather than :as => :array
153
- * Use :from => :content rather than the :content object declaration type
154
- * Specifying an unknown symbol or Class for :as will raise in 3.0
155
- * Specifying :as with anything other than a type argument e.g. :bool, Float, [Date],
156
- will not be supported in 3.0
157
- * Use :from => :attr or :from => '@attribute_name' rather than the :attr
158
- object declaration type
159
- * Passing any type declaration outside the :as parameter is deprecated
160
- * In 3.0, attributes ending in _on and _at will default to :as => Date and DateTime, respectively,
161
- rather than :text
162
- * Deprecated hash :attrs declaration syntax in favor of {:key => '@attr1', :value => '@attr2'}
163
- * Deprecated hash {Type => 'name'} declaration syntax in favor of {:as => Type, :from => 'name}
164
- * Deprecated String#to_utf and #to_latin.
165
-
166
- * bug fixes
167
-
168
- * xml_accessor now properly handles punctuation, such that the writer appears without '?' for boolean attributes
169
- * text node contents are no longer truncated when '&' are present in the contents
170
- * When using :as => Integer or Float, don't raise on missing element [James Healy]
171
-
172
- == 2.4.3 (February 1, 2009)
173
-
174
- * 1 bug fix
175
-
176
- * Fix roxml to work in ruby 1.8.6, which has been broken since the removal of
177
- extensions in version 2.4.1. Thanks Pat! [Pat Nakajima]
178
-
179
- == 2.4.2 (January 31, 2009)
180
-
181
- * 1 major enhancement
182
-
183
- * xml_namespace for declaring Class-level, inheritable default namespaces.
184
-
185
- * 4 minor enhancements
186
-
187
- * add :as => Time, DateTime, and Date support
188
- * support Pathname, IO and URI objects as #from_xml arguments
189
- * :as => :bool now supports all capitalizations of 'true', 'false', 'yes', 'no', as well as '1' and '0'
190
- * For basic types (:as => Integer, Float, Date, &c.), interpret empty strings just
191
- as missing elements (by returning nil), rather than raising. Raise behavior can be
192
- accessed by supplying your own block or using the :required option.
193
-
194
- * 3 bug fixes
195
-
196
- * Arrays of attrs or elements :as => :bool weren't previously supported. An oversight.
197
- * Don't apply xml_convention if name is explicitly set
198
- * Protect xpath operators : and / from modification via String#camelcase & such
199
-
200
- == 2.4.1 (January 28, 2009)
201
-
202
- * 3 minor enhancements
203
-
204
- * remove dependency on 'extensions' gem, as we weren't using it much and it
205
- was causing problems for some
206
- * deprecate the 'xml' declaration in favor of the more explicit 'xml_reference'
207
- declaration. Reorder params to make for cleaner 3.0 transition.
208
- * deprecate '#tag_name' in favor of 'self.class.tag_name', as it's a class-specific value
209
-
210
- == 2.4.0 (January 15, 2009)
211
-
212
- * 1 major enhancement
213
-
214
- * Add xml_convention to enable easy defaulting to common naming formats, such as camel-case and
215
- underscored [Ben Woosley]
216
-
217
- * 6 minor enhancements
218
-
219
- * Add :frozen option for freezing values on parse [Ben Woosley]
220
- * Attempt to minimize node creation by better matching wrappers [Ben Woosley]
221
- * Preserve hash values where a single key maps to multiple values, return them as an array rather
222
- any single one of them at random (as in group_by rather than index_by) [Ben Woosley]
223
- * Deprecate #xml_name? as it's only used for triggering the xml_name warning [Ben Woosley]
224
- * REXML parser ignores whitespace, which doesn't matter to us anyway [Ben Woosley]
225
- * xml_name is inherited by default [Ben Woosley]
226
-
227
- * 2 bug fixes
228
-
229
- * Don't detect objects which define their own empty? as being absent for the purposes
230
- of :default and :required [Ben Woosley]
231
- * Sub-objects pick up their parent's attributes, even if they're added after
232
- the child's use [Ben Woosley]
233
-
234
- == 2.3.2 (December 11, 2008)
235
-
236
- * Fix that both false and nil values were excluded from to_xml output, when only nil values should be [Ben Woosley]
237
-
238
- == 2.3.1 (December 9, 2008)
239
-
240
- * Add missing dependencies to extensions/enumerable and Symbol.to_proc,
241
- which are as-yet inexplicably pre-included on my system... [Ben Woosley, Per Melin]
242
-
243
- == 2.3 (December 7, 2008)
244
-
245
- * Fix a bug in the application of blocks to array types [Ben Woosley]
246
-
247
- * Objects now inherit xml attributes from their parents, as they should [Ben Woosley, Per Melin]
248
-
249
- * Add #xml_initialize, which is called at the end of #from_xml, after the xml attributes
250
- are set. Deprecate the half-baked xml_construct in it's favor. [Ben Woosley]
251
-
252
- * Fix a bug in the handling of empty Hash types [Ben Woosley]
253
-
254
- * Implement automatic bool-ification when the accessor name ends with ?. [Ben Woosley]
255
-
256
- * Add missing dependency ActiveSupport [Ben Woosley]
257
-
258
- * Remove support for installing as a rails plugin [Ben Woosley]
259
-
260
- * Fix a bug where xml_construct was using the refs' names rather than their accessor names for comparison [Ben Woosley]
261
-
262
- * Significantly reduce our footprint by selectively including smaller parts of ActiveSupport and Extensions.
263
- This avoids problems such as the conflict between ActiveSupport's #to_json and the JSON gem's #to_json.
264
- Thanks to Per Melin for reporting this problem. [Ben Woosley]
265
-
266
- * Rationalize sub-element xml naming by enforcing the following precedence for the containing xml of an object:
267
- :from of parent, xml_name of child, parent's accessor name. The previous fallback did not include xml_name.
268
- This new behavior is more consistent, explicit, predictable, and DRY, but it is a breaking change, so a warning
269
- is printed to alert others of this behavior change. ROXML::SILENCE_XML_NAME_WARNING may be used to deactivate this
270
- warning. [Ben Woosley, James W. Thompson, Delynn Berry]
271
-
272
- == 2.2 (November 2, 2008)
273
-
274
- * fix gem dependencies [James Healy]
275
-
276
- * Add block shorthands for Float and Integer, which precede the block argume if present [Ben Woosley]
277
-
278
- * Add :required option to throw on absence [Ben Woosley]
279
-
280
- * Deprecate the non-specific #parse in favor of #from_xml [Ben Woosley]
281
-
282
- * Fix a bug whereby the default value was carrying over information from one object to another [James Healy, Ben Woosley]
283
-
284
- * Fix support for :in on :attr elements [Ben Woosley]
285
-
286
- * Deprecate Array#to_h in favor of Array#to_hash [Ben Woosley]
287
-
288
- * Deprecate Object#to_latin and Object#to_utf in favor of the same methods on String [Ben Woosley]
289
-
290
- == 2.1 (October 3, 2008)
291
-
292
- * rake test now uses the default parser selection [Ben Woosley]
293
-
294
- * Added rcov code coverage for tests [Anders Engström]
295
-
296
- * Accommodate that libxml requires you to name the default namespace when available [Ben Woosley]
297
-
298
- * Enable optional selection of a parser through the early definition of ROXML::XML_PARSER
299
- [Ben Woosley]
300
-
301
- * Enable fallback to the REXML parser if LibXML is unavailable [Ben Woosley]
302
-
303
- == 2.0 (September 20, 2008)
304
-
305
- * :text_content becomes simply :content, and is joined by :name [Ben Woosley]
306
-
307
- * Allow hash mapping from node names and contents: [Ben Woosley]
308
-
309
- xml_reader :name, {:key => :name,
310
- :value => :content}, :in => 'container'
311
-
312
- * Allow supplying a default via the :else option [Ben Woosley]
313
-
314
- * Allow hash mapping of text and attr elements: [Ben Woosley]
315
-
316
- xml_reader :name, {:key => {:text => 'key_name'},
317
- :value => {:attr => 'attr_name'}}, :in => 'container'
318
-
319
- * Allow 'xml_reader :name, [Type]' as an alternative to 'xml_reader :name, Type, :as => :array'
320
- [Ben Woosley]
321
-
322
- * Allow attaching a block for manipulating a value on fetch: [Ben Woosley]
323
-
324
- xml_accessor :count, :attr => 'my_int' do |val|
325
- Integer(val)
326
- end
327
-
328
- * Collapse xml_attr, xml_text and xml_object into a single api: xml, patterned after the standard
329
- attr, and offer xml_reader and xml_accessor as well. Remove the :readonly arg in the process
330
- [Ben Woosley]
331
-
332
- * Attach string extensions (#to_latin, #to_utf) to Object rather than String, so we don't have to
333
- call #to_s first every time [Ben Woosley]
334
-
335
- * Allow a ROXML object to call its constructor on initialization with the xml_construct function
336
- [Ben Woosley]
337
-
338
- * Use symbols (e.g. :text_content) rather than TAG_CONSTANTS (e.g. TEXT_CONTENT) for readability
339
- [Ben Woosley]
340
-
341
- * Use named arguments (e.g. :as, :in) rather than positional for clarity,
342
- position-independence, and invisible exclusion [Ben Woosley]
343
-
344
- * Split out rails_plugin_package_task_gem [Ben Woosley]
345
-
346
- * Increase testing significantly, particularly on new functionality & to_xml [Ben Woosley]
347
-
348
- == 1.2 (October 10, 2007)
349
-
350
- * Fix a bug such that the TEXT_CONTENT tag is no longer also READ_ONLY [Russ Olsen]
351
-
352
- == 1.1 (September 24, 2006)
353
-
354
- * Initial design & development [Zak Mandhro & Anders Engstrom]
data/TODO DELETED
@@ -1,37 +0,0 @@
1
- Planned:
2
-
3
- v 3.2
4
-
5
- * Support outputting namespaced attrs
6
-
7
- * Consider class_inheritable_attribute rather than superclass.try stuff.
8
-
9
- * Do some benchmarking
10
-
11
- * Back with http://xml-object.rubyforge.org/doc/ to minimize need for specifications?
12
-
13
- * Commandeer #parse to use opposite #from_xml, but in an unrooted, collection-friendly fashion,
14
- ala HappyMapper's parse
15
-
16
- v 3.x
17
-
18
- * :self => true for sending method_missing to this attribute?
19
-
20
- * :attributes extensions ala HappyMapper?
21
-
22
- * Add xml_attrs helper to share :in declarations between several attributes. E.g.:
23
-
24
- xml_reader :count, :in => 'Attributes', :as => Integer
25
- xml_reader :something_else, :in => 'Attributes', :as => Date
26
-
27
- becomes:
28
-
29
- xml_attrs :in => 'Attributes' do |xml|
30
- xml.reader :count, :as => Integer
31
- xml.reader :something_else, :as => Date
32
- end
33
-
34
- * Ensure (perhaps optionally) that references are unambiguous. That is error/warn
35
- a singular specification has multiple possible node references
36
-
37
- * Use lazy evaluation to minimize parsing time for large files
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 3.1.6
@@ -1,35 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require_relative './../spec/spec_helper'
3
-
4
- # The document `pita.xml` contains both a default namespace and the 'georss'
5
- # namespace (for the 'point' xml_reader).
6
- module PITA
7
- class Base
8
- include ROXML
9
- xml_convention :camelcase
10
- end
11
-
12
- class Item < Base
13
- xml_reader :asin, :from => 'ASIN'
14
- xml_reader :detail_page_url, :from => 'DetailPageURL'
15
- xml_reader :manufacturer, :in => 'ItemAttributes'
16
- # this is the only xml_reader that exists in a different namespace, so it
17
- # must be explicitly specified
18
- xml_reader :point, :namespace => 'georss'
19
- end
20
-
21
- class ItemSearchResponse < Base
22
- xml_reader :total_results, :as => Integer, :in => 'Items'
23
- xml_reader :total_pages, :as => Integer, :in => 'Items'
24
- xml_reader :items, :as => [Item]
25
- end
26
- end
27
-
28
- unless defined?(Spec)
29
- response = PITA::ItemSearchResponse.from_xml(xml_for('amazon'))
30
- p response.total_results
31
- p response.total_pages
32
- response.items.each do |i|
33
- puts i.asin, i.detail_page_url, i.manufacturer, i.point, ''
34
- end
35
- end
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require_relative './../spec/spec_helper'
3
-
4
- class Base
5
- include ROXML
6
- xml_convention :dasherize
7
- xml_namespace 'aws'
8
- end
9
-
10
- class WeatherObservation < Base
11
- xml_name 'ob'
12
- xml_reader :temperature, :as => Float, :from => 'aws:temp'
13
- xml_reader :feels_like, :as => Integer
14
- xml_reader :current_condition #, :attributes => {:icon => String} # pending
15
- end
16
-
17
- class Weather < Base
18
- xml_reader :observation, :as => WeatherObservation, :required => true
19
- end
20
-
21
- unless defined?(Spec)
22
- current_weather = Weather.from_xml(xml_for('current_weather')).observation
23
- puts "temperature: #{current_weather.temperature}"
24
- puts "feels_like: #{current_weather.feels_like}"
25
- puts "current_condition: #{current_weather.current_condition}"
26
- # puts "current_condition.icon: #{current_weather.current_condition.icon}" # pending
27
- end