pear_warranty 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +31 -0
- data/lib/pear_warranty.rb +15 -6
- data/lib/pear_warranty/version.rb +1 -1
- data/pear_warranty.gemspec +1 -1
- data/spec/pear_warranty_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 178340311308b99dcbcbb034367ad6f0a04b2a2a
|
4
|
+
data.tar.gz: 1044186ab6a3c52c516f49733ac78e54a65339d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb592fb527fe268121d98c9a884273ff2128ccef256950167885073a368c4231b1ccc5224e5bafd37a2b35836da31eb20075a6981365f036254990f933ed7c68
|
7
|
+
data.tar.gz: 34a5b2234776489d73fce21ef662686411cd4613bc6c73d49f48a705a48b262199c92d61c0de45defbf49be2274aff5e4f283ae2853172d9b787538ed4d25d2e
|
data/README.md
CHANGED
@@ -41,6 +41,37 @@ PearWarranty.check('your IMEI here', 0)
|
|
41
41
|
```
|
42
42
|
Proxy index must be in range of 0 and `PearWarranty::PROXIES.size`. If it goes out randomly chosen will be used.
|
43
43
|
|
44
|
+
### Available proxies:
|
45
|
+
|
46
|
+
* 0 - Canada East
|
47
|
+
* 1 - Germany
|
48
|
+
* 2 - France (Strasbourg)
|
49
|
+
* 3 - Netherlands
|
50
|
+
* 4 - France (Roubaix)
|
51
|
+
* 5 - France (Gravelines)
|
52
|
+
* 6 - United States Central (TX)
|
53
|
+
* 7 - United States East (NJ)
|
54
|
+
* 8 - United States Central (IL)
|
55
|
+
* 9 - United States East (GA)
|
56
|
+
|
57
|
+
To improve speed your should to test which of proxies works for you most frequently. For my location (Ukraine) speed test show that result (each one is for 50 requests):
|
58
|
+
|
59
|
+
Proxy index | Location | Speed
|
60
|
+
:----------:|:--------:|:----:
|
61
|
+
0 | Canada | 94.452161
|
62
|
+
1 | Germany | 138.392749
|
63
|
+
2 | Strasbourg | 79.161559
|
64
|
+
3 | Netherlands | 133.401920
|
65
|
+
4 | Roubaix | 70.684222
|
66
|
+
5 | Gravelines | 71.803946
|
67
|
+
6 | TX | 83.853322
|
68
|
+
7 | NJ | 75.568946
|
69
|
+
8 | IL | 103.772447
|
70
|
+
9 | GA | 75.414354
|
71
|
+
- | random | 114.406067
|
72
|
+
|
73
|
+
That`s why I prefer to use France (Roubaix) - 4th proxy.
|
74
|
+
|
44
75
|
## Dependencies
|
45
76
|
|
46
77
|
- mechanize
|
data/lib/pear_warranty.rb
CHANGED
@@ -9,33 +9,42 @@ module PearWarranty
|
|
9
9
|
|
10
10
|
def self.check(serial, proxy_index = nil)
|
11
11
|
agent = Mechanize.new
|
12
|
-
|
12
|
+
proxies = [0,1,2,3,4,5,6,7,8,9]
|
13
|
+
unless proxy_index
|
14
|
+
proxy_index = rand(PROXIES.size)
|
15
|
+
else
|
16
|
+
proxies -= [proxy_index]
|
17
|
+
end
|
13
18
|
page = nil
|
14
19
|
error = true
|
15
20
|
apple_url = "https://selfsolve.apple.com/wcResults.do?sn=#{serial}&Continue=Continue&num=0"
|
21
|
+
correct_reg = /warrantyPage\.warrantycheck\.displayHWSupportInfo/
|
22
|
+
invalid_reg = [/but this serial number is not valid/, /but the serial number you have provided cannot be found in our records/]
|
16
23
|
TRIES.times do
|
17
24
|
form = get_form(proxy_index, apple_url, agent)
|
18
25
|
set_cookie(agent)
|
19
26
|
begin
|
20
27
|
page = agent.submit(form)
|
21
28
|
rescue Net::HTTP::Persistent::Error
|
22
|
-
proxy_index = rand(
|
29
|
+
proxy_index = proxies[rand(proxies.size)]
|
30
|
+
proxies -= [proxy_index]
|
23
31
|
next
|
24
32
|
end
|
25
33
|
page = page.body
|
26
|
-
|
34
|
+
if page =~ correct_reg or page =~ invalid_reg[1] or page =~ invalid_reg[0]
|
27
35
|
error = false
|
28
36
|
break
|
29
37
|
end
|
30
|
-
proxy_index = rand(
|
38
|
+
proxy_index = proxies[rand(proxies.size)]
|
39
|
+
proxies -= [proxy_index]
|
31
40
|
end
|
32
41
|
if error
|
33
42
|
{error: 'Problem with proxy'}
|
34
43
|
else
|
35
|
-
|
44
|
+
unless page =~ correct_reg
|
36
45
|
{ error: 'There is no such imei or service is not available at this moment' }
|
37
46
|
else
|
38
|
-
text = page.split(
|
47
|
+
text = page.split(correct_reg)[1].scan(/\(.*\)/)[0].delete('()')
|
39
48
|
params = text.split(', ')
|
40
49
|
warranty = to_boolean(params.first.delete ' ')
|
41
50
|
{
|
data/pear_warranty.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["moranibaca@gmail.com"]
|
11
11
|
spec.summary = %q{Get IPhone warranty information}
|
12
12
|
spec.description = %q{Get IPhone warranty information form https://selfsolve.apple.com by device imei}
|
13
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "https://github.com/imdrasil/pear_warranty"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
data/spec/pear_warranty_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pear_warranty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roman Kalnytsky
|
@@ -116,7 +116,7 @@ files:
|
|
116
116
|
- spec/support/uncorrect_warranty.html
|
117
117
|
- spec/support/with_warranty.html
|
118
118
|
- spec/support/without_warranty.html
|
119
|
-
homepage:
|
119
|
+
homepage: https://github.com/imdrasil/pear_warranty
|
120
120
|
licenses:
|
121
121
|
- MIT
|
122
122
|
metadata: {}
|