<commit_before>function! DependencyWTF()
  let l:line = getline('.')

  if expand('%:t') == 'Gemfile'
    call l:gemfileWTF(l:line)
  elseif expand('%:e') == 'gemspec'
    call l:gemspecWTF(l:line)
  elseif &filetype == "vim"
    call l:vimWTF(l:line)
  endif
endfunction

function! l:openURL(url)
  if exists("g:dependencywtf_testing")
    echo a:url
  else
    execute "silent !open " . a:url
  endif
endfunction

" {{{ Gemfile
function! l:gemfileWTF(line)
  let gemName = l:gemNameFromGemfile(a:line)
  if gemName != ""
    call l:openURL("https://rubygems.org/gems/" . gemName)
  endif
endfunction

function! l:gemNameFromGemfile(line)
  return matchstr(a:line, '\vgem ("|'')\zs(\w|-)+\ze("|'')')
endfunction
" }}}

" {{{ gemspec
function! l:gemspecWTF(line)
  let gemName = l:gemNameFromGemspec(a:line)
  if gemName != ""
    call l:openURL("https://rubygems.org/gems/" . gemName)
  endif
endfunction

function! l:gemNameFromGemspec(line)
  return matchstr(a:line, '\v.*add_(development_)?dependency ("|'')\zs(\w|-)+\ze("|'')')
endfunction
" }}}

" {{{ Vundle
function! l:vimWTF(line)
  let bundle = l:bundleName(a:line)

  " TODO: Support for 'git://' style
  if bundle != ""
    if match(bundle, '/') == -1
      call l:openURL("https://github.com/vim-scripts/" . bundle)
    else
      call l:openURL("https://github.com/" . bundle)
    endif
  endif
endfunction

function! l:bundleName(line)
  return matchstr(a:line, '\v^(Bundle|Plugin) ("|'')\zs(\w|-|\/|\.)+\ze("|'')')
endfunction
" }}}

" vim: fdm=marker:fmr={{{,}}}<commit_msg>Fix error messages<commit_after>function! DependencyWTF()
  let s:line = getline('.')

  if expand('%:t') == 'Gemfile'
    call s:gemfileWTF(s:line)
  elseif expand('%:e') == 'gemspec'
    call s:gemspecWTF(s:line)
  elseif &filetype == "vim"
    call s:vimWTF(s:line)
  endif
endfunction

function! s:openURL(url)
  if exists("g:dependencywtf_testing")
    echo a:url
  else
    execute "silent !open " . a:url
  endif
endfunction

" {{{ Gemfile
function! s:gemfileWTF(line)
  let gemName = s:gemNameFromGemfile(a:line)
  if gemName != ""
    call s:openURL("https://rubygems.org/gems/" . gemName)
  endif
endfunction

function! s:gemNameFromGemfile(line)
  return matchstr(a:line, '\vgem ("|'')\zs(\w|-)+\ze("|'')')
endfunction
" }}}

" {{{ gemspec
function! s:gemspecWTF(line)
  let gemName = s:gemNameFromGemspec(a:line)
  if gemName != ""
    call s:openURL("https://rubygems.org/gems/" . gemName)
  endif
endfunction

function! s:gemNameFromGemspec(line)
  return matchstr(a:line, '\v.*add_(development_)?dependency ("|'')\zs(\w|-)+\ze("|'')')
endfunction
" }}}

" {{{ Vundle
function! s:vimWTF(line)
  let bundle = s:bundleName(a:line)

  " TODO: Support for 'git://' style
  if bundle != ""
    if match(bundle, '/') == -1
      call s:openURL("https://github.com/vim-scripts/" . bundle)
    else
      call s:openURL("https://github.com/" . bundle)
    endif
  endif
endfunction

function! s:bundleName(line)
  return matchstr(a:line, '\v^(Bundle|Plugin) ("|'')\zs(\w|-|\/|\.)+\ze("|'')')
endfunction
" }}}

" vim: fdm=marker:fmr={{{,}}}
{'fraction_non_alphanumeric': 0.2021379980563654, 'fraction_numerical': 0.0006478781988986071, 'mean_word_length': 4.155258764607679, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 8, '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': '4193489', 'n_tokens_mistral': 1251, 'n_tokens_neox': 1214, 'n_words': 221}