Class: Roger::Release::Finalizers::Dir

Inherits:
Base
  • Object
show all
Defined in:
lib/roger/release/finalizers/dir.rb

Overview

Finalizes the release into a directory in target_path

The directory name will have the format PREFIX-VERSION

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Roger::Release::Finalizers::Base

Instance Method Details

#call(release, call_options = {}) ⇒ Object

Parameters:

  • options (Hash)

    a customizable set of options



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/roger/release/finalizers/dir.rb', line 10

def call(release, call_options = {})
  options = {
    prefix: "html",
    target_path: release.target_path
  }.update(@options)
  options.update(call_options) if call_options

  name = [options[:prefix], release.scm.version].join("-")

  target_dir = Pathname.new(options[:target_path])
  FileUtils.mkdir_p(target_dir) unless target_dir.exist?

  target_path = target_dir + name

  release.log(self, "Finalizing release to #{target_path}")

  if File.exist?(target_path)
    release.log(self, "Removing existing target #{target_path}")
    FileUtils.rm_rf(target_path)
  end

  FileUtils.cp_r release.build_path, target_path
end