Class: Workarea::Upgrade::Diff
- Inherits:
-
Object
- Object
- Workarea::Upgrade::Diff
show all
- Defined in:
- lib/workarea/upgrade/diff.rb,
lib/workarea/upgrade/diff/gem_diff.rb,
lib/workarea/upgrade/diff/current_app.rb,
lib/workarea/upgrade/diff/workarea_file.rb
Defined Under Namespace
Modules: CurrentApp
Classes: GemDiff, WorkareaFile
Constant Summary
collapse
- CSS =
<<-STYLE
.diff{overflow:auto;}
.diff ul{background:#fff;overflow:auto;font-size:13px;list-style:none;margin:0;padding:0;display:table;width:100%;}
.diff del, .diff ins{display:block;text-decoration:none;}
.diff li{padding:0; display:table-row;margin: 0;height:1em;}
.diff li.ins{background:#dfd; color:#080}
.diff li.del{background:#fee; color:#b00}
.diff li:hover{background:#ffc}
/* try 'whitespace:pre;' if you don't want lines to wrap */
.diff del, .diff ins, .diff span{white-space:pre-wrap;font-family:courier;}
.diff del strong{font-weight:normal;background:#fcc;}
.diff ins strong{font-weight:normal;background:#9f9;}
.diff li.diff-comment { background: none repeat scroll 0 0 gray; }
.diff li.diff-block-info { background: none repeat scroll 0 0 gray; }
STYLE
Instance Method Summary
collapse
Constructor Details
#initialize(core_to_version, options) ⇒ Diff
Returns a new instance of Diff.
20
21
22
23
|
# File 'lib/workarea/upgrade/diff.rb', line 20
def initialize(core_to_version, options)
@core_to_version = core_to_version
@options = options
end
|
Instance Method Details
#find_from_path!(gem) ⇒ Object
63
64
65
|
# File 'lib/workarea/upgrade/diff.rb', line 63
def find_from_path!(gem)
Bundler.load.specs.find { |s| s.name == "#{gem}" }&.full_gem_path
end
|
#find_to_path!(gem, version) ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/workarea/upgrade/diff.rb', line 67
def find_to_path!(gem, version)
unless version.to_s =~ /^(\d+\.)(\d+\.)(\d+)/
raise "#{version} is not a valid version number. Example format: 3.0.5"
end
result = "#{Gem.dir}/gems/#{gem}-#{version}"
if !File.directory?(result)
raise <<-eos.strip_heredoc
Couldn't find #{gem} v#{version} in installed gems!
Looked in #{result}
Try `gem install #{gem} -v #{version}`.
eos
end
result
end
|
#gem_diffs ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/workarea/upgrade/diff.rb', line 29
def gem_diffs
@gem_diffs ||= gems.map do |gem, to_version|
from_path = find_from_path!(gem)
to_path = find_to_path!(gem, to_version)
GemDiff.new(
from_path,
to_path,
@options
)
end
end
|
#gems ⇒ Object
56
57
58
59
60
61
|
# File 'lib/workarea/upgrade/diff.rb', line 56
def gems
%w(workarea-core workarea-storefront workarea-admin)
.each_with_object({}) { |gem, memo| memo[gem] = @core_to_version }
.merge(plugins)
.select { |gem, _version| find_from_path!(gem).present? }
end
|
#plugins ⇒ Object
25
26
27
|
# File 'lib/workarea/upgrade/diff.rb', line 25
def plugins
@options[:plugins].presence || {}
end
|