golia 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. data/Rakefile +1 -0
  2. data/golia.gemspec +1 -1
  3. data/lib/golia.rb +14 -9
  4. 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.1"
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-#{@host.gsub(/^https?:\/\//, '')}"
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
- puts "<= Invalid url #{link}"
28
- kill
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
- body = response.read
37
- links = body.scan(/<a.+?href=["'](.+?)["']/m).flatten
38
- links.reject! { |link| link =~ /^\/$|^https?|^mailto|^javascript|#/ || File.extname(link) != "" }
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
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: golia
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 1
10
- version: 1.2.1
9
+ - 2
10
+ version: 1.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - DAddYE