Sha256: 51b0e204205561ef0299a328584129958b4fc4ac8ad16f25ea51fd531c95341e

Contents?: true

Size: 573 Bytes

Versions: 1

Compression:

Stored size: 573 Bytes

Contents

require 'rib'
require 'tempfile'

module Rib::Edit
  include Rib::Plugin
  Shell.use(self)

  module EditImp
    def edit
      return if Rib::Edit.disabled?
      file = Tempfile.new(['rib.edit', '.rb'])
      file.puts(Rib.vars[:edit])
      file.close

      system("$EDITOR #{file.path}")

      if (shell = Rib.shell).running?
        shell.send(:multiline_buffer).pop
      else
        shell.before_loop
      end

      shell.loop_eval(Rib.vars[:edit] = File.read(file.path))

    ensure
      file.close
      file.unlink
    end
  end

  Rib.extend(EditImp)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rib-0.1.0 lib/rib/zore/edit.rb