GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Description: Ruby WDDX gem.
Homepage: http://code.juretta.com/ruby/wddx/
Clone URL: git://github.com/juretta/wddx.git
wddx / examples / example_helper.rb
100644 27 lines (24 sloc) 0.721 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# $Id: example_helper.rb 109 2007-04-07 15:29:03Z stefan $
# Author: Stefan Saasen <s@juretta.com>
 
# only required to pretty print the XML examples
require 'rexml/document'
 
# Print XML example
def print_xml(xml)
  # Print method call
  f = caller.first.split(":")
  puts IO.readlines(f.first)[f.last.to_i-1].gsub(/(print_xml|\n|#(.*)$)/, "").strip + ": "
  # Print XML
  REXML::Document.new(xml).write($stdout, 2)
  # Print separator
  puts "\n" + ("~" * 60) + "\n"
end
 
# Print example
def print_e(var)
  # Print method call
  f = caller.first.split(":")
  print IO.readlines(f.first)[f.last.to_i-1].gsub(/(print_e|\n|#(.*)$)/, "").strip + ": "
  # Print var
  puts var
  # Print separator
  puts ("~" * 60) + "\n"
end