Class: Wip::BuildContext
- Inherits:
-
Object
- Object
- Wip::BuildContext
- Defined in:
- lib/wip/build_context.rb
Overview
Filters build contexts for wslc and keeps WSL-hosted sources in a fast, persistent Windows-side shadow directory.
Instance Method Summary collapse
-
#initialize(context, ignore: nil, environment: Environment.new, shadow_root: nil) ⇒ BuildContext
constructor
A new instance of BuildContext.
-
#stage(on_progress: nil, &block) ⇒ Object
on_progress fires before copying and after each file, as
|count, total|, so a caller can report elapsed progress even while copying one large file.
Constructor Details
#initialize(context, ignore: nil, environment: Environment.new, shadow_root: nil) ⇒ BuildContext
Returns a new instance of BuildContext.
14 15 16 17 18 19 |
# File 'lib/wip/build_context.rb', line 14 def initialize(context, ignore: nil, environment: Environment.new, shadow_root: nil) @root = Pathname(context). @ignore = ignore || DockerIgnore.load(@root.join('.dockerignore')) @environment = environment @shadow_root = validated_shadow_root(shadow_root) if shadow_root end |
Instance Method Details
#stage(on_progress: nil, &block) ⇒ Object
on_progress fires before copying and after each file, as |count, total|,
so a caller can report elapsed progress even while copying one large file.
23 24 25 26 27 28 29 30 31 |
# File 'lib/wip/build_context.rb', line 23 def stage(on_progress: nil, &block) return stage_shadow(on_progress, &block) if shadow_required? return block.call(@root.to_s) if @ignore.empty? Dir.mktmpdir('wip-build-context-') do |dir| copy_included_files(Pathname(dir), on_progress) block.call(dir) end end |