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



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



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
    "    exec lighttpd -D -f lighttpd.conf\n    EOT\n  end\nend\n"

#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
    "    cd \#{@dir}\n    exec jekyll --auto --server\n    EOT\n  end\nend\n"

#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



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 "server.document-root = \"_site/\" \n\nserver.port = env.HTTPD_PORT\n\nmimetype.assign = (\n  \".html\" => \"text/html\", \n  \".txt\" => \"text/plain\",\n  \".css\" => \"text/css\",\n  \".jpg\" => \"image/jpeg\",\n  \".png\" => \"image/png\"\n)\n\nstatic-file.exclude-extensions = ( \".yaml\" )\nindex-file.names = ( \"index.html\" )\n      EOT\n  end\n  true\nend\n"

#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