Class: Solargraph::Workspace::Config

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(directory = '') ⇒ Config

Returns a new instance of Config.

Parameters:

  • directory (String) (defaults to: '')


21
22
23
24
25
26
# File 'lib/solargraph/workspace/config.rb', line 21

def initialize directory = ''
  @directory = directory
  @raw_data = config_data
  included
  excluded
end

Instance Attribute Details

#directoryString (readonly)

Returns:

  • (String)


15
16
17
# File 'lib/solargraph/workspace/config.rb', line 15

def directory
  @directory
end

#raw_dataHash (readonly)

Returns:

  • (Hash)


18
19
20
# File 'lib/solargraph/workspace/config.rb', line 18

def raw_data
  @raw_data
end

Instance Method Details

#allow?(filename) ⇒ Boolean

Returns:

  • (Boolean)


44
45
46
47
48
# File 'lib/solargraph/workspace/config.rb', line 44

def allow? filename
  filename.start_with?(directory) && 
    !excluded.include?(filename) &&
    excluded_directories.none? { |d| filename.start_with?(d) }
end

#calculatedArray<String>

The calculated array of (included - excluded) files in the workspace.

Returns:

  • (Array<String>)


53
54
55
56
# File 'lib/solargraph/workspace/config.rb', line 53

def calculated
  Solargraph.logger.info "Indexing workspace files in #{directory}" unless @calculated || directory.empty? || directory == '*'
  @calculated ||= included - excluded
end

#domainsArray<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.

Returns:

  • (Array<String>)


63
64
65
# File 'lib/solargraph/workspace/config.rb', line 63

def domains
  raw_data['domains']
end

#excludedArray<String>

An array of files excluded from the workspace.

Returns:

  • (Array<String>)


39
40
41
42
# File 'lib/solargraph/workspace/config.rb', line 39

def excluded
  return [] if directory.empty? || directory == '*'
  @excluded ||= process_exclusions(@raw_data['exclude'])
end

#formatterHash

A hash of options supported by the formatter

Returns:

  • (Hash)


91
92
93
# File 'lib/solargraph/workspace/config.rb', line 91

def formatter
  raw_data['formatter']
end

#includedArray<String>

An array of files included in the workspace (before calculating excluded files).

Returns:

  • (Array<String>)


31
32
33
34
# File 'lib/solargraph/workspace/config.rb', line 31

def included
  return [] if directory.empty? || directory == '*'
  @included ||= process_globs(@raw_data['include'])
end

#max_filesInteger

The maximum number of files to parse from the workspace.

Returns:

  • (Integer)


105
106
107
# File 'lib/solargraph/workspace/config.rb', line 105

def max_files
  raw_data['max_files']
end

#pluginsArray<String>

An array of plugins to require.

Returns:

  • (Array<String>)


98
99
100
# File 'lib/solargraph/workspace/config.rb', line 98

def plugins
  raw_data['plugins']
end

#reportersArray<String>

An array of reporters to use for diagnostics.

Returns:

  • (Array<String>)


84
85
86
# File 'lib/solargraph/workspace/config.rb', line 84

def reporters
  raw_data['reporters']
end

#require_pathsArray<String>

An array of load paths for required paths.

Returns:

  • (Array<String>)


77
78
79
# File 'lib/solargraph/workspace/config.rb', line 77

def require_paths
  raw_data['require_paths'] || []
end

#requiredArray<String>

An array of required paths to add to the workspace.

Returns:

  • (Array<String>)


70
71
72
# File 'lib/solargraph/workspace/config.rb', line 70

def required
  raw_data['require']
end