Skip to content

Instantly share code, notes, and snippets.

@theodorosploumis
Last active November 1, 2024 07:32
Show Gist options
  • Save theodorosploumis/f4fd02c6df152baf464a42d077d41ff4 to your computer and use it in GitHub Desktop.
Save theodorosploumis/f4fd02c6df152baf464a42d077d41ff4 to your computer and use it in GitHub Desktop.
Get the latest stable and supported Drupal versions on the cli
#! /usr/bin/env ruby
# Get the latets stable and supported Drupal versions on the cli
require 'nokogiri'
require 'open-uri'
require 'colorize'
# Fetch and parse HTML document
doc = Nokogiri::HTML(URI.open('https://www.drupal.org/project/drupal'))
versions = []
dates = []
# Search for Version by css
doc.css('.views-field-field-release-version h4').each do |entry|
version = entry.content.gsub! 'Drupal core ', ''
if !version.include? "dev"
versions.push(version)
end
end
# Search for Realse dates by css
doc.css('.views-field-field-release-version .release-date').each do |entry|
date = entry.content.gsub! 'Released ', ''
better_date = Time.parse(date).strftime('%F')
dates.push(better_date)
end
# puts versions
# puts dates
versions.each_index do |i|
puts "#{dates[i]}".yellow + ": #{versions[i]}"
end
@theodorosploumis
Copy link
Author

Run

ruby ./drupal-version.rb

@theodorosploumis
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment