11Representative
22==============
33
4+ [ ![ Build Status] ( https://travis-ci.org/mdub/representative.svg?branch=master )] ( https://travis-ci.org/mdub/representative )
5+
46"Representative" makes it easier to create XML or JSON representations of your Ruby objects.
57
68It works best when you want the output to roughly follow the object structure, but still want complete control of the result.
@@ -12,15 +14,15 @@ Given a Ruby data-structure:
1214
1315 @books = [
1416 Book.new(
15- :title => "Sailing for old dogs",
17+ :title => "Sailing for old dogs",
1618 :authors => ["Jim Watson"],
1719 :published => Publication.new(
1820 :by => "Credulous Print",
1921 :year => 1994
2022 )
2123 ),
2224 Book.new(
23- :title => "On the horizon",
25+ :title => "On the horizon",
2426 :authors => ["Zoe Primpton", "Stan Ford"],
2527 :published => Publication.new(
2628 :by => "McGraw-Hill",
@@ -37,7 +39,7 @@ Given a Ruby data-structure:
3739Representative::Nokogiri can be used to generate XML:
3840
3941 xml = Representative::Nokogiri.new do |r|
40-
42+
4143 r.list_of :books, @books do
4244 r.element :title
4345 r.list_of :authors
@@ -46,7 +48,7 @@ Representative::Nokogiri can be used to generate XML:
4648 r.element :year
4749 end
4850 end
49-
51+
5052 end
5153
5254 puts xml.to_s
@@ -98,7 +100,7 @@ Generating JSON
98100Representative::Json can be used to generate JSON, using exactly the same DSL:
99101
100102 json = Representative::Json.new do |r|
101-
103+
102104 r.list_of :books, @books do
103105 r.element :title
104106 r.list_of :authors
@@ -169,7 +171,7 @@ This registers handlers for "`.xml.rep`" and "`.json.rep`" templates.
169171Copyright
170172---------
171173
172- Copyright (c) 2009 Mike Williams. See LICENSE for details.
174+ Copyright (c) 2009-2016 Mike Williams. See LICENSE for details.
173175
174176Similar projects
175177----------------
0 commit comments