Skip to content

Commit

Permalink
Extract version number from the source
Browse files Browse the repository at this point in the history
"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
nobu authored and hsbt committed Aug 3, 2020
1 parent 826dcff commit c154a12
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
1 change: 1 addition & 0 deletions lib/net/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ class HTTPHeaderSyntaxError < StandardError; end
class HTTP < Protocol

# :stopdoc:
VERSION = "0.1.0"
Revision = %q$Revision$.split[1]
HTTPVersion = '1.1'
begin
Expand Down
5 changes: 0 additions & 5 deletions lib/net/http/version.rb

This file was deleted.

15 changes: 9 additions & 6 deletions net-http.gemspec
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]"]

Expand Down

0 comments on commit c154a12

Please sign in to comment.