url_verifier 2.10 → 2.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -6
- data/Rakefile +7 -2
- data/lib/url_verifier/curler.rb +4 -4
- data/lib/url_verifier/run_curler.rb +8 -11
- data/lib/url_verifier/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 882e70dccab2546030aee95cdb710a28d09f67b83e27a4b21a4290b554bf925e
|
4
|
+
data.tar.gz: b7a32bcad963e8e5b415e54613d04a79caa58e5d30ed021fc8ccef3b409e3582
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01cdb2beb56ab62890e8b88bea10bba564d41c9b082d02948da58012e57e2ff4acece7c5c9bace233af0ebdd6e9b68ff1d707b8fb4e47f91d27c1a2fd0c15cfb
|
7
|
+
data.tar.gz: 69ea39304785277eafaf3120dfcb36ff5e2a2153efc9e9b3277cfe9acaff4756760edae2081309376c247f21e9b3f5c2ad9ab68cc4e836c6e28d9239503c1292
|
data/README.md
CHANGED
@@ -41,19 +41,18 @@ Or install it yourself as:
|
|
41
41
|
|
42
42
|
### Available Methods
|
43
43
|
|
44
|
-
#### 1. Verify one URL as a
|
44
|
+
#### 1. Verify one URL as a String:
|
45
45
|
|
46
46
|
```
|
47
47
|
verifier = UrlVerifier::RunCurler.new
|
48
|
-
|
48
|
+
verified_url_hash = verifier.verify_url('example.com')
|
49
49
|
```
|
50
50
|
|
51
|
-
|
52
|
-
#### 2. Verify Array of URL strings:
|
51
|
+
#### 2. Verify Array of URL Strings:
|
53
52
|
|
54
53
|
```
|
55
54
|
verifier = UrlVerifier::RunCurler.new
|
56
|
-
verified_url_hashes = verifier.
|
55
|
+
verified_url_hashes = verifier.verify_urls(array_of_urls)
|
57
56
|
```
|
58
57
|
|
59
58
|
|
@@ -79,7 +78,7 @@ Notice the URLs in the input array above were NOT uniformly formatted. UrlVerif
|
|
79
78
|
|
80
79
|
`:verified_url` is the final verified URL. `:url_redirected` indicates that the verified URL is different than `:url_f`.
|
81
80
|
|
82
|
-
If `url_sts: 'Invalid'`, `:wx_date` will be timestamped, which helps keep track of when it became invalid, incase you are running
|
81
|
+
If `url_sts: 'Invalid'`, `:wx_date` will be timestamped, which helps keep track of when it became invalid, incase you are running periodic database URL verifications and want to include these details in your reports.
|
83
82
|
|
84
83
|
`:response_code` in the 200's is ideal. If it has recently been forwarded it will be in the 300's, and 400's indicates an issue with the URL domain or server. Some 400's could be run later when they resolve their issues, so don't always give up on them.
|
85
84
|
|
data/Rakefile
CHANGED
@@ -17,7 +17,7 @@ task :console do
|
|
17
17
|
ARGV.clear
|
18
18
|
|
19
19
|
verified_urls = run_verify_urls
|
20
|
-
|
20
|
+
binding.pry
|
21
21
|
|
22
22
|
IRB.start
|
23
23
|
end
|
@@ -26,7 +26,12 @@ end
|
|
26
26
|
def run_verify_urls
|
27
27
|
# urls = %w[https://www.century1chevy.com www.sofake.sofake http://www.mccrea.subaru.com blackwellford.com minooka.subaru.com texarkana.mercedesdealer.com www.bobilya.com hammondautoplex.com www.harbinfordscottsboro.net http://www.lancaster.subaru.com loufusz.subaru.com www.mastro.subaru.com www.muller.subaru.com reinekefamilydealerships.com]
|
28
28
|
|
29
|
-
array_of_urls = %w[blackwellford.com/staff www.mccrea.subaru.com/inventory www.sofake.sofake https://www.
|
29
|
+
# array_of_urls = %w[https://www.century1chevy.com blackwellford.com/staff www.mccrea.subaru.com/inventory www.sofake.sofake https://www.mccreasubaru.com]
|
30
|
+
|
31
|
+
array_of_urls = %w[https://www.century1chevy.com]
|
32
|
+
# array_of_urls = %w[blackwellford.com/staff]
|
33
|
+
# array_of_urls = %w[https://www.sofake.sofake]
|
34
|
+
|
30
35
|
|
31
36
|
args = { timeout_limit: 60 }
|
32
37
|
verifier = UrlVerifier::RunCurler.new(args)
|
data/lib/url_verifier/curler.rb
CHANGED
@@ -19,9 +19,8 @@ module UrlVerifier
|
|
19
19
|
|
20
20
|
begin # Curl Exception Handling
|
21
21
|
begin # Timeout Exception Handling
|
22
|
+
pre_curl_msg(url, timeout)
|
22
23
|
Timeout.timeout(timeout) do
|
23
|
-
pre_curl_msg(url, timeout)
|
24
|
-
|
25
24
|
result = Curl::Easy.perform(url) do |curl|
|
26
25
|
curl.follow_location = true
|
27
26
|
curl.useragent = "curb"
|
@@ -75,7 +74,9 @@ module UrlVerifier
|
|
75
74
|
end
|
76
75
|
|
77
76
|
def pre_curl_msg(url, timeout)
|
78
|
-
|
77
|
+
msg = "\n\n#{'='*40}\nVERIFYING: #{url}\nMax Wait Set: #{timeout} Seconds\n\n"
|
78
|
+
puts msg
|
79
|
+
msg
|
79
80
|
end
|
80
81
|
|
81
82
|
def error_parser(curl_err)
|
@@ -94,7 +95,6 @@ module UrlVerifier
|
|
94
95
|
else
|
95
96
|
curl_err = "Error: Undefined"
|
96
97
|
end
|
97
|
-
|
98
98
|
curl_err
|
99
99
|
end
|
100
100
|
|
@@ -1,26 +1,23 @@
|
|
1
1
|
|
2
2
|
module UrlVerifier
|
3
3
|
class RunCurler
|
4
|
+
attr_accessor :time_now
|
4
5
|
|
5
6
|
def initialize(args={})
|
6
7
|
@timeout_limit = args.fetch(:timeout_limit, 60)
|
7
8
|
@web_formatter = CrmFormatter::Web.new
|
8
9
|
@curler = UrlVerifier::Curler.new
|
9
|
-
|
10
|
-
# @dj_on = false
|
11
|
-
# @dj_count_limit = 0
|
12
|
-
# @dj_workers = 3
|
13
|
-
# @obj_in_grp = 10
|
14
|
-
# @dj_refresh_interval = 10
|
15
|
-
# @cut_off = 10.days.ago
|
16
|
-
# @current_process = "VerUrl"
|
17
|
-
# @url_hash = {}
|
10
|
+
@time_now = nil
|
18
11
|
end
|
19
12
|
|
20
13
|
def verify_urls(urls=[])
|
21
14
|
url_hashes = urls.map { |url| verify_url(url) }
|
22
15
|
end
|
23
16
|
|
17
|
+
def check_time
|
18
|
+
@time_now = Time.now unless @time_now == 'rspec_time'
|
19
|
+
end
|
20
|
+
|
24
21
|
def verify_url(url)
|
25
22
|
url_hash = @web_formatter.format_url(url)
|
26
23
|
url_hash = merge_url_hash(url_hash)
|
@@ -42,7 +39,7 @@ module UrlVerifier
|
|
42
39
|
url_redirected: false,
|
43
40
|
response_code: nil,
|
44
41
|
url_sts: nil,
|
45
|
-
url_date:
|
42
|
+
url_date: @time_now,
|
46
43
|
wx_date: nil,
|
47
44
|
timeout: 0
|
48
45
|
}
|
@@ -50,7 +47,7 @@ module UrlVerifier
|
|
50
47
|
end
|
51
48
|
|
52
49
|
def evaluate_formatted_url(url_hash)
|
53
|
-
url_hash = url_hash.merge({url_sts: 'Invalid', wx_date:
|
50
|
+
url_hash = url_hash.merge({url_sts: 'Invalid', wx_date: @time_now })
|
54
51
|
end
|
55
52
|
|
56
53
|
def check_for_redirect(url_hash)
|
data/lib/url_verifier/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: url_verifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '2.
|
4
|
+
version: '2.11'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Booth
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|