Class: RubyOnEtags::Core
- Inherits:
-
Object
- Object
- RubyOnEtags::Core
- Defined in:
- lib/ruby_on_etags/core.rb
Class Method Summary collapse
Instance Method Summary collapse
- #build_tags ⇒ Object
- #build_tags_current_dir ⇒ Object
- #build_tags_for_gems ⇒ Object
- #build_tags_for_standard_library ⇒ Object
- #concatenate_tags_files(tags_files) ⇒ Object
- #gems_in_use ⇒ Object
- #remove_tags ⇒ Object
Class Method Details
.install_tasks ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ruby_on_etags/core.rb', line 27 def self.install_tasks namespace :ruby_on_etags do desc "Build TAGS for whole project. GEMS='some_gem-1.0.0, another_gem-0.2.1'." task :build do self.new. end desc "Watch for changes in project directory and build TAGS when needed." task :watch do system "watchr -e 'watch(\"\.rb\") { system \"rake ruby_on_etags:build &>/dev/null\" }'" end end end |
Instance Method Details
#build_tags ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/ruby_on_etags/core.rb', line 45 def = [] << += << () end |
#build_tags_current_dir ⇒ Object
72 73 74 75 76 77 |
# File 'lib/ruby_on_etags/core.rb', line 72 def = Tempfile.new('ruby_on_etags-project-TAGS', '.') .close (["."], .path) .path end |
#build_tags_for_gems ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/ruby_on_etags/core.rb', line 54 def gems_in_use.map do |gem_spec| = File.join(cache_dir, 'gems', "#{gem_spec.name}-#{gem_spec.version.version}", 'TAGS') (gem_spec.load_paths, , :ctags_flags => "--tag-relative=no") end end |
#build_tags_for_standard_library ⇒ Object
65 66 67 68 69 70 |
# File 'lib/ruby_on_etags/core.rb', line 65 def File.join(cache_dir, 'rubies', RUBY_VERSION, 'TAGS').tap do || dirs = $:.delete_if { |path| path =~ %r|/gems/| } (dirs, , :ctags_flags => "--tag-relative=no") end end |
#concatenate_tags_files(tags_files) ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/ruby_on_etags/core.rb', line 79 def () File.open("TAGS", 'w') do || .each do || << IO.read() end end end |
#gems_in_use ⇒ Object
91 92 93 94 95 96 97 98 99 100 |
# File 'lib/ruby_on_etags/core.rb', line 91 def gems_in_use if File.exists?("Gemfile") # Bundler.load.specs Bundler::Definition.build(Bundler.default_gemfile, Bundler.default_lockfile, nil).specs else [] end end |
#remove_tags ⇒ Object
87 88 89 |
# File 'lib/ruby_on_etags/core.rb', line 87 def FileUtils.rm_f("TAGS") end |