w3clove 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -12,9 +12,9 @@ w3clove is a Ruby gem that can be installed on the usual way
12
12
 
13
13
  = Usage:
14
14
 
15
- Pass it the url of an XML sitemap to be checked, like:
15
+ Pass it the url of an XML sitemap to be checked, and the filename where you want your report to be generated, like:
16
16
 
17
- w3clove https://github.com/jaimeiniesta/w3clove/raw/master/spec/samples/sitemap.xml
17
+ w3clove https://github.com/jaimeiniesta/w3clove/raw/master/spec/samples/sitemap.xml report.html
18
18
 
19
19
  This will validate all the URLs of your sitemap.xml (so be sure to pass it a short one or you'll wait for ages), and generate an HTML file with the full report.
20
20
 
data/bin/w3clove CHANGED
@@ -4,8 +4,11 @@
4
4
  require_relative '../lib/w3clove'
5
5
 
6
6
  begin
7
- W3Clove::Validator.check(ARGV[0])
7
+ if ARGV.length == 2
8
+ W3Clove::Validator.check(ARGV[0], ARGV[1])
9
+ else
10
+ puts "USAGE: w3clove url_of_xml_sitemap output_file.html"
11
+ end
8
12
  rescue
9
13
  puts "There was an error processing your request"
10
- puts "USAGE: w3clove url_of_xml_sitemap"
11
14
  end
@@ -4,12 +4,7 @@ module W3Clove
4
4
  ##
5
5
  # A message holds a message_id, a line, a text and a type
6
6
  #
7
- # message_id... corresponds to the W3C messages list from
8
- # http://validator.w3.org/docs/errors.html
9
- # line......... line number where the error was detected
10
- # on the page that created it
11
- # text......... generic but descriptive text about the error
12
- # type......... can be :error or :warning
13
- #
7
+ # See the W3C message explanation list on
8
+ # http://validator.w3.org/docs/errors.html
14
9
  Message = Struct.new(:message_id, :line, :text, :type)
15
10
  end
data/lib/w3clove/page.rb CHANGED
@@ -31,11 +31,9 @@ module W3Clove
31
31
  # If it has no validation errors, it will be an empty array.
32
32
  # It an exception occurs, it will be nil.
33
33
  def errors
34
- @errors ||= validations.errors.map {|e|
35
- W3Clove::Message.new(e.message_id,
36
- e.line,
37
- e.message,
38
- :error)}
34
+ @errors ||= validations.errors.map do |e|
35
+ W3Clove::Message.new(e.message_id, e.line, e.message, :error)
36
+ end
39
37
  rescue Exception => e
40
38
  @exception = e.to_s
41
39
  nil
@@ -46,11 +44,9 @@ module W3Clove
46
44
  # If it has no validation warnings, it will be an empty array.
47
45
  # It an exception occurs, it will be nil.
48
46
  def warnings
49
- @warnings ||= validations.warnings.map {|w|
50
- W3Clove::Message.new(w.message_id,
51
- w.line,
52
- w.message,
53
- :warning)}
47
+ @warnings ||= validations.warnings.map do |w|
48
+ W3Clove::Message.new(w.message_id, w.line, w.message, :warning)
49
+ end
54
50
  rescue Exception => e
55
51
  @exception = e.to_s
56
52
  nil
@@ -8,14 +8,14 @@ module W3Clove
8
8
 
9
9
  ##
10
10
  # Create the html report for the sitemap
11
- def generate_html(sitemap)
11
+ def generate_html(sitemap, filename)
12
12
  template = ERB.new(open(File.dirname(__FILE__)+'/templates/w3clove.html.erb').read)
13
13
 
14
- File.open('w3clove.html', 'w') do |f|
15
- f.write(template.result(sitemap.get_binding))
16
- end
14
+ File.open(filename, 'w') do |f|
15
+ f.write(template.result(sitemap.get_binding))
16
+ end
17
17
  rescue Exception => e
18
18
  puts "ERROR generating report: #{e}"
19
19
  end
20
20
  end
21
- end
21
+ end
@@ -14,8 +14,8 @@ module W3Clove
14
14
  # Parses a remote xml sitemap and checks markup validation for each url
15
15
  # Shows progress on dot-style (...F...FFE..). A dot is a valid page,
16
16
  # an F is a page with errors, and an E is an exception
17
- # After the checking is done, a detailed summary is generated
18
- def check(url)
17
+ # After the checking is done, a detailed summary is written to filename
18
+ def check(url, filename)
19
19
  sitemap = W3Clove::Sitemap.new(url)
20
20
  say "Validating #{sitemap.pages.length} pages"
21
21
 
@@ -23,8 +23,8 @@ module W3Clove
23
23
  say_inline page.valid? ? "." : (page.errors.nil? ? 'E' : 'F')
24
24
  end
25
25
 
26
- W3Clove::Reporter.generate_html(sitemap)
27
- say "\nValidation finished, see the report at w3clove.html"
26
+ W3Clove::Reporter.generate_html(sitemap, filename)
27
+ say "\nValidation finished, see the report at #{filename}"
28
28
  end
29
29
 
30
30
  private
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  module W3Clove
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.1"
5
5
  end
data/lib/w3clove.rb CHANGED
@@ -1,9 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
- module W3Clove
4
- require_relative './w3clove/validator'
5
- require_relative './w3clove/sitemap'
6
- require_relative './w3clove/page'
7
- require_relative './w3clove/message'
8
- require_relative './w3clove/reporter'
9
- end
3
+ require_relative 'w3clove/validator'
4
+ require_relative 'w3clove/sitemap'
5
+ require_relative 'w3clove/page'
6
+ require_relative 'w3clove/message'
7
+ require_relative 'w3clove/reporter'
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 0
9
- version: 0.3.0
8
+ - 1
9
+ version: 0.3.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jaime Iniesta
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-03-23 00:00:00 +01:00
17
+ date: 2011-03-24 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency