apple_epf 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2a87068a1d217c86b226a7710fadef9ec1330bd7
4
+ data.tar.gz: 1dc1aa8b23d85f3e4e2f66a37e75ed16b7fb93dc
5
+ SHA512:
6
+ metadata.gz: faa56def47d9748e3910d7d6a4066ad527640ac45980fc201b95e2f7f324e3ddffdfe92e056292ed166c449a96a6728bc059eaa80b5cf193291596651eec3492
7
+ data.tar.gz: 4f65225dd120a03d2b1f8e2e8fd3cf5bebeafe2238e753e8ee7ee8b551276db2ca2a307882336e477ac9b0a80cfe5c07b6b2ed9e953b1f3b52bd49d3e3684990
data/README.md CHANGED
@@ -1,74 +1,95 @@
1
1
  # AppleEpf
2
2
 
3
3
  ## Installation
4
-
5
- gem 'apple_epf'
4
+ ```ruby
5
+ gem 'apple_epf'
6
+ ```
6
7
 
7
8
  ## Setup
8
9
 
9
10
  Put this in your initializer.rb if you are using Rails.
10
-
11
- AppleEpf.configure do |config|
12
- config.apple_id = 'username'
13
- config.apple_password = 'password'
14
- config.download_retry_count = 3 #
15
- config.keep_tbz_after_extract = false
16
- config.extract_dir = '' # where to extract to
17
- config.log_file = 'path to log file' #absolute path to log file
18
- config.files_matrix = {} # {popularity: ['application_popularity_per_genre']}
19
- end
11
+ ```ruby
12
+ AppleEpf.configure do |config|
13
+ config.apple_id = 'username'
14
+ config.apple_password = 'password'
15
+ config.download_retry_count = 3 #
16
+ config.keep_tbz_after_extract = false
17
+ config.extract_dir = '' # where to extract to
18
+ config.files_matrix = {} # {popularity: ['application_popularity_per_genre']}
19
+ #config.files_matrix = {itunes: [], pricing: [], popularity: []}
20
+ config.download_processor = AppleEpf::AriaDownloadProcessor
21
+ config.concurrent_downloads = 16
22
+ config.log_file = "#{Rails.root}/log/apple_epf_#{Rails.env}.log"
23
+ end
24
+ ```
20
25
 
21
26
  All of this can be redefined for every downloader.
22
27
 
23
28
  ## Manual manipulations
24
29
 
25
- # Manually download one file
26
- downloader = AppleEpf::Downloader.new('incremental', 'popularity', Date.parse('17-01-2013'))
27
- downloader.download #=> will return local filepath to downloaded file or fire exception
30
+ ```ruby
31
+ # Manually download one file
32
+ downloader = AppleEpf::Downloader.new('incremental', 'popularity', Date.parse('17-01-2013'))
33
+ downloader.download #=> will return local filepath to downloaded file or fire exception
28
34
 
35
+ # Manually extract one archive
36
+ extractor = AppleEpf::Extractor.new(filename, files_to_extract)
37
+ # filename - full path to local file
38
+ # files_to_extract - Files to be extracted from Archive (application, application_detail)
39
+ file_entry = extractor.perform #=> will return instance of FileEntry
40
+ file_entry.tbz_file #=> original file that was parsed. It is removed after untaring
41
+ file_entry.extracted_files #=> newly created(unpacked) files
29
42
 
30
- # Manually extract one archive
31
- extractor = AppleEpf::Extractor.new(filename, files_to_extract)
32
- # filename - full path to local file
33
- # files_to_extract - Files to be extracted from Archive (application, application_detail)
34
- file_entry = extractor.perform #=> will return instance of FileEntry
35
- file_entry.tbz_file #=> original file that was parsed. It is removed after untaring
36
- file_entry.extracted_files #=> newly created(unpacked) files
43
+ #Manually parse file
44
+ parser = AppleEpf::Parser.new(filename)
45
+ # filename - full local path to file
37
46
 
38
- #Manually parse file
39
- parser = AppleEpf::Parser.new(filename)
40
- # filename - full local path to file
41
-
42
- parser.process_rows do |r|
43
- puts "row is #{r}"
44
- end
47
+ parser.process_rows do |r|
48
+ puts "row is #{r}"
49
+ end
50
+ ```
45
51
 
46
52
  ## Download and Extract
47
53
  If you want to combine downloading and extracting your can use one of following
48
54
  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.
49
55
 
50
- manager = AppleEpf::Incremental.new('10-10-2012', {popularity: ['application_popularity_per_genre']})
56
+ ```ruby
57
+ manager = AppleEpf::Incremental.new('10-10-2012',
58
+ { popularity: ['application_popularity_per_genre'] })
59
+
60
+
61
+ manager = AppleEpf::Full.new('10-10-2012',
62
+ { popularity: ['application_popularity_per_genre'] })
51
63
 
52
- manager = AppleEpf::Full.new('10-10-2012', {popularity: ['application_popularity_per_genre']})
53
64
 
54
- manager.download_all_files #will download all files for this date for all keys "popularity", 'pricing', 'itunes' etc
65
+ manager.download_all_files
66
+ # will download all files for this date
67
+ # for all keys "popularity", 'pricing', 'itunes' etc
55
68
 
56
- manager.download_and_extract_all_files #will first download and than extract all files
69
+ manager.download_and_extract_all_files
70
+ #will first download and than extract all files
57
71
 
58
- 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
72
+ manager.download_and_extract('itunes', ['application', 'application_detail'])
73
+ # will download only 'itunes' and extract only ['application', 'application_detail'].
74
+ # This actually ignores matrix passed to initializer
59
75
 
60
- manager.download('itunes') #will only download file
76
+ manager.download('itunes') #will only download file
77
+ ```
61
78
 
62
79
  You can omit where to store files by setting it directly to downloader instance
63
80
 
64
- manager.store_dir = '/whatever_dir_you_like'
65
- manager.download('itunes')
81
+ ```ruby
82
+ manager.store_dir = '/whatever_dir_you_like'
83
+ manager.download('itunes')
84
+ ```
66
85
 
67
86
  OR
68
87
 
69
- downloader = AppleEpf::Downloader.new('incremental', 'popularity', Date.parse('17-01-2013'))
70
- downloader.dirpath = '/whatever_dir_you_like'
71
- downloader.download
88
+ ```ruby
89
+ downloader = AppleEpf::Downloader.new('incremental', 'popularity', Date.parse('17-01-2013'))
90
+ downloader.dirpath = '/whatever_dir_you_like'
91
+ downloader.download
92
+ ```
72
93
 
73
94
  You can also omit if you want to store initial tbz files after they will be unpacked
74
95
 
@@ -80,6 +101,22 @@
80
101
 
81
102
 
82
103
  ## Get list of current files avaliable for download
104
+ ```ruby
105
+ AppleEpf::Incremental.get_current_list #=> current incremental files
106
+ AppleEpf::Full.get_current_list #=> current full files
107
+ ```
108
+
109
+ ## Make sure to try AriaDownloadProcessor
110
+ There are 2 downloaders avaliable for use:
111
+ 1. `CurbDownloadProcessor` - default one
112
+ 2. `AriaDownloadProcessor` - we use in production
113
+
114
+ I suggest using last one, as in can do download in parallel. I sugest set
115
+ `config.concurrent_downloads = 16 or 8`. If you chose to use aria, make sure
116
+ you have `aria2c` in your `PATH`.
117
+
118
+ And of cource you write your own processor.
83
119
 
84
- AppleEpf::Incremental.get_current_list #=> current incremental files
85
- AppleEpf::Full.get_current_list #=> current full files
120
+ ## Make sure to try lbzip2
121
+ lbzip2 uncompress files in parallel. Thanks [@funkyboy](https://github.com/funkyboy) for his help.
122
+ Just set `config.use_lbzip2 = true` and make sure you have it in `PATH`. On mac you can use `brew install lbzip2` for it.
@@ -46,6 +46,9 @@ module AppleEpf
46
46
  mattr_accessor :files_matrix
47
47
  @@files_matrix = {popularity: ['application_popularity_per_genre']}.freeze
48
48
 
49
+ mattr_accessor :use_lbzip2
50
+ @@use_lbzip2 = false
51
+
49
52
  def self.configure
50
53
  yield self
51
54
  end
@@ -20,7 +20,11 @@ module AppleEpf
20
20
  @extracted_files.push File.basename(@filename, '.tbz') + '/' + f
21
21
  end
22
22
 
23
- result = system "cd #{@dirname} && tar -xjf #{@basename} #{@extracted_files.join(' ')}"
23
+ result = if AppleEpf.use_lbzip2
24
+ system "cd #{@dirname} && tar -xj #{@basename} #{@extracted_files.join(' ')} --use-compress-program lbzip2"
25
+ else
26
+ system "cd #{@dirname} && tar -xjf #{@basename} #{@extracted_files.join(' ')} "
27
+ end
24
28
 
25
29
  if result
26
30
  _extracted_files = @extracted_files.map{|f| File.join(@dirname, f)}
@@ -1,3 +1,3 @@
1
1
  module AppleEpf
2
- VERSION = "1.2.1"
2
+ VERSION = "1.2.2"
3
3
  end
metadata CHANGED
@@ -1,190 +1,167 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apple_epf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
5
- prerelease:
4
+ version: 1.2.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Artem Kramarenko
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-03-28 00:00:00.000000000 Z
11
+ date: 2015-01-06 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '2.12'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '2.12'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rails
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
33
  version: 3.2.3
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
40
  version: 3.2.3
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: guard
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: guard-rspec
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rb-fsevent
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ~>
73
+ - - "~>"
84
74
  - !ruby/object:Gem::Version
85
75
  version: 0.9.1
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ~>
80
+ - - "~>"
92
81
  - !ruby/object:Gem::Version
93
82
  version: 0.9.1
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: webmock
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - ">="
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - ">="
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: timecop
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ! '>='
101
+ - - ">="
116
102
  - !ruby/object:Gem::Version
117
103
  version: '0'
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ! '>='
108
+ - - ">="
124
109
  - !ruby/object:Gem::Version
125
110
  version: '0'
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: thin
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
- - - ! '>='
115
+ - - ">="
132
116
  - !ruby/object:Gem::Version
133
117
  version: '0'
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
- - - ! '>='
122
+ - - ">="
140
123
  - !ruby/object:Gem::Version
141
124
  version: '0'
142
125
  - !ruby/object:Gem::Dependency
143
126
  name: curb
144
127
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
128
  requirements:
147
- - - ! '>='
129
+ - - ">="
148
130
  - !ruby/object:Gem::Version
149
131
  version: '0'
150
132
  type: :runtime
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
135
  requirements:
155
- - - ! '>='
136
+ - - ">="
156
137
  - !ruby/object:Gem::Version
157
138
  version: '0'
158
139
  - !ruby/object:Gem::Dependency
159
140
  name: chronic
160
141
  requirement: !ruby/object:Gem::Requirement
161
- none: false
162
142
  requirements:
163
- - - ~>
143
+ - - "~>"
164
144
  - !ruby/object:Gem::Version
165
145
  version: 0.9.0
166
146
  type: :runtime
167
147
  prerelease: false
168
148
  version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
149
  requirements:
171
- - - ~>
150
+ - - "~>"
172
151
  - !ruby/object:Gem::Version
173
152
  version: 0.9.0
174
153
  - !ruby/object:Gem::Dependency
175
154
  name: nokogiri
176
155
  requirement: !ruby/object:Gem::Requirement
177
- none: false
178
156
  requirements:
179
- - - ! '>='
157
+ - - ">="
180
158
  - !ruby/object:Gem::Version
181
159
  version: 1.5.6
182
160
  type: :runtime
183
161
  prerelease: false
184
162
  version_requirements: !ruby/object:Gem::Requirement
185
- none: false
186
163
  requirements:
187
- - - ! '>='
164
+ - - ">="
188
165
  - !ruby/object:Gem::Version
189
166
  version: 1.5.6
190
167
  description: Downloader, Extractor and Parser for Apple Epf Affiliate files
@@ -194,28 +171,24 @@ executables: []
194
171
  extensions: []
195
172
  extra_rdoc_files: []
196
173
  files:
174
+ - MIT-LICENSE
175
+ - README.md
176
+ - Rakefile
177
+ - lib/apple_epf.rb
178
+ - lib/apple_epf/download_processor.rb
197
179
  - lib/apple_epf/download_processor/aria_download_processor.rb
198
- - lib/apple_epf/download_processor/aria_download_processor.rb~
199
180
  - lib/apple_epf/download_processor/curb_download_processor.rb
200
- - lib/apple_epf/download_processor/curb_download_processor.rb~
201
- - lib/apple_epf/download_processor.rb
202
- - lib/apple_epf/download_processor.rb~
203
181
  - lib/apple_epf/downloader.rb
204
182
  - lib/apple_epf/errors.rb
205
183
  - lib/apple_epf/extractor.rb
206
184
  - lib/apple_epf/finder.rb
207
- - lib/apple_epf/finder.rb~
208
185
  - lib/apple_epf/logging.rb
209
186
  - lib/apple_epf/main.rb
210
187
  - lib/apple_epf/parser.rb
211
188
  - lib/apple_epf/version.rb
212
- - lib/apple_epf.rb
213
189
  - lib/core_ext/array.rb
214
190
  - lib/core_ext/module.rb
215
191
  - lib/tasks/apple_epf_tasks.rake
216
- - MIT-LICENSE
217
- - Rakefile
218
- - README.md
219
192
  - spec/lib/apple_epf/download_processor/aria_download_processor_spec.rb
220
193
  - spec/lib/apple_epf/downloader_spec.rb
221
194
  - spec/lib/apple_epf/exctractor_spec.rb
@@ -236,33 +209,26 @@ files:
236
209
  - spec/support/fixtures/itunes/epf/index_of_folders.html
237
210
  homepage:
238
211
  licenses: []
212
+ metadata: {}
239
213
  post_install_message:
240
214
  rdoc_options: []
241
215
  require_paths:
242
216
  - lib
243
217
  required_ruby_version: !ruby/object:Gem::Requirement
244
- none: false
245
218
  requirements:
246
- - - ! '>='
219
+ - - ">="
247
220
  - !ruby/object:Gem::Version
248
221
  version: '0'
249
- segments:
250
- - 0
251
- hash: 2191365109496733098
252
222
  required_rubygems_version: !ruby/object:Gem::Requirement
253
- none: false
254
223
  requirements:
255
- - - ! '>='
224
+ - - ">="
256
225
  - !ruby/object:Gem::Version
257
226
  version: '0'
258
- segments:
259
- - 0
260
- hash: 2191365109496733098
261
227
  requirements: []
262
228
  rubyforge_project:
263
- rubygems_version: 1.8.23
229
+ rubygems_version: 2.2.2
264
230
  signing_key:
265
- specification_version: 3
231
+ specification_version: 4
266
232
  summary: Downloader, Extractor and Parser for Apple Epf Affiliate files
267
233
  test_files:
268
234
  - spec/lib/apple_epf/download_processor/aria_download_processor_spec.rb
File without changes
File without changes