Class: Middleman::Diff::Preview
- Inherits:
-
Object
- Object
- Middleman::Diff::Preview
- Defined in:
- lib/middleman-diff/preview.rb
Overview
Preview of the build
Instance Method Summary collapse
-
#dispose ⇒ void
Clean up any temporary files from the preview.
-
#initialize(app, build_hooks: true, temp_dir: 'tmp') ⇒ void
constructor
Generate a preview of the build.
-
#replace_build ⇒ void
Replace the existing build with the preview.
-
#show_diff ⇒ void
Output a diff of the existing build and preview.
Constructor Details
#initialize(app, build_hooks: true, temp_dir: 'tmp') ⇒ void
Generate a preview of the build.
16 17 18 19 20 21 22 |
# File 'lib/middleman-diff/preview.rb', line 16 def initialize(app, build_hooks: true, temp_dir: 'tmp') @app = app @build_hooks = build_hooks @temp_dir = Pathname.new(temp_dir) build_preview end |
Instance Method Details
#dispose ⇒ void
This method returns an undefined value.
Clean up any temporary files from the preview.
27 28 29 |
# File 'lib/middleman-diff/preview.rb', line 27 def dispose preview_dir.rmtree if preview_dir.exist? end |
#replace_build ⇒ void
This method returns an undefined value.
Replace the existing build with the preview.
34 35 36 37 |
# File 'lib/middleman-diff/preview.rb', line 34 def replace_build build_dir.rmtree FileUtils.move preview_dir, build_dir end |
#show_diff ⇒ void
This method returns an undefined value.
Output a diff of the existing build and preview.
42 43 44 45 |
# File 'lib/middleman-diff/preview.rb', line 42 def show_diff prefix = %w(git diff --no-index --patch-with-stat --) system(*(prefix + [build_dir.to_s, preview_dir.to_s])) end |