Sha256: 768872f1b9ec67a4b40b42a8b77457ad5695e86e6a20921ffda17784806e9bdb

Contents?: true

Size: 913 Bytes

Versions: 1

Compression:

Stored size: 913 Bytes

Contents

# frozen_string_literal: true

require_relative "ctags_generator/version"

module Bundler
  # This module are responsible to generate ctags file.
  module CtagsGenerator
    class Error < StandardError; end

    def self.run
      generate_tags_for_stdlib
      generate_tags_for_bundler
    end

    def self.execute_ctags(filename, path)
      cmd = "ctags --exclude='spec/*' --exclude='test/*' -f '#{filename}' --languages=ruby -R #{path}"
      system(cmd)
    end

    def self.generate_tags_for_stdlib
      stdlib_paths = Dir.glob("#{RbConfig::CONFIG["rubylibdir"]}/**/*.rb}")
      paths = stdlib_paths.join(" ").strip
      execute_ctags("stdlibs.tags", paths)
    end

    def self.generate_tags_for_bundler
      bundle_paths = `bundle show --paths`
      paths = bundle_paths.split("\n")
      path = paths.map { _1 << "/lib" }.join(" ").strip
      execute_ctags("gems.tags", path)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bundler-ctags_generator-0.1.0 lib/bundler/ctags_generator.rb