[前][次][番号順一覧][スレッド一覧]

ruby-changes:70479

From: Jean <ko1@a...>
Date: Fri, 24 Dec 2021 02:30:05 +0900 (JST)
Subject: [ruby-changes:70479] d0897e3f3a (master): [ruby/bigdecimal] Improve extconf to allow using bigdecimal as a git gem

https://git.ruby-lang.org/ruby.git/commit/?id=d0897e3f3a

From d0897e3f3afdc6d1fdb0fa60bdf4b0cb80c7de03 Mon Sep 17 00:00:00 2001
From: Jean Boussier <jean.boussier@g...>
Date: Thu, 2 Dec 2021 12:02:21 +0100
Subject: [ruby/bigdecimal] Improve extconf to allow using bigdecimal as a git
 gem

e.g.
```
gem "bigdecimal", github: "ruby/bigdecimal"
```

It would fail because bundler regenerates the `gemspec`,
so `bigdecimal_version` is gone.

https://github.com/ruby/bigdecimal/commit/bccaa66f2c
---
 ext/bigdecimal/bigdecimal.gemspec | 4 +---
 ext/bigdecimal/extconf.rb         | 5 +----
 2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/ext/bigdecimal/bigdecimal.gemspec b/ext/bigdecimal/bigdecimal.gemspec
index bb4610cbbd8..1d8b36ee54d 100644
--- a/ext/bigdecimal/bigdecimal.gemspec
+++ b/ext/bigdecimal/bigdecimal.gemspec
@@ -1,10 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.gemspec#L1
 # coding: utf-8
 
-bigdecimal_version = '3.1.0.dev'
-
 Gem::Specification.new do |s|
   s.name          = "bigdecimal"
-  s.version       = bigdecimal_version
+  s.version       = "3.1.0.dev"
   s.authors       = ["Kenta Murata", "Zachary Scott", "Shigeo Kobayashi"]
   s.email         = ["mrkn@m..."]
 
diff --git a/ext/bigdecimal/extconf.rb b/ext/bigdecimal/extconf.rb
index c92aacb3f2f..9b0c55b21c1 100644
--- a/ext/bigdecimal/extconf.rb
+++ b/ext/bigdecimal/extconf.rb
@@ -3,10 +3,7 @@ require 'mkmf' https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/extconf.rb#L3
 
 def check_bigdecimal_version(gemspec_path)
   message "checking RUBY_BIGDECIMAL_VERSION... "
-
-  bigdecimal_version =
-    IO.readlines(gemspec_path)
-      .grep(/\Abigdecimal_version\s+=\s+/)[0][/\'([^\']+)\'/, 1]
+  bigdecimal_version = File.read(gemspec_path).match(/^\s*s\.version\s+=\s+['"]([^'"]+)['"]\s*$/)[1]
 
   version_components = bigdecimal_version.split('.')
   bigdecimal_version = version_components[0, 3].join('.')
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]