From fef7ec18d87ae4259ed4b7b7ac5f92973076d9bc Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Tue, 16 Nov 2021 14:14:28 +0100 Subject: [PATCH] Expose Date::VERSION An almost universal convention for gems is to expose `Namespace::VERSION` which makes it mcuh easier when debugging etc. Many gems extracted from ruby don't do this, even though it would be even more useful because they ship with ruby, so it's less clear which version it is. --- date.gemspec | 7 ++++++- lib/date.rb | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/date.gemspec b/date.gemspec index 1a3ae812..cf076969 100644 --- a/date.gemspec +++ b/date.gemspec @@ -1,7 +1,12 @@ # frozen_string_literal: true + +version = File.foreach(File.expand_path("../lib/date.rb", __FILE__)).find do |line| + /^\s*VERSION\s*=\s*["'](.*)["']/ =~ line and break $1 +end + Gem::Specification.new do |s| s.name = "date" - s.version = '3.2.1' + s.version = version s.summary = "A subclass of Object includes Comparable module for handling dates." s.description = "A subclass of Object includes Comparable module for handling dates." diff --git a/lib/date.rb b/lib/date.rb index 49012195..c8fad9ac 100644 --- a/lib/date.rb +++ b/lib/date.rb @@ -4,6 +4,7 @@ require 'date_core' class Date + VERSION = '3.2.1' # :nodoc: def infinite? false