From 9385bd8e59d5d03c177bd2beba5fb7ad737d2008 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Tue, 8 Feb 2022 11:49:05 +0900 Subject: [PATCH] Support directory layout of ruby/ruby repository --- ipaddr.gemspec | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ipaddr.gemspec b/ipaddr.gemspec index 352570a..d571112 100644 --- a/ipaddr.gemspec +++ b/ipaddr.gemspec @@ -1,9 +1,17 @@ # frozen_string_literal: true # coding: utf-8 -lib = File.expand_path("../lib", __FILE__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -version = File.foreach(File.expand_path("ipaddr.rb", lib)).find do |line| +if File.exist?(File.expand_path("ipaddr.gemspec")) + lib = File.expand_path("../lib", __FILE__) + $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) + + file = File.expand_path("ipaddr.rb", lib) +else + # for ruby-core + file = File.expand_path("ipaddr.rb") +end + +version = File.foreach(file).find do |line| /^\s*VERSION\s*=\s*["'](.*)["']/ =~ line and break $1 end