[ditz-talk] First impressions

David Masover ninja at slaphack.com
Tue Jul 29 04:15:16 EDT 2008

Using 0.4...  Doesn't work on Ruby 1.9 (I suspect this is a 'sha1' 
vs 'digest/sha1' issue).

Aside from that, here's my startup hooks:

module Lowline
  # Put the comments at the bottom of the file,
  # as comments will be ignored anywhere, and
  # most editors make it quickest to start editing at the top.
  # Since there's no template to edit, I have to copy/paste/hack
  # the whole method...
  def ask_via_editor q, default=nil
    fn = run_editor do |f|
      f.puts default ? default : ''
      f.puts '# ' + '-'*60
      f.puts '# ' + q
      f.puts '# ' + '-'*60
      f.puts "# Lines starting with a '#' will be ignored."
    return unless fn
    IO.read(fn).gsub(/^#.*$/, "").multistrip

  # I'm quick enough with Vim that I'd rather not have to type
  # /edit every time.
  alias_method :ask_multiline, :ask_via_editor

# Blank-ify, if not already done by e.g. Rails.
# I think that's what the ditz authors were expecting.
# Turns crash into a more helpful error when quitting the editor
# without saving the file (or changing it at all).
unless nil.respond_to? :blank?
  class NilClass
    def blank?

Now, it's cool that I can extend Ditz this way. But it's kind of annoying that 
I have to -- should I be submitting a patch (or full-fledged plugin) to make 
it more simply configurable and editor-friendly? (In particular, it feels like 
the editor template could be made into a user-overridable ERB file.)

More information about the ditz-talk mailing list