Class: Jekyll::Commands::Contentful

Inherits:
Command
  • Object
show all
Defined in:
lib/jekyll/commands/contentful.rb

Class Method Summary collapse

Class Method Details

.init_with_program(prog) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/jekyll/commands/contentful.rb', line 6

def self.init_with_program(prog)
  prog.command(:contentful) do |c|
    c.syntax 'contentful [OPTIONS]'
    c.description 'Imports data from Contentful'

    options.each {|opt| c.option(*opt) }

    c.action do |args, options|
      contentful_config = Jekyll.configuration['contentful']
      process args, options, contentful_config
    end
  end
end

.optionsObject



20
21
22
23
24
# File 'lib/jekyll/commands/contentful.rb', line 20

def self.options
  [
    ['rebuild', '-r', '--rebuild', 'Rebuild Jekyll Site after fetching data'],
  ]
end

.process(args = [], options = {}, contentful_config = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/jekyll/commands/contentful.rb', line 27

def self.process(args = [], options = {}, contentful_config = {})
  Jekyll.logger.info 'Starting Contentful import'

  Jekyll::Contentful::Importer.new(contentful_config).run

  Jekyll.logger.info 'Contentful import finished'

  if options['rebuild']
    Jekyll.logger.info 'Starting Jekyll Rebuild'

    Jekyll::Commands::Build.process(options)
  end
end