Sha256: 4cc4c87410d183c56f9f29eba78397fbb055bc05b5779d6544678c798b14ee2a

Contents?: true

Size: 701 Bytes

Versions: 2

Compression:

Stored size: 701 Bytes

Contents

module ESLintRails
  class Config

    def self.read(force_default: false)
      self.new(force_default: force_default).send(:read)
    end

    private

    CONFIG_PATH = 'config/eslint.json'
    private_constant :CONFIG_PATH

    def initialize(force_default: nil)
      raise(ArgumentError, 'force_default is required') if force_default.nil?

      @force_default = force_default
      @custom_file   = Rails.root.join(CONFIG_PATH)
      @default_file  = ESLintRails::Engine.root.join(CONFIG_PATH)
    end

    def read
      config_file.read
    end

    def config_file
      (@custom_file.exist? && !@force_default) ?  @custom_file : @default_file
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
eslint-rails-ee-1.0.1 lib/eslint-rails-ee/config.rb
eslint-rails-ee-1.0 lib/eslint-rails-ee/config.rb