Class: Bunto::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/bunto/command.rb

Class Method Summary collapse

Class Method Details

.add_build_options(c) ⇒ Object

Add common options to a command for building configuration

c - the Bunto::Command to add these options to

Returns nothing



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/bunto/command.rb', line 48

def add_build_options(c)
  c.option "config", "--config CONFIG_FILE[,CONFIG_FILE2,...]",
    Array, "Custom configuration file"
  c.option "destination", "-d", "--destination DESTINATION",
    "The current folder will be generated into DESTINATION"
  c.option "source", "-s", "--source SOURCE", "Custom source directory"
  c.option "future", "--future", "Publishes posts with a future date"
  c.option "limit_posts", "--limit_posts MAX_POSTS", Integer,
    "Limits the number of posts to parse and publish"
  c.option "watch", "-w", "--[no-]watch", "Watch for changes and rebuild"
  c.option "baseurl", "-b", "--baseurl URL",
    "Serve the website from the given base URL"
  c.option "force_polling", "--force_polling", "Force watch to use polling"
  c.option "lsi", "--lsi", "Use LSI for improved related posts"
  c.option "show_drafts", "-D", "--drafts", "Render posts in the _drafts folder"
  c.option "unpublished", "--unpublished",
    "Render posts that were marked as unpublished"
  c.option "quiet", "-q", "--quiet", "Silence output."
  c.option "verbose", "-V", "--verbose", "Print verbose output."
  c.option "incremental", "-I", "--incremental", "Enable incremental rebuild."
end

.configuration_from_options(options) ⇒ Object

Create a full Bunto configuration with the options passed in as overrides

options - the configuration overrides

Returns a full Bunto configuration



39
40
41
# File 'lib/bunto/command.rb', line 39

def configuration_from_options(options)
  Bunto.configuration(options)
end

.inherited(base) ⇒ Object

Keep a list of subclasses of Bunto::Command every time it’s inherited Called automatically.

base - the subclass

Returns nothing



15
16
17
18
# File 'lib/bunto/command.rb', line 15

def inherited(base)
  subclasses << base
  super(base)
end

.process_site(site) ⇒ Object

Run Site#process and catch errors

site - the Bunto::Site object

Returns nothing



25
26
27
28
29
30
31
32
# File 'lib/bunto/command.rb', line 25

def process_site(site)
  site.process
rescue Bunto::Errors::FatalException => e
  Bunto.logger.error "ERROR:", "YOUR SITE COULD NOT BE BUILT:"
  Bunto.logger.error "", "------------------------------------"
  Bunto.logger.error "", e.message
  exit(1)
end

.subclassesObject

A list of subclasses of Bunto::Command



5
6
7
# File 'lib/bunto/command.rb', line 5

def subclasses
  @subclasses ||= []
end