Class: PlaceholderPath

Inherits:
Object
  • Object
show all
Defined in:
lib/toptranslation_cli/placeholder_path.rb

Instance Method Summary collapse

Constructor Details

#initialize(path_definition) ⇒ PlaceholderPath

Returns a new instance of PlaceholderPath.



4
5
6
# File 'lib/toptranslation_cli/placeholder_path.rb', line 4

def initialize(path_definition)
  @path_definition = path_definition
end

Instance Method Details

#for_path(path, locale_code) ⇒ Object

Returns a filepath with locale_code placeholder e.g. for the parameters path: “/locales/de/admin/index.de.po” path_definition: “/locales/locale_code/*/locale_code.po” locale_code: “de” it will return: “/locales/locale_code/admin/index.locale_code.po”



13
14
15
16
# File 'lib/toptranslation_cli/placeholder_path.rb', line 13

def for_path(path, locale_code)
  regex = regex(locale_code)
  path.match(regex).captures.join('{locale_code}')
end