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 +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +1 -0
- data/LICENSE.txt +1 -1
- data/README.md +16 -14
- data/Rakefile +0 -2
- data/govuk-diff-pages.gemspec +2 -2
- data/jenkins.sh +18 -0
- data/jenkins_branches.sh +20 -0
- data/lib/govuk/diff/pages.rb +12 -2
- data/lib/govuk/diff/pages/app_config.rb +2 -1
- data/lib/govuk/diff/pages/html_diff/differ.rb +3 -2
- data/lib/govuk/diff/pages/html_diff/runner.rb +2 -1
- data/lib/govuk/diff/pages/link_checker.rb +1 -0
- data/lib/govuk/diff/pages/page_indexer.rb +2 -1
- data/lib/govuk/diff/pages/page_searcher.rb +1 -0
- data/lib/govuk/diff/pages/tasks/rakefile.rake +2 -2
- data/lib/govuk/diff/pages/version.rb +1 -1
- data/lib/govuk/diff/pages/wraith_config_generator.rb +2 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6e91c6499155a56c00e67d5aec312045363288b
|
4
|
+
data.tar.gz: 8ddb76d46f26a3f566aa880eba8d7ad7ebeeee87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc7d876b29885716acb47e807f6d5a3d867500eb6a800229df93bb7b2fa7687d276fc02c0485c8ee43a3bf199c68197c720134915fb37006ad7b08df05776a28
|
7
|
+
data.tar.gz: b9616840304cc3f400355ee354875e478610c5dd73c218ca0a143c40e0ac6918c67b84769c7075a743632d7f56119979891ec8be6deb56ed7218144c556edf81
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
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
|
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
|
-
|
39
|
+
bundle exec rake diff
|
40
40
|
|
41
41
|
### Checking plain-text diffs
|
42
42
|
|
43
|
-
|
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
|
-
|
48
|
-
|
49
|
-
|
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
|
-
|
61
|
-
|
62
|
+
# Gemfile
|
63
|
+
gem 'govuk-diff-pages'
|
62
64
|
|
63
|
-
|
64
|
-
|
65
|
+
# Rakefile
|
66
|
+
load 'govuk/diff/pages/tasks/rakefile.rake'
|
65
67
|
|
66
|
-
|
67
|
-
|
68
|
+
# Shell
|
69
|
+
bundle exec rake -T
|
68
70
|
|
69
71
|
### Running the test suite
|
70
72
|
|
71
|
-
|
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
|
data/govuk-diff-pages.gemspec
CHANGED
@@ -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 =
|
13
|
-
spec.description =
|
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)/}) }
|
data/jenkins.sh
ADDED
@@ -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
|
data/jenkins_branches.sh
ADDED
@@ -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
|
data/lib/govuk/diff/pages.rb
CHANGED
@@ -19,11 +19,21 @@ module Govuk
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.govuk_pages_file
|
22
|
-
|
22
|
+
config_file 'govuk_pages.yml'
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.wraith_config_file
|
26
|
-
|
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 ||=
|
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 =
|
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
|
-
"#{
|
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 =
|
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|
|
@@ -6,7 +6,7 @@ module Govuk
|
|
6
6
|
class PageIndexer
|
7
7
|
def initialize
|
8
8
|
@pages = []
|
9
|
-
@config = AppConfig.new(
|
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
|
@@ -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
|
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?
|
@@ -25,7 +25,7 @@ module Govuk
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def save
|
28
|
-
File.open(
|
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.
|
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-
|
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
|