hatemile 2.0

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 (61) hide show
  1. checksums.yaml +7 -0
  2. data/CODE_OF_CONDUCT.md +46 -0
  3. data/Gemfile +9 -0
  4. data/LICENSE +202 -0
  5. data/Rakefile +64 -0
  6. data/hatemile.gemspec +37 -0
  7. data/lib/hatemile/accessible_association.rb +62 -0
  8. data/lib/hatemile/accessible_css.rb +43 -0
  9. data/lib/hatemile/accessible_display.rb +178 -0
  10. data/lib/hatemile/accessible_event.rb +95 -0
  11. data/lib/hatemile/accessible_form.rb +101 -0
  12. data/lib/hatemile/accessible_navigation.rb +82 -0
  13. data/lib/hatemile/helper.rb +58 -0
  14. data/lib/hatemile/implementation/accessible_association_implementation.rb +346 -0
  15. data/lib/hatemile/implementation/accessible_css_implementation.rb +772 -0
  16. data/lib/hatemile/implementation/accessible_display_implementation.rb +1362 -0
  17. data/lib/hatemile/implementation/accessible_event_implementation.rb +278 -0
  18. data/lib/hatemile/implementation/accessible_form_implementation.rb +386 -0
  19. data/lib/hatemile/implementation/accessible_navigation_implementation.rb +561 -0
  20. data/lib/hatemile/util/common_functions.rb +106 -0
  21. data/lib/hatemile/util/configure.rb +92 -0
  22. data/lib/hatemile/util/css/rcp/rcp_declaration.rb +77 -0
  23. data/lib/hatemile/util/css/rcp/rcp_parser.rb +115 -0
  24. data/lib/hatemile/util/css/rcp/rcp_rule.rb +86 -0
  25. data/lib/hatemile/util/css/style_sheet_declaration.rb +59 -0
  26. data/lib/hatemile/util/css/style_sheet_parser.rb +43 -0
  27. data/lib/hatemile/util/css/style_sheet_rule.rb +73 -0
  28. data/lib/hatemile/util/html/html_dom_element.rb +234 -0
  29. data/lib/hatemile/util/html/html_dom_node.rb +131 -0
  30. data/lib/hatemile/util/html/html_dom_parser.rb +150 -0
  31. data/lib/hatemile/util/html/html_dom_text_node.rb +43 -0
  32. data/lib/hatemile/util/html/nokogiri/nokogiri_html_dom_element.rb +302 -0
  33. data/lib/hatemile/util/html/nokogiri/nokogiri_html_dom_node.rb +112 -0
  34. data/lib/hatemile/util/html/nokogiri/nokogiri_html_dom_parser.rb +208 -0
  35. data/lib/hatemile/util/html/nokogiri/nokogiri_html_dom_text_node.rb +83 -0
  36. data/lib/hatemile/util/id_generator.rb +53 -0
  37. data/lib/js/common.js +98 -0
  38. data/lib/js/eventlistener.js +36 -0
  39. data/lib/js/include.js +292 -0
  40. data/lib/js/scriptlist_validation_fields.js +13 -0
  41. data/lib/js/validation.js +205 -0
  42. data/lib/locale/en-US.yml +388 -0
  43. data/lib/locale/pt-BR.yml +389 -0
  44. data/lib/skippers.xml +6 -0
  45. data/lib/symbols.xml +40 -0
  46. data/test/locale/en-US.yml +5 -0
  47. data/test/locale/pt-BR.yml +4 -0
  48. data/test/test_accessible_association_implementation.rb +258 -0
  49. data/test/test_accessible_css_implementation.rb +518 -0
  50. data/test/test_accessible_display_implementation.rb +873 -0
  51. data/test/test_accessible_form_implementation.rb +283 -0
  52. data/test/test_accessible_navigation_implementation.rb +228 -0
  53. data/test/test_common_functions.rb +128 -0
  54. data/test/test_configure.rb +73 -0
  55. data/test/test_nokogiri_html_dom_element.rb +586 -0
  56. data/test/test_nokogiri_html_dom_parser.rb +363 -0
  57. data/test/test_nokogiri_html_dom_text_node.rb +225 -0
  58. data/test/test_rcp_declaration.rb +103 -0
  59. data/test/test_rcp_parser.rb +86 -0
  60. data/test/test_rcp_rule.rb +89 -0
  61. metadata +199 -0
@@ -0,0 +1,103 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License");
2
+ # you may not use this file except in compliance with the License.
3
+ # You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+ require 'test/unit'
16
+
17
+ require File.join(
18
+ File.dirname(File.dirname(__FILE__)),
19
+ 'lib',
20
+ 'hatemile',
21
+ 'util',
22
+ 'css',
23
+ 'rcp',
24
+ 'rcp_parser'
25
+ )
26
+
27
+ ##
28
+ # Test methods of Hatemile::Util::Css::Rcp::RCPDeclaration class.
29
+ class TestRCPDeclaration < Test::Unit::TestCase
30
+ ##
31
+ # Initialize common attributes used by test methods.
32
+ def setup
33
+ @css_parser = Hatemile::Util::Css::Rcp::RCPParser.new('
34
+ #a1 {
35
+ color: red;
36
+ }
37
+ #a2:hover {
38
+ display: none;
39
+ color: green;
40
+ }
41
+ #a3 #a4 {
42
+ color: blue;
43
+ clear: both;
44
+ }
45
+ #a5 #a6:active {
46
+ width: 100px;
47
+ }
48
+ #a7 > #a8 {
49
+ font-size: 1.2em;
50
+ color: purple;
51
+ align: center;
52
+ }
53
+ #a9:hover > #a10,
54
+ #a11,
55
+ #a12 #a13 {
56
+ background-color: cyan;
57
+ margin: 10px 11px 12px 13px;
58
+ }
59
+ ')
60
+ end
61
+
62
+ ##
63
+ # Test get_value method.
64
+ def test_get_value
65
+ rules = @css_parser.get_rules(['color', 'background-color'])
66
+
67
+ assert_equal('red', rules.first.get_declarations('color').first.get_value)
68
+ assert_equal(
69
+ '10px 11px 12px 13px',
70
+ rules.last.get_declarations('margin').first.get_value
71
+ )
72
+ end
73
+
74
+ ##
75
+ # Test get_values method.
76
+ def test_get_values
77
+ rules = @css_parser.get_rules(['color', 'background-color'])
78
+
79
+ assert_equal(
80
+ ['red'],
81
+ rules.first.get_declarations('color').first.get_values
82
+ )
83
+ assert_equal(
84
+ %w[10px 11px 12px 13px],
85
+ rules.last.get_declarations('margin').first.get_values
86
+ )
87
+ end
88
+
89
+ ##
90
+ # Test get_property method.
91
+ def test_get_property
92
+ rules = @css_parser.get_rules(['color', 'background-color'])
93
+
94
+ assert_equal(
95
+ 'color',
96
+ rules.first.get_declarations('color').first.get_property
97
+ )
98
+ assert_equal(
99
+ 'background-color',
100
+ rules.last.get_declarations('background-color').first.get_property
101
+ )
102
+ end
103
+ end
@@ -0,0 +1,86 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License");
2
+ # you may not use this file except in compliance with the License.
3
+ # You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+ require 'test/unit'
16
+
17
+ require File.join(
18
+ File.dirname(File.dirname(__FILE__)),
19
+ 'lib',
20
+ 'hatemile',
21
+ 'util',
22
+ 'css',
23
+ 'rcp',
24
+ 'rcp_parser'
25
+ )
26
+
27
+ ##
28
+ # Test methods of Hatemile::Util::Css::Rcp::RCPParser class.
29
+ class TestRCPParser < Test::Unit::TestCase
30
+ ##
31
+ # The CSS code used for test all methods.
32
+ CSS_CODE = '
33
+ #a1 {
34
+ color: red;
35
+ }
36
+ #a2:hover {
37
+ display: none;
38
+ color: green;
39
+ }
40
+ #a3 #a4 {
41
+ color: blue;
42
+ clear: both;
43
+ }
44
+ #a5 #a6:active {
45
+ width: 100px;
46
+ }
47
+ #a7 > #a8 {
48
+ font-size: 1.2em;
49
+ color: purple;
50
+ align: center;
51
+ }
52
+ #a9:hover > #a10 {
53
+ background-color: cyan;
54
+ }
55
+ '.freeze
56
+
57
+ ##
58
+ # Test initialize method with CSS code argument.
59
+ def test_initialize_with_css_code
60
+ css_parser = Hatemile::Util::Css::Rcp::RCPParser.new(CSS_CODE)
61
+ rules = css_parser.get_rules(['color'])
62
+
63
+ assert_equal(4, rules.length)
64
+ end
65
+
66
+ ##
67
+ # Test initialize method with HTML parser argument.
68
+ def test_initialize_with_html_parser
69
+ html_parser = Hatemile::Util::Html::NokogiriLib::NokogiriHTMLDOMParser.new(
70
+ "<!DOCTYPE html>
71
+ <html>
72
+ <head>
73
+ <title>HaTeMiLe Tests</title>
74
+ <meta charset=\"UTF-8\" />
75
+ <style>#{CSS_CODE}</style>
76
+ </head>
77
+ <body>
78
+ </body>
79
+ </html>"
80
+ )
81
+ css_parser = Hatemile::Util::Css::Rcp::RCPParser.new(html_parser)
82
+ rules = css_parser.get_rules(['color'])
83
+
84
+ assert_equal(4, rules.length)
85
+ end
86
+ end
@@ -0,0 +1,89 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License");
2
+ # you may not use this file except in compliance with the License.
3
+ # You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+ require 'test/unit'
16
+
17
+ require File.join(
18
+ File.dirname(File.dirname(__FILE__)),
19
+ 'lib',
20
+ 'hatemile',
21
+ 'util',
22
+ 'css',
23
+ 'rcp',
24
+ 'rcp_parser'
25
+ )
26
+
27
+ ##
28
+ # Test methods of Hatemile::Util::Css::Rcp::RCPRule class.
29
+ class TestRCPRule < Test::Unit::TestCase
30
+ ##
31
+ # Initialize common attributes used by test methods.
32
+ def setup
33
+ @css_parser = Hatemile::Util::Css::Rcp::RCPParser.new('
34
+ #a1 {
35
+ color: red;
36
+ }
37
+ #a2:hover {
38
+ display: none;
39
+ color: green;
40
+ }
41
+ #a3 #a4 {
42
+ color: blue;
43
+ clear: both;
44
+ }
45
+ #a5 #a6:active {
46
+ width: 100px;
47
+ }
48
+ #a7 > #a8 {
49
+ font-size: 1.2em;
50
+ color: purple;
51
+ align: center;
52
+ }
53
+ #a9:hover > #a10,
54
+ #a11,
55
+ #a12 #a13 {
56
+ background-color: cyan;
57
+ }
58
+ ')
59
+ end
60
+
61
+ ##
62
+ # Test has_property? method.
63
+ def test_has_property
64
+ rules = @css_parser.get_rules(['color', 'background-color'])
65
+
66
+ assert(rules.first.has_property?('color'))
67
+ assert(!rules.first.has_property?('background-color'))
68
+ assert(!rules.last.has_property?('color'))
69
+ assert(rules.last.has_property?('background-color'))
70
+ end
71
+
72
+ ##
73
+ # Test get_declarations method.
74
+ def test_get_declarations
75
+ rules = @css_parser.get_rules(['color'])
76
+
77
+ assert_equal('red', rules.first.get_declarations('color').first.get_value)
78
+ assert_equal('purple', rules.last.get_declarations('color').first.get_value)
79
+ end
80
+
81
+ ##
82
+ # Test get_selector method.
83
+ def test_get_selector
84
+ rules = @css_parser.get_rules(['color', 'background-color'])
85
+
86
+ assert_equal('#a1', rules.first.get_selector)
87
+ assert_equal('#a9:hover > #a10, #a11, #a12 #a13', rules.last.get_selector)
88
+ end
89
+ end
metadata ADDED
@@ -0,0 +1,199 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hatemile
3
+ version: !ruby/object:Gem::Version
4
+ version: '2.0'
5
+ platform: ruby
6
+ authors:
7
+ - Carlson Santana Cruz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-09-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: css_parser
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.6.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.6'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.6.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: nokogiri
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.8'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 1.8.0
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '1.8'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 1.8.0
53
+ - !ruby/object:Gem::Dependency
54
+ name: bundler
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '1.3'
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '1.3'
67
+ - !ruby/object:Gem::Dependency
68
+ name: rubocop
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '0.58'
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 0.58.1
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '0.58'
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: 0.58.1
87
+ - !ruby/object:Gem::Dependency
88
+ name: yard
89
+ requirement: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - "~>"
92
+ - !ruby/object:Gem::Version
93
+ version: '0.9'
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 0.9.14
97
+ type: :development
98
+ prerelease: false
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.9'
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: 0.9.14
107
+ description: HaTeMiLe (HTML Accessible) is a open source library developed to improve
108
+ accessibility converting a HTML code in a new HTML code more accessible, its features
109
+ is based in WCAG 2.0 document, eMAG 3.1 document and some features of Job Access
110
+ With Speech (JAWS), Opera before version 15 and Mozilla Firefox.
111
+ email: hatemileforall@gmail.com
112
+ executables: []
113
+ extensions: []
114
+ extra_rdoc_files: []
115
+ files:
116
+ - CODE_OF_CONDUCT.md
117
+ - Gemfile
118
+ - LICENSE
119
+ - Rakefile
120
+ - hatemile.gemspec
121
+ - lib/hatemile/accessible_association.rb
122
+ - lib/hatemile/accessible_css.rb
123
+ - lib/hatemile/accessible_display.rb
124
+ - lib/hatemile/accessible_event.rb
125
+ - lib/hatemile/accessible_form.rb
126
+ - lib/hatemile/accessible_navigation.rb
127
+ - lib/hatemile/helper.rb
128
+ - lib/hatemile/implementation/accessible_association_implementation.rb
129
+ - lib/hatemile/implementation/accessible_css_implementation.rb
130
+ - lib/hatemile/implementation/accessible_display_implementation.rb
131
+ - lib/hatemile/implementation/accessible_event_implementation.rb
132
+ - lib/hatemile/implementation/accessible_form_implementation.rb
133
+ - lib/hatemile/implementation/accessible_navigation_implementation.rb
134
+ - lib/hatemile/util/common_functions.rb
135
+ - lib/hatemile/util/configure.rb
136
+ - lib/hatemile/util/css/rcp/rcp_declaration.rb
137
+ - lib/hatemile/util/css/rcp/rcp_parser.rb
138
+ - lib/hatemile/util/css/rcp/rcp_rule.rb
139
+ - lib/hatemile/util/css/style_sheet_declaration.rb
140
+ - lib/hatemile/util/css/style_sheet_parser.rb
141
+ - lib/hatemile/util/css/style_sheet_rule.rb
142
+ - lib/hatemile/util/html/html_dom_element.rb
143
+ - lib/hatemile/util/html/html_dom_node.rb
144
+ - lib/hatemile/util/html/html_dom_parser.rb
145
+ - lib/hatemile/util/html/html_dom_text_node.rb
146
+ - lib/hatemile/util/html/nokogiri/nokogiri_html_dom_element.rb
147
+ - lib/hatemile/util/html/nokogiri/nokogiri_html_dom_node.rb
148
+ - lib/hatemile/util/html/nokogiri/nokogiri_html_dom_parser.rb
149
+ - lib/hatemile/util/html/nokogiri/nokogiri_html_dom_text_node.rb
150
+ - lib/hatemile/util/id_generator.rb
151
+ - lib/js/common.js
152
+ - lib/js/eventlistener.js
153
+ - lib/js/include.js
154
+ - lib/js/scriptlist_validation_fields.js
155
+ - lib/js/validation.js
156
+ - lib/locale/en-US.yml
157
+ - lib/locale/pt-BR.yml
158
+ - lib/skippers.xml
159
+ - lib/symbols.xml
160
+ - test/locale/en-US.yml
161
+ - test/locale/pt-BR.yml
162
+ - test/test_accessible_association_implementation.rb
163
+ - test/test_accessible_css_implementation.rb
164
+ - test/test_accessible_display_implementation.rb
165
+ - test/test_accessible_form_implementation.rb
166
+ - test/test_accessible_navigation_implementation.rb
167
+ - test/test_common_functions.rb
168
+ - test/test_configure.rb
169
+ - test/test_nokogiri_html_dom_element.rb
170
+ - test/test_nokogiri_html_dom_parser.rb
171
+ - test/test_nokogiri_html_dom_text_node.rb
172
+ - test/test_rcp_declaration.rb
173
+ - test/test_rcp_parser.rb
174
+ - test/test_rcp_rule.rb
175
+ homepage: https://github.com/hatemile/hatemile-for-ruby
176
+ licenses:
177
+ - Apache-2.0
178
+ metadata: {}
179
+ post_install_message:
180
+ rdoc_options: []
181
+ require_paths:
182
+ - lib
183
+ required_ruby_version: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ required_rubygems_version: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - ">="
191
+ - !ruby/object:Gem::Version
192
+ version: '0'
193
+ requirements: []
194
+ rubyforge_project:
195
+ rubygems_version: 2.5.2.1
196
+ signing_key:
197
+ specification_version: 4
198
+ summary: HaTeMiLe can convert HTML code in a code more accessible.
199
+ test_files: []