module Modernize
Nested Classes and Modules
module GitUtilities for inspecting git repositories.
module LicenseSupport the analysis of authorship and license details.
class SigningResolve the RubyGems signing certificate and private key for a project.
Definitions
def self.gem_dependencies(root)
Read the gem dependencies declared by the target project, including optional groups.
Signature
-
parameter
rootString The root directory of the project.
-
returns
Array(String) The declared dependency names.
Implementation
def self.gem_dependencies(root)
require "bundler"
if path = ["gems.rb", "Gemfile"].map{|name| File.expand_path(name, root)}.find{|path| File.file?(path)}
dsl = Bundler::Dsl.new
dsl.eval_gemfile(path)
return dsl.dependencies.map(&:name)
end
return []
end
def self.template_path_for(path)
Compute the template root path relative to the gem root.
Implementation
def self.template_path_for(path)
TEMPLATE_ROOT + path
end
def self.stale?(source_path, destination_path)
Check if the destination path is stale compared to the source path.
Implementation
def self.stale?(source_path, destination_path)
if File.exist?(destination_path)
return !FileUtils.identical?(source_path, destination_path)
end
return true
end
def self.copy_template(source_path, destination_path)
Copy files from the source path to the destination path.
Signature
-
parameter
source_pathString The source path.
-
parameter
destination_pathString The destination path.
Implementation
def self.copy_template(source_path, destination_path)
glob = Build::Files::Glob.new(source_path, "**/*")
glob.each do |path|
full_path = File.join(destination_path, path.relative_path)
if File.directory?(path)
unless File.directory?(full_path)
FileUtils.mkdir_p(full_path)
end
else
if stale?(path, full_path)
FileUtils::Verbose.cp(path, full_path)
end
end
end
end