Class: LockDiff::DiffInfo
- Inherits:
-
Object
- Object
- LockDiff::DiffInfo
- Extended by:
- Forwardable
- Defined in:
- lib/lock_diff/diff_info.rb
Constant Summary collapse
- UPGRADE =
'upgrade'- DOWNGRADE =
'downgrade'- DELETE =
'delete'- NEW =
'new'
Instance Attribute Summary collapse
-
#new_package ⇒ Object
readonly
Returns the value of attribute new_package.
-
#old_package ⇒ Object
readonly
Returns the value of attribute old_package.
Instance Method Summary collapse
- #changed? ⇒ Boolean
- #changelog_name ⇒ Object
- #changelog_url ⇒ Object
- #commits_url ⇒ Object
- #commits_url_text ⇒ Object
-
#initialize(old_package:, new_package:) ⇒ DiffInfo
constructor
A new instance of DiffInfo.
- #package ⇒ Object
- #status ⇒ Object
- #status_emoji ⇒ Object
Constructor Details
#initialize(old_package:, new_package:) ⇒ DiffInfo
Returns a new instance of DiffInfo.
13 14 15 16 |
# File 'lib/lock_diff/diff_info.rb', line 13 def initialize(old_package:, new_package:) @old_package = old_package @new_package = new_package end |
Instance Attribute Details
#new_package ⇒ Object (readonly)
Returns the value of attribute new_package.
10 11 12 |
# File 'lib/lock_diff/diff_info.rb', line 10 def new_package @new_package end |
#old_package ⇒ Object (readonly)
Returns the value of attribute old_package.
10 11 12 |
# File 'lib/lock_diff/diff_info.rb', line 10 def old_package @old_package end |
Instance Method Details
#changed? ⇒ Boolean
18 19 20 |
# File 'lib/lock_diff/diff_info.rb', line 18 def changed? @old_package.different?(@new_package) end |
#changelog_name ⇒ Object
77 78 79 |
# File 'lib/lock_diff/diff_info.rb', line 77 def changelog_name File.basename(changelog_url) end |
#changelog_url ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/lock_diff/diff_info.rb', line 59 def changelog_url @changelog_url ||= begin ref = case status when UPGRADE, NEW @new_package.ref when DOWNGRADE, DELETE nil # default branch(master) end Github::ChangelogUrlFinder.new( repository: package.repository, github_url: package.github_url, ref: ref ).call end end |
#commits_url ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/lock_diff/diff_info.rb', line 81 def commits_url return unless package.github_url old_ref = @old_package.ref new_ref = @new_package.ref commits_url = case status when UPGRADE "compare/#{old_ref}...#{new_ref}" if old_ref && new_ref when DOWNGRADE "compare/#{new_ref}...#{old_ref}" if old_ref && new_ref when DELETE "commits/#{old_ref}" if old_ref when NEW "commits/#{new_ref}" if new_ref end "#{package.github_url}/#{commits_url}" if commits_url end |
#commits_url_text ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/lock_diff/diff_info.rb', line 100 def commits_url_text case status when UPGRADE "#{@old_package.version_str}...#{@new_package.version_str}" when DOWNGRADE "#{@new_package.version_str}...#{@old_package.version_str}" when DELETE "#{@old_package.version_str}" when NEW "#{@new_package.version_str}" end end |
#package ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/lock_diff/diff_info.rb', line 37 def package case status when UPGRADE, NEW @new_package when DOWNGRADE, DELETE @old_package end end |
#status ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/lock_diff/diff_info.rb', line 22 def status case when @old_package.version && @new_package.version if @old_package.version < @new_package.version UPGRADE else DOWNGRADE end when @old_package.version DELETE when @new_package.version NEW end end |