golia 1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +39 -0
- data/Rakefile +38 -0
- data/bin/golia +71 -0
- data/golia.gemspec +15 -0
- metadata +69 -0
data/README.rdoc
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
= GOLIA
|
2
|
+
|
3
|
+
Golia is an website performance analyzer. Check <b>speed</b> and <b>dead</b> links.
|
4
|
+
|
5
|
+
== Usage
|
6
|
+
|
7
|
+
$ gem install golia
|
8
|
+
$ golia www.padrinorb.com
|
9
|
+
|
10
|
+
You see an output like that:
|
11
|
+
|
12
|
+
Valid (1.01ms) http://padrinorb.com/guides/blog-tutorial
|
13
|
+
Valid (0.75ms) http://padrinorb.com/guides
|
14
|
+
Valid (0.86ms) http://padrinorb.com/pages/contribute
|
15
|
+
Valid (0.71ms) http://padrinorb.com/guides/padrino-admin
|
16
|
+
Valid (0.82ms) http://padrinorb.com/api
|
17
|
+
Valid (0.81ms) http://padrinorb.com/guides/generators
|
18
|
+
Valid (0.82ms) http://padrinorb.com/guides/controllers
|
19
|
+
Valid (0.70ms) http://padrinorb.com/guides/home
|
20
|
+
Valid (0.98ms) http://padrinorb.com/guides/basic-projects
|
21
|
+
|
22
|
+
======== SUMMARY ========
|
23
|
+
Valid Links: 46
|
24
|
+
Invalid Links: 1
|
25
|
+
http://padrinorb.com/hhttps://github.com/apeacox/picciotto
|
26
|
+
Long requests: 4
|
27
|
+
http://padrinorb.com/guides/blog-tutorial
|
28
|
+
http://padrinorb.com/changes
|
29
|
+
http://padrinorb.com/guides/mounting-applications
|
30
|
+
http://padrinorb.com/blog
|
31
|
+
Average load time 0.80ms
|
32
|
+
|
33
|
+
== Future
|
34
|
+
|
35
|
+
In future we will add w3c validations.
|
36
|
+
|
37
|
+
== Credits
|
38
|
+
|
39
|
+
This software is created by DAddYE under MIT LICENSE.
|
data/Rakefile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'rubygems/specification'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
require 'rake'
|
4
|
+
|
5
|
+
def gemspec
|
6
|
+
@gemspec ||= begin
|
7
|
+
file = File.expand_path("golia.gemspec")
|
8
|
+
::Gem::Specification.load(file)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "Validates the gemspec"
|
13
|
+
task :gemspec do
|
14
|
+
gemspec.validate
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Displays the current version"
|
18
|
+
task :version do
|
19
|
+
puts "Current version: #{gemspec.version}"
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "Release the gem"
|
23
|
+
task :release => :package do
|
24
|
+
sh "gem push pkg/#{gemspec.name}-#{gemspec.version}.gem"
|
25
|
+
sh "rm -rf pkg"
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "Installs the gem locally"
|
29
|
+
task :install => :package do
|
30
|
+
sh "gem install pkg/#{gemspec.name}-#{gemspec.version}"
|
31
|
+
sh "rm -rf pkg"
|
32
|
+
end
|
33
|
+
|
34
|
+
Rake::GemPackageTask.new(gemspec) do |pkg|
|
35
|
+
pkg.gem_spec = gemspec
|
36
|
+
end
|
37
|
+
|
38
|
+
task :package => :gemspec
|
data/bin/golia
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'open-uri'
|
4
|
+
require 'net/http'
|
5
|
+
require 'fileutils'
|
6
|
+
require 'benchmark'
|
7
|
+
require 'tmpdir'
|
8
|
+
|
9
|
+
puts "You need to pass a domain ex: www.lipsiasoft.com" and exit unless ARGV[0]
|
10
|
+
|
11
|
+
@host = ARGV[0]
|
12
|
+
@host = "http://#{@host}" unless @host =~ /^http/
|
13
|
+
@pid = "#{Dir.tmpdir}/golia-#{@host.gsub(/^http:\/\//, '')}"
|
14
|
+
@checked, @links, @invalid, @valid, @long, @ms = [], [], [], [], [], []
|
15
|
+
|
16
|
+
if File.exist?(@pid)
|
17
|
+
puts "<= Founded staled pid"
|
18
|
+
Process.kill(9, File.read(@pid).to_i) rescue nil
|
19
|
+
end
|
20
|
+
|
21
|
+
trap("INT") { puts "<= Golia has ended his set (crowd applauds)"; remove_pid; Process.kill(9, Process.pid) }
|
22
|
+
File.open(@pid, "w") { |f| f.write Process.pid }
|
23
|
+
|
24
|
+
def remove_pid
|
25
|
+
FileUtils.rm_rf(@pid)
|
26
|
+
end
|
27
|
+
|
28
|
+
def parse!(url)
|
29
|
+
begun_at = Time.now
|
30
|
+
response = open(url)
|
31
|
+
@ms << Time.now-begun_at
|
32
|
+
body = response.read
|
33
|
+
links = body.scan(/<a.+?href=["'](.+?)["']/m).flatten
|
34
|
+
links.reject! { |link| link =~ /^\/$|^http|^mailto|^javascript|#/ || File.extname(link) != "" }
|
35
|
+
links.map! { |link| link = "/"+link if link !~ /^\//; @host+link }
|
36
|
+
@links.concat(links-@checked)
|
37
|
+
end
|
38
|
+
|
39
|
+
parse!(@host)
|
40
|
+
|
41
|
+
loop do
|
42
|
+
break if @links.empty?
|
43
|
+
@links.each do |link|
|
44
|
+
begin
|
45
|
+
@checked << link
|
46
|
+
parse!(link)
|
47
|
+
@valid << link
|
48
|
+
@long << link if @ms.last > 1
|
49
|
+
puts "\e[32mValid\e[0m (%0.2fms) %s" % [@ms.last, link]
|
50
|
+
rescue Exception => e
|
51
|
+
@invalid << link
|
52
|
+
puts "\e[31mInvalid\e[0m %s - %s" % [link, e.message]
|
53
|
+
ensure
|
54
|
+
@links.delete(link)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
puts
|
59
|
+
puts "======== SUMMARY ========"
|
60
|
+
puts "Valid Links: %d" % @valid.size
|
61
|
+
puts "Invalid Links: %d" % @invalid.size
|
62
|
+
@invalid.each do |link|
|
63
|
+
puts " #{link}"
|
64
|
+
end
|
65
|
+
puts "Long requests: %d" % @long.size
|
66
|
+
@long.each do |link|
|
67
|
+
puts " #{link}"
|
68
|
+
end
|
69
|
+
puts "Average load time %0.2fms" % (@ms.inject(0) { |memo, ms| memo+=ms; memo }/@ms.size)
|
70
|
+
puts
|
71
|
+
remove_pid
|
data/golia.gemspec
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "golia"
|
3
|
+
s.rubyforge_project = "golia"
|
4
|
+
s.authors = ["DAddYE"]
|
5
|
+
s.email = "d.dagostino@lipsiasoft.com"
|
6
|
+
s.summary = "Dead Links Checker and Speed Analyzer"
|
7
|
+
s.homepage = "http://www.padrinorb.com"
|
8
|
+
s.description = "Golia is an website performance analyzer. Check speed and dead links."
|
9
|
+
s.default_executable = "golia"
|
10
|
+
s.executables = ["golia"]
|
11
|
+
s.version = "1.0"
|
12
|
+
s.date = Time.now.strftime("%Y-%m-%d")
|
13
|
+
s.extra_rdoc_files = Dir["*.rdoc"]
|
14
|
+
s.files = %w(README.rdoc Rakefile golia.gemspec)
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: golia
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 15
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: "1.0"
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- DAddYE
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-04-12 00:00:00 +02:00
|
18
|
+
default_executable: golia
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: Golia is an website performance analyzer. Check speed and dead links.
|
22
|
+
email: d.dagostino@lipsiasoft.com
|
23
|
+
executables:
|
24
|
+
- golia
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files:
|
28
|
+
- README.rdoc
|
29
|
+
files:
|
30
|
+
- README.rdoc
|
31
|
+
- Rakefile
|
32
|
+
- golia.gemspec
|
33
|
+
- bin/golia
|
34
|
+
has_rdoc: true
|
35
|
+
homepage: http://www.padrinorb.com
|
36
|
+
licenses: []
|
37
|
+
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options: []
|
40
|
+
|
41
|
+
require_paths:
|
42
|
+
- lib
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
hash: 3
|
49
|
+
segments:
|
50
|
+
- 0
|
51
|
+
version: "0"
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
requirements: []
|
62
|
+
|
63
|
+
rubyforge_project: golia
|
64
|
+
rubygems_version: 1.5.2
|
65
|
+
signing_key:
|
66
|
+
specification_version: 3
|
67
|
+
summary: Dead Links Checker and Speed Analyzer
|
68
|
+
test_files: []
|
69
|
+
|