Write a book about Ruby and run the code embedded in it

Hi! In my local Ruby user group we’re planning to write a book about
Ruby.
It’ll contain snippets of code and we’d like to be hable to run those
snippets in order to “test” the book and ensure all examples run with
different versions or Ruby.

Could you recommend me any tool or workflow to achieve this goal?

Thanks in advance!

Xmp was written for exactly this purpose.

This one? GitHub - amberbit/xmp: Extensible Metadata Platform (XMP) parser

2014-12-13 21:09 GMT-03:00 Ryan D. [email protected]:

If you treat each snippet as a test case, wouldn’t any test case
framework
do the job? (i.e. minitest, rspec, etc)

-Raj

On Sat, Dec 13, 2014 at 4:09 PM, Ryan D. [email protected]

That’s one of the ideas, yes. Even rubydoctest. But I was wondering if
there is something already set up, a framework (?) for the job.

2014-12-13 21:22 GMT-03:00 Raj S. [email protected]:

On Sun, Dec 14, 2014 at 12:31 AM, Juanjo C. [email protected]
wrote:

Hi! In my local Ruby user group we’re planning to write a book about Ruby.
It’ll contain snippets of code and we’d like to be hable to run those
snippets in order to “test” the book and ensure all examples run with
different versions or Ruby.

Could you recommend me any tool or workflow to achieve this goal?

Are you talking about Literate programming - Wikipedia
?

Cheers

robert

On Dec 13, 2014, at 16:21, Juanjo C. [email protected] wrote:

This one? GitHub - amberbit/xmp: Extensible Metadata Platform (XMP) parser

No.

gem which irb/xmp

On Dec 15, 2014, at 17:08, Ryan D. [email protected] wrote:

On Dec 13, 2014, at 16:21, Juanjo C. [email protected] wrote:

This one? GitHub - amberbit/xmp: Extensible Metadata Platform (XMP) parser

No.

gem which irb/xmp

Example:

10004 % cat blah.rb
foo = “bar”
baz = 42
10005 % irb --prompt xmp blah.rb

foo = “bar”
=> “bar”
baz = 42
=> 42