Sha256: 519514d9a971c5a4e7c443b999530b1a3449e2795db6c1fbec13c053b805d765

Contents?: true

Size: 1.39 KB

Versions: 20

Compression:

Stored size: 1.39 KB

Contents

class VersionDiffer
  def print_latest(io = $stdout)
    io.puts diff(last_version, '.')
  end

  def update(path)
    old = File.read(path)
    File.open(path, 'w') do |file|
      print_latest(file)
      file << old
    end
  end

  def generate(path)
    versions = released_versions
    versions.unshift '.'

    versions.each_cons(2) do |new_version, old_version|
      File.open(path, 'a') do |file|
        file << diff(old_version, new_version)
      end
    end
  end

  private

  def last_version
    released_versions.first
  end

  def released_versions
    require 'open-uri'
    require 'multi_json'

    versions = MultiJson.decode(open('https://rubygems.org/api/v1/versions/watir.json').read)
    versions.map! { |e| e.fetch('number') }
  end

  def diff(old_version, new_version)
    puts "diffing #{old_version} -> #{new_version}"

    left = "watir-#{old_version}.gem"
    right = new_version == '.' ? new_version : "watir-#{new_version}.gem"

    str = StringIO.new
    str.puts new_version.to_s
    str.puts '=' * new_version.length
    str.puts

    # requires YARD > 0.8.2.1 (i.e. next release at the time of writing)
    query = '!@private && @api.text != "private" && object.visibility == :public'
    content = `yard diff --all --query #{query} #{left} #{right} 2>&1`
    str.puts(content.split("\n").map { |line| line.empty? ? line : "   #{line}" })
    str.puts "\n\n"

    str.string
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
watir-7.1.0 support/version_differ.rb
watir-7.0.0 support/version_differ.rb
watir-7.0.0.beta5 support/version_differ.rb
watir-7.0.0.beta4 support/version_differ.rb
watir-7.0.0.beta3 support/version_differ.rb
watir-7.0.0.beta2 support/version_differ.rb
watir-7.0.0.beta1 support/version_differ.rb
watir-6.19.1 support/version_differ.rb
watir-6.19.0 support/version_differ.rb
watir-6.18.0 support/version_differ.rb
watir-6.17.0 support/version_differ.rb
watir-6.16.5 support/version_differ.rb
watir-6.16.4 support/version_differ.rb
watir-6.16.3 support/version_differ.rb
watir-6.16.2 support/version_differ.rb
watir-6.16.1 support/version_differ.rb
watir-6.16.0 support/version_differ.rb
watir-6.15.1 support/version_differ.rb
watir-6.15.0 support/version_differ.rb
watir-6.14.0 support/version_differ.rb