<commit_before>function! RunInTerminal(file)
  if match(a:file, '_spec\.rb') != -1
    let l:command = 'bundle exec rspec'
  elseif match(a:file, '\.feature') != -1
    let l:command = 'bundle exec cucumber'
  elseif match(a:file, '\.rb') != -1
    let l:command = 'ruby'
  endif

  if exists("l:command")
    let g:last_run_in_terminal = a:file
    let l:run_script = "!osascript ~/.vim.local/tools/run_command.applescript" 
    silent execute ":up"
    "silent execute l:run_script . " '" . l:command . " " . a:file . "' " . g:vim_terminal . " &"
    silent execute l:run_script . " '" . l:command . " " . a:file . "'"
    silent execute ":redraw!"
  else
    echo "Couldn't figure out how to run " . a:file 
  end
endfunction

function! RunFileInTerminal()
  "if exists("g:vim_terminal")
    call RunInTerminal(expand("%")) 
  "else
    "echo "You need to set g:vim_terminal to a valid TTY (e.g. /dev/ttys000)"
  "end
endfunction

function! RunFileAtLineInTerminal()
  "if exists("g:vim_terminal")
    call RunInTerminal(expand("%") . ":" . line("."))
  "else
    "echo "You need to set g:vim_terminal to a valid TTY (e.g. /dev/ttys000)"
  "endif
endfunction

function! ReRunLastFileCommand()
  "if exists("g:vim_terminal") && exists("g:last_run_in_terminal")
    call RunInTerminal(g:last_run_in_terminal)
  "endif
endfunction

command! RunFileInTerminal call RunFileInTerminal()
command! RunFileAtLineInTerminal call RunFileAtLineInTerminal()
command! ReRunLastFileCommand call ReRunLastFileCommand()
<commit_msg>run specs in terminal wip<commit_after>" TODO: figure out how to cd to root
" Map to command R

function! RunInTerminal(file)
  if match(a:file, '_spec\.rb') != -1
    let l:command = 'bundle exec rspec'
  elseif match(a:file, '\.rb') != -1
    let l:command = 'ruby'
  endif

  if exists("l:command")
    let l:run_script = "!osascript ~/.vim.local/tools/run_command.applescript" 
    silent execute ":up"
    silent execute l:run_script . " '" . l:command . " " . a:file . "' 'Ruby Tests'"
    silent execute ":redraw!"
  else
    echo "This file does not appear to be a ruby file " . a:file 
  end
endfunction

function! RunRubyFileInTerminal()
  call RunInTerminal(expand("%") . ":" . line("."))
endfunction 

command! RunRubyFileInTerminal call RunRubyFileInTerminal()

{'fraction_non_alphanumeric': 0.1417975567190227, 'fraction_numerical': 0.004799301919720768, 'mean_word_length': 3.807127882599581, 'pattern_counts': {'":': 6, '<': 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': '2353625', 'n_tokens_mistral': 842, 'n_tokens_neox': 805, 'n_words': 209}