Sha256: 07f63b7e12e97beb28c42ba9773db6122f79d898f333534b8c1693e769824c95

Contents?: true

Size: 773 Bytes

Versions: 2

Compression:

Stored size: 773 Bytes

Contents

# frozen_string_literal: true

module ExtractI18n::Adapters
  class Adapter
    def self.for(file_path)
      case file_path
      when /\.rb$/ then RubyAdapter
      when /\.slim$/ then SlimAdapter
      when /\.vue$/
        if File.read(file_path)[/lang=.pug./]
          VuePugAdapter
        else
          VueAdapter
        end
      end
    end

    attr_reader :on_ask, :file_path, :file_key, :options

    def initialize(file_key:, on_ask:, options: {})
      @on_ask = on_ask
      @file_key = file_key
      @options = options
    end

    def run(content)
      raise NotImplementedError
    end

    def self.supports_relative_keys?
      false
    end

    private

    def original_content
      @original_content ||= File.read(file_path)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
extract_i18n-0.6.1 lib/extract_i18n/adapters/adapter.rb
extract_i18n-0.6.0 lib/extract_i18n/adapters/adapter.rb