Class: Solargraph::Bench
- Inherits:
-
Object
- Object
- Solargraph::Bench
- Defined in:
- lib/solargraph/bench.rb
Overview
A container of source maps and workspace data to be cataloged in an ApiMap.
Instance Attribute Summary collapse
- #external_requires ⇒ Set<String> readonly
- #live_map ⇒ SourceMap readonly
- #source_maps ⇒ Set<SourceMap> readonly
- #workspace ⇒ Workspace readonly
Instance Method Summary collapse
- #icebox ⇒ Set<SourceMap>
-
#initialize(source_maps: [], workspace: Workspace.new, live_map: nil, external_requires: []) ⇒ Bench
constructor
A new instance of Bench.
- #source_map_hash ⇒ Hash{String => SourceMap}
Constructor Details
#initialize(source_maps: [], workspace: Workspace.new, live_map: nil, external_requires: []) ⇒ Bench
Returns a new instance of Bench.
24 25 26 27 28 29 30 31 |
# File 'lib/solargraph/bench.rb', line 24 def initialize source_maps: [], workspace: Workspace.new, live_map: nil, external_requires: [] @source_maps = source_maps.to_set @workspace = workspace @live_map = live_map @external_requires = external_requires.reject { |path| workspace.would_require?(path) } .compact .to_set end |
Instance Attribute Details
#external_requires ⇒ Set<String> (readonly)
18 19 20 |
# File 'lib/solargraph/bench.rb', line 18 def external_requires @external_requires end |
#live_map ⇒ SourceMap (readonly)
15 16 17 |
# File 'lib/solargraph/bench.rb', line 15 def live_map @live_map end |
#source_maps ⇒ Set<SourceMap> (readonly)
9 10 11 |
# File 'lib/solargraph/bench.rb', line 9 def source_maps @source_maps end |
#workspace ⇒ Workspace (readonly)
12 13 14 |
# File 'lib/solargraph/bench.rb', line 12 def workspace @workspace end |
Instance Method Details
#icebox ⇒ Set<SourceMap>
41 42 43 |
# File 'lib/solargraph/bench.rb', line 41 def icebox @icebox ||= (source_maps - [live_map]) end |
#source_map_hash ⇒ Hash{String => SourceMap}
34 35 36 37 38 |
# File 'lib/solargraph/bench.rb', line 34 def source_map_hash # @todo Work around #to_h bug in current Ruby head (3.5) with #map#to_h @source_map_hash ||= source_maps.map { |s| [s.filename, s] } .to_h end |