apple_epf 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,21 +8,26 @@ module AppleEpf
8
8
  include AppleEpf::Logging
9
9
  ITUNES_FLAT_FEED_URL = 'https://feeds.itunes.apple.com/feeds/epf/v3/full'.freeze
10
10
 
11
- attr_accessor :type, :filename, :filedate
11
+ attr_accessor :type, :filename, :filedate, :force_url
12
12
 
13
13
  attr_reader :download_to, :apple_filename_full
14
14
  attr_writer :dirpath
15
- def initialize(type, filename, filedate)
15
+ def initialize(type, filename, filedate, force_url = nil)
16
16
  @type = type
17
17
  @filename = filename #itunes, popularity, match, pricing
18
18
  @filedate = filedate
19
+ @force_url = force_url
19
20
  end
20
21
 
21
22
  def download
22
23
  _prepare_folders
23
- get_filename_by_date_and_type
24
+ if @force_url
25
+ @apple_filename_full = @force_url
26
+ else
27
+ get_filename_by_date_and_type
28
+ @apple_filename_full = apple_filename_full_url(@apple_filename_full_path)
29
+ end
24
30
 
25
- @apple_filename_full = apple_filename_full_url(@apple_filename_full_path)
26
31
  @download_to = File.join(dirpath, File.basename(@apple_filename_full))
27
32
 
28
33
  logger_info "Download file: #{@apple_filename_full}"
@@ -172,4 +177,4 @@ module AppleEpf
172
177
  end
173
178
 
174
179
  end
175
- end
180
+ end
@@ -21,10 +21,14 @@ module AppleEpf
21
21
  curl.max_redirects = 5
22
22
  curl.perform
23
23
  body = curl.body_str
24
- files = Nokogiri::HTML(body).xpath("//td/a").map(&:text).select{|s| s=~/.*tbz$/}.map{|f| f.chomp('.tbz')}
24
+
25
+ files = Nokogiri::HTML(body).xpath("//td/a").map(&:text).select{|s| s=~/.*tbz$/}
26
+
25
27
  files.inject({}) do |all, e|
26
- e.match(/([a-z]*)(\d*)/)
27
- all[$1] = $2
28
+ e.match(/([a-z]*)(\d*.tbz)/)
29
+ all[$1] = {}
30
+ all[$1][:base] = $2.chomp(".tbz")
31
+ all[$1][:full_url] = self.current_url + "/#{$2}"
28
32
  all
29
33
  end
30
34
  end
@@ -1,3 +1,3 @@
1
1
  module AppleEpf
2
- VERSION = "1.1.2"
2
+ VERSION = "1.1.3"
3
3
  end
@@ -160,10 +160,10 @@ describe AppleEpf::Main do
160
160
  to_return(:status => 200, :body => File.read(filename), :headers => {})
161
161
 
162
162
  list = {
163
- 'itunes' => '20130130',
164
- 'match' => '20130130',
165
- 'popularity' => '20130130',
166
- 'pricing' => '20130130'
163
+ "itunes" => {:base=>"20130130", :full_url=>"https://feeds.itunes.apple.com/feeds/epf/v3/full/current/20130130.tbz"},
164
+ "match" => {:base=>"20130130", :full_url=>"https://feeds.itunes.apple.com/feeds/epf/v3/full/current/20130130.tbz"},
165
+ "popularity" => {:base=>"20130130", :full_url=>"https://feeds.itunes.apple.com/feeds/epf/v3/full/current/20130130.tbz"},
166
+ "pricing" => {:base=>"20130130", :full_url=>"https://feeds.itunes.apple.com/feeds/epf/v3/full/current/20130130.tbz"}
167
167
  }
168
168
  AppleEpf::Full.get_current_list.should == list
169
169
  end
@@ -177,9 +177,13 @@ describe AppleEpf::Main do
177
177
  stub_request(:get, "https://test:test@feeds.itunes.apple.com/feeds/epf/v3/full/current/incremental/current").
178
178
  to_return(:status => 200, :body => File.read(filename), :headers => {})
179
179
 
180
- list = {"itunes"=>"20130205", "match"=>"20130205", "popularity"=>"20130205", "pricing"=>"20130205"}
180
+ list = {"itunes" => {:base=>"20130205", :full_url=>"https://feeds.itunes.apple.com/feeds/epf/v3/full/current/incremental/current/20130205.tbz"},
181
+ "match" => {:base=>"20130205", :full_url=>"https://feeds.itunes.apple.com/feeds/epf/v3/full/current/incremental/current/20130205.tbz"},
182
+ "popularity" => {:base=>"20130205", :full_url=>"https://feeds.itunes.apple.com/feeds/epf/v3/full/current/incremental/current/20130205.tbz"},
183
+ "pricing" => {:base=>"20130205", :full_url=>"https://feeds.itunes.apple.com/feeds/epf/v3/full/current/incremental/current/20130205.tbz"}
184
+ }
181
185
  AppleEpf::Incremental.get_current_list.should == list
182
186
  end
183
187
  end
184
188
  end
185
- end
189
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apple_epf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-14 00:00:00.000000000 Z
12
+ date: 2014-02-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -221,7 +221,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
221
221
  version: '0'
222
222
  segments:
223
223
  - 0
224
- hash: 1349011800637248115
224
+ hash: -2723133082959436123
225
225
  required_rubygems_version: !ruby/object:Gem::Requirement
226
226
  none: false
227
227
  requirements:
@@ -230,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
230
230
  version: '0'
231
231
  segments:
232
232
  - 0
233
- hash: 1349011800637248115
233
+ hash: -2723133082959436123
234
234
  requirements: []
235
235
  rubyforge_project:
236
236
  rubygems_version: 1.8.23