find_identical 0.0.3

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e1d7e59c0e599d7ef698e67354557054cbdbc870
4
+ data.tar.gz: ad0842a570375fc36e037aef01d159933c8772f4
5
+ SHA512:
6
+ metadata.gz: 8ac900d8f738c54e3bd34154f22693292a2a2155c9500fefd119f9d69c858d09ee60dfd34ef86e0f44186dceba5463ea8252b6c23875d7b2014709aaf0086310
7
+ data.tar.gz: '083d8f885d94bc25bbe058d02bb826769c2740919479102d54596227ea5e64d6c8d447a6bce90a7a34ea5ba6bbdac28620475dfe12b74d1bed6dd880076f9bc9'
data/bin/identical ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'find_identical'
4
+
5
+ identical = FindIdentical.new(ARGV.first).identical
6
+
7
+ if identical.empty?
8
+ puts "Any duplicate ID's found!"
9
+ else
10
+ puts "The following ID's are identical:"
11
+ identical.each { | id | puts "\t- ##{id}" }
12
+ end
@@ -0,0 +1,23 @@
1
+ require 'typhoeus'
2
+
3
+ module Reader
4
+ def html_document(source)
5
+ remote_file?(source) ? remote_html(source) : local_html(source)
6
+ end
7
+
8
+ private
9
+
10
+ def local_html(path)
11
+ File.read(path)
12
+ end
13
+
14
+
15
+ def remote_html(address)
16
+ Typhoeus.get(address).body
17
+ end
18
+
19
+
20
+ def remote_file?(source)
21
+ source.match(/^https?:\/\/.+$/)
22
+ end
23
+ end
@@ -0,0 +1,24 @@
1
+ require 'find_identical/reader'
2
+
3
+ class FindIdentical
4
+ include Reader
5
+
6
+ def initialize(document_source)
7
+ @html_document = html_document(document_source)
8
+ end
9
+
10
+ def identical
11
+ all_ids = html_ids
12
+ all_ids
13
+ .find_all { |id| all_ids.count(id) > 1 }
14
+ .reject(&:nil?)
15
+ .map { |id| id.first }
16
+ .uniq || []
17
+ end
18
+
19
+ private
20
+
21
+ def html_ids
22
+ @html_document.scan(/^.*id="([^"]*)".*$/)
23
+ end
24
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: find_identical
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Pedro Dutra
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-01-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: typhoeus
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.3.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.3.1
33
+ - !ruby/object:Gem::Dependency
34
+ name: minitest
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '5.11'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 5.11.3
43
+ type: :development
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '5.11'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 5.11.3
53
+ description: According to https://www.w3.org/TR/WCAG20-TECHS/H93.html, we should avoid
54
+ duplicate id values on web pages, because there are "errors that are known to cause
55
+ problems for assistive technologies when they are trying to parse content that has
56
+ the same id attribute on different elements". Find Identical is a Ruby Gem that
57
+ scans HTMLdocuments for duplicate ID attributes and list that on screen, helping
58
+ to making sure the Web page does not have duplicate id values.
59
+ email: pedrovpdutra@gmail.com
60
+ executables:
61
+ - identical
62
+ extensions: []
63
+ extra_rdoc_files: []
64
+ files:
65
+ - bin/identical
66
+ - lib/find_identical.rb
67
+ - lib/find_identical/reader.rb
68
+ homepage: https://github.com/dutrapedro/find_identicals
69
+ licenses:
70
+ - MIT
71
+ metadata: {}
72
+ post_install_message:
73
+ rdoc_options: []
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubyforge_project:
88
+ rubygems_version: 2.6.14
89
+ signing_key:
90
+ specification_version: 4
91
+ summary: Find duplicate id in HTML document
92
+ test_files: []