From 92453c3f028ced4c219293e7891a33351a56259d Mon Sep 17 00:00:00 2001 From: Pete Johns Date: Fri, 2 Nov 2018 18:12:12 +1100 Subject: [PATCH 1/3] Support older rubies --- lib/unwrappr/gem_version.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/unwrappr/gem_version.rb b/lib/unwrappr/gem_version.rb index a9b8136..ec488d1 100644 --- a/lib/unwrappr/gem_version.rb +++ b/lib/unwrappr/gem_version.rb @@ -43,7 +43,11 @@ def to_s private def segment(index) - segment = @version.canonical_segments[index] || 0 + segment = if @version.respond_to?(:canonical_segments) + @version.canonical_segments[index] || 0 + else + @version.segments[index] || 0 + end (segment.is_a?(Numeric) ? segment : nil) end end From 3c8a8b9d9b3a980bb5583dd20724e638d726b107 Mon Sep 17 00:00:00 2001 From: Pete Johns Date: Fri, 2 Nov 2018 18:12:44 +1100 Subject: [PATCH 2/3] Credit where lots of credit is due --- unwrappr.gemspec | 1 + 1 file changed, 1 insertion(+) diff --git a/unwrappr.gemspec b/unwrappr.gemspec index dfbc3ed..d887098 100644 --- a/unwrappr.gemspec +++ b/unwrappr.gemspec @@ -7,6 +7,7 @@ require 'unwrappr/version' AUTHORS = { 'emilyn.escabarte@envato.com' => 'Emilyn Escabarte', 'joe.sustaric@envato.com' => 'Joe Sustaric', + 'orien.madgwick@envato.com' => 'Orien Madgwick', 'pete.johns@envato.com' => 'Pete Johns', 'vladimir.chervanev@envato.com' => 'Vladimir Chervanev' }.freeze From eaf28d014665c7ae89d3afc011839893c1692e25 Mon Sep 17 00:00:00 2001 From: Pete Johns Date: Fri, 2 Nov 2018 17:27:07 +1100 Subject: [PATCH 3/3] New Rubocop, less vertical alignment --- lib/unwrappr/git_command_runner.rb | 6 ++--- lib/unwrappr/github/pr_source.rb | 10 ++++---- lib/unwrappr/lock_file_diff.rb | 8 +++---- spec/lib/unwrappr/github/pr_source_spec.rb | 10 ++++---- spec/lib/unwrappr/lock_file_annotator_spec.rb | 24 +++++++++---------- spec/lib/unwrappr/lock_file_diff_spec.rb | 6 ++--- .../unwrappr/writers/project_links_spec.rb | 2 +- .../unwrappr/writers/version_change_spec.rb | 8 +++---- 8 files changed, 37 insertions(+), 37 deletions(-) diff --git a/lib/unwrappr/git_command_runner.rb b/lib/unwrappr/git_command_runner.rb index fd0c542..9b3720f 100644 --- a/lib/unwrappr/git_command_runner.rb +++ b/lib/unwrappr/git_command_runner.rb @@ -86,9 +86,9 @@ def create_and_annotate_pull_request def annotate_pull_request(pr_number) LockFileAnnotator.annotate_github_pull_request( - repo: repo_name_and_org, - pr_number: pr_number, - client: git_client + repo: repo_name_and_org, + pr_number: pr_number, + client: git_client ) end diff --git a/lib/unwrappr/github/pr_source.rb b/lib/unwrappr/github/pr_source.rb index 983ca5e..665798b 100644 --- a/lib/unwrappr/github/pr_source.rb +++ b/lib/unwrappr/github/pr_source.rb @@ -18,11 +18,11 @@ def initialize(repo, pr_number, client) def each_file lock_file_diffs.each do |lock_file_diff| yield LockFileDiff.new( - filename: lock_file_diff.filename, - base_file: file_contents(lock_file_diff.filename, base_sha), - head_file: file_contents(lock_file_diff.filename, head_sha), - patch: lock_file_diff.patch, - sha: head_sha + filename: lock_file_diff.filename, + base_file: file_contents(lock_file_diff.filename, base_sha), + head_file: file_contents(lock_file_diff.filename, head_sha), + patch: lock_file_diff.patch, + sha: head_sha ) end end diff --git a/lib/unwrappr/lock_file_diff.rb b/lib/unwrappr/lock_file_diff.rb index 05789e7..e9f4cac 100644 --- a/lib/unwrappr/lock_file_diff.rb +++ b/lib/unwrappr/lock_file_diff.rb @@ -17,10 +17,10 @@ def initialize(filename:, base_file:, head_file:, patch:, sha:) def each_gem_change version_changes.each do |change| yield GemChange.new( - name: change[:dependency].to_s, - base_version: gem_version(change[:before]), - head_version: gem_version(change[:after]), - line_number: line_number_for_change(change), + name: change[:dependency].to_s, + base_version: gem_version(change[:before]), + head_version: gem_version(change[:after]), + line_number: line_number_for_change(change), lock_file_diff: self ) end diff --git a/spec/lib/unwrappr/github/pr_source_spec.rb b/spec/lib/unwrappr/github/pr_source_spec.rb index 008e429..eddf479 100644 --- a/spec/lib/unwrappr/github/pr_source_spec.rb +++ b/spec/lib/unwrappr/github/pr_source_spec.rb @@ -60,11 +60,11 @@ module Unwrappr it 'produces a LockFileDiff with the expected attributes' do files expect(LockFileDiff).to have_received(:new) - .with(filename: 'my/Gemfile.lock', - base_file: 'content-1', - head_file: 'content-2', - patch: 'my-gem-patch', - sha: 'head-sha') + .with(filename: 'my/Gemfile.lock', + base_file: 'content-1', + head_file: 'content-2', + patch: 'my-gem-patch', + sha: 'head-sha') end end end diff --git a/spec/lib/unwrappr/lock_file_annotator_spec.rb b/spec/lib/unwrappr/lock_file_annotator_spec.rb index 7497fe9..591f060 100644 --- a/spec/lib/unwrappr/lock_file_annotator_spec.rb +++ b/spec/lib/unwrappr/lock_file_annotator_spec.rb @@ -95,27 +95,27 @@ module Unwrappr before do allow(::Unwrappr::RubyGems).to receive(:gem_info) .with('rspec-support') - .and_return(spy(homepage_uri: 'home-uri', - source_code_uri: 'source-uri', - changelog_uri: 'changelog-uri')) + .and_return(spy(homepage_uri: 'home-uri', + source_code_uri: 'source-uri', + changelog_uri: 'changelog-uri')) allow(lock_file_diff_source).to receive(:each_file) - .and_yield(LockFileDiff.new(filename: 'Gemfile.lock', - base_file: base_lock_file, - head_file: head_lock_file, - patch: patch, - sha: '89ee3f7d')) + .and_yield(LockFileDiff.new(filename: 'Gemfile.lock', + base_file: base_lock_file, + head_file: head_lock_file, + patch: patch, + sha: '89ee3f7d')) end it 'annotates gem changes' do annotate expect(annotation_sink).to have_received(:annotate_change) .with( - having_attributes(name: 'rspec-support', + having_attributes(name: 'rspec-support', base_version: GemVersion.new('3.7.0'), head_version: GemVersion.new('3.7.1'), - filename: 'Gemfile.lock', - sha: '89ee3f7d', - line_number: 5), + filename: 'Gemfile.lock', + sha: '89ee3f7d', + line_number: 5), <<~MESSAGE ### [rspec-support](home-uri) diff --git a/spec/lib/unwrappr/lock_file_diff_spec.rb b/spec/lib/unwrappr/lock_file_diff_spec.rb index 015e9ef..0280e06 100644 --- a/spec/lib/unwrappr/lock_file_diff_spec.rb +++ b/spec/lib/unwrappr/lock_file_diff_spec.rb @@ -4,11 +4,11 @@ module Unwrappr RSpec.describe LockFileDiff do subject(:lock_file_diff) do LockFileDiff.new( - filename: 'Gemfile.lock', + filename: 'Gemfile.lock', base_file: base_file, head_file: head_file, - patch: patch, - sha: '123' + patch: patch, + sha: '123' ) end diff --git a/spec/lib/unwrappr/writers/project_links_spec.rb b/spec/lib/unwrappr/writers/project_links_spec.rb index 5d595af..8c83b27 100644 --- a/spec/lib/unwrappr/writers/project_links_spec.rb +++ b/spec/lib/unwrappr/writers/project_links_spec.rb @@ -12,7 +12,7 @@ module Writers let(:gem_change_info) do { ruby_gems: spy(source_code_uri: 'source-uri', - changelog_uri: 'changelog-uri') + changelog_uri: 'changelog-uri') } end diff --git a/spec/lib/unwrappr/writers/version_change_spec.rb b/spec/lib/unwrappr/writers/version_change_spec.rb index e03e5f0..8d06961 100644 --- a/spec/lib/unwrappr/writers/version_change_spec.rb +++ b/spec/lib/unwrappr/writers/version_change_spec.rb @@ -7,10 +7,10 @@ module Writers subject(:write) { VersionChange.write(gem_change, gem_change_info) } let(:gem_change) do - GemChange.new(name: 'test-gem', - head_version: head_version, - base_version: base_version, - line_number: 9870, + GemChange.new(name: 'test-gem', + head_version: head_version, + base_version: base_version, + line_number: 9870, lock_file_diff: instance_double(LockFileDiff)) end let(:gem_change_info) { {} }