Skip to content

Commit 8359cf7

Browse files
committed
Remove version.rb
Loading separate version.rb unnecessary increases every start-up time. In the other hand, the gemspec file is parsed only when building the gem file.
1 parent ba3bd6f commit 8359cf7

File tree

3 files changed

+14
-19
lines changed

3 files changed

+14
-19
lines changed

fileutils.gemspec

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
# frozen_string_literal: true
22

3-
begin
4-
require_relative "lib/fileutils/version"
5-
rescue LoadError
6-
# for Ruby core repository
7-
require_relative "version"
3+
source_version = ["", "lib/"].find do |dir|
4+
begin
5+
break File.open(File.join(__dir__, "#{dir}fileutils.rb")) {|f|
6+
f.gets("\n VERSION = ")
7+
f.gets[/\s*"(.+)"/, 1]
8+
}
9+
rescue Errno::ENOENT
10+
end
811
end
912

1013
Gem::Specification.new do |s|
1114
s.name = "fileutils"
12-
s.version = FileUtils::VERSION
15+
s.version = source_version
1316
s.summary = "Several file utility methods for copying, moving, removing, etc."
1417
s.description = "Several file utility methods for copying, moving, removing, etc."
1518

1619
s.require_path = %w{lib}
17-
s.files = ["LICENSE.txt", "README.md", "Rakefile", "fileutils.gemspec", "lib/fileutils.rb", "lib/fileutils/version.rb"]
20+
s.files = ["LICENSE.txt", "README.md", "Rakefile", "fileutils.gemspec", "lib/fileutils.rb"]
1821
s.required_ruby_version = ">= 2.3.0"
1922

2023
s.authors = ["Minero Aoki"]
2124
s.email = [nil]
2225
s.homepage = "https://github.com/ruby/fileutils"
2326
s.license = "BSD-2-Clause"
2427

25-
if s.respond_to?(:metadata=)
26-
s.metadata = {
27-
"source_code_uri" => "https://github.com/ruby/fileutils"
28-
}
29-
end
28+
s.metadata = {
29+
"source_code_uri" => "https://github.com/ruby/fileutils"
30+
}
3031
end

lib/fileutils.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
# for make mjit-headers
77
end
88

9-
require_relative "fileutils/version"
10-
119
#
1210
# = fileutils.rb
1311
#
@@ -104,6 +102,7 @@
104102
# <tt>:verbose</tt> flags to methods in FileUtils.
105103
#
106104
module FileUtils
105+
VERSION = "1.3.0"
107106

108107
def self.private_module_function(name) #:nodoc:
109108
module_function name

lib/fileutils/version.rb

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)