Sha256: cac9627c50c8616df4cf1c5edb48358d473b8030e852eb58e4685d7f66599b79

Contents?: true

Size: 1.46 KB

Versions: 95

Compression:

Stored size: 1.46 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

module Tags
  extend Rake::DSL if defined?(Rake::DSL)

  PROG = ENV['TAGS'] || 'ctags'

  RAKEFILES = FileList['Rakefile', '**/*.rake']

  FILES = FileList['**/*.rb', '**/*.js'] + RAKEFILES
  FILES.exclude('pkg', 'dist')

  PROJECT_DIR = ['.']

  RVM_GEMDIR = File.join(`rvm gemdir`.strip, "gems") rescue nil
  SYSTEM_DIRS = RVM_GEMDIR && File.exists?(RVM_GEMDIR) ? RVM_GEMDIR : []

  module_function

  # Convert key_word to --key-word.
  def keyword(key)
    k = key.to_s.gsub(/_/, '-')
    (k.length == 1) ? "-#{k}" : "--#{k}"
  end

  # Run ctags command
  def run(*args)
    opts = {
      :e => true,
      :totals => true,
      :recurse => true,
    }
    opts = opts.merge(args.pop) if args.last.is_a?(Hash)
    command_args = opts.map { |k, v|
      (v == true) ? keyword(k) : "#{keyword(k)}=#{v}"
    }.join(" ")
    sh %{#{Tags::PROG} #{command_args} #{args.join(' ')}}
  end
end

namespace "tags" do
  desc "Generate an Emacs TAGS file"
   task :emacs, [:all] => Tags::FILES do |t, args|
    puts "Making Emacs TAGS file"
    verbose(true) do
      Tags.run(Tags::PROJECT_DIR)
      Tags.run(Tags::RAKEFILES,
        :language_force => "ruby",
        :append => true)
      if args.all
        Tags::SYSTEM_DIRS.each do |dir|
          Tags.run(dir,
            :language_force => "ruby",
            :append => true)
        end
      end
    end
  end
end

desc "Generate the TAGS file"
task :tags, [:all] => ["tags:emacs"]

Version data entries

95 entries across 57 versions & 18 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/builder-3.2.4/rakelib/tags.rake
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/builder-3.2.4/rakelib/tags.rake
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/builder-3.2.4/rakelib/tags.rake
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/builder-3.2.4/rakelib/tags.rake
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/builder-3.2.4/rakelib/tags.rake
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/builder-3.2.4/rakelib/tags.rake
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/builder-3.2.4/rakelib/tags.rake
rubypitaya-3.12.5 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/rakelib/tags.rake
rubypitaya-3.12.4 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/rakelib/tags.rake
rubypitaya-3.12.3 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/rakelib/tags.rake
rubypitaya-3.12.2 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/rakelib/tags.rake
op_connect-0.1.2 vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/rakelib/tags.rake
ric-0.14.2 vendor/bundle/ruby/2.7.0/gems/builder-3.2.4/rakelib/tags.rake
ric-0.14.1 vendor/bundle/ruby/2.7.0/gems/builder-3.2.4/rakelib/tags.rake
phillipug-foodie-0.1.0 .vendor/ruby/3.0.0/gems/builder-3.2.4/rakelib/tags.rake
ric-0.14.0 vendor/bundle/ruby/2.7.0/gems/builder-3.2.4/rakelib/tags.rake
vagrant-unbundled-2.2.19.0 vendor/bundle/ruby/3.0.0/gems/builder-3.2.4/rakelib/tags.rake
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/builder-3.2.4/rakelib/tags.rake
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/builder-3.2.4/rakelib/tags.rake
vagrant-unbundled-2.2.18.0 vendor/bundle/ruby/3.0.0/gems/builder-3.2.4/rakelib/tags.rake