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
# File lib/terrestrial/cli/scan.rb, line 35 def print_diff puts "--- Diff" puts "- New Strings" puts create_table(new_strings) puts "" puts "- Removed Strings" puts create_table(removed_strings) end
print_results()
click to toggle source
# File lib/terrestrial/cli/scan.rb, line 21 def print_results if opts[:verbose] print_diff puts "" else if rand(10) == 1 # Show hint ~10% of the time puts "(Hint: add --verbose to the 'scan' command to view the diff of local and remote strings.)" end end puts "New Strings: #{new_strings.count}" puts "Removed Strings: #{removed_strings.count}" end
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