Module: Enola::Config

Defined in:
lib/enola/config.rb

Constant Summary collapse

FILE =
"mcp-arch.yaml"
IGNORE =
%w[**/.git/** **/node_modules/** **/vendor/** **/tmp/** **/log/** **/coverage/** **/public/assets/**].freeze

Class Method Summary collapse

Class Method Details

.path(root) ⇒ Object



9
10
11
# File 'lib/enola/config.rb', line 9

def self.path(root)
  File.join(File.expand_path(root), FILE)
end

.render(ruby: Providers.ruby) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/enola/config.rb', line 21

def self.render(ruby: Providers.ruby)
  <<~YAML
    # Written by the enola gem; edit freely. Both providers are on: Prism runs
    # under the Ruby that runs the gem, Rubydex is built into the binary and
    # fetched once. Remove one to leave it out of the graph.
    repo: .
    repos:
      - .
    ignore:
    #{IGNORE.map { |glob| "  - \"#{glob}\"" }.join("\n")}
    providers:
      - name: prism
        command: [#{ruby.inspect}, #{Providers.prism_script.inspect}]
        expected_version: "#{Providers.prism_version || '0.1.0'}"
      - name: rubydex
        expected_version: "#{Providers::RUBYDEX_EXPECTED_VERSION}"
  YAML
end

.write_default(root, ruby: Providers.ruby) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/enola/config.rb', line 13

def self.write_default(root, ruby: Providers.ruby)
  target = path(root)
  return nil if File.exist?(target)

  File.write(target, render(ruby: ruby))
  target
end