Class: Solargraph::ApiMap::Config
- Inherits:
-
Object
- Object
- Solargraph::ApiMap::Config
- Defined in:
- lib/solargraph/api_map/config.rb
Instance Attribute Summary collapse
- #raw_data ⇒ Hash readonly
- #workspace ⇒ String readonly
Instance Method Summary collapse
-
#calculated ⇒ Array<String>
The calculated array of (included - excluded) files in the workspace.
- #domains ⇒ Array<String>
-
#excluded ⇒ Array<String>
An array of files excluded from the workspace.
-
#included ⇒ Array<String>
An array of files included in the workspace (before calculating excluded files).
-
#initialize(workspace = nil) ⇒ Config
constructor
A new instance of Config.
- #plugins ⇒ Object
- #required ⇒ Object
Constructor Details
#initialize(workspace = nil) ⇒ Config
Returns a new instance of Config.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/solargraph/api_map/config.rb', line 12 def initialize workspace = nil @workspace = workspace include_globs = ['**/*.rb'] exclude_globs = ['spec/**/*', 'test/**/*'] unless @workspace.nil? sfile = File.join(@workspace, '.solargraph.yml') if File.file?(sfile) begin @raw_data = YAML.load(File.read(sfile)) conf = YAML.load(File.read(sfile)) include_globs = conf['include'] || include_globs exclude_globs = conf['exclude'] || [] rescue Exception => e STDERR.puts "Unable to read .solargraph.yml: #{e.class} #{e.}" @raw_data = {} end end end @raw_data ||= {} @raw_data['include'] ||= include_globs @raw_data['exclude'] ||= exclude_globs @raw_data['domains'] ||= [] @raw_data['required'] ||= [] @raw_data['plugins'] ||= [] end |
Instance Attribute Details
#raw_data ⇒ Hash (readonly)
10 11 12 |
# File 'lib/solargraph/api_map/config.rb', line 10 def raw_data @raw_data end |
#workspace ⇒ String (readonly)
7 8 9 |
# File 'lib/solargraph/api_map/config.rb', line 7 def workspace @workspace end |
Instance Method Details
#calculated ⇒ Array<String>
The calculated array of (included - excluded) files in the workspace.
57 58 59 |
# File 'lib/solargraph/api_map/config.rb', line 57 def calculated @calculated ||= (included - excluded) end |
#domains ⇒ Array<String>
62 63 64 |
# File 'lib/solargraph/api_map/config.rb', line 62 def domains raw_data['domains'] end |
#excluded ⇒ Array<String>
An array of files excluded from the workspace.
49 50 51 52 |
# File 'lib/solargraph/api_map/config.rb', line 49 def excluded return [] if workspace.nil? @excluded ||= process_globs(@raw_data['exclude']) end |
#included ⇒ Array<String>
An array of files included in the workspace (before calculating excluded files).
41 42 43 44 |
# File 'lib/solargraph/api_map/config.rb', line 41 def included return [] if workspace.nil? @included ||= process_globs(@raw_data['include']) end |
#plugins ⇒ Object
70 71 72 |
# File 'lib/solargraph/api_map/config.rb', line 70 def plugins raw_data['plugins'] end |
#required ⇒ Object
66 67 68 |
# File 'lib/solargraph/api_map/config.rb', line 66 def required raw_data['required'] end |