Class: Coppy::Steps::Copy
- Inherits:
-
Object
- Object
- Coppy::Steps::Copy
- Extended by:
- DSL::Module
- Defined in:
- lib/coppy/steps/copy.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(&block) ⇒ Copy
constructor
A new instance of Copy.
Methods included from DSL::Module
Constructor Details
Instance Method Details
#call(env) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/coppy/steps/copy.rb', line 16 def call(env) copy_env = Environment.new(ignore: []) @manifesto.execute!(copy_env) files = Dir.glob(File.join(env.source, "**", "*"), File::FNM_DOTMATCH) - %w[. ..] ignored_files = copy_env.ignore.flat_map do |ignore| pattern = File.join env.source, ignore pattern = File.join(pattern, "**", '*') if File.directory?(pattern) Dir.glob(pattern) end (files - ignored_files).each do |file| relative = file.sub(env.source, '') target = File.join(env.target, relative) FileUtils.mkdir_p(File.dirname target) FileUtils.cp(file, target, preserve: true) unless File.directory?(file) end end |