abrupt 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +22 -0
  3. data/.rubocop.yml +16 -0
  4. data/.travis.yml +34 -0
  5. data/Gemfile +4 -0
  6. data/Guardfile +51 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +36 -0
  9. data/Rakefile +7 -0
  10. data/abrupt.gemspec +41 -0
  11. data/assets/rules/datatypes/cax-RequiredFormElement.ttl +34 -0
  12. data/assets/rules/datatypes/cax-readability.ttl +18 -0
  13. data/assets/rules/datatypes/cax-required.ttl +15 -0
  14. data/assets/rules/list/prp-hasState.ttl +10 -0
  15. data/assets/rules/production/non_required_form_element.ttl +24 -0
  16. data/assets/rules/production/state_has_no_html_element.ttl +21 -0
  17. data/assets/schema/schema.json +49 -0
  18. data/assets/schema/v1/complexity.json +142 -0
  19. data/assets/schema/v1/input.json +1136 -0
  20. data/assets/schema/v1/link.json +41 -0
  21. data/assets/schema/v1/picture.json +47 -0
  22. data/assets/schema/v1/readability.json +51 -0
  23. data/assets/schema/v1/subject.json +88 -0
  24. data/assets/voc/tbox.ttl +1632 -0
  25. data/bin/abrupt +63 -0
  26. data/doc/paper/listings/datatype_rule.ttl +0 -0
  27. data/doc/paper/listings/description_logic_infered.ttl +3 -0
  28. data/doc/paper/listings/description_logic_rule.ttl +15 -0
  29. data/doc/paper/listings/inconsistency_rule.ttl +0 -0
  30. data/doc/paper/listings/limitations.ttl +10 -0
  31. data/doc/paper/listings/production_rule.ttl +0 -0
  32. data/doc/paper/listings/propositional_logic_infered.ttl +6 -0
  33. data/doc/paper/listings/propositional_logic_rule.ttl +15 -0
  34. data/doc/paper/listings/unique_nested_uris.ttl +10 -0
  35. data/doc/paper/literature.bib +56 -0
  36. data/doc/paper/main.tex +322 -0
  37. data/doc/poster/Poster.key +0 -0
  38. data/doc/poster/Poster.pdf +0 -0
  39. data/doc/poster/poster.indd +0 -0
  40. data/doc/poster/resources/graph.graffle +0 -0
  41. data/doc/poster/resources/graph.png +0 -0
  42. data/doc/poster/resources/graph_crop.png +0 -0
  43. data/lib/abrupt.rb +90 -0
  44. data/lib/abrupt/converter.rb +130 -0
  45. data/lib/abrupt/crawler.rb +125 -0
  46. data/lib/abrupt/service/absolute_url.rb +32 -0
  47. data/lib/abrupt/service/base.rb +75 -0
  48. data/lib/abrupt/service/complexity.rb +27 -0
  49. data/lib/abrupt/service/input.rb +15 -0
  50. data/lib/abrupt/service/link.rb +15 -0
  51. data/lib/abrupt/service/picture.rb +19 -0
  52. data/lib/abrupt/service/readability.rb +26 -0
  53. data/lib/abrupt/service/subject.rb +19 -0
  54. data/lib/abrupt/transformation/base.rb +145 -0
  55. data/lib/abrupt/transformation/client/base.rb +8 -0
  56. data/lib/abrupt/transformation/client/page_view.rb +27 -0
  57. data/lib/abrupt/transformation/client/visit.rb +56 -0
  58. data/lib/abrupt/transformation/client/visitor.rb +19 -0
  59. data/lib/abrupt/transformation/website/base.rb +8 -0
  60. data/lib/abrupt/transformation/website/complexity.rb +20 -0
  61. data/lib/abrupt/transformation/website/input.rb +42 -0
  62. data/lib/abrupt/transformation/website/link.rb +27 -0
  63. data/lib/abrupt/transformation/website/picture.rb +26 -0
  64. data/lib/abrupt/transformation/website/readability.rb +15 -0
  65. data/lib/abrupt/transformation/website/subject.rb +22 -0
  66. data/lib/abrupt/version.rb +7 -0
  67. data/spec/cassettes/Abrupt_Crawler/outputs_correct_hash.yml +91250 -0
  68. data/spec/converter_spec.rb +34 -0
  69. data/spec/crawler_spec.rb +11 -0
  70. data/spec/factories/crawled_hashes.rb +468 -0
  71. data/spec/fixtures/rikscha-mainz.owl +17456 -0
  72. data/spec/fixtures/rikscha.ohneBilder.2013-04-30_2013-08-17.xml +51759 -0
  73. data/spec/fixtures/rikscha.ohneBilder.2013-04-30_2013-08-17_min.xml +81 -0
  74. data/spec/fixtures/rikscha_Result.xml +11594 -0
  75. data/spec/fixtures/rikscha_Result_min.xml +574 -0
  76. data/spec/spec_helper.rb +26 -0
  77. data/spec/transformation/base_spec.rb +18 -0
  78. data/spec/transformation/website/complexity_spec.rb +188 -0
  79. data/spec/transformation/website/input_spec.rb +181 -0
  80. data/spec/transformation/website/link_spec.rb +13 -0
  81. data/spec/transformation/website/picture_spec.rb +20 -0
  82. data/spec/transformation/website/readability_spec.rb +22 -0
  83. data/spec/transformation/website/subject_spec.rb +40 -0
  84. metadata +424 -0
@@ -0,0 +1,26 @@
1
+ require 'codeclimate-test-reporter'
2
+ CodeClimate::TestReporter.start
3
+
4
+ require 'bundler/setup'
5
+ Bundler.setup
6
+
7
+ require 'abrupt' # and any other gems you need
8
+ require 'vcr'
9
+ require 'factory_girl'
10
+ require_relative '../spec/factories/crawled_hashes.rb'
11
+ require 'json-schema'
12
+
13
+ VCR.configure do |c|
14
+ c.cassette_library_dir = 'spec/cassettes'
15
+ c.hook_into :webmock
16
+ c.configure_rspec_metadata!
17
+ c.ignore_hosts 'codeclimate.com'
18
+ end
19
+
20
+ RSpec.configure do |config|
21
+ # some (optional) config here
22
+ config.formatter = 'documentation'
23
+ config.include FactoryGirl::Syntax::Methods
24
+ config.filter_run_excluding dev: true
25
+ config.filter_run_excluding beta: true
26
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+ # TODO: move to shared directory with a matching name
3
+ shared_examples 'convertable object' do
4
+ let(:subject) do
5
+ file = 'spec/fixtures/rikscha_Result_min.xml'
6
+ xml = Nokogiri::XML(File.read(file))
7
+ values = Hash.from_xml(xml.to_s).deep_symbolize_keys![:website][:url]
8
+ values.map { |states| described_class.customize_to_schema(states) }
9
+ end
10
+ let(:expected_values) do
11
+ []
12
+ end
13
+ it 'part is converted' do
14
+ keyname = described_class.name.split('::').last.downcase.to_sym
15
+ actual = subject.map { |s| s[:state][keyname] }.compact
16
+ expect(actual).to eql(expected_values)
17
+ end
18
+ end
@@ -0,0 +1,188 @@
1
+ require_relative '../base_spec'
2
+
3
+ describe Abrupt::Transformation::Website::Complexity do
4
+ it_should_behave_like 'convertable object' do
5
+ let(:expected_values) do
6
+ [{ contrast: { _1: { A_tag_With_Low_Contrast: '0',
7
+ TextNodes_With_Low_Contrast: '0',
8
+ paragrahps_with_too_long_lines: '0' } },
9
+ vizweb: { numberOfLeaves: 1,
10
+ textArea: '0',
11
+ numberOfTextGroups: 0,
12
+ visualComplexity: 0.79690559961371,
13
+ numberOfImageAreas: 0,
14
+ hue: 0.78842163085938,
15
+ horizontalSymmetry: '1',
16
+ horizontalBalance: 'null',
17
+ colorfulness: 13.723379102371,
18
+ nontextArea: 1.3333333333333 },
19
+ differenceMatrix: [{ matrix: [0.0,
20
+ 37.735924528226,
21
+ 69.0,
22
+ 18.0,
23
+ 41.569219381653,
24
+ 24.657656011876,
25
+ 12.649110640674,
26
+ 37.735924528226,
27
+ 0.0,
28
+ 34.885527085025,
29
+ 21.260291625469,
30
+ 25.612496949731,
31
+ 26.832815729997,
32
+ 33.226495451672,
33
+ 69.0,
34
+ 34.885527085025,
35
+ 0.0,
36
+ 51.0,
37
+ 56.364882684168,
38
+ 60.934390946328,
39
+ 66.098411478643,
40
+ 18.0,
41
+ 21.260291625469,
42
+ 51.0,
43
+ 0.0,
44
+ 34.467375879228,
45
+ 22.360679774998,
46
+ 18.439088914586,
47
+ 41.569219381653,
48
+ 25.612496949731,
49
+ 56.364882684168,
50
+ 34.467375879228,
51
+ 0.0,
52
+ 20.396078054371,
53
+ 33.466401061363,
54
+ 24.657656011876,
55
+ 26.832815729997,
56
+ 60.934390946328,
57
+ 22.360679774998,
58
+ 20.396078054371,
59
+ 0.0,
60
+ 21.908902300207,
61
+ 12.649110640674,
62
+ 33.226495451672,
63
+ 66.098411478643,
64
+ 18.439088914586,
65
+ 33.466401061363,
66
+ 21.908902300207,
67
+ 0.0],
68
+ palette: [4.0,
69
+ 4.0,
70
+ 4.0,
71
+ 12.0,
72
+ 12.0,
73
+ 40.0,
74
+ 4.0,
75
+ 4.0,
76
+ 73.0,
77
+ 4.0,
78
+ 4.0,
79
+ 22.0,
80
+ 28.0,
81
+ 28.0,
82
+ 28.0,
83
+ 12.0,
84
+ 24.0,
85
+ 16.0,
86
+ 16.0,
87
+ 4.0,
88
+ 8.0] }],
89
+ vicram: { complexity: 0.6395 },
90
+ ratios: { pageSize: { pageSize_in_pixel_squared: 289_600,
91
+ pageWidth_in_pixel: 400,
92
+ pageHeight_in_pixel: 724 },
93
+ img_Tag: { img_Area_in_pixel_squared: 2730,
94
+ img_document_tag_percentage: 0.94267955801105,
95
+ img_document_tag_ratio: 106.08058608059 } } },
96
+ { contrast: { _1: { A_tag_With_Low_Contrast: '0',
97
+ TextNodes_With_Low_Contrast: '0',
98
+ paragrahps_with_too_long_lines: '0' } },
99
+ vizweb: { numberOfLeaves: 17,
100
+ textArea: '0.0074666341145833',
101
+ numberOfTextGroups: 1,
102
+ visualComplexity: 0.98656564934711,
103
+ numberOfImageAreas: 1,
104
+ hue: 0.92692057291667,
105
+ horizontalSymmetry: '1',
106
+ horizontalBalance: 'null',
107
+ colorfulness: 13.811903651406,
108
+ nontextArea: 0.0044080946180556 },
109
+ differenceMatrix: [{ matrix: [0.0,
110
+ 347.57157536254,
111
+ 83.138438763306,
112
+ 155.335121592,
113
+ 193.98969044771,
114
+ 207.84609690827,
115
+ 67.0,
116
+ 347.57157536254,
117
+ 0.0,
118
+ 264.43524727237,
119
+ 192.26284092356,
120
+ 153.5903642811,
121
+ 139.73546436034,
122
+ 314.05254337451,
123
+ 83.138438763306,
124
+ 264.43524727237,
125
+ 0.0,
126
+ 72.228803118977,
127
+ 110.85125168441,
128
+ 124.70765814496,
129
+ 70.491134194308,
130
+ 155.335121592,
131
+ 192.26284092356,
132
+ 72.228803118977,
133
+ 0.0,
134
+ 38.794329482542,
135
+ 52.621288467691,
136
+ 129.71507237018,
137
+ 193.98969044771,
138
+ 153.5903642811,
139
+ 110.85125168441,
140
+ 38.794329482542,
141
+ 0.0,
142
+ 13.856406460551,
143
+ 164.66025628548,
144
+ 207.84609690827,
145
+ 139.73546436034,
146
+ 124.70765814496,
147
+ 52.621288467691,
148
+ 13.856406460551,
149
+ 0.0,
150
+ 177.78920102188,
151
+ 67.0,
152
+ 314.05254337451,
153
+ 70.491134194308,
154
+ 129.71507237018,
155
+ 164.66025628548,
156
+ 177.78920102188,
157
+ 0.0],
158
+ palette: [4.0,
159
+ 4.0,
160
+ 4.0,
161
+ 206.0,
162
+ 205.0,
163
+ 203.0,
164
+ 52.0,
165
+ 52.0,
166
+ 52.0,
167
+ 96.0,
168
+ 93.0,
169
+ 92.0,
170
+ 116.0,
171
+ 116.0,
172
+ 116.0,
173
+ 124.0,
174
+ 124.0,
175
+ 124.0,
176
+ 4.0,
177
+ 4.0,
178
+ 71.0] }],
179
+ vicram: { complexity: 1.3497 },
180
+ ratios: { pageSize: { pageSize_in_pixel_squared: 1_164_339,
181
+ pageWidth_in_pixel: 619,
182
+ pageHeight_in_pixel: 1881 },
183
+ img_Tag: { img_Area_in_pixel_squared: 3612,
184
+ img_document_tag_percentage: 0.3102189310845,
185
+ img_document_tag_ratio: 322.35299003322 } } }]
186
+ end
187
+ end
188
+ end
@@ -0,0 +1,181 @@
1
+ require_relative '../base_spec'
2
+
3
+ describe Abrupt::Transformation::Website::Input do
4
+ it_should_behave_like 'convertable object' do
5
+ let(:expected_values) do
6
+ [{ text: [{ id: 'termin_von',
7
+ maxlength: 10,
8
+ name: 'von',
9
+ value: nil,
10
+ class: 'text',
11
+ required: nil,
12
+ type: 'text',
13
+ size: 10 },
14
+ { id: 'termin_bis',
15
+ maxlength: 10,
16
+ name: 'bis',
17
+ value: nil,
18
+ class: 'text',
19
+ type: 'text',
20
+ size: 10 },
21
+ { id: 'termin_zeit',
22
+ maxlength: 5,
23
+ name: 'zeit',
24
+ value: nil,
25
+ class: 'textdisabled',
26
+ type: 'text',
27
+ disabled: nil,
28
+ size: 5 },
29
+ { id: 'name',
30
+ maxlength: 60,
31
+ placeholder: 'Vorname Nachname',
32
+ name: 'name',
33
+ value: nil,
34
+ class: 'text',
35
+ required: nil,
36
+ type: 'text',
37
+ size: 40 },
38
+ { maxlength: 60,
39
+ placeholder: 'Straße Hausnummer',
40
+ name: 'strasse',
41
+ value: nil,
42
+ class: 'text',
43
+ type: 'text',
44
+ size: 40 },
45
+ { maxlength: 60,
46
+ placeholder: 'PLZ Ort',
47
+ name: 'ort',
48
+ value: nil,
49
+ class: 'text',
50
+ type: 'text',
51
+ size: 40 },
52
+ { maxlength: 60,
53
+ name: 'telefon',
54
+ value: nil,
55
+ class: 'text',
56
+ type: 'text',
57
+ size: 40 },
58
+ { id: 'lieferungOrt',
59
+ placeholder: 'Lieferort',
60
+ name: 'lieferungOrt',
61
+ value: nil,
62
+ type: 'text',
63
+ size: 20 },
64
+ { maxlength: 60,
65
+ name: 'aufmerksam_sonstiges',
66
+ value: nil,
67
+ class: 'text',
68
+ type: 'text',
69
+ size: 40 }],
70
+ submit: [{ name: 'action',
71
+ value: 'Anfrage senden',
72
+ onclick: 'return(senden());',
73
+ class: 'bold',
74
+ type: 'submit' }],
75
+ email: [{ id: 'email',
76
+ maxlength: 60,
77
+ name: 'email',
78
+ value: nil,
79
+ class: 'text',
80
+ required: nil,
81
+ type: 'email',
82
+ size: 40 }],
83
+ textarea: [{ cols: 60, name: 'bemerkung', rows: 5 }],
84
+ checkbox: [{ id: 'blumenSeide',
85
+ name: 'blumen',
86
+ value: 'Seidenrosen',
87
+ type: 'checkbox' },
88
+ { id: 'herz', name: 'herz',
89
+ value: 'Herz',
90
+ type: 'checkbox' },
91
+ { id: 'aufmerksam_internet',
92
+ name: 'aufmerksam_internet',
93
+ value: 'Internet',
94
+ type: 'checkbox' },
95
+ { id: 'aufmerksam_messe',
96
+ name: 'aufmerksam_messe',
97
+ value: 'Messe',
98
+ type: 'checkbox' },
99
+ { id: 'aufmerksam_zeitschrift',
100
+ name: 'aufmerksam_zeitschrift',
101
+ value: 'Zeitschrift',
102
+ type: 'checkbox' },
103
+ { id: 'aufmerksam_empfehlung',
104
+ name: 'aufmerksam_empfehlung',
105
+ value: 'Empfehlung',
106
+ type: 'checkbox' },
107
+ { id: 'agb',
108
+ name: 'agb',
109
+ value: 'ja',
110
+ required: nil,
111
+ type: 'checkbox' }],
112
+ radio: [{ id: 'angebot_3tage',
113
+ name: 'angebot',
114
+ value: '3 Tage',
115
+ onclick: "angebotGewaehlt('3Tage');",
116
+ required: nil,
117
+ type: 'radio' },
118
+ { id: 'angebot_hz_fahrer',
119
+ name: 'angebot',
120
+ value: 'HZ-Fahrer',
121
+ onclick: "angebotGewaehlt('HZ-Fahrer');",
122
+ required: nil,
123
+ type: 'radio' },
124
+ { id: 'angebot_2tage',
125
+ name: 'angebot',
126
+ value: '2 Tage',
127
+ onclick: "angebotGewaehlt('2Tage');",
128
+ required: nil,
129
+ type: 'radio' },
130
+ { id: 'angebot_rikschafahrt',
131
+ name: 'angebot',
132
+ value: 'Rikschafahrt',
133
+ onclick: "angebotGewaehlt('Rikschafahrt');",
134
+ required: nil,
135
+ type: 'radio' },
136
+ { id: 'angebot_1tag',
137
+ name: 'angebot',
138
+ value: '1 Tag',
139
+ onclick: "angebotGewaehlt('1Tag');",
140
+ required: nil,
141
+ type: 'radio' },
142
+ { id: 'angebot_mondscheinfahrt',
143
+ name: 'angebot',
144
+ value: 'Mondscheinfahrt',
145
+ onclick: "angebotGewaehlt('Mondscheinfahrt');",
146
+ required: nil,
147
+ type: 'radio' },
148
+ { id: 'angebot_sonstiges',
149
+ name: 'angebot',
150
+ value: 'sonstiges',
151
+ onclick: "angebotGewaehlt('sonstiges');",
152
+ required: nil,
153
+ type: 'radio' },
154
+ { id: 'angebot_picknicktour',
155
+ name: 'angebot',
156
+ value: 'Picknicktour',
157
+ onclick: "angebotGewaehlt('Picknicktour');",
158
+ required: nil,
159
+ type: 'radio' },
160
+ { id: 'angebot_sonstigesFahrer',
161
+ name: 'angebot',
162
+ value: 'sonstiges Fahrer',
163
+ onclick: "angebotGewaehlt('sonstigesFahrer');",
164
+ required: nil,
165
+ type: 'radio' },
166
+ { id: 'lieferungBringen',
167
+ name: 'lieferung',
168
+ value: 'Bringen',
169
+ type: 'radio',
170
+ checked: nil },
171
+ { id: 'lieferungAbholung',
172
+ name: 'lieferung',
173
+ value: 'Abholung',
174
+ type: 'radio' },
175
+ { id: 'lieferungAnhaenger',
176
+ name: 'lieferung',
177
+ value: 'Anhänger',
178
+ type: 'radio' }] }]
179
+ end
180
+ end
181
+ end
@@ -0,0 +1,13 @@
1
+ require_relative '../base_spec'
2
+
3
+ describe Abrupt::Transformation::Website::Link do
4
+ it_should_behave_like 'convertable object' do
5
+ let(:expected_values) do
6
+ [{ a: [{ href: 'http://www.rikscha-mainz.de' },
7
+ { plaintext: 'sprechen sie uns an', href: '/Kontakt/' }] },
8
+ { form: [{ formAction: '/Gesendet/' }],
9
+ a: [{ plaintext: 'startseite', href: '/' },
10
+ { plaintext: 'allgemeinen geschaef', href: '/agb-rikscha.pdf' }] }]
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,20 @@
1
+ require_relative '../base_spec'
2
+
3
+ describe Abrupt::Transformation::Website::Picture do
4
+ it_should_behave_like 'convertable object' do
5
+ let(:expected_values) do
6
+ [{ duration: 3.9,
7
+ images: [{ mimetype: 'image/JPEG',
8
+ duration: 3.9,
9
+ filename: 'random.jpg',
10
+ type: 'normal',
11
+ geometry: '285x379' },
12
+ { mimetype: 'image/PNG',
13
+ duration: 0.0,
14
+ filename: 'RikschaLogo.png',
15
+ type: 'article',
16
+ geometry: '135x111' }] },
17
+ { duration: 0.0 }]
18
+ end
19
+ end
20
+ end