Module: Mippin

Defined in:
lib/mippin.rb,
lib/mippin/router.rb,
lib/mippin/version.rb,
lib/mippin/backports.rb,
lib/mippin/application.rb

Overview

:nodoc:

Defined Under Namespace

Modules: Backports Classes: Application, Router

Constant Summary collapse

VERSION =
"0.6.0"

Class Method Summary collapse

Class Method Details

.application(options = {}) ⇒ Object

Builds the Jekyll site, prepares the middleware stack, and returns the Rack application.

Options:

:config

use given config file (default: “_config.yml”)

:skip_build

whether to skip site generation at startup (default: false)

Other options are passed on to Jekyll::Site.

Returns a Rack application.



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/mippin.rb', line 52

def self.application(options = {})
  skip_build = options.fetch(:skip_build, default_options[:skip_build])

  config = jekyll_config(options)

  if skip_build
    puts skip_build_warning
  else
    process(config)
  end

  destination = config["destination"]
  router = Router.new(destination)

  Rack::Builder.new do
    use Rack::Head
    use Rack::ContentLength
    use Rack::ConditionalGet
    use Rack::ETag, nil, nil

    run Application.new(router)
  end
end

.build(options = {}) ⇒ Object

Builds the Jekyll site.

Accepts the same options as ::application, except for the :skip_build option which is ignored.



80
81
82
83
84
# File 'lib/mippin.rb', line 80

def self.build(options = {})
  config = jekyll_config(options)

  process(config)
end

.default_optionsObject



87
88
89
# File 'lib/mippin.rb', line 87

def self.default_options # :nodoc:
  { skip_build: false }
end

.jekyll_config(overrides = {}) ⇒ Object



92
93
94
95
96
97
# File 'lib/mippin.rb', line 92

def self.jekyll_config(overrides = {}) # :nodoc:
  overrides = overrides.dup
  default_options.each_key { |key| overrides.delete(key) }

  ::Jekyll.configuration(overrides)
end

.process(config) ⇒ Object

Wraps Jekyll::Site’s process method that builds the site.

Takes a Jekyll configuration hash as argument.



109
110
111
112
113
114
115
116
117
118
# File 'lib/mippin.rb', line 109

def self.process(config) # :nodoc:
  site = ::Jekyll::Site.new(config)
  puts "            Source: #{site.source}"
  puts "       Destination: #{site.dest}"
  puts " Generating site..."
  $stdout.flush
  site.process
  puts "                    done."
  $stdout.flush
end

.skip_build_warningObject



100
101
102
# File 'lib/mippin.rb', line 100

def self.skip_build_warning # :nodoc:
  "Build warning: Skipping the initial build."
end