{ |one, step, back| } 2 of 2 articles Syndicate: full/short

Ruby Module Spotlight: Instiki -- There is no step three.   22 Apr 04
[ print link all ]
Instiki is a really cool wiki server from David Heinemeier Hansson. It is one of the easiest wiki servers to setup and run that I have seen.

Here’s what I did. First download the tar or zip file (as you need) from here. Then …

  $ tar zxvf instiki-0.3.1.tgz
  (lot of output omitted)
  $ ruby instiki.rb 2500

Now you have a wiki server running locally on your computer. To see it, direct your browser to localhost:2500 and edit away.

What is a Wiki 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 *bold*.

Wikis are great for collaborative web sites, where everyone contributes a bit here and a bit to build the site. I’ve used Wikis to coordinate software projects and provide documentation.

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’t seem to get in the way of just entering text.


Update: Instiki now as its own domain: www.instiki.org. I’ve updated the home page link in article.



comments

Ruby Module Spotlight: Session   27 Mar 04
[ print link all ]
Here’s a sweet little module from Ara T. Howard. It is called Session 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.

How about a quick example …

  bash = Session::Bash.new
  stdout, stderr = bash.execute "ls"
  p stdout     # prints "trysession.rb\n"

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.

  bash = Session::Bash.new
  bash.execute "export GREETING=hi"
  out, err = bash.execute "echo $GREETING"
  p out    # print "hi\n"

If you pass an IO object to the session, it will append its output to that object.

  out = StringIO.new
  bash = Session::Bash.new
  bash.execute "ls", :stdout=>out
  bash.execute "ls ..", :stdout=>out
  p out  # prints the output from both "ls" commands.

One possible use of Session is to test command line scripts where you wish to check both standard output and standard error independently.

  class TestVersion < Test::Unit::TestCase
    def test_install
      out = StringIO.new
      bash = Session::Bash.new
      bash.execute "export GEMPATH=#{TESTDIR}"
      out, err = bash.execute "bin/gem --install testgem"
      assert_equals 0, bash.exit_status
      assert_equals "", err
      assert_equals EXPECTED_OUTPUT, out
      assert_test_gem_installed
    end
  end

You can find Session at www.codeforpeople.com/lib/ruby/session/


comments

 

Formatted: 08-Feb-12 12:29
Feedback: jim@weirichhouse.org