-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract version number from the source
"requiring version.rb" strategy has some issues. - cannot work when cross-compiling - often introduces wrong namespace - must know the superclasses - costs at each runtime than at build-time etc.
- Loading branch information
Showing
3 changed files
with
10 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
begin | ||
require_relative "lib/net/http/version" | ||
rescue LoadError # Fallback to load version file in ruby core repository | ||
require_relative "version" | ||
# frozen_string_literal: true | ||
|
||
name = File.basename(__FILE__, ".gemspec") | ||
version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir| | ||
break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line| | ||
/^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1 | ||
end rescue nil | ||
end | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = "net-http" | ||
spec.version = Net::Http::VERSION | ||
spec.name = name | ||
spec.version = version | ||
spec.authors = ["NARUSE, Yui"] | ||
spec.email = ["[email protected]"] | ||
|
||
|