class Terrestrial::Cli::Scan

Public Instance Methods

run() click to toggle source
# File lib/terrestrial/cli/scan.rb, line 7
def run
  Config.load!
  MixpanelClient.track("cli-scan-command")

  TerminalUI.show_spinner do
    @string_registry = StringRegistry.load
    @remote_registry = fetch_current_strings_from_web
  end

  print_results
end

Private Instance Methods

create_table(strings) click to toggle source
# File lib/terrestrial/cli/scan.rb, line 44
def create_table(strings)
  Terminal::Table.new(headings: ['Identifier', 'String', 'Comment']) do |t|
    size = strings.count
    strings.each_with_index do |string, i|
      t.add_row([string["identifier"], string["string"], string["context"]])
      t.add_separator unless i == (size - 1)
    end
  end
end
fetch_current_strings_from_web() click to toggle source
# File lib/terrestrial/cli/scan.rb, line 62
def fetch_current_strings_from_web
  web_client
  .get_app_strings(Config[:project_id], Config[:app_id])
  .body["data"]["strings"]
end
new_strings() click to toggle source
# File lib/terrestrial/cli/scan.rb, line 54
def new_strings
  EntryCollectionDiffer.additions(@remote_registry, @string_registry.entries)
end
print_diff() click to toggle source
print_results() click to toggle source
removed_strings() click to toggle source
# File lib/terrestrial/cli/scan.rb, line 58
def removed_strings
  EntryCollectionDiffer.omissions(@remote_registry, @string_registry.entries)
end
web_client() click to toggle source
# File lib/terrestrial/cli/scan.rb, line 68
def web_client
  @web_client ||= Web.new
end