diff --git a/lib/bundle_update_interactive/changelog_locator.rb b/lib/bundle_update_interactive/changelog_locator.rb index 9abb265..bd89aa1 100644 --- a/lib/bundle_update_interactive/changelog_locator.rb +++ b/lib/bundle_update_interactive/changelog_locator.rb @@ -5,10 +5,13 @@ GITHUB_PATTERN = %r{^(?:https?://)?github\.com/([^/]+/[^/]+)(?:\.git)?/?} URI_KEYS = %w[source_code_uri homepage_uri bug_tracker_uri wiki_uri].freeze +FILE_PATTERN = /(?:changelog|changes|history|news|release)/ +EXT_PATTERN = /(?:md|txt|rdoc)/ module BundleUpdateInteractive class ChangelogLocator - def find_changelog_uri(name:, version: nil) + # TODO: refactor + def find_changelog_uri(name:, version: nil) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity if version response = Faraday.get("https://rubygems.org/api/v2/rubygems/#{name}/versions/#{version}.json") version = nil unless response.success? @@ -30,7 +33,7 @@ def find_changelog_uri(name:, version: nil) github_repo = file_list.headers["Location"][GITHUB_PATTERN, 1] file_list = Faraday.get(file_list.headers["Location"]) end - match = file_list.body.match(%r{/(#{github_repo}/blob/[^/]+/(?:changelog|changes|history|news|release)(?:\.(?:md|txt|rdoc))?)"}i) + match = file_list.body.match(%r{/(#{github_repo}/blob/[^/]+/#{FILE_PATTERN}(?:\.#{EXT_PATTERN})?)"}i) changelog_uri = "https://github.com/#{match[1]}" if match end diff --git a/lib/bundle_update_interactive/cli/row.rb b/lib/bundle_update_interactive/cli/row.rb index 144271f..11cc353 100644 --- a/lib/bundle_update_interactive/cli/row.rb +++ b/lib/bundle_update_interactive/cli/row.rb @@ -34,7 +34,7 @@ def formatted_current_version end def formatted_updated_version - version = semver_change.format(&method(:apply_semver_highlight)) + version = semver_change.format { |part| apply_semver_highlight(part) } git_version = apply_semver_highlight(updated_git_version) [version, git_version].compact.join(" ") diff --git a/lib/bundle_update_interactive/lockfile.rb b/lib/bundle_update_interactive/lockfile.rb index 59dbc45..ccacd75 100644 --- a/lib/bundle_update_interactive/lockfile.rb +++ b/lib/bundle_update_interactive/lockfile.rb @@ -2,7 +2,8 @@ module BundleUpdateInteractive class Lockfile - def self.parse(lockfile_contents=File.read("Gemfile.lock")) + # TODO: refactor + def self.parse(lockfile_contents=File.read("Gemfile.lock")) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity parser = Bundler::LockfileParser.new(lockfile_contents) specs_by_name = {} exact = Set.new diff --git a/lib/bundle_update_interactive/outdated_gem.rb b/lib/bundle_update_interactive/outdated_gem.rb index cda5c7c..8ddb5c6 100644 --- a/lib/bundle_update_interactive/outdated_gem.rb +++ b/lib/bundle_update_interactive/outdated_gem.rb @@ -66,7 +66,8 @@ def git_version_changed? def github_repo return nil unless updated_git_version - updated_lockfile_entry.git_source_uri.to_s[%r{^(?:git@github.com:|https://github.com/)([^/]+/[^/]+?)(:?\.git)?(?:$|/)}i, 1] + updated_lockfile_entry.git_source_uri.to_s[%r{^(?:git@github.com:|https://github.com/)([^/]+/[^/]+?)(:?\.git)?(?:$|/)}i, + 1] end end end