{ |one, step, back| } http://www.onestepback.org/index.cgi Jim Weirich's Blog en-us { |one, step, back| } http://onestepback.org http://onestepback.org/images/jwface.gif Ruby Module Spotlight: Instiki -- There is no step three. http://www.onestepback.org/index.cgi/Tech/Ruby/Spotlight/Instiki.rdoc <a href="http://www.instiki.org">Instiki</a> is a really cool wiki server from <a href="http://www.loudthinking.com/">David Heinemeier Hansson</a>. It is one of the easiest wiki servers to setup and run that I have seen. <p> Here&#8217;s what I did. First download the tar or zip file (as you need) from <a href="http://rubyforge.org/frs/?group_id=186">here</a>. Then &#8230; </p> <pre> $ tar zxvf instiki-0.3.1.tgz (lot of output omitted) $ ruby instiki.rb 2500 </pre> <p> Now you have a wiki server running locally on your computer. To see it, direct your browser to <a href="http://localhost:2500">localhost:2500</a> and edit away. </p> <p> What is a <em>Wiki</em> you ask? A Wiki is a set of web pages that can be easily edited from a browser. Hyperlinks within a Wiki are easy to setup and generally are keyed off of words with special capitalization. New pages can be created at the drop of a hat and the pages are always live and changable. Formatting rule are usually very simple, for example asterisks surrounding a word can make it *<b>bold</b>*. </p> <p> Wikis are great for collaborative web sites, where everyone contributes a bit here and a bit to build the site. I&#8217;ve used Wikis to coordinate software projects and provide documentation. </p> <p> Instiki uses RedCloth, a Ruby implementation of Textile to handle the formatting. Although a bit different from the formatting rules used by traditional Wikis, Textile looks to be very flexible in the kind of HTML it is able to produce. Yet it doesn&#8217;t seem to get in the way of just entering text. </p> <hr size="2"></hr><p> <b><em>Update:</b> Instiki now as its own domain: <a href="http://www.instiki.org">www.instiki.org</a>. I&#8217;ve updated the home page link in article.</em> </p> <hr size="2"></hr><ul> <li><a href="http://onestepback.org/cgi-bin/osbwiki.pl?FeedBack/InstikiModule">Feedback</a> </li> </ul> Ruby Module Spotlight: Session http://www.onestepback.org/index.cgi/Tech/Ruby/Spotlight/Session.rdoc Here&#8217;s a sweet little module from Ara T. Howard. It is called <tt>Session</tt> and will run a shell session under the control of a Ruby script. Standard output and standard error are captured by the session object and made available to the script. <p> How about a quick example &#8230; </p> <pre> bash = Session::Bash.new stdout, stderr = bash.execute &quot;ls&quot; p stdout # prints &quot;trysession.rb\n&quot; </pre> <p> The shell session created is persistent. Executing multiple commands in the session is like typing multiple lines into a real shell, the state is remembered from one command to the next. If you change the current directory, subsequent commands will execute in the new location. Environment variables set in the session will be remembered in later commands. </p> <pre> bash = Session::Bash.new bash.execute &quot;export GREETING=hi&quot; out, err = bash.execute &quot;echo $GREETING&quot; p out # print &quot;hi\n&quot; </pre> <p> If you pass an IO object to the session, it will append its output to that object. </p> <pre> out = StringIO.new bash = Session::Bash.new bash.execute &quot;ls&quot;, :stdout=&gt;out bash.execute &quot;ls ..&quot;, :stdout=&gt;out p out # prints the output from both &quot;ls&quot; commands. </pre> <p> One possible use of <tt>Session</tt> is to test command line scripts where you wish to check both standard output and standard error independently. </p> <pre> class TestVersion &lt; Test::Unit::TestCase def test_install out = StringIO.new bash = Session::Bash.new bash.execute &quot;export GEMPATH=#{TESTDIR}&quot; out, err = bash.execute &quot;bin/gem --install testgem&quot; assert_equals 0, bash.exit_status assert_equals &quot;&quot;, err assert_equals EXPECTED_OUTPUT, out assert_test_gem_installed end end </pre> <p> You can find Session at <a href="http://www.codeforpeople.com/lib/ruby/session/">www.codeforpeople.com/lib/ruby/session/</a> </p>