golia 1.2.2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/README.rdoc +22 -16
  2. data/Rakefile +1 -1
  3. data/bin/golia +1 -1
  4. data/golia.gemspec +1 -1
  5. data/lib/golia.rb +31 -14
  6. metadata +4 -4
data/README.rdoc CHANGED
@@ -9,26 +9,32 @@ Golia is an website performance analyzer. Check <b>speed</b> and <b>dead</b> lin
9
9
 
10
10
  You see an output like that:
11
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
12
+ $ golia padrinorb.com --w3c
13
+
14
+ OK - Ignore - (0.66ms) http://padrinorb.com/stylesheets/padrino-bundle.css?1302660688
15
+ OK - Valid - (0.71ms) http://padrinorb.com/blog
16
+ OK - Not Valid - (0.72ms) http://padrinorb.com/api
17
+ OK - Valid - (0.65ms) http://padrinorb.com/pages/why
18
+ OK - Valid - (0.58ms) http://padrinorb.com/team
19
+ OK - Ignore - (0.88ms) http://padrinorb.com/javascripts/padrino-bundle.js?1302660688
20
+ OK - Not Valid - (0.77ms) http://padrinorb.com/guides
21
+ OK - Not Valid - (0.57ms) http://padrinorb.com/blog/padrino-slides
22
+ OK - Not Valid - (0.67ms) http://padrinorb.com/blog/looking-at-projects-using-padrino
23
+ OK - Not Valid - (0.65ms) http://padrinorb.com/blog/padrino-0-9-21-nested-forms-translations-and-more
24
+ OK - Not Valid - (0.57ms) http://padrinorb.com/blog/padrino-0-9-20-now-works-with-sinatra-1-2
21
25
 
22
26
  ======== SUMMARY ========
23
- Valid Links: 46
24
- Invalid Links: 1
25
- http://padrinorb.com/hhttps://github.com/apeacox/picciotto
27
+ OK Links: 48
28
+ KO Links: 0
26
29
  Long requests: 4
27
- http://padrinorb.com/guides/blog-tutorial
28
30
  http://padrinorb.com/changes
29
- http://padrinorb.com/guides/mounting-applications
30
- http://padrinorb.com/blog
31
- Average load time 0.80ms
31
+ http://padrinorb.com/guides/application-helpers
32
+ http://padrinorb.com/guides/home
33
+ http://padrinorb.com/guides/adding-new-components
34
+ Invalid W3C Links: 37
35
+ http://validator.lipsiasoft.com/check?uri=http://padrinorb.com/api
36
+ http://validator.lipsiasoft.com/check?uri=http://padrinorb.com/guides
37
+ Average load time 0.73ms
32
38
 
33
39
  == Future
34
40
 
data/Rakefile CHANGED
@@ -23,13 +23,13 @@ desc "Release the gem"
23
23
  task :release => :package do
24
24
  sh "gem push pkg/#{gemspec.name}-#{gemspec.version}.gem"
25
25
  sh "rm -rf pkg"
26
+ sh "git add .; git commit -m \"Bump to version #{gemspec.version}\"; git push"
26
27
  end
27
28
 
28
29
  desc "Installs the gem locally"
29
30
  task :install => :package do
30
31
  sh "gem install pkg/#{gemspec.name}-#{gemspec.version}"
31
32
  sh "rm -rf pkg"
32
- sh "git add .; git commit -m \"Bump to version #{gemspec.version}\"; git push"
33
33
  end
34
34
 
35
35
  Rake::GemPackageTask.new(gemspec) do |pkg|
data/bin/golia CHANGED
@@ -3,7 +3,7 @@ require 'rubygems'
3
3
  require File.dirname(__FILE__) + '/../lib/golia'
4
4
 
5
5
  if ARGV[0]
6
- golia = Golia.new(ARGV[0])
6
+ golia = Golia.new(ARGV[0], ARGV[1] == "--w3c")
7
7
  golia.start!
8
8
  else
9
9
  puts "<= You need to pass a domain ex: www.lipsiasoft.com"
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.2"
11
+ s.version = "1.3.0"
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
@@ -5,14 +5,15 @@ require 'benchmark'
5
5
  require 'tmpdir'
6
6
 
7
7
  class Golia
8
- def initialize(link)
8
+ def initialize(link, validate)
9
+ @okate = validate
9
10
  @host = begin
10
11
  link = "http://#{link}" unless link =~ /^http(s?)/
11
12
  "http#{$1}://" + URI.parse(link).host
12
13
  end
13
14
 
14
15
  @pid = "#{Dir.tmpdir}/golia-#{URI.parse(link).host}"
15
- @checked, @links, @invalid, @valid, @long, @ms = [], [], [], [], [], []
16
+ @checked, @links, @ko, @ok, @long, @invalid, @ms = [], [], [], [], [], [], []
16
17
 
17
18
  if File.exist?(@pid)
18
19
  puts "<= Founded staled pid"
@@ -21,12 +22,12 @@ class Golia
21
22
 
22
23
  trap("INT") { puts "<= Golia has ended his set (crowd applauds)"; kill }
23
24
 
24
- # begin
25
+ begin
25
26
  parse!(link)
26
- # rescue
27
- # puts "<= Invalid url #{link}"
28
- # kill
29
- # end
27
+ rescue
28
+ puts "<= Invalid url #{link}"
29
+ kill
30
+ end
30
31
  end
31
32
 
32
33
  def parse!(url)
@@ -45,6 +46,18 @@ class Golia
45
46
  @links.concat(links-@checked)
46
47
  end
47
48
 
49
+ def validate!(url)
50
+ return "\e[33mIgnore \e[0m" if !@okate || File.extname(url) != ""
51
+ body = open("http://validator.lipsiasoft.com/check?uri="+url).read
52
+ body =~ /<title>.+?(\[invalid\]|\[valid\])/mi
53
+ if $1 =~ /invalid/i
54
+ @invalid << url
55
+ return "\e[31mNot Valid\e[0m"
56
+ else
57
+ return "\e[32mValid \e[0m"
58
+ end
59
+ end
60
+
48
61
  def kill
49
62
  Process.kill(9, Process.pid)
50
63
  FileUtils.rm_rf(@pid)
@@ -57,12 +70,12 @@ class Golia
57
70
  begin
58
71
  @checked << link
59
72
  parse!(link)
60
- @valid << link
73
+ @ok << link
61
74
  @long << link if @ms.last > 1
62
- puts "\e[32mValid\e[0m (%0.2fms) %s" % [@ms.last, link]
75
+ puts "\e[32mOK\e[0m - #{validate!(link)} - (%0.2fms) %s" % [@ms.last, link]
63
76
  rescue Exception => e
64
- @invalid << link
65
- puts "\e[31mInvalid\e[0m %s - %s" % [link, e.message]
77
+ @ko << link
78
+ puts "\e[31mKO\e[0m %s - %s" % [link, e.message]
66
79
  ensure
67
80
  @links.delete(link)
68
81
  end
@@ -70,15 +83,19 @@ class Golia
70
83
  end
71
84
  puts
72
85
  puts "======== SUMMARY ========"
73
- puts "Valid Links: %d" % @valid.size
74
- puts "Invalid Links: %d" % @invalid.size
75
- @invalid.each do |link|
86
+ puts "OK Links: %d" % @ok.size
87
+ puts "KO Links: %d" % @ko.size
88
+ @ko.each do |link|
76
89
  puts " #{link}"
77
90
  end
78
91
  puts "Long requests: %d" % @long.size
79
92
  @long.each do |link|
80
93
  puts " #{link}"
81
94
  end
95
+ puts "Invalid W3C Links: %d" % @invalid.size
96
+ @invalid.each do |link|
97
+ puts " http://validator.lipsiasoft.com/check?uri=#{link}"
98
+ end
82
99
  puts "Average load time %0.2fms" % [@ms.inject(0) { |memo, ms| memo+=ms; memo }/@ms.size]
83
100
  puts
84
101
  kill
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 2
9
- - 2
10
- version: 1.2.2
8
+ - 3
9
+ - 0
10
+ version: 1.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - DAddYE
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-12 00:00:00 +02:00
18
+ date: 2011-04-13 00:00:00 +02:00
19
19
  default_executable: golia
20
20
  dependencies: []
21
21