The Artima Developer Community
Sponsored Link

Java Buzz Forum
New Blog Tooling

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Brian McCallister

Posts: 1282
Nickname: frums
Registered: Sep, 2003

Brian McCallister is JustaProgrammer who thinks too much.
New Blog Tooling Posted: Apr 5, 2009 11:18 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Brian McCallister.
Original Post: New Blog Tooling
Feed Title: Waste of Time
Feed URL: http://kasparov.skife.org/blog/index.rss
Feed Description: A simple waste of time and weblog experiment
Latest Java Buzz Posts
Latest Java Buzz Posts by Brian McCallister
Latest Posts From Waste of Time

Advertisement

To help out with the new blogging system I had fun hacking up some support scripts. I tried a new style this time, one base script and a bunch of plugins, so I do things now, as

$ blog create new_blog_tooling
$ blog edit new_blog_tooling
Which is kind of shiny. I did it in ruby as I wanted to just get it done, but as I futzedI realized I really wanted a module system more like Lua or Erlang’s – I didn’t want to know the module name, but wanted to access stuff on it.

The closest I got was a pretty gross eval hack, which looks like

def load_command command
it = File.open(File.join(CommandDir, "#{command}.rb")) do |f|
f.readlines.join("")
end
ms =<<-EOM
Class.new do
#{it}
end
EOM
eval(ms).new
end
Which creates an instance of an anonymous class and lets me call methods on it, the “plugins” then are just bare method definitions, like

def execute
draft_dir = File.join(BaseDir, "drafts")
name = ARGV[1]
exec "#{ENV['EDITOR']} #{File.join(draft
dir, "#{name}.textile") }"
end

def usage
"<name>"
end

def help
"open <name> in $EDITOR"
end
Which are usd to generate help and execute the actual commands,

$ blog -h
Usage: blog command [additional]

blog create <name>
creates a new draft with name <name>

blog drafts
list all drafts

blog edit <name>
open <name> in $EDITOR

blog kill <name>
destroy the draft <name>

$
Annoyed at having to use an eval hack, but hey, it works.

Read: New Blog Tooling

Topic: JVM CLR unification : IBM Sun merger held up to complete CLR licensing Previous Topic   Next Topic Topic: Zyle Progress

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use