Module: AppStoreInfo

Defined in:
lib/appstore_info.rb,
lib/appstore_info/api.rb,
lib/appstore_info/app.rb,
lib/appstore_info/genres.rb,
lib/appstore_info/regions.rb,
lib/appstore_info/version.rb,
lib/appstore_info/json_accessors.rb

Defined Under Namespace

Modules: JSONAccessors Classes: API, App, ConnectionError, EntryNotFound, GenericError, InvalidURLError, ParseError, Regions

Constant Summary collapse

DEFAULT_REGION =
'us'.freeze
GENRES =
{
  6018 => 'Books',
  6000 => 'Business',
  6022 => 'Catalogs',
  6017 => 'Education',
  6016 => 'Entertainment',
  6015 => 'Finance',
  6023 => 'Food & Drink',
  6014 => 'Games',
  6013 => 'Health & Fitness',
  6012 => 'Lifestyle',
  6020 => 'Medical',
  6011 => 'Music',
  6010 => 'Navigation',
  6009 => 'News',
  6021 => 'Magazines & Newspapers',
  6008 => 'Photo & Video',
  6007 => 'Productivity',
  6006 => 'Reference',
  6005 => 'Social Networking',
  6004 => 'Sports',
  6003 => 'Travel',
  6002 => 'Utilities',
  6001 => 'Weather',

  # Games subgenres
  7001 => 'Action',
  7002 => 'Adventure',
  7003 => 'Arcade',
  7004 => 'Board',
  7005 => 'Card',
  7006 => 'Casino',
  7007 => 'Dice',
  7008 => 'Educational',
  7009 => 'Family',
  7011 => 'Music',
  7012 => 'Puzzle',
  7013 => 'Racing',
  7014 => 'Role Playing',
  7015 => 'Simulation',
  7016 => 'Sports',
  7017 => 'Strategy',
  7018 => 'Trivia',
  7019 => 'Word',

  # Magazines & Newspapers subgenres
  13007 => 'Arts & Photography',
  13006 => 'Automotive',
  13008 => 'Brides & Weddings',
  13009 => 'Business & Investing',
  13010 => "Children's Magazines",
  13011 => 'Computers & Internet',
  13012 => 'Cooking, Food & Drink',
  13013 => 'Crafts & Hobbies',
  13014 => 'Electronics & Audio',
  13015 => 'Entertainment',
  13002 => 'Fashion & Style',
  13017 => 'Health, Mind & Body',
  13018 => 'History',
  13003 => 'Home & Garden',
  13019 => 'Literary Magazines & Journals',
  13020 => "Men's Interest",
  13021 => 'Movies & Music',
  13001 => 'News & Politics',
  13004 => 'Outdoors & Nature',
  13023 => 'Parenting & Family',
  13024 => 'Pets',
  13025 => 'Professional & Trade',
  13026 => 'Regional News',
  13027 => 'Science',
  13005 => 'Sports & Leisure',
  13028 => 'Teens',
  13029 => 'Travel & Regional',
  13030 => "Women's Interest"
}.freeze
VERSION =
'2.1'.freeze

Class Method Summary collapse

Class Method Details

.read(id, region = DEFAULT_REGION) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/appstore_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) ⇒ Object

Raises:



20
21
22
23
24
25
26
27
28
29
# File 'lib/appstore_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