Class: Bundler::Codegraph::Indexer
- Inherits:
-
Object
- Object
- Bundler::Codegraph::Indexer
- Defined in:
- lib/bundler/codegraph/indexer.rb
Overview
Builds a CodeGraph index for a single gem directory.
Never raises: every failure mode is reported as a status symbol, because
this runs from a Bundler hook where an exception would abort the whole
bundle install.
Constant Summary collapse
- INDEX_DIRNAME =
'.codegraph'- DATABASE_NAME =
'codegraph.db'- BACKUP_DIRNAME =
'.codegraph.bundler-codegraph-backup'
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#force ⇒ Object
readonly
Returns the value of attribute force.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#skip_failed ⇒ Object
readonly
Returns the value of attribute skip_failed.
-
#sync ⇒ Object
readonly
Returns the value of attribute sync.
Instance Method Summary collapse
-
#call ⇒ Symbol
:indexed, :synced, :failed, :disabled, :excluded, :missing, :failed_before, :no_ruby, :already_indexed or :unavailable.
-
#indexed? ⇒ Boolean
Same criterion as codegraph itself: a
.codegraph/directory without its database is a leftover, not an index. -
#initialize(path, name:, config: Config.new, force: false, sync: false, skip_failed: false) ⇒ Indexer
constructor
rubocop:disable-next Metrics/ParameterLists.
-
#log_hint ⇒ String
Where to find codegraph's error output after
call, as a suffix for a failure message (seeErrorLog#hint).
Constructor Details
#initialize(path, name:, config: Config.new, force: false, sync: false, skip_failed: false) ⇒ Indexer
rubocop:disable-next Metrics/ParameterLists
30 31 32 33 34 35 36 37 38 |
# File 'lib/bundler/codegraph/indexer.rb', line 30 def initialize(path, name:, config: Config.new, force: false, sync: false, skip_failed: false) @path = path.to_s @name = name.to_s @config = config @force = force @sync = sync @skip_failed = skip_failed @error_log = nil end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
19 20 21 |
# File 'lib/bundler/codegraph/indexer.rb', line 19 def config @config end |
#force ⇒ Object (readonly)
Returns the value of attribute force.
19 20 21 |
# File 'lib/bundler/codegraph/indexer.rb', line 19 def force @force end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
19 20 21 |
# File 'lib/bundler/codegraph/indexer.rb', line 19 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
19 20 21 |
# File 'lib/bundler/codegraph/indexer.rb', line 19 def path @path end |
#skip_failed ⇒ Object (readonly)
Returns the value of attribute skip_failed.
19 20 21 |
# File 'lib/bundler/codegraph/indexer.rb', line 19 def skip_failed @skip_failed end |
#sync ⇒ Object (readonly)
Returns the value of attribute sync.
19 20 21 |
# File 'lib/bundler/codegraph/indexer.rb', line 19 def sync @sync end |
Instance Method Details
#call ⇒ Symbol
Returns :indexed, :synced, :failed, :disabled, :excluded, :missing, :failed_before, :no_ruby, :already_indexed or :unavailable.
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/bundler/codegraph/indexer.rb', line 42 def call skipped = skip_reason return skipped if skipped Lock.synchronize do error_log.discard run end rescue StandardError :failed end |
#indexed? ⇒ Boolean
Same criterion as codegraph itself: a .codegraph/ directory without
its database is a leftover, not an index.
64 65 66 |
# File 'lib/bundler/codegraph/indexer.rb', line 64 def indexed? File.exist?(File.join(index_path, DATABASE_NAME)) end |
#log_hint ⇒ String
Where to find codegraph's error output after call, as a suffix for a
failure message (see ErrorLog#hint).
58 59 60 |
# File 'lib/bundler/codegraph/indexer.rb', line 58 def log_hint @error_log ? @error_log.hint : '' end |