Sha256: 9bfd65258cdc3e4cfc246477675f72cd2c2b7993380d1db8488d68fdfb117b15

Contents?: true

Size: 1.4 KB

Versions: 11

Compression:

Stored size: 1.4 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|
      show_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-webdriver.json").read)
    versions.map! { |e| e.fetch('number')}
  end

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

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

    str = StringIO.new
    str.puts "#{new_version}"
    str.puts "=" * new_version.length
    str.puts

    # requires YARD > 0.8.2.1 (i.e. next release at the time of writing)
    content = `yard diff --all --query '!@private && @api.text != "private" && object.visibility == :public' #{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

11 entries across 11 versions & 1 rubygems

Version Path
watir-webdriver-0.7.0 support/version_differ.rb
watir-webdriver-0.6.11 support/version_differ.rb
watir-webdriver-0.6.10 support/version_differ.rb
watir-webdriver-0.6.9 support/version_differ.rb
watir-webdriver-0.6.8 support/version_differ.rb
watir-webdriver-0.6.7 support/version_differ.rb
watir-webdriver-0.6.6 support/version_differ.rb
watir-webdriver-0.6.5 support/version_differ.rb
watir-webdriver-0.6.4 support/version_differ.rb
watir-webdriver-0.6.3 support/version_differ.rb
watir-webdriver-0.6.2 support/version_differ.rb