utils 0.0.37 → 0.0.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.37
1
+ 0.0.38
data/bin/probe CHANGED
@@ -29,36 +29,41 @@ end
29
29
 
30
30
  $config = Utils::Config::ConfigFile.new
31
31
  $config.parse_config_file File.expand_path('~/.utilsrc')
32
- $opt = go 't:n:h'
32
+ testrunner_args = []
33
+ if i = ARGV.index('--')
34
+ testrunner_args.concat ARGV[(i + 1)..-1]
35
+ ARGV[i..-1] = []
36
+ end
37
+ $opt = go 't:n:h-'
33
38
  filename = ARGV.shift or fail "require filename or filename:line_number as first argument"
34
39
  $opt['h'] and usage
35
40
  case ($opt['t'] || $config.probe.test_framework).to_sym
36
41
  when :rspec
37
42
  if line_number = $opt['n']
38
- cmd "rspec", '-I', $config.probe.include_dirs_argument, '-l', line_number , filename
43
+ cmd "rspec", '-I', $config.probe.include_dirs_argument, '-l', line_number, filename, *testrunner_args
39
44
  elsif filename =~ /^\s*([^:]+):(\d+)/
40
45
  filename, line_number = $1, $2
41
46
  puts "Running test at #{filename}:#{line_number}"
42
- cmd "rspec", '-I', $config.probe.include_dirs_argument, '-l', line_number , filename
47
+ cmd "rspec", '-I', $config.probe.include_dirs_argument, '-l', line_number, filename, *testrunner_args
43
48
  else
44
49
  puts "Running ALL tests in #{filename}"
45
- cmd "rspec", '-I', $config.probe.include_dirs_argument, filename
50
+ cmd "rspec", '-I', $config.probe.include_dirs_argument, filename, *testrunner_args
46
51
  end
47
52
  when :'test-unit'
48
53
  if testname = $opt['n']
49
- cmd "testrb", '-I', $config.probe.include_dirs_argument, '-n', testname , filename
54
+ cmd "testrb", '-I', $config.probe.include_dirs_argument, '-n', testname, filename, *testrunner_args
50
55
  elsif filename =~ /^\s*([^:]+):(\d+)/
51
56
  filename, line_number = $1, $2
52
57
  lf = Tins::LinesFile.for_filename filename, line_number.to_i
53
58
  if testname = lf.match_backward(/def\s+(\S+?)(?:\(|\s*$)/).full?(:first)
54
59
  puts "Running test #{testname.inspect} at #{filename}:#{lf.line_number}"
55
- cmd "testrb", '-I', $config.probe.include_dirs_argument, '-n', testname , filename
60
+ cmd "testrb", '-I', $config.probe.include_dirs_argument, '-n', testname, filename, *testrunner_args
56
61
  else
57
62
  warn "no test found before line #{line_number}"
58
63
  exit 1
59
64
  end
60
65
  else
61
66
  puts "Running ALL tests in #{filename}"
62
- cmd "testrb", '-I', $config.probe.include_dirs_argument, filename
67
+ cmd "testrb", '-I', $config.probe.include_dirs_argument, filename, *testrunner_args
63
68
  end
64
69
  end
@@ -1,12 +1,12 @@
1
1
  " autoload/rails.vim
2
- " Author: Tim Pope <vimNOSPAM@tpope.org>
2
+ " Author: Tim Pope <http://tpo.pe/>
3
3
 
4
4
  " Install this file as autoload/rails.vim.
5
5
 
6
6
  if exists('g:autoloaded_rails') || &cp
7
7
  finish
8
8
  endif
9
- let g:autoloaded_rails = '4.3'
9
+ let g:autoloaded_rails = '4.4'
10
10
 
11
11
  let s:cpo_save = &cpo
12
12
  set cpo&vim
@@ -44,6 +44,20 @@ function! s:compact(ary)
44
44
  return s:sub(s:sub(s:gsub(a:ary,'\n\n+','\n'),'\n$',''),'^\n','')
45
45
  endfunction
46
46
 
47
+ function! s:uniq(list)
48
+ let seen = {}
49
+ let i = 0
50
+ while i < len(a:list)
51
+ if has_key(seen,a:list[i])
52
+ call remove(a:list, i)
53
+ else
54
+ let seen[a:list[i]] = 1
55
+ let i += 1
56
+ endif
57
+ endwhile
58
+ return a:list
59
+ endfunction
60
+
47
61
  function! s:scrub(collection,item)
48
62
  " Removes item from a newline separated collection
49
63
  let col = "\n" . a:collection
@@ -302,10 +316,10 @@ endfunction
302
316
 
303
317
  call s:add_methods('readable',['end_of','last_opening_line','last_method_line','last_method','last_format','define_pattern'])
304
318
 
305
- let s:view_types = 'rhtml,erb,rxml,builder,rjs,mab,liquid,haml,dryml,mn'
319
+ let s:view_types = split('rhtml,erb,rxml,builder,rjs,mab,liquid,haml,dryml,mn,slim',',')
306
320
 
307
321
  function! s:viewspattern()
308
- return '\%('.s:gsub(s:view_types,',','\\|').'\)'
322
+ return '\%('.join(s:view_types,'\|').'\)'
309
323
  endfunction
310
324
 
311
325
  function! s:controller(...)
@@ -344,8 +358,10 @@ function! s:readable_controller_name(...) dict abort
344
358
  return s:sub(f,'.*<components/(.{-})/\k+\.\k+$','\1')
345
359
  elseif f =~ '\<app/models/.*\.rb$' && self.type_name('mailer')
346
360
  return s:sub(f,'.*<app/models/(.{-})\.rb$','\1')
347
- elseif f =~ '\<public/stylesheets/.*\.css$'
348
- return s:sub(f,'.*<public/stylesheets/(.{-})\.css$','\1')
361
+ elseif f =~ '\<\%(public\|app/assets\)/stylesheets/.*\.css\%(\.\w\+\)\=$'
362
+ return s:sub(f,'.*<%(public|app/assets)/stylesheets/(.{-})\.css%(\.\w+)=$','\1')
363
+ elseif f =~ '\<\%(public\|app/assets\)/javascripts/.*\.js\%(\.\w\+\)\=$'
364
+ return s:sub(f,'.*<%(public|app/assets)/javascripts/(.{-})\.js%(\.\w+)=$','\1')
349
365
  elseif a:0 && a:1
350
366
  return rails#pluralize(self.model_name())
351
367
  endif
@@ -510,7 +526,7 @@ function! rails#singularize(word)
510
526
  return word
511
527
  endif
512
528
  let word = s:sub(word,'eople$','ersons')
513
- let word = s:sub(word,'[aeio]@<!ies$','ys')
529
+ let word = s:sub(word,'%([Mm]ov|[aeio])@<!ies$','ys')
514
530
  let word = s:sub(word,'xe[ns]$','xs')
515
531
  let word = s:sub(word,'ves$','fs')
516
532
  let word = s:sub(word,'ss%(es)=$','sss')
@@ -592,7 +608,7 @@ endfunction
592
608
 
593
609
  function! s:buffer_name() dict abort
594
610
  let app = self.app()
595
- let f = s:gsub(fnamemodify(bufname(self.number()),':p'),'\\ @!','/')
611
+ let f = s:gsub(resolve(fnamemodify(bufname(self.number()),':p')),'\\ @!','/')
596
612
  let f = s:sub(f,'/$','')
597
613
  let sep = matchstr(f,'^[^\\/]\{3,\}\zs[\\/]')
598
614
  if sep != ""
@@ -921,10 +937,7 @@ function! s:BufCommands()
921
937
  command! -buffer -bar -nargs=0 -bang Rrefresh :if <bang>0|unlet! g:autoloaded_rails|source `=s:file`|endif|call s:Refresh(<bang>0)
922
938
  if exists(":NERDTree")
923
939
  command! -buffer -bar -nargs=? -complete=customlist,s:Complete_cd Rtree :NERDTree `=rails#app().path(<f-args>)`
924
- elseif exists(":Project")
925
- command! -buffer -bar -nargs=? Rtree :call s:Project(<bang>0,<q-args>)
926
940
  endif
927
- command! -buffer -bar -nargs=? Rproject :call s:warn("Warning: :Rproject has been deprecated in favor of :Rtree") | Rtree<bang> <args>
928
941
  if exists("g:loaded_dbext")
929
942
  command! -buffer -bar -nargs=? -complete=customlist,s:Complete_environments Rdbext :call s:BufDatabase(2,<q-args>)|let b:dbext_buffer_defaulted = 1
930
943
  endif
@@ -997,29 +1010,17 @@ function! rails#new_app_command(bang,...)
997
1010
  endif
998
1011
  return
999
1012
  endif
1000
- let dir = ""
1001
- if a:1 !~ '^-' && a:1 !=# 'new'
1002
- let dir = a:1
1003
- elseif a:{a:0} =~ '[\/]'
1004
- let dir = a:{a:0}
1005
- else
1006
- let dir = a:1
1007
- endif
1008
- let str = ""
1009
- let c = 1
1010
- while c <= a:0
1011
- let str .= " " . s:rquote(expand(a:{c}))
1012
- let c += 1
1013
- endwhile
1014
- let dir = expand(dir)
1015
- let append = ""
1013
+ let args = map(copy(a:000),'expand(v:val)')
1016
1014
  if a:bang
1017
- let append .= " --force"
1018
- endif
1019
- exe "!rails".append.str
1020
- if filereadable(dir."/".g:rails_default_file)
1021
- edit `=dir.'/'.g:rails_default_file`
1015
+ let args = ['--force'] + args
1022
1016
  endif
1017
+ exe '!rails '.join(map(copy(args),'s:rquote(v:val)'),' ')
1018
+ for dir in args
1019
+ if dir !~# '^-' && filereadable(dir.'/'.g:rails_default_file)
1020
+ edit `=dir.'/'.g:rails_default_file`
1021
+ return
1022
+ endif
1023
+ endfor
1023
1024
  endfunction
1024
1025
 
1025
1026
  function! s:app_tags_command() dict
@@ -1029,6 +1030,8 @@ function! s:app_tags_command() dict
1029
1030
  let cmd = "exuberant-ctags"
1030
1031
  elseif executable("ctags-exuberant")
1031
1032
  let cmd = "ctags-exuberant"
1033
+ elseif executable("exctags")
1034
+ let cmd = "exctags"
1032
1035
  elseif executable("ctags")
1033
1036
  let cmd = "ctags"
1034
1037
  elseif executable("ctags.exe")
@@ -1108,6 +1111,8 @@ let s:efm_backtrace='%D(in\ %f),'
1108
1111
  \.'%\\s%#from\ %f:%l:%m,'
1109
1112
  \.'%\\s%#from\ %f:%l:,'
1110
1113
  \.'%\\s#{RAILS_ROOT}/%f:%l:\ %#%m,'
1114
+ \.'%\\s%##\ %f:%l:%m,'
1115
+ \.'%\\s%##\ %f:%l,'
1111
1116
  \.'%\\s%#[%f:%l:\ %#%m,'
1112
1117
  \.'%\\s%#%f:%l:\ %#%m,'
1113
1118
  \.'%\\s%#%f:%l:,'
@@ -1132,7 +1137,9 @@ function! s:Rake(bang,lnum,arg)
1132
1137
  let old_makeprg = &l:makeprg
1133
1138
  let old_errorformat = &l:errorformat
1134
1139
  try
1135
- if &l:makeprg !~# 'rake'
1140
+ if exists('b:bundler_root') && b:bundler_root ==# rails#app().path()
1141
+ let &l:makeprg = 'bundle exec rake'
1142
+ else
1136
1143
  let &l:makeprg = 'rake'
1137
1144
  endif
1138
1145
  let &l:errorformat = s:efm_backtrace
@@ -1267,9 +1274,9 @@ function! s:readable_default_rake_task(lnum) dict abort
1267
1274
  let ver = matchstr(self.name(),'\<db/migrate/0*\zs\d*\ze_')
1268
1275
  if ver != ""
1269
1276
  let method = self.last_method(lnum)
1270
- if method == "down"
1277
+ if method == "down" || lnum == 1
1271
1278
  return "db:migrate:down VERSION=".ver
1272
- elseif method == "up"
1279
+ elseif method == "up" || lnum == line('$')
1273
1280
  return "db:migrate:up VERSION=".ver
1274
1281
  elseif lnum > 0
1275
1282
  return "db:migrate:down db:migrate:up VERSION=".ver
@@ -1374,6 +1381,10 @@ function! s:readable_preview_urls(lnum) dict abort
1374
1381
  let urls = urls + [s:sub(s:sub(self.name(),'^public/stylesheets/sass/','/stylesheets/'),'\.s[ac]ss$','.css')]
1375
1382
  elseif self.name() =~ '^public/'
1376
1383
  let urls = urls + [s:sub(self.name(),'^public','')]
1384
+ elseif self.name() =~ '^app/assets/stylesheets/'
1385
+ let urls = urls + ['/assets/application.css']
1386
+ elseif self.name() =~ '^app/assets/javascripts/'
1387
+ let urls = urls + ['/assets/application.js']
1377
1388
  elseif self.name() =~ '^app/stylesheets/'
1378
1389
  let urls = urls + [s:sub(s:sub(self.name(),'^app/stylesheets/','/stylesheets/'),'\.less$','.css')]
1379
1390
  elseif self.name() =~ '^app/scripts/'
@@ -1679,19 +1690,19 @@ endfunction
1679
1690
  function! s:BufNavCommands()
1680
1691
  command! -buffer -bar -nargs=? -complete=customlist,s:Complete_cd Rcd :cd `=rails#app().path(<q-args>)`
1681
1692
  command! -buffer -bar -nargs=? -complete=customlist,s:Complete_cd Rlcd :lcd `=rails#app().path(<q-args>)`
1682
- command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find Rfind :call s:Find(<count>,'<bang>' ,<f-args>)
1683
- command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find REfind :call s:Find(<count>,'E<bang>',<f-args>)
1684
- command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find RSfind :call s:Find(<count>,'S<bang>',<f-args>)
1685
- command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find RVfind :call s:Find(<count>,'V<bang>',<f-args>)
1686
- command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find RTfind :call s:Find(<count>,'T<bang>',<f-args>)
1687
- command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find Rsfind :<count>RSfind<bang> <args>
1688
- command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find Rtabfind :<count>RTfind<bang> <args>
1689
- command! -buffer -bar -nargs=* -bang -complete=customlist,s:Complete_edit Redit :call s:Edit(<count>,'<bang>' ,<f-args>)
1690
- command! -buffer -bar -nargs=* -bang -complete=customlist,s:Complete_edit REedit :call s:Edit(<count>,'E<bang>',<f-args>)
1691
- command! -buffer -bar -nargs=* -bang -complete=customlist,s:Complete_edit RSedit :call s:Edit(<count>,'S<bang>',<f-args>)
1692
- command! -buffer -bar -nargs=* -bang -complete=customlist,s:Complete_edit RVedit :call s:Edit(<count>,'V<bang>',<f-args>)
1693
- command! -buffer -bar -nargs=* -bang -complete=customlist,s:Complete_edit RTedit :call s:Edit(<count>,'T<bang>',<f-args>)
1694
- command! -buffer -bar -nargs=* -range=0 -complete=customlist,s:Complete_edit RDedit :call s:Edit(<count>,'<line1>D<bang>',<f-args>)
1693
+ command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find Rfind :call s:warn( 'Rfind has been deprecated in favor of :1R or :find' )|call s:Find(<count>,'<bang>' ,<f-args>)
1694
+ command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find REfind :call s:warn('REfind has been deprecated in favor of :1RE or :find')|call s:Find(<count>,'E<bang>',<f-args>)
1695
+ command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find RSfind :call s:warn('RSfind has been deprecated in favor of :1RS or :find')|call s:Find(<count>,'S<bang>',<f-args>)
1696
+ command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find RVfind :call s:warn('RVfind has been deprecated in favor of :1RV or :find')|call s:Find(<count>,'V<bang>',<f-args>)
1697
+ command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find RTfind :call s:warn('RTfind has been deprecated in favor of :1RT or :find')|call s:Find(<count>,'T<bang>',<f-args>)
1698
+ command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find Rsfind :call s:warn('Rsfind has been deprecated in favor of :1RS or :sfind')|<count>RSfind<bang> <args>
1699
+ command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find Rtabfind :call s:warn('Rtabfind has been deprecated in favor of :1RT or :tabfind')|<count>RTfind<bang> <args>
1700
+ command! -buffer -bar -nargs=* -bang -complete=customlist,s:Complete_edit Redit :call s:warn( 'Redit has been deprecated in favor of :R')|call s:Edit(<count>,'<bang>' ,<f-args>)
1701
+ command! -buffer -bar -nargs=* -bang -complete=customlist,s:Complete_edit REedit :call s:warn('REedit has been deprecated in favor of :RE')|call s:Edit(<count>,'E<bang>',<f-args>)
1702
+ command! -buffer -bar -nargs=* -bang -complete=customlist,s:Complete_edit RSedit :call s:warn('RSedit has been deprecated in favor of :RS')|call s:Edit(<count>,'S<bang>',<f-args>)
1703
+ command! -buffer -bar -nargs=* -bang -complete=customlist,s:Complete_edit RVedit :call s:warn('RVedit has been deprecated in favor of :RV')|call s:Edit(<count>,'V<bang>',<f-args>)
1704
+ command! -buffer -bar -nargs=* -bang -complete=customlist,s:Complete_edit RTedit :call s:warn('RTedit has been deprecated in favor of :RT')|call s:Edit(<count>,'T<bang>',<f-args>)
1705
+ command! -buffer -bar -nargs=* -range=0 -complete=customlist,s:Complete_edit RDedit :call s:warn('RDedit has been deprecated in favor of :RD')|call s:Edit(<count>,'<line1>D<bang>',<f-args>)
1695
1706
  command! -buffer -bar -nargs=* -range=0 -complete=customlist,s:Complete_related A :call s:Alternate('<bang>', <line1>,<line2>,<count>,<f-args>)
1696
1707
  command! -buffer -bar -nargs=* -range=0 -complete=customlist,s:Complete_related AE :call s:Alternate('E<bang>',<line1>,<line2>,<count>,<f-args>)
1697
1708
  command! -buffer -bar -nargs=* -range=0 -complete=customlist,s:Complete_related AS :call s:Alternate('S<bang>',<line1>,<line2>,<count>,<f-args>)
@@ -1788,8 +1799,7 @@ function! s:Complete_find(ArgLead, CmdLine, CursorPos)
1788
1799
  endfor
1789
1800
  endif
1790
1801
  endfor
1791
- let results = sort(map(keys(seen),'s:sub(v:val,"[.]rb$","")'))
1792
- return s:autocamelize(results,a:ArgLead)
1802
+ return s:autocamelize(sort(keys(seen)),a:ArgLead)
1793
1803
  endfunction
1794
1804
 
1795
1805
  function! s:Complete_edit(ArgLead, CmdLine, CursorPos)
@@ -1846,7 +1856,7 @@ function! s:findamethod(func,repl)
1846
1856
  endfunction
1847
1857
 
1848
1858
  function! s:findasymbol(sym,repl)
1849
- return s:findit('\s*:\%('.a:sym.'\)\s*=>\s*(\=\s*[@:'."'".'"]\(\f\+\)\>.\=',a:repl)
1859
+ return s:findit('\s*\%(:\%('.a:sym.'\)\s*=>\|\<'.a:sym.':\)\s*(\=\s*[@:'."'".'"]\(\f\+\)\>.\=',a:repl)
1850
1860
  endfunction
1851
1861
 
1852
1862
  function! s:findfromview(func,repl)
@@ -1901,10 +1911,10 @@ function! s:RailsFind()
1901
1911
  let res = s:findasymbol('to','app/controllers/\1')
1902
1912
  if res =~ '#'|return s:sub(res,'#','_controller.rb#')|endif
1903
1913
 
1904
- let res = s:findamethod('root\s*:to\s*=>\s*','app/controllers/\1')
1914
+ let res = s:findamethod('root\s*\%(:to\s*=>\|\<to:\)\s*','app/controllers/\1')
1905
1915
  if res =~ '#'|return s:sub(res,'#','_controller.rb#')|endif
1906
1916
 
1907
- let res = s:findamethod('\%(match\|get\|put\|post\|delete\|redirect\)\s*(\=\s*[:''"][^''"]*[''"]\=\s*\%(,\s*:to\s*\)\==>\s*','app/controllers/\1')
1917
+ let res = s:findamethod('\%(match\|get\|put\|post\|delete\|redirect\)\s*(\=\s*[:''"][^''"]*[''"]\=\s*\%(\%(,\s*:to\s*\)\==>\|,\s*to:\)\s*','app/controllers/\1')
1908
1918
  if res =~ '#'|return s:sub(res,'#','_controller.rb#')|endif
1909
1919
 
1910
1920
  let res = s:findamethod('layout','\=s:findlayout(submatch(1))')
@@ -1925,20 +1935,20 @@ function! s:RailsFind()
1925
1935
  let res = s:findasymbol('template','app/views/\1')
1926
1936
  if res != ""|return res|endif
1927
1937
 
1928
- let res = s:sub(s:sub(s:findasymbol('partial','\1'),'^/',''),'\k+$','_&')
1938
+ let res = s:sub(s:sub(s:findasymbol('partial','\1'),'^/',''),'[^/]+$','_&')
1929
1939
  if res != ""|return res."\n".s:findview(res)|endif
1930
1940
 
1931
- let res = s:sub(s:sub(s:findfromview('render\s*(\=\s*:partial\s\+=>\s*','\1'),'^/',''),'\k+$','_&')
1941
+ let res = s:sub(s:sub(s:findfromview('render\s*(\=\s*\%(:partial\s\+=>\|partial:\)\s*','\1'),'^/',''),'[^/]+$','_&')
1932
1942
  if res != ""|return res."\n".s:findview(res)|endif
1933
1943
 
1934
- let res = s:findamethod('render\s*:\%(template\|action\)\s\+=>\s*','\1.'.format.'\n\1')
1944
+ let res = s:findamethod('render\>\s*\%(:\%(template\|action\)\s\+=>\|template:\|action:\)\s*','\1.'.format.'\n\1')
1935
1945
  if res != ""|return res|endif
1936
1946
 
1937
1947
  let res = s:sub(s:findfromview('render','\1'),'^/','')
1938
1948
  if buffer.type_name('view') | let res = s:sub(res,'[^/]+$','_&') | endif
1939
1949
  if res != ""|return res."\n".s:findview(res)|endif
1940
1950
 
1941
- let res = s:findamethod('redirect_to\s*(\=\s*:action\s\+=>\s*','\1')
1951
+ let res = s:findamethod('redirect_to\s*(\=\s*\%\(:action\s\+=>\|\<action:\)\s*','\1')
1942
1952
  if res != ""|return res|endif
1943
1953
 
1944
1954
  let res = s:findfromview('stylesheet_link_tag','public/stylesheets/\1')
@@ -2033,7 +2043,7 @@ function! s:RailsIncludefind(str,...)
2033
2043
  " Classes should always be in .rb files
2034
2044
  let str .= '.rb'
2035
2045
  elseif line =~# ':partial\s*=>\s*'
2036
- let str = s:sub(str,'([^/]+)$','_\1')
2046
+ let str = s:sub(str,'[^/]+$','_&')
2037
2047
  let str = s:findview(str)
2038
2048
  elseif line =~# '\<layout\s*(\=\s*' || line =~# ':layout\s*=>\s*'
2039
2049
  let str = s:findview(s:sub(str,'^/=','layouts/'))
@@ -2124,6 +2134,7 @@ function! s:BufFinderCommands()
2124
2134
  call s:addfilecmds("controller")
2125
2135
  call s:addfilecmds("mailer")
2126
2136
  call s:addfilecmds("migration")
2137
+ call s:addfilecmds("schema")
2127
2138
  call s:addfilecmds("observer")
2128
2139
  call s:addfilecmds("helper")
2129
2140
  call s:addfilecmds("layout")
@@ -2229,11 +2240,21 @@ function! s:layoutList(A,L,P)
2229
2240
  endfunction
2230
2241
 
2231
2242
  function! s:stylesheetList(A,L,P)
2232
- return s:completion_filter(rails#app().relglob("public/stylesheets/","**/*",".css"),a:A)
2243
+ let list = rails#app().relglob('app/assets/stylesheets/','**/*.*','')
2244
+ call map(list,'s:sub(v:val,"\\..*$","")')
2245
+ let list += rails#app().relglob('public/stylesheets/','**/*','.css')
2246
+ if rails#app().has('sass')
2247
+ call extend(list,rails#app().relglob('public/stylesheets/sass/','**/*','.s?ss'))
2248
+ call s:uniq(list)
2249
+ endif
2250
+ return s:completion_filter(list,a:A)
2233
2251
  endfunction
2234
2252
 
2235
2253
  function! s:javascriptList(A,L,P)
2236
- return s:completion_filter(rails#app().relglob("public/javascripts/","**/*",".js"),a:A)
2254
+ let list = rails#app().relglob('app/assets/javascripts/','**/*.*','')
2255
+ call map(list,'s:sub(v:val,"\\..*$","")')
2256
+ let list += rails#app().relglob("public/javascripts/","**/*",".js")
2257
+ return s:completion_filter(list,a:A)
2237
2258
  endfunction
2238
2259
 
2239
2260
  function! s:metalList(A,L,P)
@@ -2269,6 +2290,14 @@ function! s:migrationList(A,L,P)
2269
2290
  endif
2270
2291
  endfunction
2271
2292
 
2293
+ function! s:schemaList(A,L,P)
2294
+ let tables = s:readfile(rails#app().path('db/schema.rb'))
2295
+ let table_re = '^\s\+create_table\s["'':]\zs[^"'',]*\ze'
2296
+ call map(tables,'matchstr(v:val, table_re)')
2297
+ call filter(tables,'strlen(v:val)')
2298
+ return s:autocamelize(tables, a:A)
2299
+ endfunction
2300
+
2272
2301
  function! s:unittestList(A,L,P)
2273
2302
  let found = []
2274
2303
  if rails#app().has('test')
@@ -2471,11 +2500,18 @@ function! s:app_migration(file) dict
2471
2500
  else
2472
2501
  let glob = '*'.rails#underscore(arg).'*rb'
2473
2502
  endif
2474
- let migr = s:sub(glob(self.path('db/migrate/').glob),'.*\n','')
2475
- if s:startswith(migr,self.path())
2476
- let migr = strpart(migr,1+strlen(self.path()))
2503
+ let files = split(glob(self.path('db/migrate/').glob),"\n")
2504
+ if arg == ''
2505
+ return get(files,-1,'')
2477
2506
  endif
2478
- return migr
2507
+ call map(files,'strpart(v:val,1+strlen(self.path()))')
2508
+ let keep = get(files,0,'')
2509
+ if glob =~# '^\*.*\*rb'
2510
+ let pattern = glob[1:-4]
2511
+ call filter(files,'v:val =~# ''db/migrate/\d\+_''.pattern.''\.rb''')
2512
+ let keep = get(files,0,keep)
2513
+ endif
2514
+ return keep
2479
2515
  endfunction
2480
2516
 
2481
2517
  call s:add_methods('app', ['migration'])
@@ -2491,6 +2527,15 @@ function! s:migrationEdit(cmd,...)
2491
2527
  endif
2492
2528
  endfunction
2493
2529
 
2530
+ function! s:schemaEdit(cmd,...)
2531
+ let cmd = s:findcmdfor(a:cmd)
2532
+ let schema = 'db/'.s:environment().'_structure.sql'
2533
+ if rails#app().has_file('db/schema.rb') || !rails#app().has_file(schema)
2534
+ let schema = 'db/schema.rb'
2535
+ endif
2536
+ call s:findedit(cmd,schema.(a:0 ? '#'.a:1 : ''))
2537
+ endfunction
2538
+
2494
2539
  function! s:fixturesEdit(cmd,...)
2495
2540
  if a:0
2496
2541
  let c = rails#underscore(a:1)
@@ -2591,7 +2636,7 @@ function! s:findview(name)
2591
2636
  return pre.name
2592
2637
  else
2593
2638
  for format in ['.'.s:format('html'), '']
2594
- for type in split(s:view_types,',')
2639
+ for type in s:view_types
2595
2640
  if self.app().has_file(pre.name.format.'.'.type)
2596
2641
  return pre.name.format.'.'.type
2597
2642
  endif
@@ -2652,7 +2697,12 @@ function! s:stylesheetEdit(cmd,...)
2652
2697
  elseif rails#app().has('lesscss') && rails#app().has_file('app/stylesheets/'.name.'.less')
2653
2698
  return s:EditSimpleRb(a:cmd,"stylesheet",name,"app/stylesheets/",".less",1)
2654
2699
  else
2655
- return s:EditSimpleRb(a:cmd,"stylesheet",name,"public/stylesheets/",".css",1)
2700
+ let types = rails#app().relglob('app/assets/stylesheets/'.name,'.*','')
2701
+ if !empty(types)
2702
+ return s:EditSimpleRb(a:cmd,'stylesheet',name,'app/assets/stylesheets/',types[0],1)
2703
+ else
2704
+ return s:EditSimpleRb(a:cmd,'stylesheet',name,'public/stylesheets/','.css',1)
2705
+ endif
2656
2706
  endif
2657
2707
  endfunction
2658
2708
 
@@ -2663,7 +2713,12 @@ function! s:javascriptEdit(cmd,...)
2663
2713
  elseif rails#app().has('coffee') && rails#app().has_file('app/scripts/'.name.'.js')
2664
2714
  return s:EditSimpleRb(a:cmd,'javascript',name,'app/scripts/','.js',1)
2665
2715
  else
2666
- return s:EditSimpleRb(a:cmd,'javascript',name,'public/javascripts/','.js',1)
2716
+ let types = rails#app().relglob('app/assets/javascripts/'.name,'.*','')
2717
+ if !empty(types)
2718
+ return s:EditSimpleRb(a:cmd,'javascript',name,'app/assets/javascripts/',types[0],1)
2719
+ else
2720
+ return s:EditSimpleRb(a:cmd,'javascript',name,'public/javascripts/','.js',1)
2721
+ endif
2667
2722
  endif
2668
2723
  endfunction
2669
2724
 
@@ -3023,6 +3078,10 @@ function! s:readable_related(...) dict abort
3023
3078
  return "config/application.rb\nconfig/environment.rb"
3024
3079
  elseif f =~ '\<config/\%(application\|environment\)\.rb$'
3025
3080
  return "config/database.yml"
3081
+ elseif f ==# 'Gemfile'
3082
+ return 'Gemfile.lock'
3083
+ elseif f ==# 'Gemfile.lock'
3084
+ return 'Gemfile'
3026
3085
  elseif f =~ '\<db/migrate/'
3027
3086
  let migrations = sort(self.app().relglob('db/migrate/','*','.rb'))
3028
3087
  let me = matchstr(f,'\<db/migrate/\zs.*\ze\.rb$')
@@ -3309,9 +3368,9 @@ function! s:invertrange(beg,end)
3309
3368
  endif
3310
3369
  let add .= s:mkeep(line)
3311
3370
  elseif line =~ '\<remove_index\>'
3312
- let add = s:sub(s:sub(line,'<remove_index','add_index'),':column\s*=>\s*','')
3313
- elseif line =~ '\<rename_\%(table\|column\)\>'
3314
- let add = s:sub(line,'<rename_%(table\s*\(=\s*|column\s*\(=\s*[^,]*,\s*)\zs([^,]*)(,\s*)([^,]*)','\3\2\1')
3371
+ let add = s:sub(s:sub(line,'<remove_index','add_index'),':column\s*\=\>\s*','')
3372
+ elseif line =~ '\<rename_\%(table\|column\|index\)\>'
3373
+ let add = s:sub(line,'<rename_%(table\s*\(=\s*|%(column|index)\s*\(=\s*[^,]*,\s*)\zs([^,]*)(,\s*)([^,]*)','\3\2\1')
3315
3374
  elseif line =~ '\<change_column\>'
3316
3375
  let add = s:migspc(line).'change_column'.s:mextargs(line,2).s:mkeep(line)
3317
3376
  elseif line =~ '\<change_column_default\>'
@@ -3435,26 +3494,26 @@ endfunction
3435
3494
 
3436
3495
  function! s:helpermethods()
3437
3496
  return ""
3438
- \."atom_feed audio_path audio_tag auto_discovery_link_tag auto_link "
3439
- \."button_to button_to_function "
3440
- \."cache capture cdata_section check_box check_box_tag collection_select concat content_for content_tag content_tag_for csrf_meta_tag current_cycle cycle "
3441
- \."date_select datetime_select debug distance_of_time_in_words distance_of_time_in_words_to_now div_for dom_class dom_id draggable_element draggable_element_js drop_receiving_element drop_receiving_element_js "
3442
- \."email_field email_field_tag error_message_on error_messages_for escape_javascript escape_once excerpt "
3443
- \."favicon_link_tag field_set_tag fields_for file_field file_field_tag form form_for form_tag "
3497
+ \."action_name atom_feed audio_path audio_tag auto_discovery_link_tag "
3498
+ \."button_tag button_to button_to_function "
3499
+ \."cache capture cdata_section check_box check_box_tag collection_select concat content_for content_tag content_tag_for controller controller_name controller_path convert_to_model cookies csrf_meta_tag csrf_meta_tags current_cycle cycle "
3500
+ \."date_select datetime_select debug distance_of_time_in_words distance_of_time_in_words_to_now div_for dom_class dom_id "
3501
+ \."email_field email_field_tag escape_javascript escape_once excerpt "
3502
+ \."favicon_link_tag field_set_tag fields_for file_field file_field_tag flash form_for form_tag "
3444
3503
  \."grouped_collection_select grouped_options_for_select "
3445
- \."hidden_field hidden_field_tag highlight "
3446
- \."image_path image_submit_tag image_tag input "
3447
- \."javascript_cdata_section javascript_include_tag javascript_path javascript_tag "
3448
- \."l label label_tag link_to link_to_function link_to_if link_to_unless link_to_unless_current localize "
3504
+ \."headers hidden_field hidden_field_tag highlight "
3505
+ \."image_alt image_path image_submit_tag image_tag "
3506
+ \."j javascript_cdata_section javascript_include_tag javascript_path javascript_tag "
3507
+ \."l label label_tag link_to link_to_function link_to_if link_to_unless link_to_unless_current localize logger "
3449
3508
  \."mail_to "
3450
3509
  \."number_field number_field_tag number_to_currency number_to_human number_to_human_size number_to_percentage number_to_phone number_with_delimiter number_with_precision "
3451
3510
  \."option_groups_from_collection_for_select options_for_select options_from_collection_for_select "
3452
- \."password_field password_field_tag path_to_audio path_to_image path_to_javascript path_to_stylesheet path_to_video phone_field phone_field_tag pluralize "
3453
- \."radio_button radio_button_tag range_field range_field_tag raw remote_function reset_cycle "
3454
- \."safe_concat sanitize sanitize_css search_field search_field_tag select select_date select_datetime select_day select_hour select_minute select_month select_second select_tag select_time select_year simple_format sortable_element sortable_element_js strip_links strip_tags stylesheet_link_tag stylesheet_path submit_tag "
3455
- \."t tag telephone_field telephone_field_tag text_area text_area_tag text_field text_field_tag time_ago_in_words time_select time_zone_options_for_select time_zone_select translate truncate "
3456
- \."update_page update_page_tag url_field url_field_tag url_for url_options "
3457
- \."video_path video_tag visual_effect "
3511
+ \."params password_field password_field_tag path_to_audio path_to_image path_to_javascript path_to_stylesheet path_to_video phone_field phone_field_tag pluralize provide "
3512
+ \."radio_button radio_button_tag range_field range_field_tag raw render request request_forgery_protection_token reset_cycle response "
3513
+ \."safe_concat safe_join sanitize sanitize_css search_field search_field_tag select select_date select_datetime select_day select_hour select_minute select_month select_second select_tag select_time select_year session simple_format strip_links strip_tags stylesheet_link_tag stylesheet_path submit_tag "
3514
+ \."t tag telephone_field telephone_field_tag text_area text_area_tag text_field text_field_tag time_ago_in_words time_select time_tag time_zone_options_for_select time_zone_select translate truncate "
3515
+ \."url_field url_field_tag url_for url_options "
3516
+ \."video_path video_tag "
3458
3517
  \."word_wrap"
3459
3518
  endfunction
3460
3519
 
@@ -3509,7 +3568,7 @@ function! s:BufSyntax()
3509
3568
  syn keyword rubyRailsARCallbackMethod after_create after_destroy after_save after_update after_validation after_validation_on_create after_validation_on_update
3510
3569
  syn keyword rubyRailsARCallbackMethod around_create around_destroy around_save around_update
3511
3570
  syn keyword rubyRailsARCallbackMethod after_commit after_find after_initialize after_rollback after_touch
3512
- syn keyword rubyRailsARClassMethod attr_accessible attr_protected establish_connection set_inheritance_column set_locking_column set_primary_key set_sequence_name set_table_name
3571
+ syn keyword rubyRailsARClassMethod attr_accessible attr_protected attr_readonly establish_connection set_inheritance_column set_locking_column set_primary_key set_sequence_name set_table_name
3513
3572
  syn keyword rubyRailsARValidationMethod validate validates validate_on_create validate_on_update validates_acceptance_of validates_associated validates_confirmation_of validates_each validates_exclusion_of validates_format_of validates_inclusion_of validates_length_of validates_numericality_of validates_presence_of validates_size_of validates_uniqueness_of
3514
3573
  syn keyword rubyRailsMethod logger
3515
3574
  endif
@@ -3521,28 +3580,27 @@ function! s:BufSyntax()
3521
3580
  syn keyword rubyRailsRenderMethod mail render
3522
3581
  syn keyword rubyRailsControllerMethod attachments default helper helper_attr helper_method
3523
3582
  endif
3524
- if buffer.type_name('controller','view','helper')
3525
- syn keyword rubyRailsMethod params request response session headers cookies flash
3526
- syn keyword rubyRailsRenderMethod render
3527
- syn keyword rubyRailsMethod logger polymorphic_path polymorphic_url
3528
- endif
3529
3583
  if buffer.type_name('helper','view')
3584
+ syn keyword rubyRailsViewMethod polymorphic_path polymorphic_url
3530
3585
  exe "syn keyword rubyRailsHelperMethod ".s:gsub(s:helpermethods(),'<%(content_for|select)\s+','')
3531
3586
  syn match rubyRailsHelperMethod '\<select\>\%(\s*{\|\s*do\>\|\s*(\=\s*&\)\@!'
3532
3587
  syn match rubyRailsHelperMethod '\<\%(content_for?\=\|current_page?\)'
3533
- syn match rubyRailsViewMethod '\.\@<!\<\(h\|html_escape\|u\|url_encode\|controller\)\>'
3588
+ syn match rubyRailsViewMethod '\.\@<!\<\(h\|html_escape\|u\|url_encode\)\>'
3534
3589
  if buffer.type_name('view-partial')
3535
3590
  syn keyword rubyRailsMethod local_assigns
3536
3591
  endif
3537
3592
  elseif buffer.type_name('controller')
3593
+ syn keyword rubyRailsMethod params request response session headers cookies flash
3594
+ syn keyword rubyRailsRenderMethod render
3595
+ syn keyword rubyRailsMethod logger polymorphic_path polymorphic_url
3538
3596
  syn keyword rubyRailsControllerMethod helper helper_attr helper_method filter layout url_for serialize exempt_from_layout filter_parameter_logging hide_action cache_sweeper protect_from_forgery caches_page cache_page caches_action expire_page expire_action rescue_from
3539
3597
  syn keyword rubyRailsRenderMethod head redirect_to render_to_string respond_with
3540
3598
  syn match rubyRailsRenderMethod '\<respond_to\>?\@!'
3541
- syn keyword rubyRailsFilterMethod before_filter append_before_filter prepend_before_filter after_filter append_after_filter prepend_after_filter around_filter append_around_filter prepend_around_filter skip_before_filter skip_after_filter
3599
+ syn keyword rubyRailsFilterMethod before_filter append_before_filter prepend_before_filter after_filter append_after_filter prepend_after_filter around_filter append_around_filter prepend_around_filter skip_before_filter skip_after_filter skip_filter
3542
3600
  syn keyword rubyRailsFilterMethod verify
3543
3601
  endif
3544
3602
  if buffer.type_name('db-migration','db-schema')
3545
- syn keyword rubyRailsMigrationMethod create_table change_table drop_table rename_table add_column rename_column change_column change_column_default remove_column add_index remove_index
3603
+ syn keyword rubyRailsMigrationMethod create_table change_table drop_table rename_table add_column rename_column change_column change_column_default remove_column add_index remove_index rename_index execute
3546
3604
  endif
3547
3605
  if buffer.type_name('test')
3548
3606
  if !empty(rails#app().user_assertions())
@@ -3556,13 +3614,13 @@ function! s:BufSyntax()
3556
3614
  syn keyword rubyRailsTestControllerMethod assert_response assert_redirected_to assert_template assert_recognizes assert_generates assert_routing assert_dom_equal assert_dom_not_equal assert_select assert_select_rjs assert_select_encoded assert_select_email assert_tag assert_no_tag
3557
3615
  endif
3558
3616
  elseif buffer.type_name('spec')
3559
- syn keyword rubyRailsTestMethod describe context it its specify shared_examples_for it_should_behave_like before after subject fixtures controller_name helper_name
3617
+ syn keyword rubyRailsTestMethod describe context it its specify shared_examples_for it_should_behave_like before after around subject fixtures controller_name helper_name scenario feature background
3560
3618
  syn match rubyRailsTestMethod '\<let\>!\='
3561
3619
  syn keyword rubyRailsTestMethod violated pending expect double mock mock_model stub_model
3562
3620
  syn match rubyRailsTestMethod '\.\@<!\<stub\>!\@!'
3563
3621
  if !buffer.type_name('spec-model')
3564
3622
  syn match rubyRailsTestControllerMethod '\.\@<!\<\%(get\|post\|put\|delete\|head\|process\|assigns\)\>'
3565
- syn keyword rubyRailsTestControllerMethod integrate_views
3623
+ syn keyword rubyRailsTestControllerMethod integrate_views render_views
3566
3624
  syn keyword rubyRailsMethod params request response session flash
3567
3625
  syn keyword rubyRailsMethod polymorphic_path polymorphic_url
3568
3626
  endif
@@ -3580,7 +3638,7 @@ function! s:BufSyntax()
3580
3638
  syn keyword rubyRailsMethod debugger
3581
3639
  syn keyword rubyRailsMethod alias_attribute alias_method_chain attr_accessor_with_default attr_internal attr_internal_accessor attr_internal_reader attr_internal_writer delegate mattr_accessor mattr_reader mattr_writer superclass_delegating_accessor superclass_delegating_reader superclass_delegating_writer
3582
3640
  syn keyword rubyRailsMethod cattr_accessor cattr_reader cattr_writer class_inheritable_accessor class_inheritable_array class_inheritable_array_writer class_inheritable_hash class_inheritable_hash_writer class_inheritable_option class_inheritable_reader class_inheritable_writer inheritable_attributes read_inheritable_attribute reset_inheritable_attributes write_inheritable_array write_inheritable_attribute write_inheritable_hash
3583
- syn keyword rubyRailsInclude require_dependency gem
3641
+ syn keyword rubyRailsInclude require_dependency
3584
3642
 
3585
3643
  syn region rubyString matchgroup=rubyStringDelimiter start=+\%(:order\s*=>\s*\)\@<="+ skip=+\\\\\|\\"+ end=+"+ contains=@rubyStringSpecial,railsOrderSpecial
3586
3644
  syn region rubyString matchgroup=rubyStringDelimiter start=+\%(:order\s*=>\s*\)\@<='+ skip=+\\\\\|\\'+ end=+'+ contains=@rubyStringSpecial,railsOrderSpecial
@@ -3610,7 +3668,7 @@ function! s:BufSyntax()
3610
3668
  syn cluster htmlArgCluster add=@rubyStringSpecial
3611
3669
  syn cluster htmlPreProc add=@rubyStringSpecial
3612
3670
 
3613
- elseif &syntax == 'eruby' || &syntax == 'haml'
3671
+ elseif &syntax =~# '^eruby\>' || &syntax == 'haml'
3614
3672
  syn case match
3615
3673
  if classes != ''
3616
3674
  exe 'syn keyword '.&syntax.'RailsUserClass '.classes.' contained containedin=@'.&syntax.'RailsRegions'
@@ -3623,9 +3681,8 @@ function! s:BufSyntax()
3623
3681
  exe 'syn keyword '.&syntax.'RailsHelperMethod '.s:gsub(s:helpermethods(),'<%(content_for|select)\s+','').' contained containedin=@'.&syntax.'RailsRegions'
3624
3682
  exe 'syn match '.&syntax.'RailsHelperMethod "\<select\>\%(\s*{\|\s*do\>\|\s*(\=\s*&\)\@!" contained containedin=@'.&syntax.'RailsRegions'
3625
3683
  exe 'syn match '.&syntax.'RailsHelperMethod "\<\%(content_for?\=\|current_page?\)" contained containedin=@'.&syntax.'RailsRegions'
3626
- exe 'syn keyword '.&syntax.'RailsMethod debugger logger polymorphic_path polymorphic_url contained containedin=@'.&syntax.'RailsRegions'
3627
- exe 'syn keyword '.&syntax.'RailsMethod params request response session headers cookies flash contained containedin=@'.&syntax.'RailsRegions'
3628
- exe 'syn match '.&syntax.'RailsViewMethod "\.\@<!\<\(h\|html_escape\|u\|url_encode\|controller\)\>" contained containedin=@'.&syntax.'RailsRegions'
3684
+ exe 'syn keyword '.&syntax.'RailsMethod debugger polymorphic_path polymorphic_url contained containedin=@'.&syntax.'RailsRegions'
3685
+ exe 'syn match '.&syntax.'RailsViewMethod "\.\@<!\<\(h\|html_escape\|u\|url_encode\)\>" contained containedin=@'.&syntax.'RailsRegions'
3629
3686
  if buffer.type_name('view-partial')
3630
3687
  exe 'syn keyword '.&syntax.'RailsMethod local_assigns contained containedin=@'.&syntax.'RailsRegions'
3631
3688
  endif
@@ -3642,10 +3699,10 @@ function! s:BufSyntax()
3642
3699
  syn include @rubyTop syntax/ruby.vim
3643
3700
  unlet g:main_syntax
3644
3701
  syn cluster yamlRailsRegions contains=yamlRailsOneLiner,yamlRailsBlock,yamlRailsExpression
3645
- syn region yamlRailsOneLiner matchgroup=yamlRailsDelimiter start="^%%\@!" end="$" contains=@rubyRailsTop containedin=ALLBUT,@yamlRailsRegions,yamlRailsComment keepend oneline
3646
- syn region yamlRailsBlock matchgroup=yamlRailsDelimiter start="<%%\@!" end="%>" contains=@rubyTop containedin=ALLBUT,@yamlRailsRegions,yamlRailsComment
3647
- syn region yamlRailsExpression matchgroup=yamlRailsDelimiter start="<%=" end="%>" contains=@rubyTop containedin=ALLBUT,@yamlRailsRegions,yamlRailsComment
3648
- syn region yamlRailsComment matchgroup=yamlRailsDelimiter start="<%#" end="%>" contains=rubyTodo,@Spell containedin=ALLBUT,@yamlRailsRegions,yamlRailsComment keepend
3702
+ syn region yamlRailsOneLiner matchgroup=yamlRailsDelimiter start="^%%\@!" end="$" contains=@rubyRailsTop containedin=ALLBUT,@yamlRailsRegions,yamlRailsComment keepend oneline
3703
+ syn region yamlRailsBlock matchgroup=yamlRailsDelimiter start="<%%\@!" end="%>" contains=@rubyTop containedin=ALLBUT,@yamlRailsRegions,yamlRailsComment
3704
+ syn region yamlRailsExpression matchgroup=yamlRailsDelimiter start="<%=" end="%>" contains=@rubyTop containedin=ALLBUT,@yamlRailsRegions,yamlRailsComment
3705
+ syn region yamlRailsComment matchgroup=yamlRailsDelimiter start="<%#" end="%>" contains=rubyTodo,@Spell containedin=ALLBUT,@yamlRailsRegions,yamlRailsComment keepend
3649
3706
  syn match yamlRailsMethod '\.\@<!\<\(h\|html_escape\|u\|url_encode\)\>' contained containedin=@yamlRailsRegions
3650
3707
  if classes != ''
3651
3708
  exe "syn keyword yamlRailsUserClass ".classes." contained containedin=@yamlRailsRegions"
@@ -3662,6 +3719,9 @@ function! s:BufSyntax()
3662
3719
  set isk+=$
3663
3720
  exe "syn keyword javascriptRailsFunction ".s:javascript_functions
3664
3721
 
3722
+ elseif &syntax == "scss" || &syntax == "sass"
3723
+ syn match sassFunction "\<\%(\%(asset\|image\|font\|video\|audio\|javascript\|stylesheet\)-\%(url\|path\)\)\>(\@=" contained
3724
+ syn match sassFunction "\<\asset-data-url\>(\@=" contained
3665
3725
  endif
3666
3726
  endif
3667
3727
  call s:HiDefaults()
@@ -3763,101 +3823,14 @@ function! rails#log_syntax()
3763
3823
  hi def link railslogHTTP Special
3764
3824
  endfunction
3765
3825
 
3766
- " }}}1
3767
- " Statusline {{{1
3768
-
3769
- function! s:addtostatus(letter,status)
3770
- let status = a:status
3771
- if status !~ 'rails' && g:rails_statusline
3772
- let status=substitute(status,'\C%'.tolower(a:letter),'%'.tolower(a:letter).'%{rails#statusline()}','')
3773
- if status !~ 'rails'
3774
- let status=substitute(status,'\C%'.toupper(a:letter),'%'.toupper(a:letter).'%{rails#STATUSLINE()}','')
3775
- endif
3776
- endif
3777
- return status
3778
- endfunction
3779
-
3780
- function! s:BufInitStatusline()
3781
- if g:rails_statusline
3782
- if &l:statusline == ''
3783
- let &l:statusline = &g:statusline
3784
- endif
3785
- if &l:statusline == ''
3786
- let &l:statusline='%<%f %h%m%r%='
3787
- if &ruler
3788
- let &l:statusline .= '%-14.(%l,%c%V%) %P'
3789
- endif
3790
- endif
3791
- let &l:statusline = s:InjectIntoStatusline(&l:statusline)
3792
- endif
3793
- endfunction
3794
-
3795
- function! s:InitStatusline()
3796
- if g:rails_statusline
3797
- if &g:statusline == ''
3798
- let &g:statusline='%<%f %h%m%r%='
3799
- if &ruler
3800
- let &g:statusline .= '%-16( %l,%c-%v %)%P'
3801
- endif
3802
- endif
3803
- let &g:statusline = s:InjectIntoStatusline(&g:statusline)
3804
- endif
3805
- endfunction
3806
-
3807
- function! s:InjectIntoStatusline(status)
3808
- let status = a:status
3809
- if status !~ 'rails'
3810
- let status = s:addtostatus('y',status)
3811
- let status = s:addtostatus('r',status)
3812
- let status = s:addtostatus('m',status)
3813
- let status = s:addtostatus('w',status)
3814
- let status = s:addtostatus('h',status)
3815
- if status !~ 'rails'
3816
- let status=substitute(status,'%=','%{rails#statusline()}%=','')
3817
- endif
3818
- if status !~ 'rails' && status != ''
3819
- let status .= '%{rails#statusline()}'
3820
- endif
3821
- endif
3822
- return status
3823
- endfunction
3824
-
3825
- function! rails#statusline(...)
3826
- if exists("b:rails_root")
3827
- let t = rails#buffer().type_name()
3828
- if t != "" && a:0 && a:1
3829
- return "[Rails-".t."]"
3830
- else
3831
- return "[Rails]"
3832
- endif
3833
- else
3834
- return ""
3835
- endif
3836
- endfunction
3837
-
3838
- function! rails#STATUSLINE(...)
3839
- if exists("b:rails_root")
3840
- let t = rails#buffer().type_name()
3841
- if t != "" && a:0 && a:1
3842
- return ",RAILS-".toupper(t)
3843
- else
3844
- return ",RAILS"
3845
- endif
3846
- else
3847
- return ""
3848
- endif
3849
- endfunction
3850
-
3851
3826
  " }}}1
3852
3827
  " Mappings {{{1
3853
3828
 
3854
3829
  function! s:BufMappings()
3855
- nnoremap <buffer> <silent> <Plug>RailsAlternate :<C-U>A<CR>
3856
- nnoremap <buffer> <silent> <Plug>RailsRelated :<C-U>R<CR>
3857
- nnoremap <buffer> <silent> <Plug>RailsFind :<C-U>REfind<CR>
3858
- nnoremap <buffer> <silent> <Plug>RailsSplitFind :<C-U>RSfind<CR>
3859
- nnoremap <buffer> <silent> <Plug>RailsVSplitFind :<C-U>RVfind<CR>
3860
- nnoremap <buffer> <silent> <Plug>RailsTabFind :<C-U>RTfind<CR>
3830
+ nnoremap <buffer> <silent> <Plug>RailsFind :<C-U>call <SID>Find(v:count1,'E')<CR>
3831
+ nnoremap <buffer> <silent> <Plug>RailsSplitFind :<C-U>call <SID>Find(v:count1,'S')<CR>
3832
+ nnoremap <buffer> <silent> <Plug>RailsVSplitFind :<C-U>call <SID>Find(v:count1,'V')<CR>
3833
+ nnoremap <buffer> <silent> <Plug>RailsTabFind :<C-U>call <SID>Find(v:count1,'T')<CR>
3861
3834
  if g:rails_mappings
3862
3835
  if !hasmapto("<Plug>RailsFind")
3863
3836
  nmap <buffer> gf <Plug>RailsFind
@@ -3868,12 +3841,6 @@ function! s:BufMappings()
3868
3841
  if !hasmapto("<Plug>RailsTabFind")
3869
3842
  nmap <buffer> <C-W>gf <Plug>RailsTabFind
3870
3843
  endif
3871
- if !hasmapto("<Plug>RailsAlternate")
3872
- nmap <buffer> [f <Plug>RailsAlternate
3873
- endif
3874
- if !hasmapto("<Plug>RailsRelated")
3875
- nmap <buffer> ]f <Plug>RailsRelated
3876
- endif
3877
3844
  if exists("$CREAM")
3878
3845
  imap <buffer> <C-CR> <C-O><Plug>RailsFind
3879
3846
  imap <buffer> <M-[> <C-O><Plug>RailsAlternate
@@ -3884,111 +3851,6 @@ function! s:BufMappings()
3884
3851
  let v:errmsg = ""
3885
3852
  endfunction
3886
3853
 
3887
- " }}}1
3888
- " Project {{{
3889
-
3890
- function! s:Project(bang,arg)
3891
- let rr = rails#app().path()
3892
- exe "Project ".a:arg
3893
- let line = search('^[^ =]*="'.s:gsub(rr,'[\/]','[\\/]').'"')
3894
- let projname = s:gsub(fnamemodify(rr,':t'),'\=','-') " .'_on_rails'
3895
- if line && a:bang
3896
- let projname = matchstr(getline('.'),'^[^=]*')
3897
- " Most of this would be unnecessary if the project.vim author had just put
3898
- " the newlines AFTER each project rather than before. Ugh.
3899
- norm zR0"_d%
3900
- if line('.') > 2
3901
- delete _
3902
- endif
3903
- if line('.') != line('$')
3904
- .-2
3905
- endif
3906
- let line = 0
3907
- elseif !line
3908
- $
3909
- endif
3910
- if !line
3911
- if line('.') > 1
3912
- append
3913
-
3914
- .
3915
- endif
3916
- let line = line('.')+1
3917
- call s:NewProject(projname,rr)
3918
- endif
3919
- normal! zMzo
3920
- if search("^ app=app {","W",line+10)
3921
- normal! zo
3922
- exe line
3923
- endif
3924
- normal! 0zt
3925
- endfunction
3926
-
3927
- function! s:NewProject(proj,rr)
3928
- let line = line('.')+1
3929
- let template = s:NewProjectTemplate(a:proj,a:rr)
3930
- silent put =template
3931
- exe line
3932
- " Ugh. how else can I force detecting folds?
3933
- setlocal foldmethod=manual
3934
- norm! $%
3935
- silent exe "doautocmd User ".s:escarg(a:rr)."/Rproject"
3936
- let newline = line('.')
3937
- exe line
3938
- norm! $%
3939
- if line('.') != newline
3940
- call s:warn("Warning: Rproject autocommand failed to leave cursor at end of project")
3941
- endif
3942
- exe line
3943
- setlocal foldmethod=marker
3944
- setlocal nomodified
3945
- " FIXME: make undo stop here
3946
- if !exists("g:maplocalleader")
3947
- silent! normal \R
3948
- else " Needs to be tested
3949
- exe 'silent! normal '.g:maplocalleader.'R'
3950
- endif
3951
- endfunction
3952
-
3953
- function! s:NewProjectTemplate(proj,rr)
3954
- let str = a:proj.'="'.a:rr."\" CD=. filter=\"*\" {\n"
3955
- let str .= " app=app {\n"
3956
- for dir in ['apis','controllers','helpers','models','views']
3957
- let str .= s:addprojectdir(a:rr,'app',dir)
3958
- endfor
3959
- let str .= " }\n"
3960
- let str .= " config=config {\n environments=environments {\n }\n }\n"
3961
- let str .= " db=db {\n"
3962
- let str .= s:addprojectdir(a:rr,'db','migrate')
3963
- let str .= " }\n"
3964
- let str .= " lib=lib filter=\"* */**/*.rb \" {\n tasks=tasks filter=\"**/*.rake\" {\n }\n }\n"
3965
- let str .= " public=public {\n images=images {\n }\n javascripts=javascripts {\n }\n stylesheets=stylesheets {\n }\n }\n"
3966
- if isdirectory(a:rr.'/spec')
3967
- let str .= " spec=spec {\n"
3968
- for dir in ['controllers','fixtures','helpers','models','views']
3969
- let str .= s:addprojectdir(a:rr,'spec',dir)
3970
- endfor
3971
- let str .= " }\n"
3972
- endif
3973
- if isdirectory(a:rr.'/test')
3974
- let str .= " test=test {\n"
3975
- for dir in ['fixtures','functional','integration','mocks','unit']
3976
- let str .= s:addprojectdir(a:rr,'test',dir)
3977
- endfor
3978
- let str .= " }\n"
3979
- end
3980
- let str .= "}\n"
3981
- return str
3982
- endfunction
3983
-
3984
- function! s:addprojectdir(rr,parentdir,dir)
3985
- if isdirectory(a:rr.'/'.a:parentdir.'/'.a:dir)
3986
- return ' '.a:dir.'='.a:dir." filter=\"**\" {\n }\n"
3987
- else
3988
- return ''
3989
- endif
3990
- endfunction
3991
-
3992
3854
  " }}}1
3993
3855
  " Database {{{1
3994
3856
 
@@ -4008,7 +3870,7 @@ function! s:app_dbext_settings(environment) dict
4008
3870
  let cmde = '}]; i=0; e=y[e] while e.respond_to?(:to_str) && (i+=1)<16; e.each{|k,v|puts k.to_s+%{=}+v.to_s}}'
4009
3871
  let out = self.lightweight_ruby_eval(cmdb.a:environment.cmde)
4010
3872
  let adapter = s:extractdbvar(out,'adapter')
4011
- let adapter = get({'mysql2': 'mysql', 'postgresql': 'pgsql', 'sqlite3': 'sqlite', 'sqlserver': 'sqlsrv', 'sybase': 'asa', 'oci': 'ora'},adapter,adapter)
3873
+ let adapter = get({'mysql2': 'mysql', 'postgresql': 'pgsql', 'sqlite3': 'sqlite', 'sqlserver': 'sqlsrv', 'sybase': 'asa', 'oracle': 'ora'},adapter,adapter)
4012
3874
  let dict['type'] = toupper(adapter)
4013
3875
  let dict['user'] = s:extractdbvar(out,'username')
4014
3876
  let dict['passwd'] = s:extractdbvar(out,'password')
@@ -4026,7 +3888,11 @@ function! s:app_dbext_settings(environment) dict
4026
3888
  let dict['dbname'] = self.path(dict['dbname'])
4027
3889
  endif
4028
3890
  let dict['profile'] = ''
4029
- let dict['srvname'] = s:extractdbvar(out,'host')
3891
+ if adapter == 'ora'
3892
+ let dict['srvname'] = s:extractdbvar(out,'database')
3893
+ else
3894
+ let dict['srvname'] = s:extractdbvar(out,'host')
3895
+ endif
4030
3896
  let dict['host'] = s:extractdbvar(out,'host')
4031
3897
  let dict['port'] = s:extractdbvar(out,'port')
4032
3898
  let dict['dsnname'] = s:extractdbvar(out,'dsn')
@@ -4155,15 +4021,15 @@ function! s:BufAbbreviations()
4155
4021
  Rabbrev coo[ cookies
4156
4022
  Rabbrev fl[ flash
4157
4023
  Rabbrev rr( render
4158
- Rabbrev ra( render :action\ =>\
4159
- Rabbrev rc( render :controller\ =>\
4160
- Rabbrev rf( render :file\ =>\
4161
- Rabbrev ri( render :inline\ =>\
4162
- Rabbrev rj( render :json\ =>\
4163
- Rabbrev rl( render :layout\ =>\
4164
- Rabbrev rp( render :partial\ =>\
4165
- Rabbrev rt( render :text\ =>\
4166
- Rabbrev rx( render :xml\ =>\
4024
+ Rabbrev ra( render :action\ =>\
4025
+ Rabbrev rc( render :controller\ =>\
4026
+ Rabbrev rf( render :file\ =>\
4027
+ Rabbrev ri( render :inline\ =>\
4028
+ Rabbrev rj( render :json\ =>\
4029
+ Rabbrev rl( render :layout\ =>\
4030
+ Rabbrev rp( render :partial\ =>\
4031
+ Rabbrev rt( render :text\ =>\
4032
+ Rabbrev rx( render :xml\ =>\
4167
4033
  endif
4168
4034
  if buffer.type_name('view','helper')
4169
4035
  Rabbrev dotiw distance_of_time_in_words
@@ -4171,8 +4037,8 @@ function! s:BufAbbreviations()
4171
4037
  endif
4172
4038
  if buffer.type_name('controller')
4173
4039
  Rabbrev re( redirect_to
4174
- Rabbrev rea( redirect_to :action\ =>\
4175
- Rabbrev rec( redirect_to :controller\ =>\
4040
+ Rabbrev rea( redirect_to :action\ =>\
4041
+ Rabbrev rec( redirect_to :controller\ =>\
4176
4042
  Rabbrev rst( respond_to
4177
4043
  endif
4178
4044
  if buffer.type_name() ==# 'model' || buffer.type_name('model-arb')
@@ -4210,13 +4076,13 @@ function! s:BufAbbreviations()
4210
4076
  Rabbrev asre( assert_response
4211
4077
  Rabbrev art( assert_redirected_to
4212
4078
  endif
4213
- Rabbrev :a :action\ =>\
4079
+ Rabbrev :a :action\ =>\
4214
4080
  " hax
4215
- Rabbrev :c :co________\ =>\
4081
+ Rabbrev :c :co________\ =>\
4216
4082
  inoreabbrev <buffer> <silent> :c <C-R>=<SID>TheCWord()<CR>
4217
- Rabbrev :i :id\ =>\
4218
- Rabbrev :o :object\ =>\
4219
- Rabbrev :p :partial\ =>\
4083
+ Rabbrev :i :id\ =>\
4084
+ Rabbrev :o :object\ =>\
4085
+ Rabbrev :p :partial\ =>\
4220
4086
  Rabbrev logd( logger.debug
4221
4087
  Rabbrev logi( logger.info
4222
4088
  Rabbrev logw( logger.warn
@@ -4231,7 +4097,6 @@ function! s:BufAbbreviations()
4231
4097
  Rabbrev AM:: ActionMailer
4232
4098
  Rabbrev AO:: ActiveModel
4233
4099
  Rabbrev AE:: ActiveResource
4234
- Rabbrev AWS:: ActionWebService
4235
4100
  endif
4236
4101
  endfunction
4237
4102
 
@@ -4508,37 +4373,14 @@ function! RailsBufInit(path)
4508
4373
  let g:RAILS_HISTORY = s:sub(g:RAILS_HISTORY,'%(.{-}\n){,'.g:rails_history_size.'}\zs.*','')
4509
4374
  endif
4510
4375
  call app.source_callback("config/syntax.vim")
4511
- if &ft == "mason"
4512
- setlocal filetype=eruby
4513
- elseif &ft =~ '^\%(conf\|ruby\)\=$' && expand("%:e") =~ '^\%(rjs\|rxml\|builder\|rake\|mab\)$'
4514
- setlocal filetype=ruby
4515
- elseif &ft =~ '^\%(conf\|ruby\)\=$' && expand("%:t") =~ '^\%(\%(Rake\|Gem\|Cap\)file\|Isolate\)$'
4516
- setlocal filetype=ruby
4517
- elseif &ft =~ '^\%(liquid\)\=$' && expand("%:e") == "liquid"
4518
- setlocal filetype=liquid
4519
- elseif &ft =~ '^\%(haml\|x\=html\)\=$' && expand("%:e") == "haml"
4520
- setlocal filetype=haml
4521
- elseif &ft =~ '^\%(sass\|conf\)\=$' && expand("%:e") == "sass"
4522
- setlocal filetype=sass
4523
- elseif &ft =~ '^\%(scss\|conf\)\=$' && expand("%:e") == "scss"
4524
- setlocal filetype=scss
4525
- elseif &ft =~ '^\%(lesscss\|conf\)\=$' && expand("%:e") == "less"
4526
- setlocal filetype=lesscss
4527
- elseif &ft =~ '^\%(dryml\)\=$' && expand("%:e") == "dryml"
4528
- setlocal filetype=dryml
4529
- elseif (&ft == "" || v:version < 701) && expand("%:e") =~ '^\%(rhtml\|erb\)$'
4530
- setlocal filetype=eruby
4531
- elseif (&ft == "" || v:version < 700) && expand("%:e") == 'yml'
4532
- setlocal filetype=yaml
4533
- elseif &ft =~ '^\%(conf\|yaml\)\=$' && expand("%:t") =~ '\.yml\.example$'
4376
+ if expand('%:t') =~ '\.yml\.example$'
4534
4377
  setlocal filetype=yaml
4378
+ elseif expand('%:e') =~ '^\%(rjs\|rxml\|builder\|jbuilder\)$'
4379
+ setlocal filetype=ruby
4535
4380
  elseif firsttime
4536
4381
  " Activate custom syntax
4537
4382
  let &syntax = &syntax
4538
4383
  endif
4539
- if firsttime
4540
- call s:BufInitStatusline()
4541
- endif
4542
4384
  if expand('%:e') == 'log'
4543
4385
  nnoremap <buffer> <silent> R :checktime<CR>
4544
4386
  nnoremap <buffer> <silent> G :checktime<Bar>$<CR>
@@ -4618,7 +4460,7 @@ function! s:BufSettings()
4618
4460
  endif
4619
4461
  if has("gui_win32") || has("gui_running")
4620
4462
  let code = '*.rb;*.rake;Rakefile'
4621
- let templates = '*.'.s:gsub(s:view_types,',',';*.')
4463
+ let templates = '*.'.join(s:view_types,';*.')
4622
4464
  let fixtures = '*.yml;*.csv'
4623
4465
  let statics = '*.html;*.css;*.js;*.xml;*.xsd;*.sql;.htaccess;README;README_FOR_APP'
4624
4466
  let b:browsefilter = ""
@@ -4630,9 +4472,9 @@ function! s:BufSettings()
4630
4472
  \."All Files (*.*)\t*.*\n"
4631
4473
  endif
4632
4474
  call self.setvar('&includeexpr','RailsIncludeexpr()')
4633
- call self.setvar('&suffixesadd', ".rb,.".s:gsub(s:view_types,',',',.').",.css,.js,.yml,.csv,.rake,.sql,.html,.xml")
4475
+ call self.setvar('&suffixesadd', ".rb,.".join(s:view_types,',.'))
4634
4476
  let ft = self.getvar('&filetype')
4635
- if ft =~ '^\%(e\=ruby\|[yh]aml\|javascript\|css\|s[ac]ss\|lesscss\)$'
4477
+ if ft =~ '^\%(e\=ruby\|[yh]aml\|coffee\|css\|s[ac]ss\|lesscss\)$'
4636
4478
  call self.setvar('&shiftwidth',2)
4637
4479
  call self.setvar('&softtabstop',2)
4638
4480
  call self.setvar('&expandtab',1)
@@ -4641,7 +4483,6 @@ function! s:BufSettings()
4641
4483
  endif
4642
4484
  endif
4643
4485
  if ft == 'ruby'
4644
- call self.setvar('&suffixesadd',".rb,.".s:gsub(s:view_types,',',',.').",.yml,.csv,.rake,s.rb")
4645
4486
  call self.setvar('&define',self.define_pattern())
4646
4487
  " This really belongs in after/ftplugin/ruby.vim but we'll be nice
4647
4488
  if exists('g:loaded_surround') && self.getvar('surround_101') == ''
@@ -4651,9 +4492,7 @@ function! s:BufSettings()
4651
4492
  endif
4652
4493
  elseif ft == 'yaml' || fnamemodify(self.name(),':e') == 'yml'
4653
4494
  call self.setvar('&define',self.define_pattern())
4654
- call self.setvar('&suffixesadd',".yml,.csv,.rb,.".s:gsub(s:view_types,',',',.').",.rake,s.rb")
4655
- elseif ft == 'eruby'
4656
- call self.setvar('&suffixesadd',".".s:gsub(s:view_types,',',',.').",.rb,.css,.js,.html,.yml,.csv")
4495
+ elseif ft =~# '^eruby\>'
4657
4496
  if exists("g:loaded_allml")
4658
4497
  call self.setvar('allml_stylesheet_link_tag', "<%= stylesheet_link_tag '\r' %>")
4659
4498
  call self.setvar('allml_javascript_include_tag', "<%= javascript_include_tag '\r' %>")
@@ -4676,7 +4515,7 @@ function! s:BufSettings()
4676
4515
  call self.setvar('ragtag_doctype_index', 10)
4677
4516
  endif
4678
4517
  endif
4679
- if ft == 'eruby' || ft == 'yaml'
4518
+ if ft =~# '^eruby\>' || ft ==# 'yaml'
4680
4519
  " surround.vim
4681
4520
  if exists("g:loaded_surround")
4682
4521
  " The idea behind the || part here is that one can normally define the
@@ -4720,9 +4559,7 @@ augroup railsPluginAuto
4720
4559
  autocmd BufWritePost */tasks/**.rake call rails#cache_clear("rake_tasks")
4721
4560
  autocmd BufWritePost */generators/** call rails#cache_clear("generators")
4722
4561
  autocmd FileType * if exists("b:rails_root") | call s:BufSettings() | endif
4723
- autocmd Syntax ruby,eruby,yaml,haml,javascript,coffee,railslog if exists("b:rails_root") | call s:BufSyntax() | endif
4724
- autocmd QuickFixCmdPre make* call s:push_chdir()
4725
- autocmd QuickFixCmdPost make* call s:pop_command()
4562
+ autocmd Syntax ruby,eruby,yaml,haml,javascript,coffee,railslog,sass,scss if exists("b:rails_root") | call s:BufSyntax() | endif
4726
4563
  augroup END
4727
4564
 
4728
4565
  " }}}1
@@ -1,7 +1,6 @@
1
1
  " rails.vim - Detect a rails application
2
- " Author: Tim Pope <vimNOSPAM@tpope.org>
2
+ " Author: Tim Pope <http://tpo.pe/>
3
3
  " GetLatestVimScripts: 1567 1 :AutoInstall: rails.vim
4
- " URL: http://rails.vim.tpope.net/
5
4
 
6
5
  " Install this file as plugin/rails.vim. See doc/rails.txt for details. (Grab
7
6
  " it from the URL above if you don't have it.) To access it from Vim, see
@@ -60,7 +59,7 @@ call s:SetOptDefault("rails_ctags_arguments","--languages=-javascript")
60
59
  call s:SetOptDefault("rails_default_file","README")
61
60
  call s:SetOptDefault("rails_root_url",'http://localhost:3000/')
62
61
  call s:SetOptDefault("rails_modelines",0)
63
- call s:SetOptDefault("rails_menu",!has('mac'))
62
+ call s:SetOptDefault("rails_menu",0)
64
63
  call s:SetOptDefault("rails_gnu_screen",1)
65
64
  call s:SetOptDefault("rails_history_size",5)
66
65
  call s:SetOptDefault("rails_generators","controller\ngenerator\nhelper\nintegration_test\nmailer\nmetal\nmigration\nmodel\nobserver\nperformance_test\nplugin\nresource\nscaffold\nscaffold_controller\nsession_migration\nstylesheets")
@@ -80,6 +79,9 @@ function! s:escvar(r)
80
79
  endfunction
81
80
 
82
81
  function! s:Detect(filename)
82
+ if exists('b:rails_root')
83
+ return s:BufInit(b:rails_root)
84
+ endif
83
85
  let fn = substitute(fnamemodify(a:filename,":p"),'\c^file://','','')
84
86
  let sep = matchstr(fn,'^[^\\/]\{3,\}\zs[\\/]')
85
87
  if sep != ""
@@ -108,7 +110,7 @@ function! s:Detect(filename)
108
110
  return s:BufInit(fn)
109
111
  endif
110
112
  let ofn = fn
111
- let fn = fnamemodify(ofn,':s?\(.*\)[\/]\(app\|config\|db\|doc\|features\|lib\|log\|public\|script\|spec\|stories\|test\|tmp\|vendor\)\($\|[\/].*$\)?\1?')
113
+ let fn = fnamemodify(ofn,':s?\(.*\)[\/]\(app\|config\|db\|doc\|extras\|features\|lib\|log\|public\|script\|spec\|stories\|test\|tmp\|vendor\)\($\|[\/].*$\)?\1?')
112
114
  endwhile
113
115
  return 0
114
116
  endfunction
data/lib/utils/editor.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'tins/xt/full'
2
+
1
3
  module Utils
2
4
  class Editor
3
5
  FILE_LINENUMBER_REGEXP = /^\s*([^:]+):(\d+)/
@@ -39,8 +41,10 @@ module Utils
39
41
  @vim ||=
40
42
  case `uname -s`
41
43
  when /\Adarwin/i
42
- if File.directory?('/Applications')
43
- '/Applications/MacVim.app/Contents/MacOS/Vim'
44
+ if File.directory?(path = File.expand_path('~/Applications/MacVim.app')) or
45
+ File.directory?(path = File.expand_path('/Applications/MacVim.app'))
46
+ then
47
+ File.join(path, 'Contents/MacOS/Vim')
44
48
  else
45
49
  'vim'
46
50
  end
@@ -80,7 +84,7 @@ module Utils
80
84
  end
81
85
 
82
86
  def expand_globs(filenames)
83
- filenames.map { |f| Dir[f] }.flatten.uniq.sort
87
+ filenames.map { |f| Dir[f] }.flatten.uniq.sort.full? || filenames
84
88
  end
85
89
 
86
90
  def edit(*filenames)
@@ -114,11 +118,7 @@ module Utils
114
118
  end
115
119
 
116
120
  def edit_source_location(source_location)
117
- if File.exist?(source_location[0])
118
- edit_file_linenumber(source_location[0], source_location[1])
119
- else
120
- false
121
- end
121
+ edit_file_linenumber(source_location[0], source_location[1])
122
122
  end
123
123
 
124
124
  def ensure_running
data/lib/utils/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Utils
2
2
  # Utils version
3
- VERSION = '0.0.37'
3
+ VERSION = '0.0.38'
4
4
  VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
data/utils.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "utils"
5
- s.version = "0.0.37"
5
+ s.version = "0.0.38"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Florian Frank"]
9
- s.date = "2012-02-14"
9
+ s.date = "2012-03-01"
10
10
  s.description = "This ruby gem provides some useful command line utilities"
11
11
  s.email = "flori@ping.de"
12
12
  s.executables = ["chroot-exec", "chroot-libs", "classify", "discover", "edit", "edit_wait", "enum", "errf", "git-empty", "myex", "number_files", "path", "probe", "same_files", "search", "sedit", "sshscreen", "strip_spaces", "unquarantine_apps", "untest", "utils-install-config", "utils-utilsrc", "vacuum_firefox_sqlite", "xmp"]
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.homepage = "http://github.com/flori/utils"
16
16
  s.rdoc_options = ["--title", "Utils - Some useful command line utilities", "--main", "README.rdoc"]
17
17
  s.require_paths = ["lib"]
18
- s.rubygems_version = "1.8.15"
18
+ s.rubygems_version = "1.8.17"
19
19
  s.summary = "Some useful command line utilities"
20
20
 
21
21
  if s.respond_to? :specification_version then
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.37
4
+ version: 0.0.38
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-14 00:00:00.000000000 Z
12
+ date: 2012-03-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gem_hadar
16
- requirement: &2161469420 !ruby/object:Gem::Requirement
16
+ requirement: &2153080320 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.1.4
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2161469420
24
+ version_requirements: *2153080320
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: tins
27
- requirement: &2161468980 !ruby/object:Gem::Requirement
27
+ requirement: &2153079600 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0.3'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2161468980
35
+ version_requirements: *2153079600
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: term-ansicolor
38
- requirement: &2161468560 !ruby/object:Gem::Requirement
38
+ requirement: &2153078600 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '1.0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2161468560
46
+ version_requirements: *2153078600
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: dslkit
49
- requirement: &2161467580 !ruby/object:Gem::Requirement
49
+ requirement: &2153077740 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0.2'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *2161467580
57
+ version_requirements: *2153077740
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: pry-editline
60
- requirement: &2161467220 !ruby/object:Gem::Requirement
60
+ requirement: &2153037600 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *2161467220
68
+ version_requirements: *2153037600
69
69
  description: This ruby gem provides some useful command line utilities
70
70
  email: flori@ping.de
71
71
  executables:
@@ -96,17 +96,28 @@ executables:
96
96
  extensions: []
97
97
  extra_rdoc_files:
98
98
  - README.rdoc
99
- - lib/utils/config/config_file.rb
100
- - lib/utils/config.rb
101
- - lib/utils/editor.rb
102
- - lib/utils/file_xt.rb
103
- - lib/utils/find.rb
104
- - lib/utils/finder.rb
105
- - lib/utils/grepper.rb
106
- - lib/utils/md5.rb
107
- - lib/utils/patterns.rb
108
- - lib/utils/version.rb
109
- - lib/utils.rb
99
+ - !binary |-
100
+ bGliL3V0aWxzL2NvbmZpZy9jb25maWdfZmlsZS5yYg==
101
+ - !binary |-
102
+ bGliL3V0aWxzL2NvbmZpZy5yYg==
103
+ - !binary |-
104
+ bGliL3V0aWxzL2VkaXRvci5yYg==
105
+ - !binary |-
106
+ bGliL3V0aWxzL2ZpbGVfeHQucmI=
107
+ - !binary |-
108
+ bGliL3V0aWxzL2ZpbmQucmI=
109
+ - !binary |-
110
+ bGliL3V0aWxzL2ZpbmRlci5yYg==
111
+ - !binary |-
112
+ bGliL3V0aWxzL2dyZXBwZXIucmI=
113
+ - !binary |-
114
+ bGliL3V0aWxzL21kNS5yYg==
115
+ - !binary |-
116
+ bGliL3V0aWxzL3BhdHRlcm5zLnJi
117
+ - !binary |-
118
+ bGliL3V0aWxzL3ZlcnNpb24ucmI=
119
+ - !binary |-
120
+ bGliL3V0aWxzLnJi
110
121
  files:
111
122
  - .gitignore
112
123
  - COPYING
@@ -214,6 +225,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
214
225
  - - ! '>='
215
226
  - !ruby/object:Gem::Version
216
227
  version: '0'
228
+ segments:
229
+ - 0
230
+ hash: 2842823016203684465
217
231
  required_rubygems_version: !ruby/object:Gem::Requirement
218
232
  none: false
219
233
  requirements:
@@ -222,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
236
  version: '0'
223
237
  requirements: []
224
238
  rubyforge_project:
225
- rubygems_version: 1.8.15
239
+ rubygems_version: 1.8.17
226
240
  signing_key:
227
241
  specification_version: 3
228
242
  summary: Some useful command line utilities