Class: Guard::CtagsBundler::CtagsGenerator
- Inherits:
-
Object
- Object
- Guard::CtagsBundler::CtagsGenerator
- Defined in:
- lib/guard/ctags-bundler/ctags_generator.rb
Instance Method Summary collapse
- #generate_bundler_tags ⇒ Object
- #generate_project_tags ⇒ Object
- #generate_stdlib_tags ⇒ Object
-
#initialize(opts = {}) ⇒ CtagsGenerator
constructor
A new instance of CtagsGenerator.
Constructor Details
#initialize(opts = {}) ⇒ CtagsGenerator
Returns a new instance of CtagsGenerator.
8 9 10 |
# File 'lib/guard/ctags-bundler/ctags_generator.rb', line 8 def initialize(opts = {}) @opts = opts end |
Instance Method Details
#generate_bundler_tags ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/guard/ctags-bundler/ctags_generator.rb', line 16 def # FIXME: Using bundler API cases issues when guard is executed in the non-bundler environment #::Bundler.configure # in case we're not running guard from inside Bundler #definition = ::Bundler::Definition.build("Gemfile", "Gemfile.lock", nil) #runtime = ::Bundler::Runtime.new(Dir.pwd, definition) #paths = runtime.requested_specs.map(&:full_gem_path) gemfile = @opts.fetch(:gemfile, 'Gemfile') lockfile = "#{gemfile}.lock" # this is ugly, but should work with every bundler version cmd = <<-CMD require('bundler') require('bundler/runtime') ::Bundler.configure definition = ::Bundler::Definition.build('#{gemfile}', '#{lockfile}', nil) runtime = ::Bundler::Runtime.new(Dir.pwd, definition) paths = runtime.requested_specs.map(&:full_gem_path) puts(paths.join(' ')) CMD paths = `ruby -e "#{cmd}"` (paths.strip, custom_path_for(@opts.fetch(:bundler_tags_file, "gems.tags"))) end |
#generate_project_tags ⇒ Object
12 13 14 |
# File 'lib/guard/ctags-bundler/ctags_generator.rb', line 12 def (@opts[:src_path] || ".", custom_path_for(@opts.fetch(:project_file, "tags"))) end |
#generate_stdlib_tags ⇒ Object
40 41 42 |
# File 'lib/guard/ctags-bundler/ctags_generator.rb', line 40 def (stdlib_path, custom_path_for(@opts.fetch(:stdlib_file, "stdlib.tags"))) end |