class ToptranslationCli::Status

Public Class Methods

run() click to toggle source
# File lib/toptranslation_cli/status.rb, line 6
def run
  ToptranslationCli.configuration.load

  proj = project

  local_files = FileFinder.local_files(proj)
  remote_files = FileFinder.remote_files(proj)

  only_local, only_remote, changed = diff(local_files, remote_files)

  print_status(only_local, only_remote, changed)

  (only_local + only_remote + changed).length
end

Private Class Methods

changed_files(local, remote, only_local, only_remote) click to toggle source
# File lib/toptranslation_cli/status.rb, line 31
def changed_files(local, remote, only_local, only_remote)
  (local.to_a - remote.to_a | remote.to_a - local.to_a)
    .flat_map(&:first)
    .uniq - only_remote - only_local
end
diff(local, remote) click to toggle source
# File lib/toptranslation_cli/status.rb, line 23
def diff(local, remote)
  only_local = local.keys - remote.keys
  only_remote = remote.keys - local.keys
  changed = changed_files(local, remote, only_local, only_remote)

  [only_local, only_remote, changed]
end
print_section(description, paths) click to toggle source
print_status(only_local, only_remote, changed) click to toggle source
project() click to toggle source
# File lib/toptranslation_cli/status.rb, line 54
def project
  ToptranslationCli
    .connection
    .projects
    .find(ToptranslationCli.configuration.project_identifier)
end