Skip to content

Commit bccaa66

Browse files
committed
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.
1 parent c019cae commit bccaa66

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

bigdecimal.gemspec

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# coding: utf-8
22

3-
bigdecimal_version = '3.1.0.dev'
4-
53
Gem::Specification.new do |s|
64
s.name = "bigdecimal"
7-
s.version = bigdecimal_version
5+
s.version = "3.1.0.dev"
86
s.authors = ["Kenta Murata", "Zachary Scott", "Shigeo Kobayashi"]
97
s.email = ["mrkn@mrkn.jp"]
108

ext/bigdecimal/extconf.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33

44
def check_bigdecimal_version(gemspec_path)
55
message "checking RUBY_BIGDECIMAL_VERSION... "
6-
7-
bigdecimal_version =
8-
IO.readlines(gemspec_path)
9-
.grep(/\Abigdecimal_version\s+=\s+/)[0][/\'([^\']+)\'/, 1]
6+
bigdecimal_version = File.read(gemspec_path).match(/^\s*s\.version\s+=\s+['"]([^'"]+)['"]\s*$/)[1]
107

118
version_components = bigdecimal_version.split('.')
129
bigdecimal_version = version_components[0, 3].join('.')

0 commit comments

Comments
 (0)