govuk_publishing_components 21.58.0 → 21.60.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +31 -6
  3. data/app/assets/javascripts/component_guide/accessibility-test.js +21 -21
  4. data/app/assets/javascripts/component_guide/filter-components.js +19 -19
  5. data/app/assets/javascripts/component_guide/visual-regression.js +38 -37
  6. data/app/assets/javascripts/govuk_publishing_components/components/checkboxes.js +2 -2
  7. data/app/assets/javascripts/govuk_publishing_components/components/details.js +5 -3
  8. data/app/assets/javascripts/govuk_publishing_components/components/step-by-step-nav.js +4 -4
  9. data/app/assets/javascripts/govuk_publishing_components/lib/auto-track-event.js +31 -0
  10. data/app/assets/javascripts/govuk_publishing_components/lib/cookie-functions.js +24 -24
  11. data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/youtube-link-enhancement.js +17 -17
  12. data/app/assets/stylesheets/component_guide/application.scss +15 -15
  13. data/app/assets/stylesheets/govuk_publishing_components/components/_action-link.scss +0 -8
  14. data/app/assets/stylesheets/govuk_publishing_components/components/_breadcrumbs.scss +1 -1
  15. data/app/assets/stylesheets/govuk_publishing_components/components/_checkboxes.scss +4 -0
  16. data/app/assets/stylesheets/govuk_publishing_components/components/_cookie-banner.scss +1 -8
  17. data/app/assets/stylesheets/govuk_publishing_components/components/_feedback.scss +0 -1
  18. data/app/assets/stylesheets/govuk_publishing_components/components/_govspeak-html-publication.scss +4 -5
  19. data/app/assets/stylesheets/govuk_publishing_components/components/_heading.scss +3 -8
  20. data/app/assets/stylesheets/govuk_publishing_components/components/_image-card.scss +1 -1
  21. data/app/assets/stylesheets/govuk_publishing_components/components/_input.scss +1 -1
  22. data/app/assets/stylesheets/govuk_publishing_components/components/_inverse-header.scss +5 -8
  23. data/app/assets/stylesheets/govuk_publishing_components/components/_radio.scss +4 -0
  24. data/app/assets/stylesheets/govuk_publishing_components/components/_related-navigation.scss +2 -2
  25. data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +0 -1
  26. data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-header.scss +0 -5
  27. data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-related.scss +1 -4
  28. data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav.scss +8 -12
  29. data/app/assets/stylesheets/govuk_publishing_components/components/_table.scss +21 -24
  30. data/app/assets/stylesheets/govuk_publishing_components/components/_tabs.scss +4 -8
  31. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_attachment.scss +2 -0
  32. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_button.scss +1 -4
  33. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_charts.scss +6 -6
  34. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_contact.scss +2 -0
  35. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_footnotes.scss +2 -0
  36. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_highlight-answer.scss +2 -0
  37. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_place.scss +1 -1
  38. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_typography.scss +2 -0
  39. data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_markdown-typography.scss +1 -1
  40. data/app/assets/stylesheets/govuk_publishing_components/components/print/_govspeak.scss +2 -0
  41. data/app/assets/stylesheets/govuk_publishing_components/components/print/_step-by-step-nav-header.scss +0 -4
  42. data/app/assets/stylesheets/govuk_publishing_components/components/print/_step-by-step-nav.scss +2 -10
  43. data/app/controllers/govuk_publishing_components/audit_controller.rb +52 -0
  44. data/app/controllers/govuk_publishing_components/component_guide_controller.rb +2 -2
  45. data/app/models/govuk_publishing_components/audit_applications.rb +117 -0
  46. data/app/models/govuk_publishing_components/audit_comparer.rb +198 -0
  47. data/app/models/govuk_publishing_components/audit_components.rb +158 -0
  48. data/app/views/govuk_publishing_components/audit/show.html.erb +258 -0
  49. data/app/views/govuk_publishing_components/component_guide/index.html.erb +7 -1
  50. data/app/views/govuk_publishing_components/components/_breadcrumbs.html.erb +1 -1
  51. data/app/views/govuk_publishing_components/components/_image_card.html.erb +1 -1
  52. data/app/views/govuk_publishing_components/components/_machine_readable_metadata.html.erb +1 -1
  53. data/app/views/govuk_publishing_components/components/_radio.html.erb +13 -5
  54. data/app/views/govuk_publishing_components/components/_share_links.html.erb +9 -9
  55. data/app/views/govuk_publishing_components/components/_step_by_step_nav_header.html.erb +2 -2
  56. data/app/views/govuk_publishing_components/components/docs/checkboxes.yml +4 -0
  57. data/app/views/govuk_publishing_components/components/docs/govspeak.yml +45 -0
  58. data/app/views/govuk_publishing_components/components/docs/heading.yml +6 -3
  59. data/app/views/govuk_publishing_components/components/docs/image_card.yml +13 -1
  60. data/app/views/govuk_publishing_components/components/docs/radio.yml +4 -0
  61. data/config/routes.rb +1 -0
  62. data/lib/govuk_publishing_components/presenters/checkboxes_helper.rb +15 -7
  63. data/lib/govuk_publishing_components/presenters/heading_helper.rb +21 -1
  64. data/lib/govuk_publishing_components/presenters/image_card_helper.rb +2 -1
  65. data/lib/govuk_publishing_components/version.rb +1 -1
  66. data/node_modules/axe-core/package.json +145 -220
  67. data/node_modules/govuk-frontend/govuk/all.js +160 -57
  68. data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +16 -8
  69. data/node_modules/govuk-frontend/govuk/components/character-count/macro-options.json +6 -0
  70. data/node_modules/govuk-frontend/govuk/components/character-count/template.njk +1 -0
  71. data/node_modules/govuk-frontend/govuk/components/checkboxes/_index.scss +6 -5
  72. data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +68 -21
  73. data/node_modules/govuk-frontend/govuk/components/date-input/macro-options.json +1 -1
  74. data/node_modules/govuk-frontend/govuk/components/file-upload/_index.scss +0 -27
  75. data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +0 -3
  76. data/node_modules/govuk-frontend/govuk/components/footer/template.njk +1 -1
  77. data/node_modules/govuk-frontend/govuk/components/header/template.njk +1 -1
  78. data/node_modules/govuk-frontend/govuk/components/hint/_index.scss +2 -2
  79. data/node_modules/govuk-frontend/govuk/components/hint/template.njk +2 -2
  80. data/node_modules/govuk-frontend/govuk/components/input/_index.scss +0 -3
  81. data/node_modules/govuk-frontend/govuk/components/input/macro-options.json +6 -0
  82. data/node_modules/govuk-frontend/govuk/components/input/template.njk +1 -0
  83. data/node_modules/govuk-frontend/govuk/components/radios/radios.js +76 -28
  84. data/node_modules/govuk-frontend/govuk/components/select/_index.scss +0 -3
  85. data/node_modules/govuk-frontend/govuk/components/skip-link/_index.scss +1 -0
  86. data/node_modules/govuk-frontend/govuk/components/textarea/_index.scss +0 -3
  87. data/node_modules/govuk-frontend/govuk/components/textarea/macro-options.json +6 -0
  88. data/node_modules/govuk-frontend/govuk/components/textarea/template.njk +1 -0
  89. data/node_modules/govuk-frontend/govuk/components/warning-text/_index.scss +4 -2
  90. data/node_modules/govuk-frontend/govuk/helpers/_colour.scss +1 -1
  91. data/node_modules/govuk-frontend/govuk/settings/_colours-applied.scss +2 -2
  92. data/node_modules/govuk-frontend/govuk/settings/_colours-palette.scss +1 -1
  93. data/node_modules/govuk-frontend/govuk/settings/_measurements.scss +4 -1
  94. data/node_modules/govuk-frontend/package.json +14 -81
  95. data/node_modules/jquery/package.json +44 -116
  96. metadata +29 -66
  97. data/Rakefile +0 -37
@@ -37,28 +37,26 @@ $table-row-even-background-colour: govuk-colour("light-grey", $legacy: "grey-4")
37
37
  padding-right: $sort-link-arrow-size;
38
38
  color: $govuk-link-colour;
39
39
  text-decoration: none;
40
+ }
40
41
 
41
- &:focus {
42
- @include govuk-focused-text;
43
- }
44
-
45
- &::after {
46
- content: "";
47
- position: absolute;
48
- top: 5px;
49
- right: 0;
50
-
51
- @include govuk-shape-arrow($direction: up, $base: $sort-link-arrow-size-small, $display: block);
52
- }
42
+ .app-table__sort-link:focus {
43
+ @include govuk-focused-text;
44
+ }
53
45
 
54
- &::before {
55
- content: "";
56
- position: absolute;
57
- top: 13px;
58
- right: 0;
46
+ .app-table__sort-link:after {
47
+ content: "";
48
+ position: absolute;
49
+ top: 5px;
50
+ right: 0;
51
+ @include govuk-shape-arrow($direction: up, $base: $sort-link-arrow-size-small, $display: block);
52
+ }
59
53
 
60
- @include govuk-shape-arrow($direction: down, $base: $sort-link-arrow-size-small, $display: block);
61
- }
54
+ .app-table__sort-link:before {
55
+ content: "";
56
+ position: absolute;
57
+ top: 13px;
58
+ right: 0;
59
+ @include govuk-shape-arrow($direction: down, $base: $sort-link-arrow-size-small, $display: block);
62
60
  }
63
61
  }
64
62
 
@@ -81,12 +79,12 @@ $table-row-even-background-colour: govuk-colour("light-grey", $legacy: "grey-4")
81
79
  }
82
80
  }
83
81
 
84
- .app-table__sort-link--ascending::before,
85
- .app-table__sort-link--descending::before {
82
+ .app-table__sort-link--ascending:before,
83
+ .app-table__sort-link--descending:before {
86
84
  content: none;
87
85
  }
88
86
 
89
- .app-table__sort-link--ascending::after {
87
+ .app-table__sort-link--ascending:after {
90
88
  content: "";
91
89
  position: absolute;
92
90
  top: $sort-link-arrow-spacing;
@@ -96,7 +94,7 @@ $table-row-even-background-colour: govuk-colour("light-grey", $legacy: "grey-4")
96
94
  @include govuk-shape-arrow($direction: up, $base: $sort-link-arrow-size, $display: inline-block);
97
95
  }
98
96
 
99
- .app-table__sort-link--descending::after {
97
+ .app-table__sort-link--descending:after {
100
98
  content: "";
101
99
  position: absolute;
102
100
  top: $sort-link-arrow-spacing;
@@ -105,7 +103,6 @@ $table-row-even-background-colour: govuk-colour("light-grey", $legacy: "grey-4")
105
103
 
106
104
  @include govuk-shape-arrow($direction: down, $base: $sort-link-arrow-size, $display: inline-block);
107
105
  }
108
-
109
106
  }
110
107
 
111
108
  .govuk-table__row {
@@ -11,25 +11,21 @@
11
11
  // We have some styles within GOVUK (.content-block) which can leak into the list styles for this component.
12
12
  // These styles are defined in Static: https://github.com/alphagov/static/blob/a815620cada7ea1c65428c1c3b3ac4dbe28977bf/app/assets/stylesheets/helpers/_text.scss
13
13
  // This sets more specific selectors so those unwanted styles are overidden
14
- // scss-lint:disable QualifyingElement
15
- // sass-lint:disable no-qualifying-elements
16
- ul.govuk-tabs__list {
14
+ ul.govuk-tabs__list { // stylelint-disable-line selector-no-qualifying-type
17
15
  margin: 0;
18
16
  padding: 0;
19
17
  list-style: none;
20
18
  @include govuk-responsive-margin(6, "bottom");
21
19
  }
22
20
 
23
- li.govuk-tabs__list-item {
21
+ li.govuk-tabs__list-item { // stylelint-disable-line selector-no-qualifying-type
24
22
  margin-left: govuk-spacing(5);
25
23
  }
26
24
 
27
- .js-enabled {
25
+ .js-enabled { // stylelint-disable-line no-duplicate-selectors
28
26
  @include govuk-media-query($from: tablet) {
29
- ul.govuk-tabs__list {
27
+ ul.govuk-tabs__list { // stylelint-disable-line selector-no-qualifying-type
30
28
  margin-bottom: 0;
31
29
  }
32
30
  }
33
31
  }
34
- // scss-lint:enable QualifyingElement
35
- // sass-lint:enable no-qualifying-elements
@@ -5,6 +5,8 @@
5
5
  // - alphagov/whitehall: ✔︎
6
6
  // - alphagov/govspeak: ✔︎
7
7
 
8
+ // stylelint-disable max-nesting-depth
9
+
8
10
  .gem-c-govspeak {
9
11
 
10
12
  // Scope attachment and attachment-link component styles to gem-c-govspeak
@@ -1,7 +1,6 @@
1
1
  @import "govuk/components/button/button";
2
2
 
3
- // scss-lint:disable PlaceholderInExtend
4
- // sass-lint:disable placeholder-in-extend
3
+ // stylelint-disable scss/at-extend-no-missing-placeholder
5
4
  .gem-c-govspeak {
6
5
  .gem-c-button {
7
6
  @extend .govuk-button;
@@ -11,5 +10,3 @@
11
10
  @extend .govuk-button--start;
12
11
  }
13
12
  }
14
- // sass-lint:enable placeholder-in-extend
15
- // scss-lint:enable PlaceholderInExtend
@@ -9,6 +9,8 @@
9
9
  // adapted from magna-charta example stylesheet
10
10
  // https://github.com/alphagov/magna-charta/blob/master/demo/stylesheets/magna-charta.css
11
11
 
12
+ // stylelint-disable max-nesting-depth
13
+
12
14
  .gem-c-govspeak {
13
15
  // DEFAULT CHART STYLES
14
16
 
@@ -27,8 +29,9 @@
27
29
  $chart-border: govuk-colour("white"); // Chart border colour
28
30
  $key-border: govuk-colour("white"); // Key border colour
29
31
  $bar-colours: govuk-colour("blue"), govuk-colour("turquoise"), govuk-colour("green"), govuk-colour("light-green"), govuk-colour("yellow"), govuk-colour("orange"), govuk-colour("red"), govuk-colour("bright-purple", $legacy: "bright-red");
30
- $bar-cell-colour: #ebebeb;
31
- $bar-outdented-colour: #111111;
32
+ $bar-text-colours: govuk-colour("white"), govuk-colour("black"), govuk-colour("white"), govuk-colour("black"), govuk-colour("black"), govuk-colour("black"), govuk-colour("white"), govuk-colour("white");
33
+ $bar-cell-colour: govuk-colour("black");
34
+ $bar-outdented-colour: govuk-colour("black");
32
35
 
33
36
  // CHART STYLES
34
37
  .mc-chart {
@@ -138,6 +141,7 @@
138
141
  @for $i from 0 to length($bar-colours) {
139
142
  .mc-bar-#{$i + 1} {
140
143
  background-color: nth($bar-colours, $i + 1);
144
+ color: nth($bar-text-colours, $i + 1);
141
145
  }
142
146
  }
143
147
 
@@ -266,10 +270,6 @@
266
270
  text-align: left;
267
271
  }
268
272
 
269
- .mc-chart.mc-negative .mc-td.mc-key-cell {
270
- padding-right: 25px;
271
- }
272
-
273
273
  .mc-toggle-link {
274
274
  display: block;
275
275
  margin-top: 30px;
@@ -5,6 +5,8 @@
5
5
  // - alphagov/whitehall: ✔︎
6
6
  // - alphagov/govspeak: ✔︎
7
7
 
8
+ // stylelint-disable max-nesting-depth
9
+
8
10
  .gem-c-govspeak {
9
11
  // .address is used by the `$A` markdown pattern
10
12
  .address,
@@ -9,6 +9,8 @@
9
9
  // - alphagov/whitehall: ✔︎
10
10
  // - alphagov/govspeak: ✔︎
11
11
 
12
+ // stylelint-disable max-nesting-depth
13
+
12
14
  .gem-c-govspeak {
13
15
  .footnotes {
14
16
  border-top: 1px solid govuk-colour("mid-grey", $legacy: "grey-2");
@@ -1,3 +1,5 @@
1
+ // stylelint-disable max-nesting-depth
2
+
1
3
  $highlight-answer-bg-color: govuk-colour("green");
2
4
  $highlight-answer-color: govuk-colour("white");
3
5
 
@@ -1,4 +1,4 @@
1
- .gem-c-govspeak .place {
1
+ .gem-c-govspeak .place {
2
2
  margin: 1.5em 0;
3
3
  border-bottom: solid 1px govuk-colour("mid-grey", $legacy: "grey-2");
4
4
  padding-bottom: 1.5em;
@@ -9,6 +9,8 @@
9
9
  // - alphagov/whitehall: ✔︎
10
10
  // - alphagov/govspeak: ✔︎
11
11
 
12
+ // stylelint-disable max-nesting-depth
13
+
12
14
  .gem-c-govspeak {
13
15
  @include markdown-typography;
14
16
 
@@ -105,7 +105,7 @@
105
105
  }
106
106
 
107
107
  li {
108
- margin: 0 0 5px 0;
108
+ margin: 0 0 5px;
109
109
  padding: 0;
110
110
 
111
111
  p {
@@ -1,3 +1,5 @@
1
+ // stylelint-disable max-nesting-depth
2
+
1
3
  .gem-c-govspeak {
2
4
  .media-player {
3
5
  display: none;
@@ -1,5 +1,3 @@
1
- // scss-lint:disable SelectorFormat
2
-
3
1
  .gem-c-step-nav-header__part-of {
4
2
  display: block;
5
3
  }
@@ -11,5 +9,3 @@
11
9
  .gem-c-step-nav-header__skip-link {
12
10
  display: none;
13
11
  }
14
-
15
- // scss-lint:enable SelectorFormat
@@ -1,5 +1,3 @@
1
- // scss-lint:disable SelectorFormat
2
-
3
1
  $grey-2: #bfc1c3;
4
2
  $white: #ffffff;
5
3
  $number-circle-size: 35px;
@@ -40,6 +38,7 @@ $stroke-width: 3px;
40
38
  }
41
39
 
42
40
  .gem-c-step-nav__step {
41
+ padding-left: 60px;
43
42
  position: relative;
44
43
  }
45
44
 
@@ -74,14 +73,9 @@ $stroke-width: 3px;
74
73
  padding-bottom: 1em;
75
74
  }
76
75
 
77
- .gem-c-step-nav__step {
78
- position: relative;
79
- padding-left: 60px;
80
- }
81
-
82
76
  .gem-c-step-nav__title {
83
77
  @include govuk-font(19, $weight: bold);
84
- margin: 0 0 .5em 0;
78
+ margin: 0 0 .5em;
85
79
  padding: 0;
86
80
  }
87
81
 
@@ -120,5 +114,3 @@ $stroke-width: 3px;
120
114
  .gem-c-step-nav__circle-step-colon {
121
115
  display: none;
122
116
  }
123
-
124
- // scss-lint:enable SelectorFormat
@@ -0,0 +1,52 @@
1
+ module GovukPublishingComponents
2
+ class AuditController < GovukPublishingComponents::ApplicationController
3
+ def show
4
+ path = Dir.pwd
5
+
6
+ components = AuditComponents.new(path)
7
+ applications = analyse_applications(File.expand_path("..", path))
8
+ compared_data = AuditComparer.new(components.data, applications)
9
+
10
+ @applications = compared_data.applications_data || []
11
+ @components = compared_data.gem_data || []
12
+ end
13
+
14
+ private
15
+
16
+ def analyse_applications(path)
17
+ results = []
18
+ applications = %w[
19
+ calculators
20
+ collections
21
+ collections-publisher
22
+ content-data-admin
23
+ content-publisher
24
+ email-alert-frontend
25
+ feedback
26
+ finder-frontend
27
+ frontend
28
+ government-frontend
29
+ govspeak-preview
30
+ info-frontend
31
+ licence-finder
32
+ manuals-frontend
33
+ release
34
+ search-admin
35
+ service-manual-frontend
36
+ signon
37
+ smart-answers
38
+ static
39
+ travel-advice-publisher
40
+ whitehall
41
+ ].sort
42
+
43
+ applications.each do |application|
44
+ application_path = [path, application].join("/")
45
+ app = AuditApplications.new(application_path, application)
46
+ results << app.data
47
+ end
48
+
49
+ results
50
+ end
51
+ end
52
+ end
@@ -83,9 +83,9 @@ module GovukPublishingComponents
83
83
  def components_in_use
84
84
  matches = []
85
85
 
86
- files = Dir["#{@application_path}/app/views/**/*.html.erb"]
86
+ files = Dir["#{@application_path}/app/views/**/*.erb"]
87
87
  files.concat Dir["#{@application_path}/app/**/*.rb"]
88
- files.concat Dir["#{@application_path}/lib/**/*.rb"]
88
+ files.concat Dir["#{@application_path}/lib/**/*.{rb,erb}"]
89
89
 
90
90
  files.each do |file|
91
91
  data = File.read(file)
@@ -0,0 +1,117 @@
1
+ module GovukPublishingComponents
2
+ class AuditApplications
3
+ attr_reader :data
4
+
5
+ def initialize(path, name)
6
+ @path = path
7
+ application_found = application_exists(path)
8
+ components_found = []
9
+ @gem_style_references = []
10
+
11
+ if application_found
12
+ templates = Dir["#{path}/app/views/**/*.erb"]
13
+ stylesheets = Dir["#{path}/app/assets/stylesheets/**/*.scss"]
14
+ javascripts = Dir["#{path}/app/assets/javascripts/**/*.js"]
15
+
16
+ find_components = /(?<=govuk_publishing_components\/components\/)[\/a-zA-Z_-]+(?=['"])/
17
+
18
+ @find_all_stylesheets = /@import ["']{1}govuk_publishing_components\/all_components/
19
+ find_stylesheets = /(?<=@import ["']{1}govuk_publishing_components\/components\/)(?!print\/)+[a-zA-Z_-]+(?=['"])/
20
+
21
+ @find_all_print_stylesheets = /@import ["']{1}govuk_publishing_components\/all_components_print/
22
+ find_print_stylesheets = /(?<=@import ["']{1}govuk_publishing_components\/components\/print\/)[a-zA-Z_-]+(?=['"])/
23
+
24
+ @find_all_javascripts = /\/\/[ ]*= require govuk_publishing_components\/all_components/
25
+ find_javascripts = /(?<=require govuk_publishing_components\/components\/)[a-zA-Z_-]+/
26
+
27
+ components_in_templates = find_components(templates, find_components, "templates") || []
28
+ components_in_stylesheets = find_components(stylesheets, find_stylesheets, "stylesheets") || []
29
+ components_in_print_stylesheets = find_components(stylesheets, find_print_stylesheets, "print_stylesheets") || []
30
+ components_in_javascripts = find_components(javascripts, find_javascripts, "javascripts") || []
31
+
32
+ ruby_paths = %w[/app/helpers/ /app/presenters/ /lib/]
33
+ components_in_ruby = []
34
+ ruby_paths.each do |ruby_path|
35
+ components_in_ruby << find_components(Dir["#{path}#{ruby_path}**/*.{rb,erb}"], find_components, "ruby") || []
36
+ end
37
+ components_in_ruby = components_in_ruby.flatten.uniq
38
+
39
+ components_found = [
40
+ {
41
+ location: "templates",
42
+ components: components_in_templates,
43
+ },
44
+ {
45
+ location: "stylesheets",
46
+ components: components_in_stylesheets,
47
+ },
48
+ {
49
+ location: "print_stylesheets",
50
+ components: components_in_print_stylesheets,
51
+ },
52
+ {
53
+ location: "javascripts",
54
+ components: components_in_javascripts,
55
+ },
56
+ {
57
+ location: "ruby",
58
+ components: components_in_ruby,
59
+ },
60
+ ]
61
+ end
62
+
63
+ @data = {
64
+ name: name,
65
+ application_found: application_found,
66
+ components_found: components_found,
67
+ gem_style_references: @gem_style_references.flatten.uniq.sort,
68
+ }
69
+ end
70
+
71
+ private
72
+
73
+ def find_components(files, find, type)
74
+ components_found = []
75
+
76
+ files.each do |file|
77
+ src = File.read(file)
78
+ components_found << find_match(find, src, type)
79
+ gem_references = find_gem_references(file, src)
80
+ @gem_style_references << gem_references if gem_references
81
+ rescue StandardError
82
+ puts "File #{file} not found"
83
+ end
84
+
85
+ components_found.flatten.uniq.sort
86
+ end
87
+
88
+ def find_match(find, src, type)
89
+ return %w[all] if src.match(@find_all_stylesheets) && type == "stylesheets"
90
+ return %w[all] if src.match(@find_all_print_stylesheets) && type == "print_stylesheets"
91
+ return %w[all] if src.match(@find_all_javascripts) && type == "javascripts"
92
+
93
+ matches = src.scan(find)
94
+ all_matches = []
95
+ matches.each do |match|
96
+ all_matches << clean_file_name(match.tr('[])\'"', ""))
97
+ end
98
+
99
+ all_matches
100
+ end
101
+
102
+ def find_gem_references(file, src)
103
+ find_gem_classes = /gem-c-[-_a-zA-Z]+/
104
+ clean_file_path = /(?<=#{Regexp.escape(@path)}\/)[\/a-zA-Z_-]+.[a-zA-Z.]+/
105
+
106
+ return file[clean_file_path] if find_gem_classes.match?(src)
107
+ end
108
+
109
+ def clean_file_name(name)
110
+ name.tr("_-", " ").strip
111
+ end
112
+
113
+ def application_exists(directory)
114
+ File.directory?(directory)
115
+ end
116
+ end
117
+ end