machinery-tool 1.21.0 → 1.22.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.git_revision +1 -1
- data/NEWS +8 -0
- data/html/index.html.haml +8 -7
- data/html/partials/changed_config_files.html.haml +1 -1
- data/html/partials/changed_managed_files.html.haml +1 -1
- data/html/partials/unmanaged_files.html.haml +2 -2
- data/lib/cli.rb +26 -4
- data/lib/diff_widget.rb +73 -0
- data/lib/dpkg_database.rb +16 -1
- data/lib/haml_helpers.rb +60 -0
- data/lib/kiwi_config.rb +7 -0
- data/lib/machinery.rb +3 -0
- data/lib/man_task.rb +3 -2
- data/lib/move_task.rb +1 -0
- data/lib/remote_system.rb +4 -0
- data/lib/server.rb +2 -105
- data/lib/static_html.rb +75 -0
- data/lib/system.rb +2 -1
- data/lib/system_description.rb +10 -0
- data/lib/version.rb +1 -1
- data/machinery-helper/version.go +1 -1
- data/man/generated/machinery.1.gz +0 -0
- data/manual/docs/README.md +8 -16
- data/manual/docs/docs.md +42 -4
- data/manual/docs/index.html +6 -2
- data/manual/docs/machinery-analyze.1.md +6 -10
- data/manual/docs/machinery-build.1.md +7 -11
- data/manual/docs/machinery-compare.1.md +5 -10
- data/manual/docs/machinery-config.1.md +4 -7
- data/manual/docs/machinery-copy.1.md +5 -10
- data/manual/docs/machinery-deploy.1.md +8 -12
- data/manual/docs/machinery-export-autoyast.1.md +10 -17
- data/manual/docs/machinery-export-html.1.md +32 -0
- data/manual/docs/machinery-export-kiwi.1.md +7 -12
- data/manual/docs/{machinery-inspect-docker.1.md → machinery-inspect-container.1.md} +10 -15
- data/manual/docs/machinery-inspect.1.md +10 -15
- data/manual/docs/machinery-list.1.md +4 -8
- data/manual/docs/machinery-man.1.md +4 -6
- data/manual/docs/machinery-move.1.md +4 -8
- data/manual/docs/machinery-remove.1.md +5 -10
- data/manual/docs/machinery-serve.1.md +5 -9
- data/manual/docs/machinery-show.1.md +7 -11
- data/manual/docs/machinery-upgrade-format.1.md +5 -9
- data/manual/docs/machinery-validate.1.md +4 -8
- data/manual/docs/machinery_main_general.1.md +33 -51
- data/manual/docs/machinery_main_scopes.1.md +13 -14
- data/manual/docs/{machinery_security_implications.1.md → machinery_main_security_implications.1.md} +15 -15
- data/manual/docs/machinery_main_usecases.1.md +2 -30
- data/manual/mkdocs.yml +9 -9
- data/manual/site/docs/index.html +71 -25
- data/manual/site/index.html +6 -2
- data/manual/site/machinery-analyze.1/index.html +34 -27
- data/manual/site/machinery-build.1/index.html +35 -28
- data/manual/site/machinery-compare.1/index.html +33 -26
- data/manual/site/machinery-config.1/index.html +32 -25
- data/manual/site/machinery-copy.1/index.html +33 -27
- data/manual/site/machinery-deploy.1/index.html +36 -29
- data/manual/site/machinery-export-autoyast.1/index.html +38 -32
- data/manual/site/machinery-export-html.1/index.html +175 -0
- data/manual/site/machinery-export-kiwi.1/index.html +35 -28
- data/manual/site/machinery-inspect-container.1/index.html +249 -0
- data/manual/site/machinery-inspect.1/index.html +38 -31
- data/manual/site/machinery-list.1/index.html +32 -25
- data/manual/site/machinery-man.1/index.html +32 -26
- data/manual/site/machinery-move.1/index.html +32 -25
- data/manual/site/machinery-remove.1/index.html +33 -26
- data/manual/site/machinery-serve.1/index.html +33 -26
- data/manual/site/machinery-show.1/index.html +35 -28
- data/manual/site/machinery-upgrade-format.1/index.html +33 -26
- data/manual/site/machinery-validate.1/index.html +32 -25
- data/manual/site/machinery_main_general.1/index.html +63 -70
- data/manual/site/machinery_main_scopes.1/index.html +41 -36
- data/manual/site/machinery_main_security_implications.1/index.html +228 -0
- data/manual/site/machinery_main_usecases.1/index.html +30 -48
- data/manual/site/mkdocs/search_index.json +246 -201
- data/manual/site/sitemap.xml +40 -30
- data/plugins/os/os_inspector.rb +1 -1
- data/plugins/packages/packages.yml +1 -1
- data/plugins/patterns/patterns.yml +2 -5
- data/plugins/repositories/repositories.yml +2 -2
- data/plugins/unmanaged_files/unmanaged_files.yml +3 -3
- data/plugins/unmanaged_files/unmanaged_files_renderer.rb +1 -1
- metadata +11 -5
- data/manual/docs/subcommand-template.1.md +0 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33037a49f9cd5990355d5c07ad549d035542379b
|
4
|
+
data.tar.gz: ea404796918a26ef4e0571a568bf60045d4dbd0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c93f3958a8423294a50709550983a336fc65ab4f9588f1a5957a4d6c3ed10eda6d899986941194694525f8de96a28b3e5b7095e7984d3565bcfee6c24df7e6d
|
7
|
+
data.tar.gz: e7a29850ca4d1891e2bf1719870fe24a9f37312d0dcd3814e69274f2a012c9ed1e3fcbdf1c9356fb220842da15f1a3e5274644e66d1f7e49b9ccbc026bf6bceb
|
data/.git_revision
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
964505b0908b5f767f7fb74053b19884ae2e0954
|
data/NEWS
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
# Machinery Release Notes
|
2
2
|
|
3
3
|
|
4
|
+
## Version 1.22.0 - Thu Oct 06 17:03:33 CEST 2016 - thardeck@suse.de
|
5
|
+
|
6
|
+
* Add remaining systemd service states in Kiwi export (gh#SUSE/machinery#2122)
|
7
|
+
* Add export of system descriptions as HTML page. This provides an offline
|
8
|
+
view of descrptions (gh#SUSE/machinery#2119)
|
9
|
+
* Fix changed files inspections on dpkg systems in case of diversions
|
10
|
+
(gh#SUSE/machinery#2138)
|
11
|
+
|
4
12
|
## Version 1.21.0 - Tue Jun 21 16:28:31 CEST 2016 - thardeck@suse.de
|
5
13
|
|
6
14
|
* Add attribute in patterns scope to identify the patterns manager
|
data/html/index.html.haml
CHANGED
@@ -30,11 +30,12 @@
|
|
30
30
|
.spinner
|
31
31
|
%textarea#file-modal-file-content{ "readonly" => "true" }
|
32
32
|
#file-modal-error{ "style" => "display: none" }
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
33
|
+
- unless @static_html
|
34
|
+
.modal-footer
|
35
|
+
%a.btn.btn-success#file-modal-download-link{ "target" => "_blank" }
|
36
|
+
Download
|
37
|
+
%button.btn.btn-primary{ "type" => "button", "data-dismiss" => "modal" }
|
38
|
+
Close
|
38
39
|
|
39
40
|
#file_popover{ :style => "display: none" }
|
40
41
|
.header
|
@@ -42,11 +43,11 @@
|
|
42
43
|
.body
|
43
44
|
%textarea.content
|
44
45
|
|
45
|
-
= render_partial "description_selector"
|
46
|
+
= render_partial "description_selector" unless @static_html
|
46
47
|
|
47
48
|
.container-fluid
|
48
49
|
#nav-bar
|
49
|
-
= render_partial "nav_bar"
|
50
|
+
= render_partial "nav_bar" unless @static_html
|
50
51
|
.row.toolbar
|
51
52
|
%small.col-xs-1
|
52
53
|
%a#expand-all{ :href => "#", :style => "display: none" }
|
@@ -26,7 +26,7 @@
|
|
26
26
|
%th.medium Group
|
27
27
|
%th.medium Size
|
28
28
|
- if unmanaged_files.has_subdir_counts?
|
29
|
-
%th.medium
|
29
|
+
%th.medium Directories
|
30
30
|
%th.medium Files in Directory
|
31
31
|
- else
|
32
32
|
%th.medium File Objects
|
@@ -34,7 +34,7 @@
|
|
34
34
|
- unmanaged_files.each do |file|
|
35
35
|
%tr
|
36
36
|
%td
|
37
|
-
- if file.on_disk?
|
37
|
+
- if file.on_disk? && !@static_html
|
38
38
|
%a.file-download{ href: "#" }
|
39
39
|
= file.name
|
40
40
|
- else
|
data/lib/cli.rb
CHANGED
@@ -471,7 +471,7 @@ class Cli
|
|
471
471
|
c.flag ["kiwi-dir", :k], type: String, required: true,
|
472
472
|
desc: "Location where the description will be stored", arg_name: "DIRECTORY"
|
473
473
|
c.switch :force, default_value: false, required: false, negatable: false,
|
474
|
-
desc: "Overwrite existing
|
474
|
+
desc: "Overwrite existing directory"
|
475
475
|
|
476
476
|
c.action do |global_options,options,args|
|
477
477
|
name = shift_arg(args, "NAME")
|
@@ -498,7 +498,7 @@ class Cli
|
|
498
498
|
c.flag ["autoyast-dir", :a], type: String, required: true,
|
499
499
|
desc: "Location where the autoyast profile will be stored", arg_name: "DIRECTORY"
|
500
500
|
c.switch :force, default_value: false, required: false, negatable: false,
|
501
|
-
desc: "Overwrite existing
|
501
|
+
desc: "Overwrite existing directory"
|
502
502
|
|
503
503
|
c.action do |_global_options, options, args|
|
504
504
|
name = shift_arg(args, "NAME")
|
@@ -513,11 +513,34 @@ class Cli
|
|
513
513
|
end
|
514
514
|
end
|
515
515
|
|
516
|
+
desc "Export static HTML view of a system description"
|
517
|
+
long_desc <<-LONGDESC
|
518
|
+
Export system description as HTML
|
519
|
+
|
520
|
+
The HTML view will be placed in a subdirectory at the given location by the 'html-dir'
|
521
|
+
option.
|
522
|
+
LONGDESC
|
523
|
+
arg "NAME"
|
524
|
+
command "export-html" do |c|
|
525
|
+
c.flag ["html-dir", :d], type: String, required: true,
|
526
|
+
desc: "Location where the HTML view will be stored", arg_name: "DIRECTORY"
|
527
|
+
c.switch :force, default_value: false, required: false, negatable: false,
|
528
|
+
desc: "Overwrite existing directory"
|
529
|
+
|
530
|
+
c.action do |_global_options, options, args|
|
531
|
+
name = shift_arg(args, "NAME")
|
532
|
+
description = SystemDescription.load(name, system_description_store)
|
533
|
+
exporter = StaticHtml.new(description, options["html-dir"])
|
534
|
+
exporter.create_directory(options[:force])
|
535
|
+
exporter.write
|
536
|
+
end
|
537
|
+
end
|
538
|
+
|
516
539
|
def self.define_inspect_command_options(c)
|
517
540
|
c.flag [:name, :n], type: String, required: false, arg_name: "NAME",
|
518
541
|
desc: "Store system description under the specified name"
|
519
542
|
c.flag [:scope, :s], type: String, required: false,
|
520
|
-
desc: "
|
543
|
+
desc: "Inspect specified scopes", arg_name: "SCOPE_LIST"
|
521
544
|
c.flag ["ignore-scope", :e], type: String, required: false,
|
522
545
|
desc: "Exclude specified scopes", arg_name: "SCOPE_LIST"
|
523
546
|
c.flag "skip-files", required: false, negatable: false,
|
@@ -834,7 +857,6 @@ class Cli
|
|
834
857
|
|
835
858
|
Machinery::Ui.puts "# Inspection details\n" + details unless details.empty?
|
836
859
|
end
|
837
|
-
|
838
860
|
task = ShowTask.new
|
839
861
|
opts = {
|
840
862
|
show_diffs: options["show-diffs"],
|
data/lib/diff_widget.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
class DiffWidget
|
2
|
+
def initialize(diff_text)
|
3
|
+
diff = Machinery.scrub(diff_text)
|
4
|
+
@lines = diff.lines[2..-1]
|
5
|
+
@widget = {
|
6
|
+
file: diff[/--- a(.*)/, 1],
|
7
|
+
additions: @lines.select { |l| l.start_with?("+") }.length,
|
8
|
+
deletions: @lines.select { |l| l.start_with?("-") }.length
|
9
|
+
}
|
10
|
+
|
11
|
+
@original_line_number = 0
|
12
|
+
@new_line_number = 0
|
13
|
+
end
|
14
|
+
|
15
|
+
def widget
|
16
|
+
@widget[:lines] = @lines.map do |line|
|
17
|
+
line = ERB::Util.html_escape(line.chomp).gsub("\\", "\").gsub("\t", " " * 8)
|
18
|
+
case line
|
19
|
+
when /^@.*/
|
20
|
+
entry = header_entry(line)
|
21
|
+
@original_line_number = line[/-(\d+)/, 1].to_i
|
22
|
+
@new_line_number = line[/\+(\d+)/, 1].to_i
|
23
|
+
when /^ .*/, ""
|
24
|
+
entry = common_entry(line)
|
25
|
+
@new_line_number += 1
|
26
|
+
@original_line_number += 1
|
27
|
+
when /^\+.*/
|
28
|
+
entry = addition_entry(line)
|
29
|
+
@new_line_number += 1
|
30
|
+
when /^\-.*/
|
31
|
+
entry = deletion_entry(line)
|
32
|
+
@original_line_number += 1
|
33
|
+
end
|
34
|
+
|
35
|
+
entry
|
36
|
+
end
|
37
|
+
@widget
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def header_entry(line)
|
43
|
+
{
|
44
|
+
type: "header",
|
45
|
+
content: line
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
def common_entry(line)
|
50
|
+
{
|
51
|
+
type: "common",
|
52
|
+
new_line_number: @new_line_number,
|
53
|
+
original_line_number: @original_line_number,
|
54
|
+
content: line[1..-1]
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
def addition_entry(line)
|
59
|
+
{
|
60
|
+
type: "addition",
|
61
|
+
new_line_number: @new_line_number,
|
62
|
+
content: line[1..-1]
|
63
|
+
}
|
64
|
+
end
|
65
|
+
|
66
|
+
def deletion_entry(line)
|
67
|
+
{
|
68
|
+
type: "deletion",
|
69
|
+
original_line_number: @original_line_number,
|
70
|
+
content: line[1..-1]
|
71
|
+
}
|
72
|
+
end
|
73
|
+
end
|
data/lib/dpkg_database.rb
CHANGED
@@ -28,7 +28,16 @@ class DpkgDatabase < ManagedFilesDatabase
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def package_for_file_path(file)
|
31
|
-
|
31
|
+
output = @system.run_command(
|
32
|
+
"dpkg", "-S", file, stdout: :capture
|
33
|
+
)
|
34
|
+
|
35
|
+
package_name = if output.lines == 1
|
36
|
+
output.split(":").first
|
37
|
+
else
|
38
|
+
extract_package_name_from_file_diversions(output)
|
39
|
+
end
|
40
|
+
|
32
41
|
package_details = @system.run_command("dpkg", "-s", package_name, stdout: :capture)
|
33
42
|
package_version = package_details.match(/^Version: (.*)$/)[1]
|
34
43
|
|
@@ -65,4 +74,10 @@ class DpkgDatabase < ManagedFilesDatabase
|
|
65
74
|
@system.check_requirement("stat", "--version")
|
66
75
|
@system.check_requirement("find", "--version")
|
67
76
|
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
def extract_package_name_from_file_diversions(output)
|
81
|
+
output.lines.last.split(":").first.split(",").first
|
82
|
+
end
|
68
83
|
end
|
data/lib/haml_helpers.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# Copyright (c) 2013-2016 SUSE LLC
|
3
|
+
#
|
4
|
+
# This program is free software; you can redistribute it and/or
|
5
|
+
# modify it under the terms of version 3 of the GNU General Public License as
|
6
|
+
# published by the Free Software Foundation.
|
7
|
+
#
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License
|
14
|
+
# along with this program; if not, contact SUSE LLC.
|
15
|
+
#
|
16
|
+
# To contact SUSE about this file by physical or electronic mail,
|
17
|
+
# you may find current contact information at www.suse.com
|
18
|
+
module HamlHelpers
|
19
|
+
def render_partial(partial, locals = {})
|
20
|
+
source = File.read(File.join(Machinery::ROOT, "html/partials/#{partial}.html.haml"))
|
21
|
+
haml source, locals: locals
|
22
|
+
end
|
23
|
+
|
24
|
+
def render_scope(scope)
|
25
|
+
render_partial scope, scope => @description[scope]
|
26
|
+
end
|
27
|
+
|
28
|
+
def scope_meta_info(scope)
|
29
|
+
return "" unless @description[scope]
|
30
|
+
|
31
|
+
" (" \
|
32
|
+
"inspected host: '#{@description[scope].meta.hostname}', " \
|
33
|
+
"at: #{DateTime.parse(@description[scope].meta.modified).strftime("%F %T")})"
|
34
|
+
end
|
35
|
+
|
36
|
+
def scope_help(scope)
|
37
|
+
text = scope_info(scope)[:description]
|
38
|
+
Kramdown::Document.new(text).to_html
|
39
|
+
end
|
40
|
+
|
41
|
+
def scope_info(scope)
|
42
|
+
YAML.load(File.read(File.join(Machinery::ROOT, "plugins", "#{scope}/#{scope}.yml")))
|
43
|
+
end
|
44
|
+
|
45
|
+
def scope_title(scope)
|
46
|
+
scope_info(scope)[:name]
|
47
|
+
end
|
48
|
+
|
49
|
+
def scope_initials(scope)
|
50
|
+
scope_info(scope)[:initials].upcase
|
51
|
+
end
|
52
|
+
|
53
|
+
def nav_class(scope)
|
54
|
+
if @description
|
55
|
+
return @description[scope] ? "" : "disabled"
|
56
|
+
elsif @description_a && @description_b
|
57
|
+
return @description_a[scope] && @description_b[scope] ? "" : "disabled"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/kiwi_config.rb
CHANGED
@@ -345,11 +345,18 @@ EOF
|
|
345
345
|
when "linked"
|
346
346
|
# Don't do anything because linking doesn't mean enabling
|
347
347
|
# nor disabling.
|
348
|
+
when "indirect"
|
349
|
+
# Don't do anything because indirect doesn't mean enabling
|
350
|
+
# nor disabling.
|
348
351
|
when "enabled-runtime"
|
349
352
|
when "linked-runtime"
|
350
353
|
when "masked-runtime"
|
354
|
+
when "transient"
|
355
|
+
when "generated"
|
351
356
|
# Don't do anything because these states are not supposed
|
352
357
|
# to be permanent.
|
358
|
+
when "bad"
|
359
|
+
# Don't do anything because the unit file is broken
|
353
360
|
else
|
354
361
|
raise Machinery::Errors::ExportFailed.new(
|
355
362
|
"The systemd unit state #{service.state} is unknown."
|
data/lib/machinery.rb
CHANGED
@@ -49,6 +49,7 @@ require_relative "array"
|
|
49
49
|
require_relative "object"
|
50
50
|
require_relative "constants"
|
51
51
|
require_relative "manifest"
|
52
|
+
require_relative "diff_widget"
|
52
53
|
require_relative "system_description"
|
53
54
|
require_relative "version"
|
54
55
|
require_relative "tarball"
|
@@ -103,6 +104,7 @@ require_relative "man_task"
|
|
103
104
|
require_relative "comparison"
|
104
105
|
require_relative "serve_html_task"
|
105
106
|
require_relative "file_diff"
|
107
|
+
require_relative "haml_helpers"
|
106
108
|
require_relative "server"
|
107
109
|
require_relative "html"
|
108
110
|
require_relative "machinery_helper"
|
@@ -116,6 +118,7 @@ require_relative "managed_files_database"
|
|
116
118
|
require_relative "rpm_database"
|
117
119
|
require_relative "dpkg_database"
|
118
120
|
require_relative "tee_io"
|
121
|
+
require_relative "static_html"
|
119
122
|
|
120
123
|
Dir[File.join(Machinery::ROOT, "plugins", "**", "*.rb")].each { |f| require(f) }
|
121
124
|
|
data/lib/man_task.rb
CHANGED
@@ -17,8 +17,9 @@
|
|
17
17
|
|
18
18
|
class ManTask
|
19
19
|
def self.compile_documentation
|
20
|
-
docs =
|
21
|
-
|
20
|
+
docs = "# Scopes\n\n"
|
21
|
+
docs += Inspector.all_scopes.map do |scope|
|
22
|
+
scope_doc = "* #{scope.tr("_", "-")}\n\n"
|
22
23
|
scope_doc += YAML.load_file(
|
23
24
|
File.join(Machinery::ROOT, "plugins/#{scope}/#{scope}.yml")
|
24
25
|
)[:description]
|
data/lib/move_task.rb
CHANGED
data/lib/remote_system.rb
CHANGED
@@ -145,6 +145,10 @@ class RemoteSystem < System
|
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
148
|
+
def check_retrieve_files_dependencies
|
149
|
+
LocalSystem.new.check_requirement("rsync", "--version")
|
150
|
+
end
|
151
|
+
|
148
152
|
# Reads a file from the System. Returns nil if it does not exist.
|
149
153
|
def read_file(file)
|
150
154
|
run_command("cat", file, stdout: :capture, privileged: true)
|
data/lib/server.rb
CHANGED
@@ -40,48 +40,7 @@ end
|
|
40
40
|
|
41
41
|
class Server < Sinatra::Base
|
42
42
|
module Helpers
|
43
|
-
|
44
|
-
source = File.read(File.join(Machinery::ROOT, "html/partials/#{partial}.html.haml"))
|
45
|
-
haml source, locals: locals
|
46
|
-
end
|
47
|
-
|
48
|
-
def render_scope(scope)
|
49
|
-
render_partial scope, scope => @description[scope]
|
50
|
-
end
|
51
|
-
|
52
|
-
def scope_meta_info(scope)
|
53
|
-
return "" unless @description[scope]
|
54
|
-
|
55
|
-
" (" \
|
56
|
-
"inspected host: '#{@description[scope].meta.hostname}', " \
|
57
|
-
"at: #{DateTime.parse(@description[scope].meta.modified).strftime("%F %T")})"
|
58
|
-
end
|
59
|
-
|
60
|
-
def scope_help(scope)
|
61
|
-
text = scope_info(scope)[:description]
|
62
|
-
Kramdown::Document.new(text).to_html
|
63
|
-
end
|
64
|
-
|
65
|
-
def scope_info(scope)
|
66
|
-
YAML.load(File.read(File.join(Machinery::ROOT, "plugins", "#{scope}/#{scope}.yml")))
|
67
|
-
end
|
68
|
-
|
69
|
-
def scope_title(scope)
|
70
|
-
scope_info(scope)[:name]
|
71
|
-
end
|
72
|
-
|
73
|
-
def scope_initials(scope)
|
74
|
-
scope_info(scope)[:initials].upcase
|
75
|
-
end
|
76
|
-
|
77
|
-
def nav_class(scope)
|
78
|
-
if @description
|
79
|
-
return @description[scope] ? "" : "disabled"
|
80
|
-
elsif @description_a && @description_b
|
81
|
-
return @description_a[scope] && @description_b[scope] ? "" : "disabled"
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
43
|
+
include HamlHelpers
|
85
44
|
def safe_length(object, attribute)
|
86
45
|
if collection = object.try(attribute)
|
87
46
|
collection.length
|
@@ -170,60 +129,6 @@ class Server < Sinatra::Base
|
|
170
129
|
|
171
130
|
value.to_s
|
172
131
|
end
|
173
|
-
|
174
|
-
def diff_to_object(diff)
|
175
|
-
diff = Machinery.scrub(diff)
|
176
|
-
lines = diff.lines[2..-1]
|
177
|
-
diff_object = {
|
178
|
-
file: diff[/--- a(.*)/, 1],
|
179
|
-
additions: lines.select { |l| l.start_with?("+") }.length,
|
180
|
-
deletions: lines.select { |l| l.start_with?("-") }.length
|
181
|
-
}
|
182
|
-
|
183
|
-
original_line_number = 0
|
184
|
-
new_line_number = 0
|
185
|
-
diff_object[:lines] = lines.map do |line|
|
186
|
-
line = ERB::Util.html_escape(line.chomp).
|
187
|
-
gsub("\\", "\").
|
188
|
-
gsub("\t", " " * 8)
|
189
|
-
case line
|
190
|
-
when /^@.*/
|
191
|
-
entry = {
|
192
|
-
type: "header",
|
193
|
-
content: line
|
194
|
-
}
|
195
|
-
original_line_number = line[/-(\d+)/, 1].to_i
|
196
|
-
new_line_number = line[/\+(\d+)/, 1].to_i
|
197
|
-
when /^ .*/, ""
|
198
|
-
entry = {
|
199
|
-
type: "common",
|
200
|
-
new_line_number: new_line_number,
|
201
|
-
original_line_number: original_line_number,
|
202
|
-
content: line[1..-1]
|
203
|
-
}
|
204
|
-
new_line_number += 1
|
205
|
-
original_line_number += 1
|
206
|
-
when /^\+.*/
|
207
|
-
entry = {
|
208
|
-
type: "addition",
|
209
|
-
new_line_number: new_line_number,
|
210
|
-
content: line[1..-1]
|
211
|
-
}
|
212
|
-
new_line_number += 1
|
213
|
-
when /^\-.*/
|
214
|
-
entry = {
|
215
|
-
type: "deletion",
|
216
|
-
original_line_number: original_line_number,
|
217
|
-
content: line[1..-1]
|
218
|
-
}
|
219
|
-
original_line_number += 1
|
220
|
-
end
|
221
|
-
|
222
|
-
entry
|
223
|
-
end
|
224
|
-
|
225
|
-
diff_object
|
226
|
-
end
|
227
132
|
end
|
228
133
|
|
229
134
|
helpers Helpers
|
@@ -357,15 +262,7 @@ class Server < Sinatra::Base
|
|
357
262
|
@error = e
|
358
263
|
haml File.read(File.join(Machinery::ROOT, "html/exception.html.haml"))
|
359
264
|
else
|
360
|
-
|
361
|
-
if @description.changed_config_files && diffs_dir
|
362
|
-
# Enrich description with the config file diffs
|
363
|
-
@description.changed_config_files.each do |file|
|
364
|
-
path = File.join(diffs_dir, file.name + ".diff")
|
365
|
-
file.diff = diff_to_object(File.read(path)) if File.exist?(path)
|
366
|
-
end
|
367
|
-
end
|
368
|
-
|
265
|
+
@description.load_existing_diffs
|
369
266
|
haml File.read(File.join(Machinery::ROOT, "html/index.html.haml"))
|
370
267
|
end
|
371
268
|
end
|