Giter Site home page Giter Site logo

apple_epf's Introduction

AppleEpf

Installation

gem 'apple_epf'

Setup

Put this in your initializer.rb if you are using Rails.

AppleEpf.configure do |config|
  config.apple_id = 'username'
  config.apple_password = 'password'
  config.download_retry_count = 3 #
  config.keep_tbz_after_extract = false
  config.extract_dir = '' # where to extract to
  config.log_file = 'path to log file' #absolute path to log file
  config.files_matrix = {} # {popularity: ['application_popularity_per_genre']}
end

All of this can be redefined for every downloader.

Manual manipulations

# Manually download one file
downloader = AppleEpf::Downloader.new('incremental', 'popularity', Date.parse('17-01-2013'))
downloader.download #=> will return local filepath to downloaded file or fire exception


# Manually extract one archive
extractor = AppleEpf::Extractor.new(filename, files_to_extract)
# filename - full path to local file
# files_to_extract - Files to be extracted from Archive (application, application_detail)
file_entry = extractor.perform #=> will return instance of FileEntry
file_entry.tbz_file #=> original file that was parsed. It is removed after untaring
file_entry.extracted_files #=> newly created(unpacked) files

#Manually parse file
parser = AppleEpf::Parser.new(filename)
# filename - full local path to file

parser.process_rows do |r|
  puts "row is #{r}"
end

Download and Extract

If you want to combine downloading and extracting your can use one of following methonds. My personal feeling is to parsing should we something live alone and should not be combined in one stack with download and extract. And of cource it is better to download and extract files one by one.

manager = AppleEpf::Incremental.new('10-10-2012', {popularity: ['application_popularity_per_genre']})

manager = AppleEpf::Full.new('10-10-2012', {popularity: ['application_popularity_per_genre']})

manager.download_all_files #will download all files for this date for all keys "popularity", 'pricing', 'itunes' etc

manager.download_and_extract_all_files #will first download and than extract all files

manager.download_and_extract('itunes', ['application', 'application_detail']) #will donwload only 'itunes' and extract only ['application', 'application_detail']. This actually ignored matrix passed to initializer

manager.download('itunes') #will only download file

You can omit where to store files by setting it directly to downloader instance

manager.store_dir = '/whatever_dir_you_like'
manager.download('itunes')

OR

downloader = AppleEpf::Downloader.new('incremental', 'popularity', Date.parse('17-01-2013'))
downloader.dirpath = '/whatever_dir_you_like'
downloader.download

You can also omit if you want to store initial tbz files after they will be unpacked

extractor.keep_tbz_after_extract = true

OR

manager.keep_tbz_after_extract = true

Get list of current files avaliable for download

AppleEpf::Incremental.get_current_list #=> current incremental files AppleEpf::Full.get_current_list #=> current full files

apple_epf's People

Contributors

andoriyu avatar artemk avatar funkyboy avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.