Method: WebTranslateIt::Configuration#files_from_project

Defined in:
lib/web_translate_it/configuration.rb

#files_from_project(project) ⇒ Object

Set the project files from the Project API. Implementation example:

configuration = WebTranslateIt::Configuration.new
files = configuration.files # returns an array of TranslationFile


67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/web_translate_it/configuration.rb', line 67

def files_from_project(project) # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
  array_files = []
  project['project_files'].each do |project_file|
    if project_file['name'].nil? || (project_file['name'].strip == '')
      puts "File #{project_file['id']} not set up"
    elsif ignore_files&.any? { |glob| File.fnmatch(glob, project_file['name']) }
      puts "Ignoring #{project_file['name']}"
    else
      array_files.push TranslationFile.new(project_file['id'], project_file['name'], project_file['locale_code'], api_key, project_file['updated_at'], project_file['hash_file'], project_file['master_project_file_id'], project_file['fresh'])
    end
  end
  array_files
end