govuk_schemas 2.1.0 → 2.1.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
  SHA1:
3
- metadata.gz: ac6896c57c2532adcb41b53a7299bc0199aee11e
4
- data.tar.gz: 8aae891ff22402cff6c858b33490edaaaf326a7b
3
+ metadata.gz: 7ae3fcbab8090c1fc21b77822f02f3d13ad1e6b7
4
+ data.tar.gz: e417e9c8d4ee30225e1e55c9852af054692f1c45
5
5
  SHA512:
6
- metadata.gz: fb53487240a352345f504c932aee0b4895ae5aa8fb71aa91709563983fa3a6c0a06767009f8798dc126952655d865e4cff39ab1a242cba294e05d0b19ed97ad1
7
- data.tar.gz: dd87037cb8ea2887b1397ecf55ccdbe45654067b4d834c3a854c7cab36eb9cc54260d64b0e43a31d6abdc302e47bdcfcbe507952722aaac6fbfa8ec979b77fb9
6
+ metadata.gz: 5e87fd5bc7f3c42d7e6cf1193361a9056b6da54d14c7579173ffa3c4b94ea04c932194fe597a84930dcced18c893032dee84834afad9b20e14b8a2cf147b5ed1
7
+ data.tar.gz: e803c13e394c7778836a8c87c416de4a38d81f75ab79d44659b1caf0adc4bff314ee2986f59b4e8e9480ea43543aadd9e567b6f30d538d9e9775a61c20332f16
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 2.1.1
2
+
3
+ * Support for a new regex in GOV.UK content schemas
4
+
1
5
  # 2.1.0
2
6
 
3
7
  * Add `Schema.schema_names` to return all schema names
data/Jenkinsfile ADDED
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env groovy
2
+
3
+ REPOSITORY = 'govuk_schemas'
4
+
5
+ node {
6
+ def govuk = load '/var/lib/jenkins/groovy_scripts/govuk_jenkinslib.groovy'
7
+
8
+ try {
9
+ stage('Checkout') {
10
+ checkout scm
11
+ }
12
+
13
+ stage('Clean') {
14
+ govuk.cleanupGit()
15
+ govuk.mergeMasterBranch()
16
+ }
17
+
18
+ stage("Set up content schema dependency") {
19
+ govuk.contentSchemaDependency()
20
+ }
21
+
22
+ stage('Bundle') {
23
+ echo 'Bundling'
24
+ sh("bundle install --path ${JENKINS_HOME}/bundles/${JOB_NAME}")
25
+ }
26
+
27
+ stage('Linter') {
28
+ govuk.rubyLinter()
29
+ }
30
+
31
+ stage('Tests') {
32
+ govuk.setEnvar('RAILS_ENV', 'test')
33
+ govuk.runTests('spec')
34
+ }
35
+
36
+ if(env.BRANCH_NAME == "master") {
37
+ stage('Publish Gem') {
38
+ govuk.publishGem(REPOSITORY, env.BRANCH_NAME)
39
+ }
40
+ }
41
+
42
+ } catch (e) {
43
+ currentBuild.result = 'FAILED'
44
+ step([$class: 'Mailer',
45
+ notifyEveryUnstableBuild: true,
46
+ recipients: 'govuk-ci-notifications@digital.cabinet-office.gov.uk',
47
+ sendToIndividuals: true])
48
+ throw e
49
+ }
50
+ }
data/README.md CHANGED
@@ -37,10 +37,6 @@ To rebuild the documentation, run:
37
37
 
38
38
  $ bundle exec rake yard
39
39
 
40
- ## Releasing the gem
41
-
42
- This gem uses [gem_publisher](https://github.com/alphagov/gem_publisher). Updating the [version](lib/govuk_schemas/version.rb) will automatically release a new version to Rubygems.
43
-
44
40
  ## License
45
41
 
46
42
  The gem is available as open source under the terms of the [MIT License](LICENSE.md).
data/Rakefile CHANGED
@@ -1,19 +1,11 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
- require "gem_publisher"
4
3
  require "yard"
5
4
 
6
5
  RSpec::Core::RakeTask.new(:spec)
7
6
 
8
7
  task default: [:spec]
9
8
 
10
- desc "Publish gem to RubyGems"
11
- task :publish_gem do |_t|
12
- published_gem = GemPublisher.publish_if_updated("govuk_schemas.gemspec", :rubygems)
13
- puts "Published #{published_gem}" if published_gem
14
- end
15
-
16
-
17
9
  YARD::Rake::YardocTask.new do |t|
18
10
  t.options = ['--no-private', '--markup', 'markdown', '--output-dir', 'docs']
19
11
  end
@@ -24,7 +24,6 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.add_development_dependency "rake", "~> 10.0"
26
26
  spec.add_development_dependency "rspec", "~> 3.4"
27
- spec.add_development_dependency "gem_publisher", "~> 1.5.0"
28
27
  spec.add_development_dependency "pry-byebug"
29
28
  spec.add_development_dependency "govuk-lint", "~> 1.2.1"
30
29
  spec.add_development_dependency "yard", "~> 0.8"
@@ -1,3 +1,5 @@
1
+ require 'securerandom'
2
+
1
3
  module GovukSchemas
2
4
  # @private
3
5
  module Random
@@ -28,9 +30,11 @@ module GovukSchemas
28
30
  "/" + rand(1..5).times.map { SecureRandom.uuid }.join('/')
29
31
  end
30
32
 
31
- def govuk_campaign_url
32
- subdomain = rand(1..5).times.map { ('a'..'z').to_a.sample(rand(1..5)).join }.join('.')
33
- "https://#{subdomain}.campaign.gov.uk#{base_path}"
33
+ def govuk_subdomain_url
34
+ subdomain = rand(2..4).times.map {
35
+ ('a'..'z').to_a.sample(rand(3..8)).join
36
+ }.join('.')
37
+ "https://#{subdomain}.gov.uk#{base_path}"
34
38
  end
35
39
 
36
40
  def string(minimum_chars = nil, maximum_chars = nil)
@@ -72,7 +76,9 @@ module GovukSchemas
72
76
  when "^/(([a-zA-Z0-9._~!$&'()*+,;=:@-]|%[0-9a-fA-F]{2})+(/([a-zA-Z0-9._~!$&'()*+,;=:@-]|%[0-9a-fA-F]{2})*)*)?(\\?([a-zA-Z0-9._~!$&'()*+,;=:@-]|%[0-9a-fA-F]{2})*)?(#([a-zA-Z0-9._~!$&'()*+,;=:@-]|%[0-9a-fA-F]{2})*)?$"
73
77
  base_path
74
78
  when "^https://([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[A-Za-z0-9])?\\.)+campaign\\.gov\\.uk(/(([a-zA-Z0-9._~!$&'()*+,;=:@-]|%[0-9a-fA-F]{2})+(/([a-zA-Z0-9._~!$&'()*+,;=:@-]|%[0-9a-fA-F]{2})*)*)?(\\?([a-zA-Z0-9._~!$&'()*+,;=:@-]|%[0-9a-fA-F]{2})*)?(#([a-zA-Z0-9._~!$&'()*+,;=:@-]|%[0-9a-fA-F]{2})*)?)?$"
75
- govuk_campaign_url
79
+ govuk_subdomain_url
80
+ when "^https://([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[A-Za-z0-9])?\\.)*gov\\.uk(/(([a-zA-Z0-9._~!$&'()*+,;=:@-]|%[0-9a-fA-F]{2})+(/([a-zA-Z0-9._~!$&'()*+,;=:@-]|%[0-9a-fA-F]{2})*)*)?(\\?([a-zA-Z0-9._~!$&'()*+,;=:@-]|%[0-9a-fA-F]{2})*)?(#([a-zA-Z0-9._~!$&'()*+,;=:@-]|%[0-9a-fA-F]{2})*)?)?$"
81
+ govuk_subdomain_url
76
82
  when '[a-z0-9\-_]'
77
83
  "#{SecureRandom.hex}-#{SecureRandom.hex}"
78
84
  else
@@ -9,8 +9,8 @@ module GovukSchemas
9
9
  #
10
10
  # For example:
11
11
  #
12
- # schema = GovukSchemas::Schema.find("detailed_guide", schema_type: "frontend")
13
- # GovukSchemas::RandomExample.new(schema).payload
12
+ # schema = GovukSchemas::Schema.find(frontend_schema: "detailed_guide")
13
+ # GovukSchemas::RandomExample.new(schema: schema).payload
14
14
  #
15
15
  # @param [Hash] schema A JSON schema.
16
16
  # @return [GovukSchemas::RandomExample]
@@ -1,4 +1,4 @@
1
1
  module GovukSchemas
2
2
  # @private
3
- VERSION = "2.1.0".freeze
3
+ VERSION = "2.1.1".freeze
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_schemas
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-14 00:00:00.000000000 Z
11
+ date: 2017-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json-schema
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.4'
55
- - !ruby/object:Gem::Dependency
56
- name: gem_publisher
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: 1.5.0
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: 1.5.0
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: pry-byebug
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -121,6 +107,7 @@ files:
121
107
  - ".ruby-version"
122
108
  - CHANGELOG.md
123
109
  - Gemfile
110
+ - Jenkinsfile
124
111
  - LICENSE.md
125
112
  - README.md
126
113
  - Rakefile
@@ -143,8 +130,6 @@ files:
143
130
  - docs/method_list.html
144
131
  - docs/top-level-namespace.html
145
132
  - govuk_schemas.gemspec
146
- - jenkins-schema.sh
147
- - jenkins.sh
148
133
  - lib/govuk_schemas.rb
149
134
  - lib/govuk_schemas/example.rb
150
135
  - lib/govuk_schemas/random.rb
data/jenkins-schema.sh DELETED
@@ -1,6 +0,0 @@
1
- #!/bin/bash
2
-
3
- export REPO_NAME="alphagov/govuk-content-schemas"
4
- export CONTEXT_MESSAGE="Verify govuk_schemas_gem against content schemas"
5
-
6
- exec ./jenkins.sh
data/jenkins.sh DELETED
@@ -1,74 +0,0 @@
1
- #!/bin/bash
2
-
3
- set -e
4
-
5
- REPO_NAME=${REPO_NAME:-"alphagov/govuk_schemas_gem"}
6
- CONTEXT_MESSAGE=${CONTEXT_MESSAGE:-"default"}
7
- GH_STATUS_GIT_COMMIT=${SCHEMA_GIT_COMMIT:-${GIT_COMMIT}}
8
-
9
- function github_status {
10
- REPO_NAME="$1"
11
- STATUS="$2"
12
- MESSAGE="$3"
13
- gh-status "$REPO_NAME" "$GH_STATUS_GIT_COMMIT" "$STATUS" -d "Build #${BUILD_NUMBER} ${MESSAGE}" -u "$BUILD_URL" -c "$CONTEXT_MESSAGE" >/dev/null
14
- }
15
-
16
- function error_handler {
17
- trap - ERR # disable error trap to avoid recursion
18
- local parent_lineno="$1"
19
- local message="$2"
20
- local code="${3:-1}"
21
- if [[ -n "$message" ]] ; then
22
- echo "Error on or near line ${parent_lineno}: ${message}; exiting with status ${code}"
23
- else
24
- echo "Error on or near line ${parent_lineno}; exiting with status ${code}"
25
- fi
26
- github_status "$REPO_NAME" error "errored on Jenkins"
27
- exit "${code}"
28
- }
29
-
30
- trap 'error_handler ${LINENO}' ERR
31
- github_status "$REPO_NAME" pending "is running on Jenkins"
32
-
33
- # Cleanup anything left from previous test runs
34
- git clean -fdx
35
-
36
- # Try to merge master into the current branch, and abort if it doesn't exit
37
- # cleanly (ie there are conflicts). This will be a noop if the current branch
38
- # is master.
39
- git merge --no-commit origin/master || git merge --abort
40
-
41
- echo "Running ruby linter"
42
- bundle install --path "${HOME}/bundles/${JOB_NAME}"
43
- bundle exec govuk-lint-ruby \
44
- --format html --out rubocop-${GIT_COMMIT}.html \
45
- --format clang
46
-
47
- # Clone govuk-content-schemas depedency for contract tests
48
- rm -rf /tmp/govuk-content-schemas
49
- git clone git@github.com:alphagov/govuk-content-schemas.git /tmp/govuk-content-schemas
50
- (
51
- cd /tmp/govuk-content-schemas
52
- git checkout ${SCHEMA_GIT_COMMIT:-"master"}
53
- )
54
- export GOVUK_CONTENT_SCHEMAS_PATH=/tmp/govuk-content-schemas
55
-
56
- # Bundle and run tests against multiple ruby versions
57
- for version in 2.3.1; do
58
- rm -f Gemfile.lock
59
- export RBENV_VERSION=$version
60
- echo "Running tests under ruby $version"
61
- bundle install --path "${HOME}/bundles/${JOB_NAME}"
62
- if ! bundle exec rake ${TEST_TASK:-"default"}; then
63
- github_status "$REPO_NAME" failure "failed on Jenkins"
64
- exit 1
65
- fi
66
- done
67
- unset RBENV_VERSION
68
-
69
- if [[ -n "$PUBLISH_GEM" ]]; then
70
- bundle install --path "${HOME}/bundles/${JOB_NAME}"
71
- bundle exec rake publish_gem --trace
72
- fi
73
-
74
- github_status "$REPO_NAME" success "succeeded on Jenkins"