govuk_publishing_components 21.55.0 → 21.55.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67b6a6a998771d72bbbe83523102343350d083190a7c77e2bfd158d89104be3a
4
- data.tar.gz: f64d56023c03cc92dc84dec30e06436e5904f98f2334e14440e4468886d27f55
3
+ metadata.gz: 34577f5058eb49bcbf88cbbdc4a50dc11ad7f87ee10706f1cb15bbcd7a08988e
4
+ data.tar.gz: 97ae0ad84975a91c8b2f560b4b80a095fbc75b7f6fd552bb6fcb92d9d8bbd9dc
5
5
  SHA512:
6
- metadata.gz: a9fb15374f204846907e809baff835885ae63698064184bbe55b0dbe0c5fbf82ed0986595de7ebfdc62b50144ee0173c73c2b30f58468c72e1701745848f50c7
7
- data.tar.gz: 30a0a5885f0bf9343d2bcb9679630829d394148447ee1041ff737704105b07ff4e28fd7711bee68ac604d7c864c6bd103606d7204ee2e010a94a0c9ebdd9a977
6
+ metadata.gz: 39186c5eb0a7a811aade0cfb0be8b483102473b19ac4f85035d384b01812909a54fda71dade7d9491d6c92968d118594b455682b49d5e3a894ebc6b835579120
7
+ data.tar.gz: 74b21c40ad38212747054d025dfcbca802a44465f9e833606c79e31a1c1fcbbdea880237eb9405361664129b8953ac6abc85498e66a72066cce6ade2f7ed005b
@@ -47,16 +47,7 @@ module GovukPublishingComponents
47
47
  additional_files = "@import 'govuk_publishing_components/govuk_frontend_support';\n"
48
48
  additional_files << "@import 'govuk_publishing_components/component_support';\n" unless print_styles
49
49
 
50
- components = components_in_use
51
- extra_components = []
52
-
53
- components.each do |component|
54
- components_in_component = components_within_component(component)
55
- extra_components << components_in_component
56
- end
57
-
58
- components << extra_components.compact
59
- components = components.flatten.uniq.sort
50
+ components = find_all_partials_in(components_in_use)
60
51
 
61
52
  components.map { |component|
62
53
  "@import 'govuk_publishing_components/components/#{print_path}#{component.gsub('_', '-')}';" if component_has_sass_file(component.gsub("_", "-"), print_styles)
@@ -66,16 +57,7 @@ module GovukPublishingComponents
66
57
  def components_in_use_js
67
58
  additional_files = "//= require govuk_publishing_components/lib\n"
68
59
 
69
- components = components_in_use
70
- extra_components = []
71
-
72
- components.each do |component|
73
- components_in_component = components_within_component(component)
74
- extra_components << components_in_component
75
- end
76
-
77
- components << extra_components.compact
78
- components = components.flatten.uniq.sort
60
+ components = find_all_partials_in(components_in_use)
79
61
 
80
62
  components.map { |component|
81
63
  "//= require govuk_publishing_components/components/#{component.gsub('_', '-')}" if component_has_js_file(component.gsub("_", "-"))
@@ -110,6 +92,34 @@ module GovukPublishingComponents
110
92
  matches.flatten.uniq.map(&:to_s).sort.map { |m| m.gsub("govuk_publishing_components/components/", "") }
111
93
  end
112
94
 
95
+ def find_all_partials_in(components)
96
+ components_to_search = components
97
+ partials_found = true
98
+
99
+ while partials_found
100
+ extra_components = find_partials_in(components_to_search)
101
+
102
+ if extra_components.any?
103
+ components << extra_components
104
+ components_to_search = extra_components
105
+ else
106
+ partials_found = false
107
+ end
108
+ end
109
+
110
+ components.flatten.uniq.sort
111
+ end
112
+
113
+ def find_partials_in(components)
114
+ extra_components = []
115
+ components.each do |component|
116
+ components_in_component = components_within_component(component)
117
+ extra_components << components_in_component
118
+ end
119
+
120
+ extra_components.flatten.uniq.sort
121
+ end
122
+
113
123
  def component_has_sass_file(component, print_styles)
114
124
  print_path = "print/" if print_styles
115
125
  Pathname.new(@component_gem_path + "/app/assets/stylesheets/govuk_publishing_components/components/#{print_path}_#{component}.scss").exist?
@@ -120,8 +130,10 @@ module GovukPublishingComponents
120
130
  end
121
131
 
122
132
  def components_within_component(component)
123
- data = File.read(@component_gem_path + "/app/views/govuk_publishing_components/components/_#{component}.html.erb")
124
- match = data.scan(/(govuk_publishing_components\/components\/[a-z_-]+)/)
133
+ filename = @component_gem_path + "/app/views/govuk_publishing_components/components/#{component}.html.erb"
134
+ filename = filename.sub(/.*\K\//, "/_") # files begin with _ but the method may have been passed 'filename' or 'dir/partial'
135
+ data = File.read(filename)
136
+ match = data.scan(/(govuk_publishing_components\/components\/[\/a-z_-]+)/)
125
137
  match.flatten.uniq.map(&:to_s).sort.map { |m| m.gsub("govuk_publishing_components/components/", "") }
126
138
  end
127
139
 
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "21.55.0".freeze
2
+ VERSION = "21.55.1".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 21.55.0
4
+ version: 21.55.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-02 00:00:00.000000000 Z
11
+ date: 2020-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gds-api-adapters