Module: GoobyHelpProducer
- Included in:
- GoobyProcess
- Defined in:
- lib/gooby_help_producer.rb
Overview
Gooby = Google APIs + Ruby. Copyright 2009 by Chris Joakim. Gooby is available under GNU General Public License (GPL) license.
The help information is obtained here by “grepping” the given source code filename, and selecting the lines which contain three consecutive hash symbols. This enables the documentation to reside with the actual code.
Instance Method Summary collapse
Instance Method Details
#produce_help_page(source_filename, print_it = false) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/gooby_help_producer.rb', line 16 def produce_help_page(source_filename, print_it=false) help_content, marker, lines = [], '###', IO.readlines(source_filename) lines.each { | line | if line.match(marker) if line.strip == marker help_content << "\n" else help_content << line.strip[4..999] end end } help_content << '' if ENV['GOOBY_HOME'] help_content << "Your GOOBY_HOME directory is currently set to #{ENV['GOOBY_HOME']}" else help_content << "Your GOOBY_HOME directory environment variable has not been set; please do so." end help_content << '' if print_it help_content.each { | line | puts line } end help_content end |