0.0
No commit activity in last 3 years
No release in over 3 years
Inject a script output into the source file as comments.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0
 Project Readme

CodeOutput Build Status

Inject a script output into the source file as comments. This is particularly useful to generate code examples.

Usage

Command line

code_output example.rb

Library

# example.rb

class Example

  def initialize
    p __method__
  end

  p __method__

end

Example.new
parser = CodeOutput::Parser.new "example.rb"
parser.run # executes the script

parser.raw_output #=> "nil\n:initialize\n"
parser.file_with_output #=> "# example.rb\n\nclass Example\n\n  def initialize\n    p __method__ #=> :initialize\n  end\n\n  p __method__ #=> nil\n\nend\n\nExample.new\n"

parser.dump 'example_with_output.rb' # writes file_with_output into the given file

Installation

Add this line to your application's Gemfile:

gem 'code_output'

And then execute:

$ bundle

Or install it yourself as:

$ gem install code_output

License

MIT