summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2021-01-20 21:43:04 -0800
committerTakashi Kokubun <takashikkbn@gmail.com>2021-01-20 21:43:05 -0800
commit5f7df72b56ebb741dcc1935897a79f42bc077bcf (patch)
tree4fa32b77d9bcff3dae26f843f4896c293e5b3372 /lib
parent084662dc9f1629995777a11cde72faa98ccb0efc (diff)
[ruby/erb] Unify ERB version definitions
https://github.com/ruby/erb/commit/5df06b8473
Diffstat (limited to 'lib')
-rw-r--r--lib/erb.gemspec9
-rw-r--r--lib/erb.rb5
-rw-r--r--lib/erb/version.rb5
3 files changed, 16 insertions, 3 deletions
diff --git a/lib/erb.gemspec b/lib/erb.gemspec
index d310f40979..bb3f10f97d 100644
--- a/lib/erb.gemspec
+++ b/lib/erb.gemspec
@@ -1,6 +1,13 @@
+begin
+ require_relative 'lib/erb/version'
+rescue LoadError
+ # for Ruby core repository
+ require_relative 'version'
+end
+
Gem::Specification.new do |spec|
spec.name = 'erb'
- spec.version = '2.2.0'
+ spec.version = ERB.const_get(:VERSION, false)
spec.authors = ['Masatoshi SEKI']
spec.email = ['seki@ruby-lang.org']
diff --git a/lib/erb.rb b/lib/erb.rb
index f8533efda9..48e0505157 100644
--- a/lib/erb.rb
+++ b/lib/erb.rb
@@ -12,7 +12,8 @@
#
# You can redistribute it and/or modify it under the same terms as Ruby.
-require "cgi/util"
+require 'cgi/util'
+require 'erb/version'
#
# = ERB -- Ruby Templating
@@ -260,7 +261,7 @@ class ERB
# Returns revision information for the erb.rb module.
def self.version
- "erb.rb [2.2.0 #{ERB::Revision.split[1]}]"
+ "erb.rb [#{VERSION} #{ERB::Revision.split[1]}]"
end
end
diff --git a/lib/erb/version.rb b/lib/erb/version.rb
new file mode 100644
index 0000000000..83a88f3358
--- /dev/null
+++ b/lib/erb/version.rb
@@ -0,0 +1,5 @@
+# frozen_string_literal: false
+class ERB
+ VERSION = '2.2.0'
+ private_constant :VERSION
+end