govuk_publishing_components 0.5.0 → 0.6.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.
- checksums.yaml +4 -4
- data/README.md +10 -0
- data/lib/generators/govuk_publishing_components/USAGE +5 -0
- data/lib/generators/govuk_publishing_components/component_generator.rb +33 -0
- data/lib/generators/govuk_publishing_components/templates/_component.html.erb +3 -0
- data/lib/generators/govuk_publishing_components/templates/_component.scss +3 -0
- data/lib/generators/govuk_publishing_components/templates/component.yml.erb +12 -0
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb12fc8693ac887695dfcde1c8faefeeee539dfe
|
4
|
+
data.tar.gz: 45ab14567e89f2a3e27794a281458e03623c4cca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b464c0efd5ae644bd424caf161261c2526fcb514f22d290b8ab92e6240b114db19cd8b013ded19edfb360bffe45dd5ee8f02cafcfb316238167e2c652a40775
|
7
|
+
data.tar.gz: d32a0efdfb5b90a50aeeb62761918bbc1f7abce4dea413f9361516f8f318a9837d2c92fbad37cab2bdc3251e77355b5295be521a32bfa70b27122787ec2e553d
|
data/README.md
CHANGED
@@ -71,6 +71,16 @@ if defined?(GovukPublishingComponents)
|
|
71
71
|
end
|
72
72
|
```
|
73
73
|
|
74
|
+
## Component generator
|
75
|
+
|
76
|
+
The gem includes a component generator to stub the minimal files required for a component.
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
rails generate govuk_publishing_components:component [component_name]
|
80
|
+
```
|
81
|
+
|
82
|
+
This will create a template, scss file and yml documentation file for a new component. It will not create a test file as this cannot be reliably done automatically across applications, but a test file will be necessary.
|
83
|
+
|
74
84
|
## Licence
|
75
85
|
|
76
86
|
[MIT Licence](LICENCE.md)
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module GovukPublishingComponents
|
5
|
+
class ComponentGenerator < ::Rails::Generators::NamedBase
|
6
|
+
source_root File.expand_path('../templates', __FILE__)
|
7
|
+
|
8
|
+
def copy_component_files
|
9
|
+
@public_name = file_name.dasherize
|
10
|
+
|
11
|
+
template_dir = "app/views/components/"
|
12
|
+
docs_dir = "app/views/components/docs/"
|
13
|
+
scss_dir = "app/assets/stylesheets/components/"
|
14
|
+
|
15
|
+
create_directory_if_not_exists(template_dir)
|
16
|
+
create_directory_if_not_exists(docs_dir)
|
17
|
+
create_directory_if_not_exists(scss_dir)
|
18
|
+
|
19
|
+
template '_component.html.erb', "#{template_dir}_#{@public_name}.html.erb"
|
20
|
+
template 'component.yml.erb', "#{docs_dir}#{@public_name}.yml"
|
21
|
+
template '_component.scss', "#{scss_dir}_#{@public_name}.scss"
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def create_directory_if_not_exists(dir)
|
27
|
+
if not File.directory?(dir)
|
28
|
+
puts("Directory #{dir} not found, creating")
|
29
|
+
FileUtils::mkdir_p dir
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
name: <%= @public_name %>
|
2
|
+
description: Short description of component
|
3
|
+
body: |
|
4
|
+
Optional markdown providing further detail about the component
|
5
|
+
acceptance_criteria: |
|
6
|
+
Markdown listing what this component must do to be accessible. For example:
|
7
|
+
|
8
|
+
The link must:
|
9
|
+
|
10
|
+
* be keyboard focusable
|
11
|
+
fixtures:
|
12
|
+
default: {}
|
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: 0.
|
4
|
+
version: 0.6.0
|
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: 2017-08-
|
11
|
+
date: 2017-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -168,6 +168,11 @@ files:
|
|
168
168
|
- app/views/govuk_publishing_components/component_guide/show.html.erb
|
169
169
|
- app/views/layouts/govuk_publishing_components/application.html.erb
|
170
170
|
- config/routes.rb
|
171
|
+
- lib/generators/govuk_publishing_components/USAGE
|
172
|
+
- lib/generators/govuk_publishing_components/component_generator.rb
|
173
|
+
- lib/generators/govuk_publishing_components/templates/_component.html.erb
|
174
|
+
- lib/generators/govuk_publishing_components/templates/_component.scss
|
175
|
+
- lib/generators/govuk_publishing_components/templates/component.yml.erb
|
171
176
|
- lib/govuk_publishing_components.rb
|
172
177
|
- lib/govuk_publishing_components/config.rb
|
173
178
|
- lib/govuk_publishing_components/engine.rb
|