Skip to content

Commit

Permalink
[ruby/bigdecimal] Improve extconf to allow using bigdecimal as a git gem
Browse files Browse the repository at this point in the history
e.g.
```
gem "bigdecimal", github: "ruby/bigdecimal"
```

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

ruby/bigdecimal@bccaa66f2c
  • Loading branch information
byroot authored and mrkn committed Dec 23, 2021
1 parent 84ae7a5 commit d0897e3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
4 changes: 1 addition & 3 deletions ext/bigdecimal/bigdecimal.gemspec
@@ -1,10 +1,8 @@
# 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@mrkn.jp"]

Expand Down
5 changes: 1 addition & 4 deletions ext/bigdecimal/extconf.rb
Expand Up @@ -3,10 +3,7 @@

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('.')
Expand Down

0 comments on commit d0897e3

Please sign in to comment.