Module: AppCask

Defined in:
lib/appcask.rb,
lib/appcask/version.rb,
lib/appcask/local_app.rb,
sig/appcask.rbs

Defined Under Namespace

Classes: Error, LocalApp

Constant Summary collapse

ICON_SIZES =
{
  "0" => { display: "60x60", key: "artworkUrl60" },
  "1" => { display: "100x100", key: "artworkUrl100" },
  "2" => { display: "512x512", key: "artworkUrl512" },
  "3" => { display: "1024x1024", key: "artworkUrl512" }
}.freeze
SCREENSHOT_DEVICES =
{
  "iphone" => "iPhone screenshots",
  "ipad" => "iPad screenshots"
}.freeze
COUNTRIES =
{
  "us" => "United States",
  "cn" => "China",
  "jp" => "Japan",
  "kr" => "South Korea",
  "hk" => "Hong Kong",
  "tw" => "Taiwan",
  "gb" => "United Kingdom",
  "de" => "Germany",
  "fr" => "France"
}.freeze
DOWNLOAD_MODES =
{
  "1" => { name: "Icon Only", method: :download_icon },
  "2" => { name: "Screenshots Only", method: :download_screenshots },
  "3" => { name: "Description Only", method: :download_description },
  "4" => { name: "All Assets", method: :download_all }
}.freeze
VERSION =

Returns:

  • (String)
"0.6.0"

Class Method Summary collapse

Class Method Details

.getObject



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/appcask.rb', line 64

def get
  show_banner

  app_name = get_app_name
  country = get_country

  puts "\nšŸ” Searching for \"#{app_name}\"..."

  results = search_app(app_name, country)

  if results.nil? || results["resultCount"].to_i.zero?
    warn "āŒ No apps found for \"#{app_name}\"."
    return
  end

  selected_app = select_app(results)
  return unless selected_app

  mode = select_download_mode
  return unless mode

  send(mode[:method], selected_app, country)
end

.mainObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/appcask.rb', line 44

def main
  command = ARGV[0]&.downcase

  case command
  when "fetch", "local"
    show_banner
    require_relative "appcask/local_app"
    AppCask::LocalApp.fetch_all
  else
    get
  end
rescue Interrupt
  puts "\n\nšŸ‘‹ Goodbye!"
  exit 0
rescue StandardError => e
  warn "\nāŒ Error: #{e.message}"
  warn e.backtrace if ENV["DEBUG"]
  exit 1
end