<commit_before>#!/usr/bin/env ruby

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')

  RVM_GEMDIR = begin
                 File.join(`rvm gemdir`.strip, "gems")
               rescue Errno::ENOENT
                 nil
               end

  DIR_LIST = ['.']
  DIR_LIST << RVM_GEMDIR if RVM_GEMDIR and File.exists? RVM_GEMDIR
  DIRS = DIR_LIST.join(" ")

  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 => Tags::FILES do<commit_msg>`rvm gemdir` is the same as Gem.dir, right?<commit_after>#!/usr/bin/env ruby

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')

  DIR_LIST = ['.']
  DIR_LIST << Gem.dir
  DIRS = DIR_LIST.join(" ")

  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 => Tags::FILES do
{'fraction_non_alphanumeric': 0.20322886989553657, 'fraction_numerical': 0.000949667616334283, 'mean_word_length': 2.5894378194207834, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '6493103', 'n_tokens_mistral': 871, 'n_tokens_neox': 830, 'n_words': 186}