golia 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -0
- data/golia.gemspec +1 -1
- data/lib/golia.rb +14 -9
- metadata +3 -3
data/Rakefile
CHANGED
@@ -29,6 +29,7 @@ desc "Installs the gem locally"
|
|
29
29
|
task :install => :package do
|
30
30
|
sh "gem install pkg/#{gemspec.name}-#{gemspec.version}"
|
31
31
|
sh "rm -rf pkg"
|
32
|
+
sh "git add .; git commit -m \"Bump to version #{gemspec.version}\"; git push"
|
32
33
|
end
|
33
34
|
|
34
35
|
Rake::GemPackageTask.new(gemspec) do |pkg|
|
data/golia.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.description = "Golia is an website performance analyzer. Check speed and dead links."
|
9
9
|
s.default_executable = "golia"
|
10
10
|
s.executables = ["golia"]
|
11
|
-
s.version = "1.2.
|
11
|
+
s.version = "1.2.2"
|
12
12
|
s.date = Time.now.strftime("%Y-%m-%d")
|
13
13
|
s.extra_rdoc_files = Dir["*.rdoc"]
|
14
14
|
s.files = %w(README.rdoc Rakefile golia.gemspec) + Dir["lib/**/*"]
|
data/lib/golia.rb
CHANGED
@@ -11,7 +11,7 @@ class Golia
|
|
11
11
|
"http#{$1}://" + URI.parse(link).host
|
12
12
|
end
|
13
13
|
|
14
|
-
@pid = "#{Dir.tmpdir}/golia-#{
|
14
|
+
@pid = "#{Dir.tmpdir}/golia-#{URI.parse(link).host}"
|
15
15
|
@checked, @links, @invalid, @valid, @long, @ms = [], [], [], [], [], []
|
16
16
|
|
17
17
|
if File.exist?(@pid)
|
@@ -21,21 +21,26 @@ class Golia
|
|
21
21
|
|
22
22
|
trap("INT") { puts "<= Golia has ended his set (crowd applauds)"; kill }
|
23
23
|
|
24
|
-
begin
|
24
|
+
# begin
|
25
25
|
parse!(link)
|
26
|
-
rescue
|
27
|
-
|
28
|
-
|
29
|
-
end
|
26
|
+
# rescue
|
27
|
+
# puts "<= Invalid url #{link}"
|
28
|
+
# kill
|
29
|
+
# end
|
30
30
|
end
|
31
31
|
|
32
32
|
def parse!(url)
|
33
33
|
begun_at = Time.now
|
34
34
|
response = open(url)
|
35
35
|
@ms << Time.now-begun_at
|
36
|
-
|
37
|
-
|
38
|
-
links
|
36
|
+
return if File.extname(url) != ""
|
37
|
+
body = response.read
|
38
|
+
links = body.scan(/href=["'](.+?)["']/m).flatten
|
39
|
+
links += body.scan(/<script.+?src=["'](.+?)["']/m).flatten
|
40
|
+
links.reject! do |link|
|
41
|
+
link =~ /^\/$|^https?|^mailto|^javascript|#|"|'/ ||
|
42
|
+
File.extname(link) !~ /\.css|\.js|^$/
|
43
|
+
end
|
39
44
|
links.map! { |link| link = "/"+link if link !~ /^\//; @host+link }
|
40
45
|
@links.concat(links-@checked)
|
41
46
|
end
|
metadata
CHANGED