### Home Classes Methods

### In Files

- lib/plugins/haml.rb

### Parent

Object

### Methods

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

### Files

- README.rdoc

### Class/Module Index

Quicksearch

- Termtter
- Termtter::API
- Termtter::ActiveRubytter
- Termtter::Client
- Termtter::Client::UserSearchEvent
- Termtter::Command
- Termtter::CommandLine
- Termtter::Config
- Termtter::ConfigSetup
- Termtter::Crypt
- 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::RubytterProxy
- Termtter::RubytterProxy::FrequentAccessError
- Termtter::RubytterProxy::LimitManager
- Termtter::Status
- Termtter::Storage
- Termtter::Storage::Status
- Termtter::Task
- Termtter::TaskManager
- Termtter::UserStreamReceiver
- OAuth
- OAuth::AccessToken
- Array
- Growl
- IRB
- Object
- Readline
- Status
- String
- Symbol
- TermColor
- 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.