Class: Solargraph::ApiMap::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/solargraph/api_map/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(workspace = nil) ⇒ Config



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/solargraph/api_map/config.rb', line 19

def initialize workspace = nil
  @workspace = workspace
  include_globs = ['**/*.rb']
  exclude_globs = ['spec/**/*', 'test/**/*']
  @included = []
  @excluded = []
  @domains = []
  unless @workspace.nil?
    include_globs = ['**/*.rb']
    exclude_globs = ['spec/**/*', 'test/**/*']
    sfile = File.join(@workspace, '.solargraph.yml')
    if File.file?(sfile)
      @raw_data = YAML.load(File.read(sfile))
      conf = YAML.load(File.read(sfile))
      include_globs = conf['include'] || include_globs
      exclude_globs = conf['exclude'] || []
      @domains = conf['domains'] || []
    end
    @included.concat process_globs(include_globs)
    @excluded.concat process_globs(exclude_globs)
  end
  @raw_data ||= {}
  @raw_data['include'] = @raw_data['include'] || include_globs
  @raw_data['exclude'] = @raw_data['exclude'] || exclude_globs
  # @todo If the domains config goes stable, add it to @raw_data
end

Instance Attribute Details

#domainsArray<String> (readonly)



17
18
19
# File 'lib/solargraph/api_map/config.rb', line 17

def domains
  @domains
end

#excludedArray<String> (readonly)



14
15
16
# File 'lib/solargraph/api_map/config.rb', line 14

def excluded
  @excluded
end

#includedArray<String> (readonly)



11
12
13
# File 'lib/solargraph/api_map/config.rb', line 11

def included
  @included
end

#raw_dataObject (readonly)

Returns the value of attribute raw_data.



8
9
10
# File 'lib/solargraph/api_map/config.rb', line 8

def raw_data
  @raw_data
end

#workspaceString (readonly)



7
8
9
# File 'lib/solargraph/api_map/config.rb', line 7

def workspace
  @workspace
end