govuk-diff-pages 0.1.0 → 0.1.1

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: d7461d5624d6438b64b89ee14db3a51a49c6789d
4
- data.tar.gz: 5575a5c4d1a74062a4d50c72dd6d29b2e2e05293
3
+ metadata.gz: d6e91c6499155a56c00e67d5aec312045363288b
4
+ data.tar.gz: 8ddb76d46f26a3f566aa880eba8d7ad7ebeeee87
5
5
  SHA512:
6
- metadata.gz: 9363e7d7ef669768b36d6acea6c8a2301c3dbe0d32dfc51d83f872a803d0a66003e28ceeb13759a4ac07dba798dcc58dece2a0c394ed933a8d7c1e59e6267e41
7
- data.tar.gz: abfc0131220eb9ad866edfd83f2b36e7ea958f86cbc4608be01483a9d7c2471ec46a4971c5a8e6d9057c3cdd40b725f2887c056688aad565a55c2e1434227fc3
6
+ metadata.gz: bc7d876b29885716acb47e807f6d5a3d867500eb6a800229df93bb7b2fa7687d276fc02c0485c8ee43a3bf199c68197c720134915fb37006ad7b08df05776a28
7
+ data.tar.gz: b9616840304cc3f400355ee354875e478610c5dd73c218ca0a143c40e0ac6918c67b84769c7075a743632d7f56119979891ec8be6deb56ed7218144c556edf81
data/.gitignore CHANGED
@@ -31,3 +31,4 @@ config/wraith.yaml
31
31
 
32
32
  # This is a gem
33
33
  Gemfile.lock
34
+ *.gem
@@ -0,0 +1,7 @@
1
+ ## 0.1.1
2
+
3
+ - Resolves issues with configured path resolution (#9)
4
+
5
+ ## 0.1.0
6
+
7
+ - Initial version
data/Gemfile CHANGED
@@ -1,5 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'wraith', git: 'git@github.com:alphagov/wraith.git', branch: 'psr'
4
+ gem 'govuk-lint', '~> 0.8'
4
5
 
5
6
  gemspec
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016 Ben Lovell
3
+ Copyright (c) 2016 Government Digital Service
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  This app provides a rake task to produce visual diffs as screenshots, HTML
4
4
  diffs and textual diffs of the production GOVUK website as compared with
5
- staging. Viewable as browser pages or directly in the terminal. It looks a the
5
+ staging. Viewable as browser pages or directly in the terminal. It looks at the
6
6
  10 most popular pages (this is configurable) of each document format.
7
7
 
8
8
  ## Screenshots
@@ -36,17 +36,19 @@ these pages.
36
36
 
37
37
  ### Running the application locally
38
38
 
39
- bundle exec rake diff
39
+ bundle exec rake diff
40
40
 
41
41
  ### Checking plain-text diffs
42
42
 
43
- bundle exec rake diff:text pages.yml
43
+ bundle exec rake diff:text pages.yml
44
44
 
45
45
  Where `pages.yml` is a YAML array of paths to compare. For example:
46
46
 
47
- - government/organisations/prime-ministers-office-10-downing-street
48
- - government/topical-events/budget-2016
49
- - topic/competition/regulatory-appeals-references
47
+ ```
48
+ - government/organisations/prime-ministers-office-10-downing-street
49
+ - government/topical-events/budget-2016
50
+ - topic/competition/regulatory-appeals-references
51
+ ```
50
52
 
51
53
  Text diffs can also specify the domains to compare using the `LEFT` and `RIGHT`
52
54
  environment variables. Defaulting to our `www-origin.staging` and
@@ -57,19 +59,19 @@ individual page files.
57
59
 
58
60
  ### Using the gem from an existing project
59
61
 
60
- # Gemfile
61
- gem 'govuk-diff-pages'
62
+ # Gemfile
63
+ gem 'govuk-diff-pages'
62
64
 
63
- # Rakefile
64
- load 'govuk/diff/pages/tasks/rakefile.rake'
65
+ # Rakefile
66
+ load 'govuk/diff/pages/tasks/rakefile.rake'
65
67
 
66
- # Shell
67
- bundle exec rake -T
68
+ # Shell
69
+ bundle exec rake -T
68
70
 
69
71
  ### Running the test suite
70
72
 
71
- bundle exec rake
73
+ bundle exec rake
72
74
 
73
75
  ## Licence
74
76
 
75
- [MIT License](LICENCE)
77
+ [MIT License](LICENCE.txt)
data/Rakefile CHANGED
@@ -6,8 +6,6 @@ load File.dirname(__FILE__) + "/lib/govuk/diff/pages/tasks/rakefile.rake"
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
  task default: :spec
8
8
 
9
- RSpec::Core::RakeTask.new(:spec)
10
-
11
9
  task :publish_gem do
12
10
  gem = GemPublisher.publish_if_updated("govuk-diff-pages.gemspec", :rubygems)
13
11
  puts "Published #{gem}" if gem
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Ben Lovell"]
10
10
  spec.email = ["benjamin.lovell@gmail.com"]
11
11
 
12
- spec.summary = %q{Visual and textual page diffing.}
13
- spec.description = %q{Diffs web pages both visually and textually.}
12
+ spec.summary = 'Visual and textual page diffing.'
13
+ spec.description = 'Diffs web pages both visually and textually.'
14
14
  spec.homepage = "https://github.com/alphagov/govuk-diff-pages"
15
15
  spec.license = "MIT"
16
16
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
@@ -0,0 +1,18 @@
1
+ #!/bin/bash -xe
2
+
3
+ # Gemfile.lock is not in source control because this is a gem
4
+ rm -f Gemfile.lock
5
+
6
+ git clean -fdx
7
+
8
+ bundle install --path "${HOME}/bundles/${JOB_NAME}"
9
+
10
+ if [[ ${GIT_BRANCH} != "origin/master" ]]; then
11
+ bundle exec govuk-lint-ruby --format clang
12
+ fi
13
+
14
+ bundle exec rake
15
+
16
+ if [[ -n "$PUBLISH_GEM" ]]; then
17
+ bundle exec rake publish_gem
18
+ fi
@@ -0,0 +1,20 @@
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ VENV_PATH="${HOME}/venv/${JOB_NAME}"
5
+
6
+ [ -x ${VENV_PATH}/bin/pip ] || virtualenv ${VENV_PATH}
7
+ . ${VENV_PATH}/bin/activate
8
+
9
+ pip install -q ghtools
10
+
11
+ REPO="alphagov/govuk-diff-pages"
12
+ gh-status "$REPO" "$GIT_COMMIT" pending -d "\"Build #${BUILD_NUMBER} is running on Jenkins\"" -u "$BUILD_URL" >/dev/null
13
+
14
+ if ./jenkins.sh; then
15
+ gh-status "$REPO" "$GIT_COMMIT" success -d "\"Build #${BUILD_NUMBER} succeeded on Jenkins\"" -u "$BUILD_URL" >/dev/null
16
+ exit 0
17
+ else
18
+ gh-status "$REPO" "$GIT_COMMIT" failure -d "\"Build #${BUILD_NUMBER} failed on Jenkins\"" -u "$BUILD_URL" >/dev/null
19
+ exit 1
20
+ fi
@@ -19,11 +19,21 @@ module Govuk
19
19
  end
20
20
 
21
21
  def self.govuk_pages_file
22
- File.expand_path(root_dir + '/../../config/govuk_pages.yml')
22
+ config_file 'govuk_pages.yml'
23
23
  end
24
24
 
25
25
  def self.wraith_config_file
26
- File.expand_path(root_dir + '/../../config/wraith.yaml')
26
+ config_file 'wraith.yaml'
27
+ end
28
+
29
+ def self.settings_file
30
+ config_file 'settings.yml'
31
+ end
32
+
33
+ private
34
+
35
+ def self.config_file(filename)
36
+ File.expand_path(root_dir + "/../../config/#{filename}")
27
37
  end
28
38
  end
29
39
  end
@@ -16,7 +16,7 @@ module Govuk
16
16
  if path_or_hash.is_a?(Hash)
17
17
  @config = populate_config(path_or_hash)
18
18
  else
19
- path_or_hash ||= "#{Govuk::Diff::Pages.root_dir}/config/settings.yml"
19
+ path_or_hash ||= Govuk::Diff::Pages.settings_file
20
20
  hash = YAML.load_file(path_or_hash)
21
21
  @config = populate_config(hash)
22
22
  end
@@ -43,6 +43,7 @@ module Govuk
43
43
  end
44
44
 
45
45
  private
46
+
46
47
  def populate_config(hash)
47
48
  config = OpenStruct.new
48
49
  hash.each do |key, value|
@@ -18,7 +18,7 @@ module Govuk
18
18
  def initialize(config)
19
19
  @config = config
20
20
  @template = File.read "#{Govuk::Diff::Pages.root_dir}/diff/pages/html_diff/assets/html_diff_template.erb"
21
- @diff_dir = "#{Govuk::Diff::Pages.root_dir}/#{@config.html_diff.directory}"
21
+ @diff_dir = File.join(Govuk::Diff::Pages.root_dir, '..', '..', @config.html_diff.directory)
22
22
  reset_html_diffs_dir
23
23
  @differing_pages = {}
24
24
  end
@@ -34,6 +34,7 @@ module Govuk
34
34
  end
35
35
 
36
36
  private
37
+
37
38
  def reset_html_diffs_dir
38
39
  Dir.mkdir(@diff_dir) unless Dir.exist?(@diff_dir)
39
40
  FileUtils.rm Dir.glob("#{@diff_dir}/*")
@@ -47,7 +48,7 @@ module Govuk
47
48
  end
48
49
 
49
50
  def html_diff_filename(base_path)
50
- "#{Govuk::Diff::Pages.root_dir}/#{@config.html_diff.directory}/#{safe_filename(base_path)}.html"
51
+ File.join(@diff_dir, "#{safe_filename(base_path)}.html")
51
52
  end
52
53
 
53
54
  def safe_filename(base_path)
@@ -22,9 +22,10 @@ module Govuk
22
22
  end
23
23
 
24
24
  private
25
+
25
26
  def create_gallery_page
26
27
  @result_hash = @differ.differing_pages
27
- shots_dir = "#{Govuk::Diff::Pages.root_dir}/#{@config.html_diff.directory}"
28
+ shots_dir = File.join(Govuk::Diff::Pages.root_dir, "..", "..", @config.html_diff.directory)
28
29
  Dir.mkdir(shots_dir) unless Dir.exist?(shots_dir)
29
30
  renderer = ERB.new(@gallery_template)
30
31
  File.open("#{shots_dir}/gallery.html", "w") do |fp|
@@ -19,6 +19,7 @@ module Govuk
19
19
  end
20
20
 
21
21
  private
22
+
22
23
  def print_results
23
24
  puts "Number of pages checked: #{@num_links}"
24
25
  puts " of which:"
@@ -6,7 +6,7 @@ module Govuk
6
6
  class PageIndexer
7
7
  def initialize
8
8
  @pages = []
9
- @config = AppConfig.new("#{Govuk::Diff::Pages.root_dir}/config/settings.yml")
9
+ @config = AppConfig.new(Govuk::Diff::Pages.settings_file)
10
10
  end
11
11
 
12
12
  def run
@@ -18,6 +18,7 @@ module Govuk
18
18
  end
19
19
 
20
20
  private
21
+
21
22
  def get_formats
22
23
  @formats = FormatSearcher.new(@config).run
23
24
  end
@@ -25,6 +25,7 @@ module Govuk
25
25
  end
26
26
 
27
27
  private
28
+
28
29
  def top_pages_for_format(format)
29
30
  result_set = JSON.parse(result_set_for_format(format))
30
31
  extract_top_govuk_pages(result_set)
@@ -4,7 +4,7 @@ namespace :diff do
4
4
  desc 'produce visual diffs'
5
5
  task visual: ['config:pre_flight_check'] do
6
6
  puts "---> Creating Visual Diffs"
7
- cmd = "wraith capture #{Govuk::Diff::Pages::WRAITH_CONFIG_FILE}"
7
+ cmd = "wraith capture #{Govuk::Diff::Pages.wraith_config_file}"
8
8
  puts cmd
9
9
  system cmd
10
10
  end
@@ -40,7 +40,7 @@ namespace :config do
40
40
  task :pre_flight_check do
41
41
  puts "Checking required packages installed."
42
42
  dependencies_present = true
43
- {imagemagick: 'convert', phantomjs: 'phantomjs'}.each do |package, binary|
43
+ { imagemagick: 'convert', phantomjs: 'phantomjs' }.each do |package, binary|
44
44
  print "#{package}..... "
45
45
  result = %x[ which #{binary} ]
46
46
  if result.empty?
@@ -1,7 +1,7 @@
1
1
  module Govuk
2
2
  module Diff
3
3
  module Pages
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
6
6
  end
7
7
  end
@@ -25,7 +25,7 @@ module Govuk
25
25
  end
26
26
 
27
27
  def save
28
- File.open(WRAITH_CONFIG_FILE, 'w') do |fp|
28
+ File.open(Govuk::Diff::Pages.wraith_config_file, 'w') do |fp|
29
29
  fp.puts YAML.dump(@wraith_config)
30
30
  end
31
31
  end
@@ -35,6 +35,7 @@ module Govuk
35
35
  end
36
36
 
37
37
  private
38
+
38
39
  def validate_hard_coded_pages
39
40
  errors = []
40
41
  @config.hard_coded_pages.to_h.each do |_key, url|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk-diff-pages
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Lovell
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-16 00:00:00.000000000 Z
11
+ date: 2016-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diffy
@@ -132,14 +132,16 @@ files:
132
132
  - ".gitignore"
133
133
  - ".rspec"
134
134
  - ".ruby-version"
135
+ - CHANGELOG.md
135
136
  - Gemfile
136
- - Gemfile.lock
137
137
  - LICENSE.txt
138
138
  - README.md
139
139
  - Rakefile
140
140
  - config/settings.yml
141
141
  - docs/screenshots/gallery.png
142
142
  - govuk-diff-pages.gemspec
143
+ - jenkins.sh
144
+ - jenkins_branches.sh
143
145
  - lib/govuk/diff/pages.rb
144
146
  - lib/govuk/diff/pages/app_config.rb
145
147
  - lib/govuk/diff/pages/format_searcher.rb