Module: Docker::Template::Cache
- Defined in:
- lib/docker/template/cache.rb
Class Method Summary collapse
-
.aliased_context(builder) ⇒ Object
– rubocop:disable Metrics/LineLength –.
-
.cleanup(repo) ⇒ Object
– Cleanup the context caches, removing the caches we no longer need.
-
.context(builder, context) ⇒ Object
– Cache the context into the cache directory.
-
.readme(builder) ⇒ Object
– Note: We normally expect but do not require you to have a README.
Class Method Details
.aliased_context(builder) ⇒ Object
– rubocop:disable Metrics/LineLength –
31 32 33 34 35 36 37 38 |
# File 'lib/docker/template/cache.rb', line 31 def aliased_context(builder) if builder.aliased_repo.cache_dir.exist? $stderr.puts Simple::Ansi.yellow(format("Copying %s context to %s", builder.aliased_repo, builder.repo)) builder.aliased_repo.cache_dir.cp_r(builder.repo.cache_dir.tap( &:rm_rf )) end end |
.cleanup(repo) ⇒ Object
– Cleanup the context caches, removing the caches we no longer need. rubocop:enable Metrics/LineLength –
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/docker/template/cache.rb', line 45 def cleanup(repo) return unless repo.clean_cache? cache_dir = repo.cache_dir.parent if cache_dir.exist? cache_dir.children.each do |file| next unless repo...include?(file.basename) $stdout.puts Simple::Ansi.yellow(format("Removing %s.", file.relative_path_from(Template.root) )) file.rm_rf end end end |
.context(builder, context) ⇒ Object
– Cache the context into the cache directory. –
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/docker/template/cache.rb', line 14 def context(builder, context) builder.repo.cache_dir.rm_rf $stderr.puts Simple::Ansi.yellow(format("Copying context for %s", builder.repo)) cache_dir = builder.repo.cache_dir cache_dir.parent.mkdir_p context.cp_r(cache_dir.tap( &:rm_rf )) readme(builder) end |
.readme(builder) ⇒ Object
– Note: We normally expect but do not require you to have a README. Search for and copy the readme if available. –
66 67 68 69 70 71 |
# File 'lib/docker/template/cache.rb', line 66 def readme(builder) return unless file = builder.repo.root.children.find { |val| val =~ /readme/i } file.safe_copy(builder.repo.cache_dir, { :root => file.parent }) end |