Skip to content

Instantly share code, notes, and snippets.

@theodorosploumis
Last active May 4, 2023 07:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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

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