### Home Classes Methods

### In Files

- lib/plugins/haml.rb

### Parent

Object

### Methods

- ::new
- #editor
- #haml
- #plugin_config
- #run

### Files

- ChangeLog
- README.rdoc

### Class/Module Index

Quicksearch

- Termtter
- Termtter::API
- Termtter::ActiveRubytter
- Termtter::Client
- Termtter::Client::DirectMessage
- Termtter::Client::Jakigan
- Termtter::Client::SearchEvent
- Termtter::Client::UserSearchEvent
- Termtter::Command
- Termtter::CommandCanceled
- Termtter::CommandLine
- Termtter::CommandNotFound
- Termtter::Config
- Termtter::ConfigSetup
- Termtter::Crypt
- Termtter::English
- Termtter::Event
- Termtter::HTTPpool
- Termtter::Hook
- Termtter::HookCanceled
- Termtter::Hookable
- Termtter::JSONError
- Termtter::MemoryCache
- Termtter::MemoryCache::MemCacheMock
- Termtter::OptParser
- Termtter::Plugin
- Termtter::Plugin::Screen
- Termtter::Plugins
- Termtter::Plugins::Haml
- Termtter::Plugins::ListSwitch
- Termtter::RubytterProxy
- Termtter::RubytterProxy::FrequentAccessError
- Termtter::RubytterProxy::LimitManager
- Termtter::Status
- Termtter::StdOut
- Termtter::Storage
- Termtter::Storage::SQLite3
- Termtter::Storage::Status
- Termtter::Task
- Termtter::TaskManager
- Termtter::TypableIdGenerator
- Termtter::UserStreamReceiver
- Yharian
- Yharian::Alex
- Yharian::Jenifer
- Yharian::Remark
- Yharian::Speaker
- Yharian::Vicki
- Yharian::Yhara
- HatenaKeywordHaiku
- HatenaKeywordHaiku::Word
- OAuth
- OAuth::AccessToken
- Readline
- Readline::LIBREADLINE
- AAMaker
- Array
- BrowserNotFound
- Growl
- IRB
- Object
- Status
- String
- Symbol
- TermColor
- TermtterIrcGateway
- User

No matching classes.

# Termtter::Plugins::Haml

### Public Class Methods

new(config = Termtter::Config.instance, logger = Termtter::Client.logger) click to toggle source

    # File lib/plugins/haml.rb, line 7
    def initialize(config = Termtter::Config.instance, logger = Termtter::Client.logger)
      @config, @logger = config, logger

      plugin_config.set_default :options, {}
    end

### Public Instance Methods

editor(extname) click to toggle source

    # File lib/plugins/haml.rb, line 38
    def editor(extname)
      unless cmd = ENV['VISUAL'] || ENV['EDITOR']
        raise 'Please set VISUAL or EDITOR variable.'
      end

      # XXX: works only in Ruby 1.8.7 or later
      Tempfile.open(['tmp', ".#{extname}"]) do |f|
        system cmd, f.path
        return f.read
      end
    end

haml(format) click to toggle source

    # File lib/plugins/haml.rb, line 31
    def haml(format)
      return unless input = editor(:haml)

      opts = plugin_config.options.merge(format.empty? ? {} : {:format => format.to_sym})
      ::Haml::Engine.new(input, opts).render.chomp
    end

plugin_config() click to toggle source

    # File lib/plugins/haml.rb, line 13
    def plugin_config
      @config.plugins.haml
    end

run(arg) click to toggle source

    # File lib/plugins/haml.rb, line 17
    def run(arg)
      begin
        hamlified = haml(arg)
      rescue => e
        @logger.error e
        return
      end

      return if hamlified.nil? || hamlified.empty?

      Termtter::API.twitter.update(hamlified)
      puts "=> #{hamlified}"
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.