crown_marketplace_utils 0.1.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +110 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +208 -0
- data/LICENSE.txt +21 -0
- data/README.md +42 -0
- data/Rakefile +10 -0
- data/crown_marketplace_utils.gemspec +48 -0
- data/lib/crown_marketplace_utils/engine.rb +11 -0
- data/lib/crown_marketplace_utils/gov_uk_helper/details.rb +39 -0
- data/lib/crown_marketplace_utils/gov_uk_helper/error_message.rb +52 -0
- data/lib/crown_marketplace_utils/gov_uk_helper/hint.rb +29 -0
- data/lib/crown_marketplace_utils/gov_uk_helper.rb +15 -0
- data/lib/crown_marketplace_utils/version.rb +5 -0
- data/lib/crown_marketplace_utils.rb +9 -0
- data/sig/crown_marketplace_utils.rbs +4 -0
- metadata +177 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 06b0933612954153f5c6a0a37d666db46ad61709d6ce33705790b3f2906101ec
|
4
|
+
data.tar.gz: d8622845984e64cabf38557e3c0045cadf2265975c8a38a5bac6ab25ffd93119
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 34d668ad1d821617e5cd81d9d040e32d5d9e503eb0e68c55757ecf945a1b38e25a59c3c08fadb4d15dd3158b7a238b1e933066748f3b7f3e5801574bea4474de
|
7
|
+
data.tar.gz: a5c067665e8af0370c960d7868af516aeb3b8d86453aa94c732841a6824d3cb32ed3d400be26e81608b643eff119f44b30b7a0fdb8d13c6715c59bcf00daa18f
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
---
|
2
|
+
require:
|
3
|
+
- rubocop-rspec
|
4
|
+
- rubocop-rails
|
5
|
+
- rubocop-rake
|
6
|
+
|
7
|
+
AllCops:
|
8
|
+
NewCops: enable
|
9
|
+
TargetRubyVersion: 2.7
|
10
|
+
Exclude:
|
11
|
+
- 'bin/**/*'
|
12
|
+
- 'tmp/**/*'
|
13
|
+
- 'vendor/**/*'
|
14
|
+
|
15
|
+
Bundler/OrderedGems:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
Style/Alias:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
Style/FrozenStringLiteralComment:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
Style/NumericLiterals:
|
25
|
+
Enabled: false
|
26
|
+
|
27
|
+
Style/TrailingCommaInArrayLiteral:
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
Style/TrailingCommaInHashLiteral:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
Style/TrailingCommaInArguments:
|
34
|
+
Enabled: false
|
35
|
+
|
36
|
+
Style/Documentation:
|
37
|
+
Enabled: false
|
38
|
+
|
39
|
+
Style/DoubleNegation:
|
40
|
+
Enabled: false
|
41
|
+
|
42
|
+
Style/WordArray:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
Style/ClassAndModuleChildren:
|
46
|
+
Enabled: false
|
47
|
+
|
48
|
+
Layout/EndOfLine:
|
49
|
+
EnforcedStyle: lf
|
50
|
+
|
51
|
+
Layout/TrailingEmptyLines:
|
52
|
+
Enabled: true
|
53
|
+
|
54
|
+
Layout/LineLength:
|
55
|
+
Max: 120
|
56
|
+
Enabled: false
|
57
|
+
AllowedPatterns:
|
58
|
+
- 'it .* do$'
|
59
|
+
- 'context .* do$'
|
60
|
+
- 'scenario .* do$'
|
61
|
+
|
62
|
+
Metrics/ClassLength:
|
63
|
+
Enabled: false
|
64
|
+
|
65
|
+
Metrics/MethodLength:
|
66
|
+
Max: 50
|
67
|
+
Exclude:
|
68
|
+
|
69
|
+
Metrics/AbcSize:
|
70
|
+
Max: 25 # TODO: Restore to '20'
|
71
|
+
Exclude:
|
72
|
+
- 'spec/**/*'
|
73
|
+
|
74
|
+
Metrics/BlockLength:
|
75
|
+
Max: 40
|
76
|
+
Exclude:
|
77
|
+
- 'spec/**/*'
|
78
|
+
|
79
|
+
RSpec/ContextWording:
|
80
|
+
Prefixes:
|
81
|
+
- when
|
82
|
+
- with
|
83
|
+
- without
|
84
|
+
- and
|
85
|
+
|
86
|
+
Metrics/ModuleLength:
|
87
|
+
Exclude:
|
88
|
+
- 'spec/models/**/*'
|
89
|
+
- 'spec/controllers/**/*'
|
90
|
+
|
91
|
+
RSpec/MultipleMemoizedHelpers:
|
92
|
+
Enabled: false
|
93
|
+
|
94
|
+
RSpec/VariableName:
|
95
|
+
Enabled: false
|
96
|
+
|
97
|
+
Naming/VariableNumber:
|
98
|
+
Enabled: false
|
99
|
+
|
100
|
+
Lint/MissingSuper:
|
101
|
+
Enabled: false
|
102
|
+
|
103
|
+
Rails/HelperInstanceVariable:
|
104
|
+
Enabled: false
|
105
|
+
|
106
|
+
Style/OptionalBooleanParameter:
|
107
|
+
Enabled: false
|
108
|
+
|
109
|
+
RSpec/VerifiedDoubleReference:
|
110
|
+
Enabled: false
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,208 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
crown_marketplace_utils (0.1.0.beta.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
actioncable (7.0.4)
|
10
|
+
actionpack (= 7.0.4)
|
11
|
+
activesupport (= 7.0.4)
|
12
|
+
nio4r (~> 2.0)
|
13
|
+
websocket-driver (>= 0.6.1)
|
14
|
+
actionmailbox (7.0.4)
|
15
|
+
actionpack (= 7.0.4)
|
16
|
+
activejob (= 7.0.4)
|
17
|
+
activerecord (= 7.0.4)
|
18
|
+
activestorage (= 7.0.4)
|
19
|
+
activesupport (= 7.0.4)
|
20
|
+
mail (>= 2.7.1)
|
21
|
+
net-imap
|
22
|
+
net-pop
|
23
|
+
net-smtp
|
24
|
+
actionmailer (7.0.4)
|
25
|
+
actionpack (= 7.0.4)
|
26
|
+
actionview (= 7.0.4)
|
27
|
+
activejob (= 7.0.4)
|
28
|
+
activesupport (= 7.0.4)
|
29
|
+
mail (~> 2.5, >= 2.5.4)
|
30
|
+
net-imap
|
31
|
+
net-pop
|
32
|
+
net-smtp
|
33
|
+
rails-dom-testing (~> 2.0)
|
34
|
+
actionpack (7.0.4)
|
35
|
+
actionview (= 7.0.4)
|
36
|
+
activesupport (= 7.0.4)
|
37
|
+
rack (~> 2.0, >= 2.2.0)
|
38
|
+
rack-test (>= 0.6.3)
|
39
|
+
rails-dom-testing (~> 2.0)
|
40
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
41
|
+
actiontext (7.0.4)
|
42
|
+
actionpack (= 7.0.4)
|
43
|
+
activerecord (= 7.0.4)
|
44
|
+
activestorage (= 7.0.4)
|
45
|
+
activesupport (= 7.0.4)
|
46
|
+
globalid (>= 0.6.0)
|
47
|
+
nokogiri (>= 1.8.5)
|
48
|
+
actionview (7.0.4)
|
49
|
+
activesupport (= 7.0.4)
|
50
|
+
builder (~> 3.1)
|
51
|
+
erubi (~> 1.4)
|
52
|
+
rails-dom-testing (~> 2.0)
|
53
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
54
|
+
activejob (7.0.4)
|
55
|
+
activesupport (= 7.0.4)
|
56
|
+
globalid (>= 0.3.6)
|
57
|
+
activemodel (7.0.4)
|
58
|
+
activesupport (= 7.0.4)
|
59
|
+
activerecord (7.0.4)
|
60
|
+
activemodel (= 7.0.4)
|
61
|
+
activesupport (= 7.0.4)
|
62
|
+
activestorage (7.0.4)
|
63
|
+
actionpack (= 7.0.4)
|
64
|
+
activejob (= 7.0.4)
|
65
|
+
activerecord (= 7.0.4)
|
66
|
+
activesupport (= 7.0.4)
|
67
|
+
marcel (~> 1.0)
|
68
|
+
mini_mime (>= 1.1.0)
|
69
|
+
activesupport (7.0.4)
|
70
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
71
|
+
i18n (>= 1.6, < 2)
|
72
|
+
minitest (>= 5.1)
|
73
|
+
tzinfo (~> 2.0)
|
74
|
+
ast (2.4.2)
|
75
|
+
builder (3.2.4)
|
76
|
+
concurrent-ruby (1.1.10)
|
77
|
+
crass (1.0.6)
|
78
|
+
diff-lcs (1.5.0)
|
79
|
+
erubi (1.11.0)
|
80
|
+
globalid (1.0.0)
|
81
|
+
activesupport (>= 5.0)
|
82
|
+
i18n (1.12.0)
|
83
|
+
concurrent-ruby (~> 1.0)
|
84
|
+
json (2.6.2)
|
85
|
+
loofah (2.19.0)
|
86
|
+
crass (~> 1.0.2)
|
87
|
+
nokogiri (>= 1.5.9)
|
88
|
+
mail (2.7.1)
|
89
|
+
mini_mime (>= 0.1.1)
|
90
|
+
marcel (1.0.2)
|
91
|
+
method_source (1.0.0)
|
92
|
+
mini_mime (1.1.2)
|
93
|
+
minitest (5.16.3)
|
94
|
+
net-imap (0.3.1)
|
95
|
+
net-protocol
|
96
|
+
net-pop (0.1.2)
|
97
|
+
net-protocol
|
98
|
+
net-protocol (0.1.3)
|
99
|
+
timeout
|
100
|
+
net-smtp (0.3.2)
|
101
|
+
net-protocol
|
102
|
+
nio4r (2.5.8)
|
103
|
+
nokogiri (1.13.8-x86_64-darwin)
|
104
|
+
racc (~> 1.4)
|
105
|
+
nokogiri (1.13.8-x86_64-linux)
|
106
|
+
racc (~> 1.4)
|
107
|
+
parallel (1.22.1)
|
108
|
+
parser (3.1.2.1)
|
109
|
+
ast (~> 2.4.1)
|
110
|
+
racc (1.6.0)
|
111
|
+
rack (2.2.4)
|
112
|
+
rack-test (2.0.2)
|
113
|
+
rack (>= 1.3)
|
114
|
+
rails (7.0.4)
|
115
|
+
actioncable (= 7.0.4)
|
116
|
+
actionmailbox (= 7.0.4)
|
117
|
+
actionmailer (= 7.0.4)
|
118
|
+
actionpack (= 7.0.4)
|
119
|
+
actiontext (= 7.0.4)
|
120
|
+
actionview (= 7.0.4)
|
121
|
+
activejob (= 7.0.4)
|
122
|
+
activemodel (= 7.0.4)
|
123
|
+
activerecord (= 7.0.4)
|
124
|
+
activestorage (= 7.0.4)
|
125
|
+
activesupport (= 7.0.4)
|
126
|
+
bundler (>= 1.15.0)
|
127
|
+
railties (= 7.0.4)
|
128
|
+
rails-dom-testing (2.0.3)
|
129
|
+
activesupport (>= 4.2.0)
|
130
|
+
nokogiri (>= 1.6)
|
131
|
+
rails-html-sanitizer (1.4.3)
|
132
|
+
loofah (~> 2.3)
|
133
|
+
railties (7.0.4)
|
134
|
+
actionpack (= 7.0.4)
|
135
|
+
activesupport (= 7.0.4)
|
136
|
+
method_source
|
137
|
+
rake (>= 12.2)
|
138
|
+
thor (~> 1.0)
|
139
|
+
zeitwerk (~> 2.5)
|
140
|
+
rainbow (3.1.1)
|
141
|
+
rake (13.0.6)
|
142
|
+
regexp_parser (2.6.0)
|
143
|
+
rexml (3.2.5)
|
144
|
+
rspec (3.11.0)
|
145
|
+
rspec-core (~> 3.11.0)
|
146
|
+
rspec-expectations (~> 3.11.0)
|
147
|
+
rspec-mocks (~> 3.11.0)
|
148
|
+
rspec-core (3.11.0)
|
149
|
+
rspec-support (~> 3.11.0)
|
150
|
+
rspec-expectations (3.11.1)
|
151
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
152
|
+
rspec-support (~> 3.11.0)
|
153
|
+
rspec-mocks (3.11.1)
|
154
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
155
|
+
rspec-support (~> 3.11.0)
|
156
|
+
rspec-support (3.11.1)
|
157
|
+
rubocop (1.36.0)
|
158
|
+
json (~> 2.3)
|
159
|
+
parallel (~> 1.10)
|
160
|
+
parser (>= 3.1.2.1)
|
161
|
+
rainbow (>= 2.2.2, < 4.0)
|
162
|
+
regexp_parser (>= 1.8, < 3.0)
|
163
|
+
rexml (>= 3.2.5, < 4.0)
|
164
|
+
rubocop-ast (>= 1.20.1, < 2.0)
|
165
|
+
ruby-progressbar (~> 1.7)
|
166
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
167
|
+
rubocop-ast (1.21.0)
|
168
|
+
parser (>= 3.1.1.0)
|
169
|
+
rubocop-rails (2.16.1)
|
170
|
+
activesupport (>= 4.2.0)
|
171
|
+
rack (>= 1.1)
|
172
|
+
rubocop (>= 1.33.0, < 2.0)
|
173
|
+
rubocop-rake (0.6.0)
|
174
|
+
rubocop (~> 1.0)
|
175
|
+
rubocop-rspec (2.13.2)
|
176
|
+
rubocop (~> 1.33)
|
177
|
+
ruby-progressbar (1.11.0)
|
178
|
+
thor (1.2.1)
|
179
|
+
timeout (0.3.0)
|
180
|
+
tzinfo (2.0.5)
|
181
|
+
concurrent-ruby (~> 1.0)
|
182
|
+
unicode-display_width (2.3.0)
|
183
|
+
webrick (1.7.0)
|
184
|
+
websocket-driver (0.7.5)
|
185
|
+
websocket-extensions (>= 0.1.0)
|
186
|
+
websocket-extensions (0.1.5)
|
187
|
+
yard (0.9.28)
|
188
|
+
webrick (~> 1.7.0)
|
189
|
+
zeitwerk (2.6.1)
|
190
|
+
|
191
|
+
PLATFORMS
|
192
|
+
x86_64-darwin-19
|
193
|
+
x86_64-linux
|
194
|
+
|
195
|
+
DEPENDENCIES
|
196
|
+
bundler
|
197
|
+
crown_marketplace_utils!
|
198
|
+
rails
|
199
|
+
rake (~> 13.0)
|
200
|
+
rspec (~> 3.0)
|
201
|
+
rubocop
|
202
|
+
rubocop-rails
|
203
|
+
rubocop-rake
|
204
|
+
rubocop-rspec
|
205
|
+
yard
|
206
|
+
|
207
|
+
BUNDLED WITH
|
208
|
+
2.3.12
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 tim-s-ccs
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# Crown Marketplace Utilities
|
2
|
+
|
3
|
+
![Test Status](https://github.com/tim-s-ccs/crown_marketplace_utils/actions/workflows/main.yml/badge.svg)
|
4
|
+
|
5
|
+
The Crown Marketplace Utilities gem was created for use in the Crown Marketplace projects at the Crown Commercial Service.
|
6
|
+
This project contains two applications (both use the Ruby on Rails framework):
|
7
|
+
- [Crown Marketplace](https://github.com/Crown-Commercial-Service/crown-marketplace)
|
8
|
+
- [Crown Marketplace Legacy](https://github.com/Crown-Commercial-Service/crown-marketplace-legacy)
|
9
|
+
|
10
|
+
As these projects share a lot of code it was thought useful to put that shared code into it's own gem, thus Crown Marketplace Utilities was created.
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Install the gem and add to the application's Gemfile by executing:
|
14
|
+
|
15
|
+
$ bundle add crown_marketplace_utils
|
16
|
+
|
17
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
18
|
+
|
19
|
+
$ gem install crown_marketplace_utils
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
To use this gem, simply at it to your Gemfile (as described above) and you will have access to the methods in the GovUkHelper once you restart your server.
|
24
|
+
|
25
|
+
Documentation for the helper methods can be found at [LINK TO RDOCS](#)
|
26
|
+
## Development
|
27
|
+
|
28
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
29
|
+
|
30
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
31
|
+
|
32
|
+
## Future plans
|
33
|
+
|
34
|
+
At the moment this Gem only contains view helpers. It would be good in the future to add other kinds of modules to this gem so that they can be shared and managed in one place.
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
|
38
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/tim-s-ccs/crown_marketplace_utils.
|
39
|
+
|
40
|
+
## Licence
|
41
|
+
|
42
|
+
The gem is available as open source under the terms of the [MIT Licence](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/crown_marketplace_utils/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'crown_marketplace_utils'
|
7
|
+
spec.version = CrownMarketplaceUtils::VERSION
|
8
|
+
spec.authors = ['tim-s-ccs']
|
9
|
+
spec.email = ['timothy.south@crowncommercial.gov.uk']
|
10
|
+
|
11
|
+
spec.summary = 'Gem containing shared code for the CCS Crown Marketplace projects'
|
12
|
+
spec.description = 'A Gem containing shared code for the CCS Crown Marketplace projects, for example view helpers'
|
13
|
+
spec.homepage = 'https://github.com/tim-s-ccs/crown_marketplace_utils'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
spec.required_ruby_version = '>= 2.7.0'
|
16
|
+
|
17
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
|
18
|
+
|
19
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
20
|
+
spec.metadata['source_code_uri'] = 'https://github.com/tim-s-ccs/crown_marketplace_utils'
|
21
|
+
spec.metadata['changelog_uri'] = 'https://github.com/tim-s-ccs/crown_marketplace_utils/blob/master/CHANGELOG.md'
|
22
|
+
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
+
spec.files = Dir.chdir(__dir__) do
|
26
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
28
|
+
end
|
29
|
+
end
|
30
|
+
spec.bindir = 'exe'
|
31
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
32
|
+
spec.require_paths = ['lib']
|
33
|
+
|
34
|
+
# Uncomment to register a new dependency of your gem
|
35
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
36
|
+
spec.add_development_dependency 'bundler'
|
37
|
+
spec.add_development_dependency 'rails'
|
38
|
+
spec.add_development_dependency 'rspec', '~> 3.2'
|
39
|
+
spec.add_development_dependency 'rubocop'
|
40
|
+
spec.add_development_dependency 'rubocop-rails'
|
41
|
+
spec.add_development_dependency 'rubocop-rake'
|
42
|
+
spec.add_development_dependency 'rubocop-rspec'
|
43
|
+
spec.add_development_dependency 'yard'
|
44
|
+
|
45
|
+
# For more information and examples about making a new gem, check out our
|
46
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
47
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
48
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails/engine'
|
4
|
+
|
5
|
+
module CrownMarketplaceUtils
|
6
|
+
class Engine < ::Rails::Engine
|
7
|
+
initializer 'crown_marketplace_utils.engine' do |_app|
|
8
|
+
ActiveSupport.on_load(:action_view) { include CrownMarketplaceUtils::GovUkHelper }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CrownMarketplaceUtils
|
4
|
+
module GovUkHelper
|
5
|
+
# = GOV.UK Details
|
6
|
+
#
|
7
|
+
# This helper is used for generating the details component from the
|
8
|
+
# {https://design-system.service.gov.uk/components/details GDS - Components - Details}
|
9
|
+
|
10
|
+
module Details
|
11
|
+
# Generates the HTML for the GOV.UK Details component
|
12
|
+
#
|
13
|
+
# @param summary_text [String] the summary text for the details element
|
14
|
+
# @param details_options [Hash] options that will be used in customising the HTML
|
15
|
+
#
|
16
|
+
# @option details_options [String] :classes additional CSS classes for the error message HTML
|
17
|
+
# @option details_options [Hash] :attributes ({ data: { module: 'govuk-details' } }) any additional attributes that will added as part of the HTML
|
18
|
+
#
|
19
|
+
# @yield HTML that will be contained within the 'govuk-details__text' div
|
20
|
+
#
|
21
|
+
# @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Details
|
22
|
+
# which can then be rendered on the page
|
23
|
+
|
24
|
+
def govuk_details(summary_text, **details_options, &block)
|
25
|
+
govuk_details_classes = ['govuk-details']
|
26
|
+
govuk_details_classes << details_options[:classes]
|
27
|
+
details_options[:attributes] ||= {}
|
28
|
+
(details_options[:attributes][:data] ||= {}).merge!({ module: 'govuk-details' })
|
29
|
+
|
30
|
+
tag.details(class: govuk_details_classes, **details_options[:attributes]) do
|
31
|
+
capture do
|
32
|
+
concat(tag.summary(tag.span(summary_text, class: 'govuk-details__summary-text'), class: 'govuk-details__summary'))
|
33
|
+
concat(tag.div(class: 'govuk-details__text', &block))
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CrownMarketplaceUtils
|
4
|
+
module GovUkHelper
|
5
|
+
# = GOV.UK Error Message
|
6
|
+
#
|
7
|
+
# This helper is used for generating the error message component from the
|
8
|
+
# {https://design-system.service.gov.uk/components/error-message GDS - Components - Error message}
|
9
|
+
|
10
|
+
module ErrorMessage
|
11
|
+
# Generates the HTML for the GOV.UK Error message component
|
12
|
+
#
|
13
|
+
# @param message [String] the message to be displayed
|
14
|
+
# @param attribute [String, Symbol] the attribute that has an error
|
15
|
+
# @param error_message_options [Hash] options that will be used in customising the HTML
|
16
|
+
#
|
17
|
+
# @option error_message_options [String] :classes additional CSS classes for the error message HTML
|
18
|
+
# @option error_message_options [String] :visually_hidden_text ('Error') visualy hidden text before the error message
|
19
|
+
# @option error_message_options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
|
20
|
+
#
|
21
|
+
# @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Error message
|
22
|
+
# which can then be rendered on the page
|
23
|
+
|
24
|
+
def govuk_error_message(message, attribute, **error_message_options)
|
25
|
+
class_list = ['govuk-error-message']
|
26
|
+
class_list << error_message_options[:classes]
|
27
|
+
visually_hidden_text = error_message_options[:visually_hidden_text] || 'Error'
|
28
|
+
|
29
|
+
tag.p(id: "#{attribute}-error", class: class_list, **(error_message_options[:attributes] || {})) do
|
30
|
+
capture do
|
31
|
+
concat(tag.span("#{visually_hidden_text}: ", class: 'govuk-visually-hidden')) if visually_hidden_text.present?
|
32
|
+
concat(message)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Generates the HTML for the GOV.UK Error message component using the error messages in an ActiveModel
|
38
|
+
#
|
39
|
+
# @param model [ActiveModel] model that will be used to find the error message
|
40
|
+
# @param attribute [String, Symbol] the attribute that has an error
|
41
|
+
# @param error_message_options [Hash] options that will be used in customising the HTML
|
42
|
+
#
|
43
|
+
# @option (see #govuk_error_message)
|
44
|
+
#
|
45
|
+
# @return (see #govuk_error_message)
|
46
|
+
|
47
|
+
def govuk_error_message_with_model(model, attribute, **error_message_options)
|
48
|
+
govuk_error_message(model.errors[attribute].first, attribute, **error_message_options)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CrownMarketplaceUtils
|
4
|
+
module GovUkHelper
|
5
|
+
# = GOV.UK Hint
|
6
|
+
#
|
7
|
+
# This helper is used for generating the hint text component from the Government Design Systems
|
8
|
+
|
9
|
+
module Hint
|
10
|
+
# Generates the HTML for the GOV.UK Hint component
|
11
|
+
#
|
12
|
+
# @param hint_text [String] the hint text
|
13
|
+
# @param hint_options [Hash] options that will be used in customising the HTML
|
14
|
+
#
|
15
|
+
# @option hint_options [String] :classes additional CSS classes for the hint HTML
|
16
|
+
# @option hint_options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
|
17
|
+
#
|
18
|
+
# @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Hint
|
19
|
+
# which can then be rendered on the page
|
20
|
+
|
21
|
+
def govuk_hint(hint_text, **hint_options)
|
22
|
+
govuk_hint_classes = ['govuk-hint']
|
23
|
+
govuk_hint_classes << hint_options[:classes]
|
24
|
+
|
25
|
+
tag.div(hint_text, class: govuk_hint_classes, **(hint_options[:attributes] || {}))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'gov_uk_helper/error_message'
|
4
|
+
require_relative 'gov_uk_helper/details'
|
5
|
+
require_relative 'gov_uk_helper/hint'
|
6
|
+
|
7
|
+
module CrownMarketplaceUtils
|
8
|
+
# This module loads in all the GOV.UK Helper methods
|
9
|
+
|
10
|
+
module GovUkHelper
|
11
|
+
include Details
|
12
|
+
include ErrorMessage
|
13
|
+
include Hint
|
14
|
+
end
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: crown_marketplace_utils
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0.beta.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- tim-s-ccs
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-10-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rails
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.2'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop-rails
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop-rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop-rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: yard
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: A Gem containing shared code for the CCS Crown Marketplace projects,
|
126
|
+
for example view helpers
|
127
|
+
email:
|
128
|
+
- timothy.south@crowncommercial.gov.uk
|
129
|
+
executables: []
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- ".rspec"
|
134
|
+
- ".rubocop.yml"
|
135
|
+
- CHANGELOG.md
|
136
|
+
- Gemfile
|
137
|
+
- Gemfile.lock
|
138
|
+
- LICENSE.txt
|
139
|
+
- README.md
|
140
|
+
- Rakefile
|
141
|
+
- crown_marketplace_utils.gemspec
|
142
|
+
- lib/crown_marketplace_utils.rb
|
143
|
+
- lib/crown_marketplace_utils/engine.rb
|
144
|
+
- lib/crown_marketplace_utils/gov_uk_helper.rb
|
145
|
+
- lib/crown_marketplace_utils/gov_uk_helper/details.rb
|
146
|
+
- lib/crown_marketplace_utils/gov_uk_helper/error_message.rb
|
147
|
+
- lib/crown_marketplace_utils/gov_uk_helper/hint.rb
|
148
|
+
- lib/crown_marketplace_utils/version.rb
|
149
|
+
- sig/crown_marketplace_utils.rbs
|
150
|
+
homepage: https://github.com/tim-s-ccs/crown_marketplace_utils
|
151
|
+
licenses:
|
152
|
+
- MIT
|
153
|
+
metadata:
|
154
|
+
homepage_uri: https://github.com/tim-s-ccs/crown_marketplace_utils
|
155
|
+
source_code_uri: https://github.com/tim-s-ccs/crown_marketplace_utils
|
156
|
+
changelog_uri: https://github.com/tim-s-ccs/crown_marketplace_utils/blob/master/CHANGELOG.md
|
157
|
+
rubygems_mfa_required: 'true'
|
158
|
+
post_install_message:
|
159
|
+
rdoc_options: []
|
160
|
+
require_paths:
|
161
|
+
- lib
|
162
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 2.7.0
|
167
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
168
|
+
requirements:
|
169
|
+
- - ">"
|
170
|
+
- !ruby/object:Gem::Version
|
171
|
+
version: 1.3.1
|
172
|
+
requirements: []
|
173
|
+
rubygems_version: 3.1.6
|
174
|
+
signing_key:
|
175
|
+
specification_version: 4
|
176
|
+
summary: Gem containing shared code for the CCS Crown Marketplace projects
|
177
|
+
test_files: []
|