Class: Jekyll::Commands::Contentful

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

Overview

jekyll contentful Command

Class Method Summary collapse

Class Method Details

.command_action(command) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/jekyll/commands/contentful.rb', line 30

def self.command_action(command)
  command.action do |args, options|
    jekyll_options = configuration_from_options(options)
    contentful_config = jekyll_options['contentful']
    process args, options, contentful_config
  end
end

.init_with_program(prog) ⇒ Object



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

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) }

    add_build_options(c)

    command_action(c)
  end
end

.optionsObject



21
22
23
24
25
26
27
28
# File 'lib/jekyll/commands/contentful.rb', line 21

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

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



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/jekyll/commands/contentful.rb', line 38

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'

  return unless options['rebuild']

  Jekyll.logger.info 'Starting Jekyll Rebuild'
  Jekyll::Commands::Build.process(options)
end