Class: Jekyll::Commands::GhDeploy

Inherits:
Command
  • Object
show all
Defined in:
lib/jekyll/commands/ghdeploy.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
# File 'lib/jekyll/commands/ghdeploy.rb', line 6

def init_with_program(prog)
  prog.command(:ghdeploy) do |c|

    c.syntax "deploy REPOSITORY"
    
    c.description "Deploys your site to your gh-pages branch"
    
    c.action do |args, options|
      Jekyll::Commands::GhDeploy.process(args, options)
    end
  end
end

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



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/jekyll/commands/ghdeploy.rb', line 19

def process(args, options = {})

  config = YAML.load_file('_config.yml')    
  message = `git log -1 --pretty=%s`

  if args.empty? && config['repository'].blank?
    raise ArgumentError, "You must specify a repository."
  elsif args.empty?
    repo = config['repository']
  else 
    repo = args[0]
  end

  site = JekyllGhDeploy::Site.new(repo, message)
  
  at_exit do
   site.clean
  end 
  
  site.deploy

end