Module: Bake::Modernize
- Defined in:
- lib/bake/modernize.rb,
lib/bake/modernize/license.rb,
lib/bake/modernize/version.rb
Defined Under Namespace
Modules: License
Constant Summary collapse
- ROOT =
File.("../..", __dir__)
- TEMPLATE_ROOT =
Build::Files::Path.new(ROOT) + "template"
- VERSION =
"0.29.0"
Class Method Summary collapse
-
.copy_template(source_path, destination_path) ⇒ Object
Copy files from the source path to the destination path.
-
.stale?(source_path, destination_path) ⇒ Boolean
Check if the destination path is stale compared to the source path.
-
.template_path_for(path) ⇒ Object
Compute the template root path relative to the gem root.
Class Method Details
.copy_template(source_path, destination_path) ⇒ Object
Copy files from the source path to the destination path.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/bake/modernize.rb', line 37 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 |
.stale?(source_path, destination_path) ⇒ Boolean
Check if the destination path is stale compared to the source path.
25 26 27 28 29 30 31 |
# File 'lib/bake/modernize.rb', line 25 def self.stale?(source_path, destination_path) if File.exist?(destination_path) return !FileUtils.identical?(source_path, destination_path) end return true end |
.template_path_for(path) ⇒ Object
Compute the template root path relative to the gem root.
20 21 22 |
# File 'lib/bake/modernize.rb', line 20 def self.template_path_for(path) TEMPLATE_ROOT + path end |