Add task for generating ctags
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Râu Cao 2025-04-26 12:37:10 +04:00
parent 536052e9bf
commit fb054ae455
Signed by: raucao
GPG Key ID: 37036C356E56CC51
2 changed files with 32 additions and 0 deletions

3
.gitignore vendored
View File

@ -47,3 +47,6 @@ dump.rdb
/app/assets/builds/* /app/assets/builds/*
!/app/assets/builds/.keep !/app/assets/builds/.keep
# Ignore generated ctags
*.tags

29
lib/tasks/ctags.rake Normal file
View File

@ -0,0 +1,29 @@
module Kosmos
class Ctags
def self.generate_app_tags
excludes = %w[.git gitno log tmp public].join(" --exclude ")
cmd = "ctags -R --languages=ruby --exclude #{excludes} ."
system cmd
end
def self.generate_bundler_tags
runtime = ::Bundler::Runtime.new Dir.pwd, ::Bundler.definition
paths = runtime.specs.map(&:full_gem_path)
generate_tags(paths, "gems.tags")
end
def self.generate_tags(paths, tag_file)
paths = paths.join(' ').strip
cmd = "find #{paths} -ignore_readdir_race -type f -name '*.rb' 2>/dev/null | ctags -f #{tag_file} -L -"
system cmd
end
end
end
namespace :ctags do
desc 'generate ctags'
task :create do
Kosmos::Ctags.generate_app_tags
Kosmos::Ctags.generate_bundler_tags
end
end