From 3ef57b5b394ff6ae1399c74abccbf5e4ab444293 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Tue, 5 Dec 2023 11:23:24 +0900 Subject: [PATCH 1/2] Detect json version from version.rb --- json-java.gemspec | 6 +++++- json.gemspec | 6 +++++- json_pure.gemspec | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/json-java.gemspec b/json-java.gemspec index b766fa2f..5a5b61a5 100644 --- a/json-java.gemspec +++ b/json-java.gemspec @@ -1,6 +1,10 @@ +version = File.foreach(File.join(__dir__, "lib/json/version.rb")) do |line| + /^\s*VERSION\s*=\s*'(.*)'/ =~ line and break $1 +end rescue nil + spec = Gem::Specification.new do |s| s.name = "json" - s.version = File.read("VERSION").chomp + s.version = version s.summary = "JSON Implementation for Ruby" s.description = "A JSON implementation as a JRuby extension." diff --git a/json.gemspec b/json.gemspec index 9cd4ceee..33d21407 100644 --- a/json.gemspec +++ b/json.gemspec @@ -1,6 +1,10 @@ +version = File.foreach(File.join(__dir__, "lib/json/version.rb")) do |line| + /^\s*VERSION\s*=\s*'(.*)'/ =~ line and break $1 +end rescue nil + Gem::Specification.new do |s| s.name = "json" - s.version = File.read(File.expand_path('../VERSION', __FILE__)).chomp + s.version = version s.summary = "JSON Implementation for Ruby" s.description = "This is a JSON implementation as a Ruby extension in C." diff --git a/json_pure.gemspec b/json_pure.gemspec index 7b42a714..26f1fb3a 100644 --- a/json_pure.gemspec +++ b/json_pure.gemspec @@ -1,6 +1,10 @@ +version = File.foreach(File.join(__dir__, "lib/json/version.rb")) do |line| + /^\s*VERSION\s*=\s*'(.*)'/ =~ line and break $1 +end rescue nil + Gem::Specification.new do |s| s.name = "json_pure".freeze - s.version = File.read("VERSION").chomp + s.version = version s.summary = "JSON Implementation for Ruby".freeze s.description = "This is a JSON implementation in pure Ruby.".freeze From 113ade8f176f2665033cb9a36bbbbe2feac0b866 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Tue, 5 Dec 2023 11:23:47 +0900 Subject: [PATCH 2/2] Removed obsoleted version definition --- Rakefile | 4 +++- VERSION | 1 - json.gemspec | 1 - json_pure.gemspec | 1 - 4 files changed, 3 insertions(+), 4 deletions(-) delete mode 100644 VERSION diff --git a/Rakefile b/Rakefile index c61016ef..1292d040 100644 --- a/Rakefile +++ b/Rakefile @@ -26,7 +26,9 @@ which = lambda { |c| MAKE = ENV['MAKE'] || %w[gmake make].find(&which) BUNDLE = ENV['BUNDLE'] || %w[bundle].find(&which) -PKG_VERSION = File.read('VERSION').chomp +PKG_VERSION = version = File.foreach(File.join(__dir__, "lib/json/version.rb")) do |line| + /^\s*VERSION\s*=\s*'(.*)'/ =~ line and break $1 +end rescue nil EXT_ROOT_DIR = 'ext/json/ext' EXT_PARSER_DIR = "#{EXT_ROOT_DIR}/parser" diff --git a/VERSION b/VERSION deleted file mode 100644 index 24ba9a38..00000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -2.7.0 diff --git a/json.gemspec b/json.gemspec index 33d21407..64d0c813 100644 --- a/json.gemspec +++ b/json.gemspec @@ -19,7 +19,6 @@ Gem::Specification.new do |s| "CHANGES.md", "LICENSE", "README.md", - "VERSION", "ext/json/ext/fbuffer/fbuffer.h", "ext/json/ext/generator/depend", "ext/json/ext/generator/extconf.rb", diff --git a/json_pure.gemspec b/json_pure.gemspec index 26f1fb3a..c0ebc41e 100644 --- a/json_pure.gemspec +++ b/json_pure.gemspec @@ -18,7 +18,6 @@ Gem::Specification.new do |s| "CHANGES.md".freeze, "LICENSE".freeze, "README.md".freeze, - "VERSION".freeze, "json_pure.gemspec".freeze, "lib/json.rb".freeze, "lib/json/add/bigdecimal.rb".freeze,