Skip to content

Commit 587ae69

Browse files
committed
Expose IPAddr::VERSION
An almost universal convention for gems is to expose Namespace::VERSION which makes it much easier when debugging etc.
1 parent 72a2649 commit 587ae69

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

ipaddr.gemspec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33
lib = File.expand_path("../lib", __FILE__)
44
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
55

6+
version = File.foreach(File.expand_path("ipaddr.rb", lib)).find do |line|
7+
/^\s*VERSION\s*=\s*["'](.*)["']/ =~ line and break $1
8+
end
9+
610
Gem::Specification.new do |spec|
711
spec.name = "ipaddr"
8-
spec.version = "1.2.3"
12+
spec.version = version
913
spec.authors = ["Akinori MUSHA", "Hajimu UMEMOTO"]
1014
spec.email = ["knu@idaemons.org", "ume@mahoroba.org"]
1115

lib/ipaddr.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
# p ipaddr3 #=> #<IPAddr: IPv4:192.168.2.0/255.255.255.0>
4141

4242
class IPAddr
43+
VERSION = "1.2.3"
4344

4445
# 32 bit mask for IPv4
4546
IN4MASK = 0xffffffff

0 commit comments

Comments
 (0)