Module: Utcd

Extended by:
API, Tools
Defined in:
lib/utcd.rb,
lib/utcd/version.rb

Constant Summary collapse

VERSION =
'0.2.0'.freeze

Constants included from Queries

Queries::Client, Queries::CreateSegment, Queries::RetrieveAllLocales, Queries::RetrieveAllLocalesForPlatform, Queries::RetrieveTranslationsForLocale

Constants included from Network

Network::HTTP, Network::Schema

Constants included from Constants

Constants::BASE_URI

Class Method Summary collapse

Methods included from Tools

create_path_from_segment, platform, platform_extension, read_localizable_file, retrieve_files_in_locale, retrieve_locales, retrieve_localizable_folder_path, status, write_to_file

Methods included from API

check_server_locales, check_server_locales_for_platform, create_segment_on_server, download_server_locale_file, retrieve_server_translations_for_locale, upload_server_locale_file

Methods included from Network

#create_schema

Class Method Details

.pull(locale) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/utcd.rb', line 27

def self.pull(locale)
  # 1. Get all server files for chosen locale
  server_files = retrieve_server_translations_for_locale(locale)

  # 2. Download synchronously all files and swap them with local files
  puts "Updating files for locale #{locale}"
  for file in server_files
      content = download_server_locale_file(file)
      file_name = file.split('/').last
      folder_path = "#{retrieve_localizable_folder_path}/#{locale}#{platform_extension}/#{file_name}"
      write_to_file(folder_path, content)
      puts " - #{locale}#{platform_extension}/#{file_name}"
  end
end

.push(locale) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/utcd.rb', line 10

def self.push(locale)
  # 1º. Check that the locale folder is not empty
  files = retrieve_files_in_locale(locale)
  if files.nil? || files.empty? then
      puts "No files found for locale #{locale}"
  end

  # 2. Upload synchronously all files in the locale folder
  current_platform = platform
  puts "Uploading files for locale #{locale}"
  for file_path in files
      file_path = upload_server_locale_file(file_path, platform, locale)
      create_segment_on_server(file_path, locale)
      puts "- #{file_path}"
  end
end