Class: ToptranslationCli::FileFinder
- Inherits:
-
Object
- Object
- ToptranslationCli::FileFinder
- Defined in:
- lib/toptranslation_cli/file_finder.rb
Class Method Summary collapse
Instance Method Summary collapse
- #files(locale_code = '**') ⇒ Object
-
#initialize(path_definition) ⇒ FileFinder
constructor
A new instance of FileFinder.
Constructor Details
#initialize(path_definition) ⇒ FileFinder
Returns a new instance of FileFinder.
5 6 7 |
# File 'lib/toptranslation_cli/file_finder.rb', line 5 def initialize(path_definition) @path_definition = path_definition end |
Class Method Details
.local_files(project) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/toptranslation_cli/file_finder.rb', line 14 def local_files(project) ToptranslationCli.configuration.files.each_with_object({}) do |path_definition, mem| project&.locales&.map(&:code)&.each do |locale_code| mem.merge!(local_files_for_path_definition(path_definition, locale_code)) end end end |
.remote_files(project) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/toptranslation_cli/file_finder.rb', line 22 def remote_files(project) project_locales = project&.locales project&.documents&.each_with_object({}) do |document, files| project_locales&.each do |locale| translation = document.translations.find { |t| t.locale.code == locale.code } next unless translation path = document.path.gsub('{locale_code}', locale.code) files[path] = remote_file(document, locale, translation) end end end |
Instance Method Details
#files(locale_code = '**') ⇒ Object
9 10 11 |
# File 'lib/toptranslation_cli/file_finder.rb', line 9 def files(locale_code = '**') Dir.glob(@path_definition.gsub('{locale_code}', locale_code)) end |