peek-a-view 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,7 +1,5 @@
1
1
  # PeekAView
2
2
 
3
- Experimental software ahead! Use with caution, if at all.
4
-
5
3
  ## What?
6
4
 
7
5
  This gem provides a Rails engine adds functionality to an application
@@ -56,4 +54,47 @@ Start your rails application and point your browser at
56
54
  If everything went well, you see a list of links to your views.
57
55
 
58
56
 
57
+ ## Checking & Reporting
58
+
59
+ Peek-a-View includes a few Rake tasks and their support code for
60
+ checking the stubbed views with. Currently supported are
61
+
62
+ * the HTML5 validator from http://validator.nu/
63
+ * YSlow
64
+
65
+ The checkers are available through these tasks
66
+
67
+ rake peek-a-view:check # Run all checks
68
+ rake peek-a-view:check:html # Check view markup with validator.nu
69
+ rake peek-a-view:check:speed # Check views with YSlow and generate reports
70
+ rake peek-a-view:report # Run all checks and generate reports
71
+ rake peek-a-view:report:html # Check view markup with validator.nu and generate reports
72
+ rake peek-a-view:report:speed # Check views with YSlow and generate reports
73
+
74
+ Checks write their output to the console, reports generate xUnit-style (aka surefire)
75
+ reports in reports/html_validator and reports/yslow respectively.
76
+
77
+ These tasks have dependencies that are not explicitly declared for this gems.
78
+ This is to avoid dragging in gems for task that you may not want to use.
79
+
80
+ ### Requirements for HTML5 checking/reporting
81
+
82
+ HTML5 checks require at instance of Validator.nu to be available at
83
+ http://localhost:8888/ or whatever URI the environment variable HTML_VALIDATOR
84
+ contains.
85
+
86
+ You can obtain the sources for the validator from
87
+ http://about.validator.nu/#src
88
+
89
+
90
+ ### YSlow
91
+
92
+ YSlow runs as a JavaScript in the headless browser PhantomJS.
93
+ A version of the YSlow script itself is packaged with this gem.
94
+ To use it, you need to install PhantomJS
95
+
96
+ http://code.google.com/p/phantomjs/
97
+
98
+
99
+
59
100
  This project rocks and uses MIT-LICENSE.
@@ -15,13 +15,6 @@ module PeekAView
15
15
 
16
16
  protected
17
17
 
18
- def print_hash(out, title, hash)
19
- out.puts title
20
- hash.each do |k, v|
21
- out.puts "#{k}: #{v}"
22
- end
23
- end
24
-
25
18
  def report_dir
26
19
  raise NotImplementedError,
27
20
  "report_dir must be overridden in subclasses of #{self.class}."
@@ -21,16 +21,28 @@ module PeekAView
21
21
  end
22
22
 
23
23
  def check(uri)
24
- @validator.validate_uri(uri)
24
+ results = validate(uri)
25
+ puts "Valid: #{results.is_valid?}"
26
+ puts
27
+ puts 'Errors'
28
+ puts results.errors.map(&:message)
29
+ puts
30
+ puts 'Warnings'
31
+ puts results.warnings.map(&:message)
32
+ puts
25
33
  end
26
34
 
27
35
  def report(uri)
28
- results = check(uri)
36
+ results = validate(uri)
29
37
  write_report(uri, results)
30
38
  end
31
39
 
32
40
  private
33
41
 
42
+ def validate(uri)
43
+ @validator.validate_uri(uri)
44
+ end
45
+
34
46
  def write_report(uri, results)
35
47
  xml = Builder::XmlMarkup.new(indent: 2)
36
48
  xml.instruct!
@@ -16,7 +16,7 @@ module PeekAView
16
16
  private
17
17
 
18
18
  def yslow_script
19
- File.join(PeekAView::Engine.config.root, 'tools', 'yslow.js')
19
+ File.join(PeekAView::Engine.config.root, 'vendor', 'yslow.js')
20
20
  end
21
21
 
22
22
  def report_dir
@@ -1,3 +1,3 @@
1
1
  module PeekAView
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -28,6 +28,17 @@ namespace 'peek-a-view' do
28
28
  end
29
29
  end
30
30
 
31
+ task :init_html_validator do
32
+ require 'peek_a_view/tools/html_validator'
33
+
34
+ validator_uri = ENV['HTML_VALIDATOR'] || 'http://localhost:8888/'
35
+ @html_validator = PeekAView::Tools::HtmlValidator.new(
36
+ validator_uri: validator_uri,
37
+ prefix: @index_uri,
38
+ encoding: Rails.configuration.encoding
39
+ )
40
+ end
41
+
31
42
  desc "List views served by Peek-a-View"
32
43
  task :list => :prepare do
33
44
  require 'peek_a_view/tools'
@@ -49,23 +60,47 @@ namespace 'peek-a-view' do
49
60
  end
50
61
 
51
62
  desc "Check view markup with validator.nu"
52
- task :html => :prepare do
53
- require 'peek_a_view/tools/html_validator'
63
+ task :html => [:prepare, :init_html_validator] do
64
+ @view_uris.each do |uri|
65
+ puts "-" * 70
66
+ puts "Validation results for #{uri}"
67
+ @html_validator.check(uri)
68
+ end
69
+ end
70
+
71
+ desc "Check views with YSlow and generate reports"
72
+ task :speed => :prepare do
73
+ require 'peek_a_view/tools/yslow'
74
+
75
+ yslow = PeekAView::Tools::YSlow.new(prefix: @index_uri)
76
+
77
+ @view_uris.each do |uri|
78
+ yslow.check(uri)
79
+ end
80
+ end
81
+ end
82
+
83
+
84
+ desc "Run all checks and generate reports"
85
+ task :report => 'report:run'
86
+
87
+ namespace :report do
88
+ task :run => [:html, :speed]
89
+
90
+ task :prepare do
91
+ Rake::Task['peek-a-view:prepare'].invoke
92
+ end
54
93
 
55
- validator_uri = ENV['HTML_VALIDATOR'] || 'http://localhost:8888/'
56
- validator = PeekAView::Tools::HtmlValidator.new(
57
- validator_uri: validator_uri,
58
- prefix: @index_uri,
59
- encoding: Rails.configuration.encoding
60
- )
61
- validator.clean_reports
94
+ desc "Check view markup with validator.nu and generate reports"
95
+ task :html => [:prepare, :init_html_validator] do
96
+ @html_validator.clean_reports
62
97
 
63
98
  @view_uris.each do |uri|
64
- validator.report(uri)
99
+ @html_validator.report(uri)
65
100
  end
66
101
  end
67
102
 
68
- desc "Check views with YSlow"
103
+ desc "Check views with YSlow and generate reports"
69
104
  task :speed => :prepare do
70
105
  require 'peek_a_view/tools/yslow'
71
106
 
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peek-a-view
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-28 00:00:00.000000000 Z
12
+ date: 2012-08-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &11362780 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,12 @@ dependencies:
21
21
  version: 3.2.6
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *11362780
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 3.2.6
25
30
  description: Show views using stubbed data.
26
31
  email:
27
32
  - michael@schuerig.de
@@ -84,7 +89,7 @@ files:
84
89
  - test/integration/navigation_test.rb
85
90
  - test/peek-a-view_test.rb
86
91
  - test/test_helper.rb
87
- - tools/yslow.js
92
+ - vendor/yslow.js
88
93
  homepage: ''
89
94
  licenses:
90
95
  - MIT
@@ -100,7 +105,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
100
105
  version: '0'
101
106
  segments:
102
107
  - 0
103
- hash: -1813702072172185498
108
+ hash: -984046266106858959
104
109
  required_rubygems_version: !ruby/object:Gem::Requirement
105
110
  none: false
106
111
  requirements:
@@ -109,10 +114,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
114
  version: '0'
110
115
  segments:
111
116
  - 0
112
- hash: -1813702072172185498
117
+ hash: -984046266106858959
113
118
  requirements: []
114
119
  rubyforge_project:
115
- rubygems_version: 1.8.15
120
+ rubygems_version: 1.8.23
116
121
  signing_key:
117
122
  specification_version: 3
118
123
  summary: Look at your Rails views without bothering the application