module AppStoreInfo

Constants

DEFAULT_REGION
GENRES
VERSION

Public Class Methods

read(id, region = DEFAULT_REGION) click to toggle source
# File lib/app_store_info.rb, line 10
def self.read(id, region = DEFAULT_REGION)
  # The region can be wrong because of the multiple app store formats (and our way of  getting) it
  # from the URL. If that's the case then just fallback to 'us'.
  region = DEFAULT_REGION unless Regions.find(region)

  json = AppStoreInfo::API.new(id, region).parse

  App.new(json)
end
read_url(url) click to toggle source
# File lib/app_store_info.rb, line 20
def self.read_url(url)
  match = url.match(%r{\Ahttps://itunes.apple.com/(\w+)/.+/?id=?([\d]+)})

  raise InvalidURLError, 'Invalid App Store URL' unless match

  region = match.captures.first
  id = match.captures.last

  read(id, region)
end