Class: Jekyll::Commands::DeployKakuyomu

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

Constant Summary collapse

COMMAND_OPTIONS =
{
  'email'    => ['--email EMAIL', 'Email of Kakuyomu account'],
  'password' => ['--password PASSWORD', 'Password of Kakuyomu account'],
  'work_id'  => ['--work_id WORK_ID', Integer, 'The posts will be deployed into Kakuyomu work of WORK_ID'],
}

Class Method Summary collapse

Class Method Details

.init_with_program(prog) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/jekyll/commands/deploy_kakuyomu.rb', line 11

def init_with_program(prog)
  prog.command(:'deploy-kakuyomu') do |c|
    c.syntax 'deploy-kakuyomu [options]'
    c.description 'Deploy posts to Kakuyomu'
    c.alias :dk

    c.option 'config', '--config CONFIG_FILE[,CONFIG_FILE2,...]', Array, 'Custom configuration file'
    c.option "future", "--future", "Publishes posts with a future date"
    c.option 'verbose', '-V', '--verbose', 'Print verbose output.'

    COMMAND_OPTIONS.each do |key, val|
      c.option key, *val
    end

    c.action do |_args, options|
      options['kakuyomu'] = {}
      COMMAND_OPTIONS.keys.each do |key|
        options['kakuyomu'][key] = options[key] unless options[key].nil?
      end

      process(options)
    end
  end
end

.process(options, deployer: JekyllDeployShosetsu::Deployers::Kakuyomu.new) ⇒ Object



36
37
38
39
40
41
42
43
44
# File 'lib/jekyll/commands/deploy_kakuyomu.rb', line 36

def process(options, deployer: JekyllDeployShosetsu::Deployers::Kakuyomu.new)
  Jekyll.logger.adjust_verbosity(options)

  site = Jekyll::Site.new(configure(options))
  site.reset
  site.read

  deployer.deploy(site)
end