Class: Solargraph::Workspace::Config
- Inherits:
-
Object
- Object
- Solargraph::Workspace::Config
- Defined in:
- lib/solargraph/workspace/config.rb
Overview
Configuration data for a workspace.
Constant Summary collapse
- MAX_FILES =
The maximum number of files that can be added to a workspace. The workspace’s .solargraph.yml can override this value.
5000
Instance Attribute Summary collapse
- #directory ⇒ String readonly
- #raw_data ⇒ Hash{String => undefined, nil} readonly
Instance Method Summary collapse
- #allow?(filename) ⇒ Boolean
-
#calculated ⇒ Array<String>
The calculated array of (included - excluded) files in the workspace.
-
#domains ⇒ Array<String>
An array of domains configured for the workspace.
-
#excluded ⇒ Array<String>
An array of files excluded from the workspace.
-
#formatter ⇒ Hash
A hash of options supported by the formatter.
-
#included ⇒ Array<String>
An array of files included in the workspace (before calculating excluded files).
-
#initialize(directory = '') ⇒ Config
constructor
A new instance of Config.
-
#max_files ⇒ Integer
The maximum number of files to parse from the workspace.
-
#plugins ⇒ Array<String>
An array of plugins to require.
-
#reporters ⇒ Array<String>
An array of reporters to use for diagnostics.
-
#require_paths ⇒ Array<String>
An array of load paths for required paths.
-
#required ⇒ Array<String>
An array of required paths to add to the workspace.
- #type_checker_rules ⇒ Hash{Symbol => Symbol}
Constructor Details
#initialize(directory = '') ⇒ Config
Returns a new instance of Config.
22 23 24 25 26 27 |
# File 'lib/solargraph/workspace/config.rb', line 22 def initialize directory = '' @directory = File.absolute_path(directory) @raw_data = config_data included excluded end |
Instance Attribute Details
#directory ⇒ String (readonly)
15 16 17 |
# File 'lib/solargraph/workspace/config.rb', line 15 def directory @directory end |
#raw_data ⇒ Hash{String => undefined, nil} (readonly)
Need to validate config
19 20 21 |
# File 'lib/solargraph/workspace/config.rb', line 19 def raw_data @raw_data end |
Instance Method Details
#allow?(filename) ⇒ Boolean
46 47 48 49 50 51 |
# File 'lib/solargraph/workspace/config.rb', line 46 def allow? filename filename = File.absolute_path(filename, directory) filename.start_with?(directory) && !excluded.include?(filename) && excluded_directories.none? { |d| filename.start_with?(d) } end |
#calculated ⇒ Array<String>
The calculated array of (included - excluded) files in the workspace.
56 57 58 59 60 61 |
# File 'lib/solargraph/workspace/config.rb', line 56 def calculated unless @calculated || directory.empty? || directory == '*' Solargraph.logger.info "Indexing workspace files in #{directory}" end @calculated ||= included - excluded end |
#domains ⇒ Array<String>
An array of domains configured for the workspace. A domain is a namespace that the ApiMap should include in the global namespace. It’s typically used to identify available DSLs.
@sg-ignore Need to validate config
69 70 71 |
# File 'lib/solargraph/workspace/config.rb', line 69 def domains raw_data['domains'] end |
#excluded ⇒ Array<String>
An array of files excluded from the workspace.
40 41 42 43 |
# File 'lib/solargraph/workspace/config.rb', line 40 def excluded return [] if directory.empty? || directory == '*' @excluded ||= process_exclusions(@raw_data['exclude']) end |
#formatter ⇒ Hash
A hash of options supported by the formatter
@sg-ignore Need to validate config
102 103 104 |
# File 'lib/solargraph/workspace/config.rb', line 102 def formatter raw_data['formatter'] end |
#included ⇒ Array<String>
An array of files included in the workspace (before calculating excluded files).
32 33 34 35 |
# File 'lib/solargraph/workspace/config.rb', line 32 def included return [] if directory.empty? || directory == '*' @included ||= process_globs(@raw_data['include']) end |
#max_files ⇒ Integer
The maximum number of files to parse from the workspace.
@sg-ignore Need to validate config
118 119 120 |
# File 'lib/solargraph/workspace/config.rb', line 118 def max_files raw_data['max_files'] end |
#plugins ⇒ Array<String>
An array of plugins to require.
@sg-ignore Need to validate config
110 111 112 |
# File 'lib/solargraph/workspace/config.rb', line 110 def plugins raw_data['plugins'] end |
#reporters ⇒ Array<String>
An array of reporters to use for diagnostics.
@sg-ignore Need to validate config
94 95 96 |
# File 'lib/solargraph/workspace/config.rb', line 94 def reporters raw_data['reporters'] end |
#require_paths ⇒ Array<String>
An array of load paths for required paths.
@sg-ignore Need to validate config @sg-ignore Need to validate config
86 87 88 |
# File 'lib/solargraph/workspace/config.rb', line 86 def require_paths raw_data['require_paths'] || [] end |
#required ⇒ Array<String>
An array of required paths to add to the workspace.
@sg-ignore Need to validate config
77 78 79 |
# File 'lib/solargraph/workspace/config.rb', line 77 def required raw_data['require'] end |
#type_checker_rules ⇒ Hash{Symbol => Symbol}
123 124 125 126 127 128 129 |
# File 'lib/solargraph/workspace/config.rb', line 123 def type_checker_rules # @type [Hash{String => String}] raw_rules = raw_data.fetch('type_checker', {}).fetch('rules', {}) raw_rules.to_h do |k, v| [k.to_sym, v.to_sym] end end |