pugin 0.8.5 → 0.8.6.pre

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
  SHA1:
3
- metadata.gz: eadf3c6054f9428bcb8f2e0a8659e9d6d9b99b90
4
- data.tar.gz: 67115adf068391fb641faa9e38e25094309a247c
3
+ metadata.gz: ead24bb9ca07f105257830abe4aa843e933ce7ab
4
+ data.tar.gz: ea7c4d958e3c64556ce937cfc54febf678faab6d
5
5
  SHA512:
6
- metadata.gz: 93317babc8acd89546fe4be7541e8c3ec2563854979bf091d9738966084de6ecce2e3fc609a1ce9b0250e96bf8bf4caa97591c0ebf8490ae6c65578f65cdf4f1
7
- data.tar.gz: cafb31ac9b106ccd0892138edebcdd8194b5968b58956d27ffbad0dc4a1cdd31a5f11bb31e55d5b6236d9cdfa66cff913d6e528541589930d6b81a356e35aa13
6
+ metadata.gz: a4041fbd51b33225014277870eb8d8722dffd02b4acf48f2b8b67396d68b0e7d1ee93d87862ec84cd26b275349f831ceb502e28da4d76341c018f5c9af265746
7
+ data.tar.gz: dd3c79fa8f92a794a23531caa3f27f832a26b51bf170674c1e1391f8c9147f47ac70399997c0848ba8a3a74442ab8e5e69d6210705b691978c20f469f187a0f3
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Pugin Components Rails
2
- [pugin-components-rails][pugin-components-rails] is a component-based pattern design library created by the [Parliamentary Digital Service][pds] that holds all of the reusable partials for elements of the UK Parliament's microservices.
2
+ [pugin-components-ruby][pugin-components-ruby] is a component-based pattern design library created by the [Parliamentary Digital Service][pds] that holds all of the reusable partials for elements of the UK Parliament's microservices.
3
3
 
4
4
  [![Build Status][shield-travis]][info-travis] [![Test Coverage][shield-coveralls]][info-coveralls] [![License][shield-license]][info-license]
5
5
 
@@ -14,6 +14,9 @@
14
14
  - [Installation](#installation)
15
15
  - [Usage](#usage)
16
16
  - [Example](#example)
17
+ - [Adding the Parliamentary layout](#adding-the-parliamentary-layout)
18
+ - [Including rel-alternate links](#including-rel-alternate-links)
19
+ - [Example](#example-1)
17
20
  - [Getting Started with Development](#getting-started-with-development)
18
21
  - [Running the tests](#running-the-tests)
19
22
  - [Contributing](#contributing)
@@ -23,7 +26,7 @@
23
26
 
24
27
 
25
28
  ## Requirements
26
- [pugin-components-rails][pugin-components-rails] requires the following:
29
+ [pugin-components-ruby][pugin-components-ruby] requires the following:
27
30
  * [Ruby][ruby] - [click here][ruby-version] for the exact version
28
31
  * [Bundler][bundler]
29
32
  * [Rails][rails]
@@ -57,12 +60,34 @@ Add the following line into the application controller within your host applicat
57
60
  layout 'pugin/layouts/pugin'
58
61
  ```
59
62
 
63
+ #### Including rel-alternate links
64
+ When rendering using the Parliamentary layout, if you'd like to document rel-alternates like so:
65
+
66
+ ```html
67
+ <link rel="alternate" type="application/rdf+json" href="https://api.example.com/some/url" />
68
+ <link rel="alternate" type="application/rdf+xml" href="https://api.example.com/some/other/url" />
69
+ ```
70
+
71
+ You can do so automatically by setting `Pugin.alternates`.
72
+
73
+ ##### Example
74
+ Within your controller:
75
+
76
+ ```ruby
77
+ alternates = [
78
+ { type: 'application/rdf+json', href: 'https://api.example.com/some/url' },
79
+ { type: 'application/rdf+xml', href: 'https://api.example.com/some/other/url' }
80
+ ]
81
+
82
+ Pugin.alternates = alternates
83
+ ```
84
+
60
85
 
61
86
  ## Getting Started with Development
62
87
  To clone the repository and set up the dependencies, run the following:
63
88
  ```bash
64
- git clone https://github.com/ukparliament/pugin-components-rails.git
65
- cd pugin-components-rails
89
+ git clone https://github.com/ukparliament/pugin-components-ruby.git
90
+ cd pugin-components-ruby
66
91
  bundle install
67
92
  ```
68
93
 
@@ -85,12 +110,12 @@ If you wish to submit a bug fix or feature, you can create a pull request and it
85
110
 
86
111
 
87
112
  ## License
88
- [pugin-components-rails][pugin-components-rails] is licensed under the [Open Parliament Licence][info-license].
113
+ [pugin-components-ruby][pugin-components-ruby] is licensed under the [Open Parliament Licence][info-license].
89
114
 
90
115
  [ruby]: https://www.ruby-lang.org/en/
91
116
  [bundler]: http://bundler.io
92
117
  [rspec]: http://rspec.info
93
- [pugin-components-rails]: https://github.com/ukparliament/parliament.uk-pugin-components-rails
118
+ [pugin-components-ruby]: https://github.com/ukparliament/parliament.uk-pugin-components-ruby
94
119
  [pds]: https://www.parliament.uk/mps-lords-and-offices/offices/bicameral/parliamentary-digital-service/
95
120
  [ruby-version]: https://github.com/ukparliament/pugin/blob/master/.ruby-version
96
121
  [rails]: http://rubyonrails.org
@@ -8,6 +8,12 @@
8
8
  %link{rel: 'shortcut icon', type: 'image/x-icon', href: "#{Pugin::STATIC_ASSET_LOCATION_URL}/favicon.ico"}
9
9
  - if ENV['GTM_KEY']
10
10
  = render partial: 'pugin/javascript/google_tag_manager'
11
+ - unless Pugin.alternates.empty?
12
+ / /==========================\
13
+ / [ See below for data views ]
14
+ / \==========================/
15
+ - Pugin.alternates.each do |alternate|
16
+ %link{rel: 'alternate', type: alternate[:type], href: alternate[:href]}
11
17
  %body.no-js
12
18
  - if ENV['GTM_KEY']
13
19
  = render partial: 'pugin/javascript/google_tag_manager_noscript'
@@ -0,0 +1,51 @@
1
+ <!--
2
+
3
+ ...........
4
+ ,,,,,,,,,
5
+ .,, .. ,,,,, . ,,.
6
+ .,,,, .,,,... ,,,,..,,,...,,, ...,,,, ,,,,.
7
+ ,,,, ...,,,,,,,. ,,,,,,,,,,,,,,, .,,,,,,,,,. ,,,,
8
+ ,,,, ., ,,,,,,,,, , ,,,,,.,,,.,,,,, ,,,,,,,,, ,. ,,,,
9
+ ,,,,,,, , ,,,, ,, .,,,. ,, ,,,, , ,,,,,,,
10
+ .,,,,,, .,,,, .,,,,,. ,,,,. ,,,,,,.
11
+ .,,. ,. ,,,,. .,,,,,,,,,. .,,,, , .,,.
12
+ ,,,.. .,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ..,,,
13
+ .,,,,,,,,,,,,,,,,,,, ,,,,,,,,,,,,,,,,,,,,
14
+ ... .,,,,,,,, ,,,,,,,,. ...
15
+ .,,,,,,,. ,, ,, .,,,,,,,.
16
+ ,,, ,,,.................................................,,. ,,,.
17
+ ,,. . .,,,,.,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.,,,,. ...,,,
18
+ ,,,,,,,. .,,, ,,,,. ,,,,, .,,,, .,,. .,,,,,,,
19
+ ,,. .,,, ,,,,. ,,,,, .,,,, .,,. ,,,
20
+ .,,.. .,,, ,,,,. ,,,,, .,,,, .,,. .,,
21
+ .,,,,,,,. .,,,......,,,,......,,,,,......,,,,.......,,. .,,,,,,,.
22
+ ,,. .,,. .,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,. ,,, . ,,,
23
+ ,,.....,, .,,,......,,,,......,,,,,.....,,,,,.......,,. ,,,.,,.,,
24
+ ,,,,,,, .,,, ,,,,. ,,,,, .,,,, .,,. ,,,,,,,
25
+ ,,. .,,, ,,,,. ,,,,, .,,,, .,,. ,,,
26
+ .,,.. .,,, ,,,,. ,,,,, .,,,, .,,. ..,,.
27
+ .,,,,,,,. .,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,. .,,,,,,,.
28
+ ,,, ,,. .,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,. ,,. ,,,
29
+ ,,..,..,, .,,, ,,,,. ,,,,, .,,,, .,,. .,..,,,,,
30
+ ,,,,,,, .,,, ,,,,. ,,,,, .,,,, .,,. .,,,,,,
31
+ ,,. .,,, ,,,,. ,,,,, .,,,, .,,. ,,,
32
+ .,,,,,. .,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,. .,,,,,.
33
+ .,,.,.,,. .,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,. .,,.,,.,.
34
+ ,, ,,, .,,, ,,,,. ,,,,, .,,,, .,,. ,,, ,,,
35
+ .,,.,.,,. .,,, ,,,,. ,,,,, .,,,, .,,. .,,.,,.,,
36
+ ,,,,,,, .,,, ,,,,. ,,,,, .,,,, .,,. ,,,,,,,
37
+ ,,. .,,,.. ..,,,,.. .,,,,,. ..,,,,.. ...,,. ,,,
38
+ .,,,,,. .,,,,, .,,,,, ,,,,,,, ,,,,,. ,,,,,. .,,,,,.
39
+ .,.,,,.,, .,,. ,,,, ,,,,, ,,,, ,,,. .,,,,,.,,
40
+ ,, ,,, .,. ,,,, ,,, ,,,, .,. ,,. ,,,
41
+ ,,,..,,,, .. .. ,,, .. .. ,,,,.,,,,
42
+ ,,,,,, . , , . ,,,,,,
43
+
44
+ Developers!
45
+ Have a look at the "alternate" <link> rels for our new data views...
46
+
47
+ Did you know we're building a new data service for Parliament?
48
+ https://pds.blog.parliament.uk/2017/06/23/a-new-data-service-for-parliament/
49
+
50
+ -->
51
+ <%= render 'pugin/layouts/layout' %>
data/lib/pugin.rb CHANGED
@@ -1,11 +1,17 @@
1
1
  require 'pugin/version'
2
2
 
3
3
  module Pugin
4
- ASSET_VERSION = '1.4.11'.freeze
4
+ ASSET_VERSION = '1.5.0'.freeze
5
5
  ASSET_LOCATION_URL = ENV.fetch('ASSET_LOCATION_URL', 'https://s3-eu-west-1.amazonaws.com/web1devci.pugin-website')
6
6
  STATIC_ASSET_LOCATION_URL = ENV.fetch('STATIC_ASSET_LOCATION_URL', 'https://s3-eu-west-1.amazonaws.com/web1devci.static-assets')
7
7
 
8
8
  class << self
9
+ attr_writer :alternates
10
+
11
+ def alternates
12
+ @alternates || []
13
+ end
14
+
9
15
  # Inspired by bootsrap-sass
10
16
  def load!
11
17
  if rails?
data/lib/pugin/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pugin
2
- VERSION = '0.8.5'.freeze
2
+ VERSION = '0.8.6.pre'.freeze
3
3
  end
data/spec/pugin_spec.rb CHANGED
@@ -12,4 +12,26 @@ describe Pugin do
12
12
  it 'has an asset version' do
13
13
  expect(Pugin::ASSET_VERSION).not_to be_nil
14
14
  end
15
+
16
+ describe '#alternates' do
17
+ context 'with no value set' do
18
+ it 'returns an empty array' do
19
+ expect(Pugin.alternates).to eq([])
20
+ end
21
+ end
22
+
23
+ context 'with a value set' do
24
+ before :each do
25
+ Pugin.alternates = [{ type: 'text/foo', href: 'https://api.example.com/' }]
26
+ end
27
+
28
+ after :each do
29
+ Pugin.alternates = nil
30
+ end
31
+
32
+ it 'returns the value' do
33
+ expect(Pugin.alternates).to eq([{ type: 'text/foo', href: 'https://api.example.com/' }])
34
+ end
35
+ end
36
+ end
15
37
  end
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+ require 'haml'
3
+
4
+ describe 'pugin/layouts/_layout.html.haml', type: :view do
5
+ before :each do
6
+ HousesHelper = Class.new
7
+ allow(HousesHelper).to receive(:commons_id).and_return('123')
8
+ allow(HousesHelper).to receive(:lords_id).and_return('456')
9
+ allow(view).to receive(:mps_path).and_return("/mps")
10
+ allow(view).to receive(:house_members_current_a_z_letter_path).and_return("houses/#{HousesHelper.lords_id}/members/current/a-z/a")
11
+ allow(view).to receive(:constituencies_current_a_z_letter_path).and_return("constituencies/current/a-z/a")
12
+ allow(view).to receive(:house_parties_current_path).and_return("houses/#{HousesHelper.commons_id}/parties/current/")
13
+ end
14
+
15
+ it 'renders HAML without errors' do
16
+ render
17
+ expect(rendered).to have_title(I18n.t('.pugin.layouts.pugin.website_brand'))
18
+ end
19
+
20
+ context 'with Pugin.alternates set' do
21
+ let(:alternates) do
22
+ [
23
+ { type: 'text/foo', href: 'https://api.example.com/' },
24
+ { type: 'application/bar', href: 'https://api.example.com/' },
25
+ ]
26
+ end
27
+
28
+ before :each do
29
+ allow(Pugin).to receive(:alternates).and_return(alternates)
30
+ render
31
+ end
32
+
33
+ it 'renders rel-alternate links' do
34
+ expect(rendered).to include('<link href=\'https://api.example.com/\' rel=\'alternate\' type=\'text/foo\'>')
35
+ expect(rendered).to include('<link href=\'https://api.example.com/\' rel=\'alternate\' type=\'application/bar\'>')
36
+ end
37
+ end
38
+
39
+ context 'without Pugin.alternates set' do
40
+ before :each do
41
+ allow(Pugin).to receive(:alternates).and_return([])
42
+ render
43
+ end
44
+
45
+ it 'renders rel-alternate links' do
46
+ expect(rendered).not_to include('<link href=\'https://api.example.com/\' rel=\'alternate\' type=\'text/foo\'>')
47
+ expect(rendered).not_to include('<link href=\'https://api.example.com/\' rel=\'alternate\' type=\'application/bar\'>')
48
+ end
49
+ end
50
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.5
4
+ version: 0.8.6.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Rayner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-22 00:00:00.000000000 Z
11
+ date: 2017-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -203,8 +203,9 @@ files:
203
203
  - app/views/pugin/elements/_skip-content.haml
204
204
  - app/views/pugin/javascript/_google_tag_manager.haml
205
205
  - app/views/pugin/javascript/_google_tag_manager_noscript.haml
206
+ - app/views/pugin/layouts/_layout.html.haml
206
207
  - app/views/pugin/layouts/pugin-sinatra.haml
207
- - app/views/pugin/layouts/pugin.haml
208
+ - app/views/pugin/layouts/pugin.html.erb
208
209
  - app/views/pugin/parties/list/_list.html.haml
209
210
  - app/views/pugin/parties/list/current/current_party.html.haml
210
211
  - app/views/pugin/parties/list/former/former_party.html.haml
@@ -295,7 +296,7 @@ files:
295
296
  - spec/views/pugin/components/_status.html.haml_spec.rb
296
297
  - spec/views/pugin/constituencies/list/_list.html.haml_spec.rb
297
298
  - spec/views/pugin/elements/_list.html.haml_spec.rb
298
- - spec/views/pugin/layouts/pugin.html.haml_spec.rb
299
+ - spec/views/pugin/layouts/_layout.html.haml_spec.rb
299
300
  - spec/views/pugin/people/list/_list.html.haml
300
301
  - spec/views/pugin/people/list/lord/_lord.html.haml
301
302
  - spec/views/pugin/people/list/member/_member.html.haml
@@ -314,9 +315,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
314
315
  version: '0'
315
316
  required_rubygems_version: !ruby/object:Gem::Requirement
316
317
  requirements:
317
- - - ">="
318
+ - - ">"
318
319
  - !ruby/object:Gem::Version
319
- version: '0'
320
+ version: 1.3.1
320
321
  requirements: []
321
322
  rubyforge_project:
322
323
  rubygems_version: 2.6.8
@@ -384,7 +385,7 @@ test_files:
384
385
  - spec/lib/pugin/feature/simple_feature_spec.rb
385
386
  - spec/lib/pugin/feature/bandiera_spec.rb
386
387
  - spec/pugin/engine_spec.rb
387
- - spec/views/pugin/layouts/pugin.html.haml_spec.rb
388
+ - spec/views/pugin/layouts/_layout.html.haml_spec.rb
388
389
  - spec/views/pugin/cards/_person-list.html.haml_spec.rb
389
390
  - spec/views/pugin/constituencies/list/_list.html.haml_spec.rb
390
391
  - spec/views/pugin/components/_status.html.haml_spec.rb
@@ -1,26 +0,0 @@
1
- require 'spec_helper'
2
- require 'haml'
3
-
4
- describe 'pugin/layouts/pugin.html.haml', type: :view do
5
- context 'with a fully implemented person' do
6
- let(:person) { double('Grom::Node') }
7
-
8
- before :each do
9
- allow(person).to receive(:name).and_return('Jane Smith')
10
- allow(person).to receive(:position).and_return('Minister for Tests')
11
- allow(person).to receive(:id).and_return('123')
12
- HousesHelper = Class.new
13
- allow(HousesHelper).to receive(:commons_id).and_return('123')
14
- allow(HousesHelper).to receive(:lords_id).and_return('456')
15
- allow(view).to receive(:mps_path).and_return("/mps")
16
- allow(view).to receive(:house_members_current_a_z_letter_path).and_return("houses/#{HousesHelper.lords_id}/members/current/a-z/a")
17
- allow(view).to receive(:constituencies_current_a_z_letter_path).and_return("constituencies/current/a-z/a")
18
- allow(view).to receive(:house_parties_current_path).and_return("houses/#{HousesHelper.commons_id}/parties/current/")
19
- end
20
-
21
- it 'renders HAML without errors' do
22
- render
23
- expect(rendered).to have_title(I18n.t('.pugin.layouts.pugin.website_brand'))
24
- end
25
- end
26
- end