<commit_before>
require 'rib'
require 'tempfile'

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

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

      system("#{ENV['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(Imp)
end
<commit_msg>[rib/more/edit] default editor to vim, and you could override it<commit_after>
require 'rib'
require 'tempfile'

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

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

      shell = Rib.shell
      system("#{shell.editor} #{file.path}")

      if 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

  def editor
    ENV['EDITOR'] || 'vim'
  end

  Rib.extend(Imp)
end

{'fraction_non_alphanumeric': 0.1331293037490436, 'fraction_numerical': 0.0, 'mean_word_length': 2.397402597402597, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '470674', 'n_tokens_mistral': 463, 'n_tokens_neox': 438, 'n_words': 95}