sitediff 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/sitediff +2 -3
- data/lib/sitediff.rb +35 -24
- data/lib/sitediff/cache.rb +53 -47
- data/lib/sitediff/cli.rb +127 -114
- data/lib/sitediff/config.rb +35 -59
- data/lib/sitediff/config/creator.rb +95 -90
- data/lib/sitediff/crawler.rb +83 -72
- data/lib/sitediff/diff.rb +7 -5
- data/lib/sitediff/exception.rb +3 -1
- data/lib/sitediff/fetch.rb +47 -41
- data/lib/sitediff/files/html_report.html.erb +3 -0
- data/lib/sitediff/files/rules/drupal.yaml +36 -6
- data/lib/sitediff/result.rb +13 -11
- data/lib/sitediff/rules.rb +47 -47
- data/lib/sitediff/sanitize.rb +145 -150
- data/lib/sitediff/sanitize/dom_transform.rb +73 -74
- data/lib/sitediff/sanitize/regexp.rb +55 -52
- data/lib/sitediff/uriwrapper.rb +37 -26
- data/lib/sitediff/webserver.rb +80 -77
- data/lib/sitediff/webserver/resultserver.rb +117 -76
- metadata +32 -44
@@ -1,98 +1,139 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'sitediff'
|
2
4
|
require 'sitediff/webserver'
|
3
5
|
require 'erb'
|
4
6
|
|
5
7
|
class SiteDiff
|
6
|
-
class Webserver
|
7
|
-
class ResultServer < Webserver
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
class Webserver
|
9
|
+
class ResultServer < Webserver
|
10
|
+
# Display a page from the cache
|
11
|
+
class CacheServlet < WEBrick::HTTPServlet::AbstractServlet
|
12
|
+
def initialize(_server, cache)
|
13
|
+
@cache = cache
|
14
|
+
end
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
def do_GET(req, res)
|
17
|
+
path = req.path_info
|
18
|
+
(md = %r{^/([^/]+)(/.*)$}.match(path)) ||
|
19
|
+
raise(WEBrick::HTTPStatus::NotFound)
|
20
|
+
tag, path = *md.captures
|
21
|
+
(r = @cache.get(tag.to_sym, path)) ||
|
22
|
+
raise(WEBrick::HTTPStatus::NotFound)
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
+
raise WEBrick::HTTPStatus[r.error_code] if r.error_code
|
25
|
+
raise WEBrick::HTTPStatus::InternalServerError, r.error if r.error
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
res['content-type'] = 'text/html'
|
28
|
+
res.body = r.content
|
29
|
+
end
|
30
|
+
end
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
# Display two pages side by side
|
33
|
+
class SideBySideServlet < WEBrick::HTTPServlet::AbstractServlet
|
34
|
+
def initialize(_server, cache, settings)
|
35
|
+
@cache = cache
|
36
|
+
@settings = settings
|
37
|
+
end
|
38
|
+
|
39
|
+
def urls(path)
|
40
|
+
%w[before after].map do |tag|
|
41
|
+
base = @settings[tag]
|
42
|
+
base = "/cache/#{tag}" if @settings['cached'].include? tag
|
43
|
+
base + path
|
44
|
+
end
|
45
|
+
end
|
36
46
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
47
|
+
def do_GET(req, res)
|
48
|
+
path = req.path_info
|
49
|
+
before, after = *urls(path)
|
50
|
+
|
51
|
+
res['content-type'] = 'text/html'
|
52
|
+
erb = File.join(SiteDiff::FILES_DIR, 'sidebyside.html.erb')
|
53
|
+
res.body = ERB.new(File.read(erb)).result(binding)
|
54
|
+
end
|
42
55
|
end
|
43
|
-
end
|
44
56
|
|
45
|
-
|
46
|
-
|
47
|
-
|
57
|
+
# Run sitediff command from browser. Probably dangerous in general.
|
58
|
+
class RunServlet < WEBrick::HTTPServlet::AbstractServlet
|
59
|
+
def initialize(_server, dir)
|
60
|
+
@dir = dir
|
61
|
+
end
|
48
62
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
63
|
+
def do_GET(req, res)
|
64
|
+
path = req.path_info
|
65
|
+
if path != '/diff'
|
66
|
+
res['content-type'] = 'text/plain'
|
67
|
+
res.body = 'ERROR: Only /run/diff is supported by the /run API at the moment'
|
68
|
+
return
|
69
|
+
end
|
70
|
+
# Thor assumes only one command is called and some values like
|
71
|
+
# `options` are share across all SiteDiff::Cli instances so
|
72
|
+
# we can't just call SiteDiff::Cli.new().diff
|
73
|
+
# This is likely to go very wrong depending on how `sitediff serve`
|
74
|
+
# was actually called
|
75
|
+
cmd = "#{$PROGRAM_NAME} diff -C #{@dir} --cached=all"
|
76
|
+
system(cmd)
|
54
77
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
78
|
+
# Could also add a message to indicate success/failure
|
79
|
+
# But for the moment, all our files are static
|
80
|
+
res.set_redirect(WEBrick::HTTPStatus::Found,
|
81
|
+
"/files/#{SiteDiff::REPORT_FILE}")
|
82
|
+
end
|
83
|
+
end
|
60
84
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
"/files/#{SiteDiff::REPORT_FILE}")
|
67
|
-
end
|
85
|
+
def initialize(port, dir, opts = {})
|
86
|
+
unless File.exist?(File.join(dir, SiteDiff::SETTINGS_FILE))
|
87
|
+
raise SiteDiffException,
|
88
|
+
"Please run 'sitediff diff' before running 'sitediff serve'"
|
89
|
+
end
|
68
90
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
end
|
91
|
+
@settings = YAML.load_file(File.join(dir, SiteDiff::SETTINGS_FILE))
|
92
|
+
@cache = opts[:cache]
|
93
|
+
super(port, [dir], opts)
|
94
|
+
end
|
74
95
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
96
|
+
def server(opts)
|
97
|
+
dir = opts.delete(:DocumentRoot)
|
98
|
+
srv = super(opts)
|
99
|
+
srv.mount_proc('/') do |req, res|
|
100
|
+
if req.path == '/'
|
101
|
+
res.set_redirect(WEBrick::HTTPStatus::Found,
|
102
|
+
"/files/#{SiteDiff::REPORT_FILE}")
|
103
|
+
else
|
104
|
+
res.set_redirect(WEBrick::HTTPStatus::TemporaryRedirect,
|
105
|
+
"#{@settings['after']}#{req.path}")
|
106
|
+
end
|
107
|
+
end
|
81
108
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
109
|
+
srv.mount('/files', WEBrick::HTTPServlet::FileHandler, dir, true)
|
110
|
+
srv.mount('/cache', CacheServlet, @cache)
|
111
|
+
srv.mount('/sidebyside', SideBySideServlet, @cache, @settings)
|
112
|
+
srv.mount('/run', RunServlet, dir)
|
113
|
+
srv
|
114
|
+
end
|
88
115
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
116
|
+
def setup
|
117
|
+
super
|
118
|
+
root = uris.first
|
119
|
+
puts "Serving at #{root}"
|
120
|
+
open_in_browser(root) if @opts[:browse]
|
121
|
+
end
|
122
|
+
|
123
|
+
def open_in_browser(url)
|
124
|
+
commands = %w[xdg-open open]
|
125
|
+
cmd = commands.find { |c| which(c) }
|
126
|
+
system(cmd, url) if cmd
|
127
|
+
cmd
|
128
|
+
end
|
129
|
+
|
130
|
+
def which(cmd)
|
131
|
+
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
|
132
|
+
file = File.join(path, cmd)
|
133
|
+
return file if File.executable?(file)
|
134
|
+
end
|
135
|
+
nil
|
136
|
+
end
|
93
137
|
end
|
94
|
-
return nil
|
95
138
|
end
|
96
139
|
end
|
97
|
-
end
|
98
|
-
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sitediff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Dergachev
|
@@ -10,22 +10,36 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2018-12-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: pkg-config
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.1'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '1.1'
|
15
29
|
- !ruby/object:Gem::Dependency
|
16
30
|
name: thor
|
17
31
|
requirement: !ruby/object:Gem::Requirement
|
18
32
|
requirements:
|
19
33
|
- - "~>"
|
20
34
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.
|
35
|
+
version: 0.20.0
|
22
36
|
type: :runtime
|
23
37
|
prerelease: false
|
24
38
|
version_requirements: !ruby/object:Gem::Requirement
|
25
39
|
requirements:
|
26
40
|
- - "~>"
|
27
41
|
- !ruby/object:Gem::Version
|
28
|
-
version: 0.
|
42
|
+
version: 0.20.0
|
29
43
|
- !ruby/object:Gem::Dependency
|
30
44
|
name: typhoeus
|
31
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -46,89 +60,63 @@ dependencies:
|
|
46
60
|
requirements:
|
47
61
|
- - "~>"
|
48
62
|
- !ruby/object:Gem::Version
|
49
|
-
version:
|
50
|
-
- - "<"
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: '2.2'
|
63
|
+
version: 3.0.0
|
53
64
|
type: :runtime
|
54
65
|
prerelease: false
|
55
66
|
version_requirements: !ruby/object:Gem::Requirement
|
56
67
|
requirements:
|
57
68
|
- - "~>"
|
58
69
|
- !ruby/object:Gem::Version
|
59
|
-
version:
|
60
|
-
- - "<"
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: '2.2'
|
70
|
+
version: 3.0.0
|
63
71
|
- !ruby/object:Gem::Dependency
|
64
72
|
name: nokogiri
|
65
73
|
requirement: !ruby/object:Gem::Requirement
|
66
74
|
requirements:
|
67
75
|
- - "~>"
|
68
76
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
70
|
-
- - "<"
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
version: '1.7'
|
77
|
+
version: 1.8.2
|
73
78
|
type: :runtime
|
74
79
|
prerelease: false
|
75
80
|
version_requirements: !ruby/object:Gem::Requirement
|
76
81
|
requirements:
|
77
82
|
- - "~>"
|
78
83
|
- !ruby/object:Gem::Version
|
79
|
-
version:
|
80
|
-
- - "<"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '1.7'
|
84
|
+
version: 1.8.2
|
83
85
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
86
|
+
name: addressable
|
85
87
|
requirement: !ruby/object:Gem::Requirement
|
86
88
|
requirements:
|
87
89
|
- - "~>"
|
88
90
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
90
|
-
- - "<"
|
91
|
-
- !ruby/object:Gem::Version
|
92
|
-
version: 3.0.5
|
91
|
+
version: 2.5.2
|
93
92
|
type: :runtime
|
94
93
|
prerelease: false
|
95
94
|
version_requirements: !ruby/object:Gem::Requirement
|
96
95
|
requirements:
|
97
96
|
- - "~>"
|
98
97
|
- !ruby/object:Gem::Version
|
99
|
-
version:
|
100
|
-
- - "<"
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: 3.0.5
|
98
|
+
version: 2.5.2
|
103
99
|
- !ruby/object:Gem::Dependency
|
104
|
-
name:
|
100
|
+
name: diffy
|
105
101
|
requirement: !ruby/object:Gem::Requirement
|
106
102
|
requirements:
|
107
103
|
- - "~>"
|
108
104
|
- !ruby/object:Gem::Version
|
109
|
-
version:
|
110
|
-
- - "<"
|
111
|
-
- !ruby/object:Gem::Version
|
112
|
-
version: '2.5'
|
105
|
+
version: 3.2.0
|
113
106
|
type: :runtime
|
114
107
|
prerelease: false
|
115
108
|
version_requirements: !ruby/object:Gem::Requirement
|
116
109
|
requirements:
|
117
110
|
- - "~>"
|
118
111
|
- !ruby/object:Gem::Version
|
119
|
-
version:
|
120
|
-
|
121
|
-
|
122
|
-
version: '2.5'
|
123
|
-
description: 'SiteDiff makes it easy to see differences between two versions of a
|
124
|
-
website. It accepts a set of paths to compare two versions of the site together
|
112
|
+
version: 3.2.0
|
113
|
+
description: " SiteDiff makes it easy to see differences between two versions of
|
114
|
+
a website. It accepts a set of paths to compare two versions of the site together
|
125
115
|
with potential normalization/sanitization rules. From the provided paths and configuration
|
126
116
|
SiteDiff generates an HTML report of all the status of HTML comparison between the
|
127
117
|
given paths together with a readable diff-like HTML for each specified path containing
|
128
118
|
the differences between the two versions of the site. It is useful tool for QAing
|
129
|
-
re-deployments, site upgrades, etc
|
130
|
-
|
131
|
-
'
|
119
|
+
re-deployments, site upgrades, etc.\n"
|
132
120
|
email: alex@evolvingweb.ca
|
133
121
|
executables:
|
134
122
|
- sitediff
|
@@ -171,7 +159,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
171
159
|
requirements:
|
172
160
|
- - ">="
|
173
161
|
- !ruby/object:Gem::Version
|
174
|
-
version:
|
162
|
+
version: '2.3'
|
175
163
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
176
164
|
requirements:
|
177
165
|
- - ">="
|