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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82791bc5677fa763b86403bba364aca06041d381
4
- data.tar.gz: 365d38fbf1bf2e86f653fc1fac4ddce6301aa7c3
3
+ metadata.gz: fb12fc8693ac887695dfcde1c8faefeeee539dfe
4
+ data.tar.gz: 45ab14567e89f2a3e27794a281458e03623c4cca
5
5
  SHA512:
6
- metadata.gz: c4471c1805124fc072d7e6d115b2bd3618c17d0ae2ac151ea8ab7bbef8032b312cd4822d82a004db43e2ffcae2e5c3cc4c2a15ad88ac49b5e479af296b8dd67e
7
- data.tar.gz: 5750331c65f4e146b6d392c550d386139f8ad9620ce2bc40f192c3a31249d2ea4aca1754b572b6e32e5cd8f321b7e42f01a81bbfe3f0003e6caa4d2e34a34276
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,5 @@
1
+ Description:
2
+ Generates a new component
3
+
4
+ Example:
5
+ rails generate govuk_publishing_components:component [component_name]
@@ -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,3 @@
1
+ <div class="app-c-<%= @public_name %>">
2
+ <h2><a href="https://github.com/alphagov/govuk_publishing_components/blob/master/docs/component_conventions.md">How to build a component</a></h2>
3
+ </div>
@@ -0,0 +1,3 @@
1
+ .app-c-<%= @public_name %> {
2
+
3
+ }
@@ -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: {}
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = '0.5.0'.freeze
2
+ VERSION = '0.6.0'.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: 0.5.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-08 00:00:00.000000000 Z
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