Sha256: f2690587c5e906c3ac8c551edfd4c9a36bd78fba0da7fb75ccc47c4892385733

Contents?: true

Size: 741 Bytes

Versions: 8

Compression:

Stored size: 741 Bytes

Contents

#! /usr/bin/env ruby

require 'pathname'

$VERBOSE=nil

def indent s, n = 2
  ws = ' ' * n
  s.gsub %r/^/, ws 
end

template = IO::read 'README.tmpl'

samples = ''
prompt = '~ > '

Dir['sample*/*'].sort.each do |sample|
  samples << "\n" << "  <========< #{ sample } >========>" << "\n\n"

  cmd = "cat #{ sample }" 
  samples << indent(prompt + cmd, 2) << "\n\n" 
  samples << indent(`#{ cmd }`, 4) << "\n" 

  cmd = "ruby #{ sample }" 
  samples << indent(prompt + cmd, 2) << "\n\n" 

  cmd = "ruby -e'STDOUT.sync=true; exec %(ruby -Ilib #{ sample })'" 
  #cmd = "ruby -Ilib #{ sample }" 
  samples << indent(`#{ cmd } 2>&1`, 4) << "\n" 
end

#samples.gsub! %r/^/, '  '

readme  = template.gsub %r/^\s*@samples\s*$/, samples
print readme 

Version data entries

8 entries across 8 versions & 4 rubygems

Version Path
redef-0.4.2 gen_readme.rb
shared-0.4.4 gen_readme.rb
shared-1.0.0 gen_readme.rb
shared-0.4.2 gen_readme.rb
shared-0.4.3 gen_readme.rb
state-0.4.2 gen_readme.rb
terminator-0.4.3 gen_readme.rb
terminator-0.4.2 gen_readme.rb