Class: Wip::BuildContext
- Inherits:
-
Object
- Object
- Wip::BuildContext
- Defined in:
- lib/wip/build_context.rb
Overview
Stages a build context into a scratch directory with anything matched by
.dockerignore left out, since wslc build (unlike docker build) sends the
context as-is instead of filtering it itself.
Instance Method Summary collapse
-
#initialize(context, ignore: nil) ⇒ BuildContext
constructor
A new instance of BuildContext.
-
#stage(on_progress: nil) ⇒ 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) ⇒ BuildContext
Returns a new instance of BuildContext.
12 13 14 15 |
# File 'lib/wip/build_context.rb', line 12 def initialize(context, ignore: nil) @root = Pathname(context). @ignore = ignore || DockerIgnore.load(@root.join('.dockerignore')) end |
Instance Method Details
#stage(on_progress: nil) ⇒ 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.
19 20 21 22 23 24 25 26 |
# File 'lib/wip/build_context.rb', line 19 def stage(on_progress: nil) return yield @root.to_s if @ignore.empty? Dir.mktmpdir('wip-build-context-') do |dir| copy_included_files(Pathname(dir), on_progress) yield dir end end |