Class: Geb::CLI::Commands::Build

Inherits:
Dry::CLI::Command
  • Object
show all
Defined in:
lib/geb/commands/build.rb

Overview

Define build command

Instance Method Summary collapse

Instance Method Details

#call(**options) ⇒ Object

Call method for the build command



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/geb/commands/build.rb', line 29

def call(**options)

  # initialise a new site and load the site from the current directory
  site = Geb::Site.new
  site.load(Dir.pwd)

  # build the pages unless the skip_pages option is set
  # it is important to build assets first as there may be pages in the assets directory
  Geb.log "Skipping building pages as told." if options[:skip_pages]
  site.build_pages unless options[:skip_pages]

  # build the assets (images, css, js) unless the skip_assets option is set
  Geb.log "Skipping building assets as told." if options[:skip_assets]
  site.build_assets unless options[:skip_assets]

  # put a smartarse message to the console if both options are set
  Geb.log "You told me to skip everything, so I did." if options[:skip_assets] && options[:skip_pages]

rescue Geb::Error => e

  # print error message
  puts
  warn e.message

end