Sha256: 7627da0f9921d080f6af518fe375ed19b7039d45dbba752f2f81618a83ac64d1

Contents?: true

Size: 1.19 KB

Versions: 6

Compression:

Stored size: 1.19 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require 'headdesk'
require 'nokogiri'
require 'open-uri'
require 'yaml'

@facebook_sdk_versions = {}

def add_version(str, matcher)
  major, minor, patch, date = str.match(matcher).captures
  version_string = "#{major.to_i || 0}.#{minor.to_i || 0}.#{patch.to_i || 0}"
  @facebook_sdk_versions[version_string] = {
    major: major.to_i || 0,
    minor: minor.to_i || 0,
    patch: patch.to_i || 0,
    version: version_string,
    date: Date.parse(date)
  }
end

html_doc = Nokogiri::HTML(open('https://developers.facebook.com/docs/android/change-log-4x'))

html_match = /^(\d+)\.(\d+)\.?(\d+)? \- (.*)$/
html_doc.xpath('//h2')
        .select { |h2| html_match.match?(h2.text) }
        .collect do |h2|
  add_version(h2.text, html_match)
end

changelog_md = open('https://raw.githubusercontent.com/facebook/facebook-android-sdk/master/CHANGELOG.md') { |f| f.read }

markdown_match = /^## \[(\d+)\.(\d+)\.?(\d+)?\] \- (.*)$/
changelog_md.each_line.select { |line| markdown_match.match?(line) }
                      .collect do |line|
  add_version(line, markdown_match)
end

File.write(Headdesk::FACEBOOK_SDK_VERSIONS_YAML, @facebook_sdk_versions.values.to_yaml)

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
headdesk-0.17.0 bin/facebook_sdk_versions
headdesk-0.16.2 bin/facebook_sdk_versions
headdesk-0.16.1 bin/facebook_sdk_versions
headdesk-0.16.0 bin/facebook_sdk_versions
headdesk-0.15.1 bin/facebook_sdk_versions
headdesk-0.15.0 bin/facebook_sdk_versions