class Solargraph::Workspace::Config
Configuration data for a workspace.
def calculated
-
(Array-)
def calculated @calculated ||= included - excluded end
def domains
-
(Array-)
def domains raw_data['domains'] end
def excluded
-
(Array-)
def excluded return [] if workspace.nil? @excluded ||= process_exclusions(@raw_data['exclude']) end
def glob_is_directory? glob
-
(Boolean)-
Parameters:
-
glob(String) --
def glob_is_directory? glob File.directory?(glob) || File.directory?(glob_to_directory(glob)) end
def glob_to_directory glob
-
(String)-
Parameters:
-
glob(String) --
def glob_to_directory glob glob.gsub(/(\/\*|\/\*\*\/\*\*?)$/, '') end
def included
-
(Array-)
def included return [] if workspace.nil? @included ||= process_globs(@raw_data['include']) end
def initialize workspace = nil
-
workspace(String) --
def initialize workspace = nil @workspace = workspace include_globs = ['**/*.rb'] exclude_globs = ['spec/**/*', 'test/**/*', 'vendor/**/*', '.bundle/**/*'] unless @workspace.nil? sfile = File.join(@workspace, '.solargraph.yml') if File.file?(sfile) @raw_data = YAML.safe_load(File.read(sfile)) include_globs = @raw_data['include'] || include_globs exclude_globs = @raw_data['exclude'] || [] end end @raw_data ||= {} @raw_data['include'] ||= include_globs @raw_data['exclude'] ||= exclude_globs @raw_data['require'] ||= [] @raw_data['domains'] ||= [] @raw_data['reporters'] ||= %w[rubocop require_not_found] @raw_data['plugins'] ||= [] @raw_data['require_paths'] ||= [] @raw_data['max_files'] ||= MAX_FILES included excluded end
def max_files
-
(Integer)-
def max_files raw_data['max_files'] end
def plugins
-
(Array-)
def plugins raw_data['plugins'] end
def process_exclusions globs
-
(Array-)
Parameters:
-
globs(Array) --
def process_exclusions globs remainder = globs.select do |glob| if glob_is_directory?(glob) exdir = File.join(workspace, glob_to_directory(glob)) included.delete_if { |file| file.start_with?(exdir) } false else true end end process_globs remainder end
def process_globs globs
-
(Array-)
Parameters:
-
globs(Array) --
def process_globs globs result = [] globs.each do |glob| result.concat Dir[File.join workspace, glob].map{ |f| f.gsub(/\\/, '/') } end result end
def reporters
-
(Array-)
def reporters raw_data['reporters'] end
def require_paths
-
(Array-)
def require_paths raw_data['require_paths'] || [] end
def required
-
(Array-)
def required raw_data['require'] end