Sha256: aeaff4dc7e229e25f282016a5b920318a3fc486a917e51c772e60b115fe3f7e9

Contents?: true

Size: 1.27 KB

Versions: 16

Compression:

Stored size: 1.27 KB

Contents

require 'excon'

module PantographCore
  class Changelog
    class << self
      def show_changes(gem_name, current_version, update_gem_command: "bundle update")
        did_show_changelog = false

        self.releases(gem_name).each_with_index do |release, index|
          next unless Gem::Version.new(release['tag_name']) > Gem::Version.new(current_version)
          puts("")
          puts(release['name'].green)
          puts(release['body'])
          did_show_changelog = true

          next unless index == 2
          puts("")
          puts("To see all new releases, open https://github.com/johnknapprs/#{gem_name}/releases".green)
          break
        end

        puts("")
        puts("Please update using `#{update_gem_command}`".green) if did_show_changelog
      rescue
        # Something went wrong, we don't care so much about this
      end

      def releases(gem_name)
        url = "https://api.github.com/repos/johnknapprs/#{gem_name}/releases"
        # We have to follow redirects, since some repos were moved away into a separate org
        server_response = Excon.get(url,
                                    middlewares: Excon.defaults[:middlewares] + [Excon::Middleware::RedirectFollower])
        JSON.parse(server_response.body)
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
pantograph-0.1.20 pantograph_core/lib/pantograph_core/update_checker/changelog.rb
pantograph-0.1.19 pantograph_core/lib/pantograph_core/update_checker/changelog.rb
pantograph-0.1.17 pantograph_core/lib/pantograph_core/update_checker/changelog.rb
pantograph-0.1.16 pantograph_core/lib/pantograph_core/update_checker/changelog.rb
pantograph-0.1.15 pantograph_core/lib/pantograph_core/update_checker/changelog.rb
pantograph-0.1.14 pantograph_core/lib/pantograph_core/update_checker/changelog.rb
pantograph-0.1.13 pantograph_core/lib/pantograph_core/update_checker/changelog.rb
pantograph-0.1.12 pantograph_core/lib/pantograph_core/update_checker/changelog.rb
pantograph-0.1.10 pantograph_core/lib/pantograph_core/update_checker/changelog.rb
pantograph-0.1.8 pantograph_core/lib/pantograph_core/update_checker/changelog.rb
pantograph-0.1.7 pantograph_core/lib/pantograph_core/update_checker/changelog.rb
pantograph-0.1.6 pantograph_core/lib/pantograph_core/update_checker/changelog.rb
pantograph-0.1.4 pantograph_core/lib/pantograph_core/update_checker/changelog.rb
pantograph-0.1.3 pantograph_core/lib/pantograph_core/update_checker/changelog.rb
pantograph-0.1.1 pantograph_core/lib/pantograph_core/update_checker/changelog.rb
pantograph-0.1.0 pantograph_core/lib/pantograph_core/update_checker/changelog.rb