class Paperwork::Tasks::Template

Task for generating middleman template directory for building

Attributes

dir[R]
template[R]

Public Class Methods

new(name, *dependencies) click to toggle source
Calls superclass method Paperwork::Tasks::Base::new
# File lib/paperwork/tasks/template.rb, line 17
def initialize(name, *dependencies)
    @dir = File.join(Paperwork::Config[:build_root], name.to_s)
    @bundle = File.join(Paperwork::Config[:build_root], ".bundle")
    super(self.dir, File.dirname(self.dir), @bundle, *dependencies)

    BuildDir.new(@bundle)
    BuildDir.new(File.dirname(self.dir))
    @template = File.expand_path("middleman_template", __dir__)
end

Public Instance Methods

tasks() click to toggle source
# File lib/paperwork/tasks/template.rb, line 27
def tasks
    directory self.name => self.dependencies do
        cp_r template, self.dir
        Dir.chdir(self.dir) do
            cmd = "bundle install --path=../.bundle/gems --jobs 8 --without test development"
            if defined? Bundler
                Bundler.with_unbundled_env do
                    Process.spawn(cmd, out: :out, in: :in, err: :err)
                end
            else
                Process.spawn(cmd, out: :out, in: :in, err: :err)
            end
            Process.spawn("yarn install", out: :out, in: :in, err: :err)
            Process.waitall
        end
    end
end