Class: Circus::Profiles::Jekyll

Inherits:
Base
  • Object
show all
Defined in:
lib/circus/profiles/jekyll.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#mark_for_persistent_run?, #package_for_deploy, #package_for_dev, #supported_for_development?

Constructor Details

#initialize(name, dir, props) ⇒ Jekyll

Returns a new instance of Jekyll.



12
13
14
# File 'lib/circus/profiles/jekyll.rb', line 12

def initialize(name, dir, props)
  super(name, dir, props)
end

Class Method Details

.accepts?(name, dir, props) ⇒ Boolean

Checks if this is a Jekyll site based on whether there is a file named _config.yml on the root directory

Returns:

  • (Boolean)


8
9
10
# File 'lib/circus/profiles/jekyll.rb', line 8

def self.accepts?(name, dir, props)
  return File.exists?(File.join(dir, "_config.yml"))
end

Instance Method Details

#cleanup_after_deploy(logger, overlay_dir) ⇒ Object



54
55
56
# File 'lib/circus/profiles/jekyll.rb', line 54

def cleanup_after_deploy(logger, overlay_dir)
  FileUtils.rm_rf(File.join(@dir, '_site'))
end

#deploy_run_script_contentObject



67
68
69
70
71
72
73
# File 'lib/circus/profiles/jekyll.rb', line 67

def deploy_run_script_content
  shell_run_script do
    <<-EOT
    exec lighttpd -D -f lighttpd.conf
    EOT
  end
end

#dev_run_script_contentObject



58
59
60
61
62
63
64
65
# File 'lib/circus/profiles/jekyll.rb', line 58

def dev_run_script_content
  shell_run_script do
    <<-EOT
    cd #{@dir}
    exec jekyll --auto --server
    EOT
  end
end

#extra_dirsObject



25
26
27
# File 'lib/circus/profiles/jekyll.rb', line 25

def extra_dirs
  ["#{@dir}/_site"]
end

#nameObject

The name of this profile



17
18
19
# File 'lib/circus/profiles/jekyll.rb', line 17

def name
  "jekyll"
end

#package_base_dir?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/circus/profiles/jekyll.rb', line 21

def package_base_dir?
  false
end

#prepare_for_deploy(logger, overlay_dir) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/circus/profiles/jekyll.rb', line 29

def prepare_for_deploy(logger, overlay_dir)
  run_external(logger, 'Generate site with Jekyll', "cd #{@dir}; jekyll")

  # Create lighttpd.conf
  File.open(File.join(overlay_dir, 'lighttpd.conf'), 'w') do |f|
      f.write <<-EOT
server.document-root = "_site/" 

server.port = env.HTTPD_PORT

mimetype.assign = (
  ".html" => "text/html", 
  ".txt" => "text/plain",
  ".css" => "text/css",
  ".jpg" => "image/jpeg",
  ".png" => "image/png"
)

static-file.exclude-extensions = ( ".yaml" )
index-file.names = ( "index.html" )
      EOT
  end
  true
end

#requirementsObject

Describes the resources required by the deployed application. Jekyll sites automatically require a port to serve content on.



77
78
79
80
81
82
83
84
85
# File 'lib/circus/profiles/jekyll.rb', line 77

def requirements
  res = super
    
  # TODO: The clown should be able to automatically allocate listening ports
  res['system-properties'] ||= {}
  res['system-properties']['HTTPD_PORT'] = 3000
  
  res
end