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
- #changelogs ⇒ 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
14 15 16 17 |
# File 'lib/lock_diff/diff_info.rb', line 14 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
19 20 21 |
# File 'lib/lock_diff/diff_info.rb', line 19 def changed? @old_package.different?(@new_package) end |
#changelogs ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/lock_diff/diff_info.rb', line 60 def changelogs return nil if [DOWNGRADE, DELETE].include?(status) Github::ChangelogUrlFinder.new( repository: package.repository, repository_url: package.repository_url, ref: @new_package.ref, package_name: package.name ).call.map do |url| Changelog.new(url) end end |
#commits_url ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/lock_diff/diff_info.rb', line 73 def commits_url return unless package.repository_url old_ref = @old_package.ref new_ref = @new_package.ref compare_path = 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.repository_url}/#{compare_path}" if compare_path end |
#commits_url_text ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/lock_diff/diff_info.rb', line 92 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
38 39 40 41 42 43 44 45 |
# File 'lib/lock_diff/diff_info.rb', line 38 def package case status when UPGRADE, NEW @new_package when DOWNGRADE, DELETE @old_package end end |
#status ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/lock_diff/diff_info.rb', line 23 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 |
#status_emoji ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/lock_diff/diff_info.rb', line 47 def status_emoji case status when UPGRADE ':chart_with_upwards_trend:' when DOWNGRADE ':chart_with_downwards_trend:' when DELETE ':x:' when NEW ':new:' end end |