Sha256: 2c06df5637790997f741a6339ade07b3c2031541566eeb1584cf8592280df672

Contents?: true

Size: 649 Bytes

Versions: 38

Compression:

Stored size: 649 Bytes

Contents

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 -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

38 entries across 38 versions & 7 rubygems

Version Path
slave-1.2.2 gen_readme.rb
arrayfields-4.0.0 gen_readme.rb
arrayfields-4.7.1 gen_readme.rb
arrayfields-4.7.0 gen_readme.rb
arrayfields-4.6.0 gen_readme.rb
arrayfields-4.2.0 gen_readme.rb
arrayfields-4.3.0 gen_readme.rb
arrayfields-4.7.2 gen_readme.rb
arrayfields-4.1.0 gen_readme.rb
arrayfields-4.4.0 gen_readme.rb
arrayfields-4.7.3 gen_readme.rb
arrayfields-4.5.0 gen_readme.rb
arrayfields-3.7.0 gen_readme.rb
forkoff-0.0.4 gen_readme.rb
forkoff-0.0.0 gen_readme.rb
forkoff-0.0.1 gen_readme.rb
pervasives-1.1.0 gen_readme.rb
pervasives-0.0.1 gen_readme.rb
pervasives-1.0.0 gen_readme.rb
prototype-0.3.0 gen_readme.rb