def build name, destination, **opts
dir = File.join(SCAFFOLDS_PATH, name)
raise LoadError, "Scaffold `#{name}` does not exist" unless File.directory?(dir)
path = Pathname.new('.').join(destination).realdirpath
data = Binder.new(name: File.basename(path), **opts)
files = Dir.glob(File.join(dir, '**', '*'), File::FNM_DOTMATCH).select { |entry| File.file?(entry) }
map = {}
files.each do |file|
next if file.include?('/spec') && !opts[:specs]
rename = File.join(File.dirname(file), File.basename(file)).gsub('__name__', data.snake_case(data.name))
dst = File.join(destination, rename[dir.length..-1])
raise "Gamefic generation would overwrite existing file #{rename}" if File.file?(dst)
map[file] = dst
end
map.each_pair { |src, dst| custom_copy src, dst, data }
Bundler.with_unbundled_env do
Dir.chdir(path) { system 'bundle install' }
end
end