Sha256: 321a9e48d59ae46f59620d213961e46886c4dd8d689885f00f2c51e5779ced08

Contents?: true

Size: 1.04 KB

Versions: 20

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2020-2023, by Samuel Williams.

require_relative 'modernize/license'
require_relative 'modernize/version'
require 'build/files/glob'
require 'fileutils'

module Bake
	module Modernize
		ROOT = File.expand_path("../..", __dir__)
		
		TEMPLATE_ROOT = Build::Files::Path.new(ROOT) + "template"
		
		def self.template_path_for(path)
			TEMPLATE_ROOT + path
		end
		
		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)
			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
	end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
bake-modernize-0.26.0 lib/bake/modernize.rb
bake-modernize-0.25.0 lib/bake/modernize.rb
bake-modernize-0.24.0 lib/bake/modernize.rb
bake-modernize-0.23.0 lib/bake/modernize.rb
bake-modernize-0.22.0 lib/bake/modernize.rb
bake-modernize-0.21.0 lib/bake/modernize.rb
bake-modernize-0.20.0 lib/bake/modernize.rb
bake-modernize-0.19.4 lib/bake/modernize.rb
bake-modernize-0.19.3 lib/bake/modernize.rb
bake-modernize-0.19.2 lib/bake/modernize.rb
bake-modernize-0.19.1 lib/bake/modernize.rb
bake-modernize-0.19.0 lib/bake/modernize.rb
bake-modernize-0.18.0 lib/bake/modernize.rb
bake-modernize-0.17.8 lib/bake/modernize.rb
bake-modernize-0.17.7 lib/bake/modernize.rb
bake-modernize-0.17.6 lib/bake/modernize.rb
bake-modernize-0.17.5 lib/bake/modernize.rb
bake-modernize-0.17.4 lib/bake/modernize.rb
bake-modernize-0.17.3 lib/bake/modernize.rb
bake-modernize-0.17.2 lib/bake/modernize.rb