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
# File lib/toptranslation_cli/status.rb, line 43 def print_section(description, paths) return if paths.empty? puts <<~SECTION #{description} #{paths.sort.map { |path| "\t#{path}" }.join("\n")} SECTION end
print_status(only_local, only_remote, changed)
click to toggle source
# File lib/toptranslation_cli/status.rb, line 37 def print_status(only_local, only_remote, changed) print_section 'Local: These documents exist only locally', only_local print_section 'Changed: These documents exist both locally and remotely but differ', changed print_section 'Remote: These documents exist only remotely', only_remote end
project()
click to toggle source
# File lib/toptranslation_cli/status.rb, line 54 def project ToptranslationCli .connection .projects .find(ToptranslationCli.configuration.project_identifier) end