jigsaw-bpa 1.0.1
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.
- checksums.yaml +7 -0
- data/lib/jigsaw-bpa-lib.rb +56 -0
- metadata +58 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e071ef42f73cff50a40dce62d5669c7060e66d93
|
4
|
+
data.tar.gz: 8111fca86a588ac36b876e233fa1377fbe522d5c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7e21b005a47512097dbafa7dd74c8dcf2639d60ae1165416ab537362addccb5d610e681d9e0e38aecddd49d69a0a863d86fc642adb802b67edfdda52bc6ae4a9
|
7
|
+
data.tar.gz: ce0ec855b093a1b19e4d317bd555f7ee2de6d48b7f176a5c5f5a6d0e67e318dba5c73ecd0ea199447ab512cb495cfba951e8ef4f0071da942d8a6add5d0ab9a1
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'oga'
|
2
|
+
require 'open-uri'
|
3
|
+
|
4
|
+
def get_body_from_source(source)
|
5
|
+
Oga.parse_html(open(source).read)
|
6
|
+
end
|
7
|
+
|
8
|
+
def run_all_tests(source)
|
9
|
+
body = get_body_from_source(source)
|
10
|
+
|
11
|
+
failed = false
|
12
|
+
|
13
|
+
failed = run_test("Thou shalt not have CSS outside of head tag", :css_in_head, body) || failed
|
14
|
+
failed = run_test("Thou shalt not have other attributes in style references", :css_other_attr, body) || failed
|
15
|
+
failed = run_test("Thou shalt not use defer async in script tags", :js_defer_async, body) || failed
|
16
|
+
failed = run_test("Thou shalt not have inline script tags", :js_inline, body) || failed
|
17
|
+
failed = run_test("Thou shalt not deliver CSS outside of /assets", :css_asset_path, body) || failed
|
18
|
+
failed = run_test("Thou shalt not deliver JS outside of /assets", :js_asset_path, body) || failed
|
19
|
+
|
20
|
+
abort("At least one test failed") if failed
|
21
|
+
end
|
22
|
+
|
23
|
+
def run_test(name,test,content)
|
24
|
+
print "#{name}".ljust(60,'.')
|
25
|
+
failed = send(test,content)
|
26
|
+
if failed
|
27
|
+
print "failed\n"
|
28
|
+
else
|
29
|
+
print "succeeded\n"
|
30
|
+
end
|
31
|
+
failed
|
32
|
+
end
|
33
|
+
|
34
|
+
def css_in_head(content)
|
35
|
+
content.xpath(%q(//link[@rel="stylesheet" and not(ancestor::head)])).empty? ? false : true
|
36
|
+
end
|
37
|
+
|
38
|
+
def css_other_attr(content)
|
39
|
+
content.xpath(%q(//link[@rel="stylesheet"]/@*[not(name()='rel') and not(name()='href')])).empty? ? false : true
|
40
|
+
end
|
41
|
+
|
42
|
+
def js_defer_async(content)
|
43
|
+
content.xpath(%q(//script[@src and (@defer or @async)])).empty? ? false : true
|
44
|
+
end
|
45
|
+
|
46
|
+
def js_inline(content)
|
47
|
+
content.xpath(%q(//script[not(@src)])).empty? ? false : true
|
48
|
+
end
|
49
|
+
|
50
|
+
def css_asset_path(content)
|
51
|
+
content.xpath(%q(//link[@rel="stylesheet" and not(starts-with(@href, "/assets"))])).empty? ? false : true
|
52
|
+
end
|
53
|
+
|
54
|
+
def js_asset_path(content)
|
55
|
+
content.xpath(%q(//script[@src and not(starts-with(@src, "http")) and not(starts-with(@src, "/assets"))])).empty? ? false : true
|
56
|
+
end
|
metadata
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jigsaw-bpa
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- AutoScout24
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: oga
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.2.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.2.1
|
27
|
+
description: Provides metrics over given url regarding jigsaw ui composition best
|
28
|
+
practices
|
29
|
+
email:
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- lib/jigsaw-bpa-lib.rb
|
35
|
+
homepage:
|
36
|
+
licenses: []
|
37
|
+
metadata: {}
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options: []
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
requirements: []
|
53
|
+
rubyforge_project:
|
54
|
+
rubygems_version: 2.5.1
|
55
|
+
signing_key:
|
56
|
+
specification_version: 4
|
57
|
+
summary: Jigsaw best practice analyser
|
58
|
+
test_files: []
|