Class: ExtractI18n::Adapters::Adapter

Inherits:
Object
  • Object
show all
Defined in:
lib/extract_i18n/adapters/adapter.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_key:, on_ask:, options: {}) ⇒ Adapter

Returns a new instance of Adapter.



22
23
24
25
26
# File 'lib/extract_i18n/adapters/adapter.rb', line 22

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

Instance Attribute Details

#file_keyObject (readonly)

Returns the value of attribute file_key.



20
21
22
# File 'lib/extract_i18n/adapters/adapter.rb', line 20

def file_key
  @file_key
end

#file_pathObject (readonly)

Returns the value of attribute file_path.



20
21
22
# File 'lib/extract_i18n/adapters/adapter.rb', line 20

def file_path
  @file_path
end

#on_askObject (readonly)

Returns the value of attribute on_ask.



20
21
22
# File 'lib/extract_i18n/adapters/adapter.rb', line 20

def on_ask
  @on_ask
end

#optionsObject (readonly)

Returns the value of attribute options.



20
21
22
# File 'lib/extract_i18n/adapters/adapter.rb', line 20

def options
  @options
end

Class Method Details

.for(file_path) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/extract_i18n/adapters/adapter.rb', line 5

def self.for(file_path)
  case file_path
  when /\.rb$/ then RubyAdapter
  when /\.erb$/ then ErbAdapter
  when /\.slim$/ then SlimAdapter
  when /\.ts$/, /\.js$/, /\.mjs/, /\.jsx$/ then JsAdapter
  when /\.vue$/
    if File.read(file_path)[/lang=.pug./]
      VuePugAdapter
    else
      VueAdapter
    end
  end
end

.supports_relative_keys?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/extract_i18n/adapters/adapter.rb', line 32

def self.supports_relative_keys?
  false
end

Instance Method Details

#run(content) ⇒ Object

Raises:

  • (NotImplementedError)


28
29
30
# File 'lib/extract_i18n/adapters/adapter.rb', line 28

def run(content)
  raise NotImplementedError
end