home

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

2012-05-13-jekyll-foreman-guard-bundler.org (2104B)


      1 #+title: Jekyll Forman Guard Bundler
      2 #+date: <2012-05-13 Sun>
      3 #+filetags: jekyll ruby bundler guard foreman
      4 #+setupfile: ../templates/post.org
      5 
      6 * Introduction
      7 
      8 This post is a quick "How did I setup my Jekyll environnement ?". We are
      9 going all the tools that are quite awesome in Ruby.
     10 
     11 * Goal
     12   :PROPERTIES:
     13   :CUSTOM_ID: goal
     14   :END:
     15 
     16 The goal is simple :
     17 
     18 1. I want to be able to install any dependent
     19    [[http://rubygems.org][Gem]] with a /on-liner/ command
     20 2. I want to be able to run a /Jekyll server/ that auto updates.
     21 
     22 We are going to play with : [[http://gembundler.com/][Bundler]],
     23 [[https://github.com/guard/guard][Guard]] and
     24 [[https://github.com/ddollar/foreman][foreman]].
     25 
     26 * Bundler
     27    :PROPERTIES:
     28    :CUSTOM_ID: bundler
     29    :END:
     30 
     31 Bundler let us run =bundle install= to get all Ruby Gems we will need ;
     32 It use a file name =Gemfile=. The gems we need are simple : =jekyll=,
     33 =guard= and some Guard extensions.
     34 
     35 #+begin_src ruby
     36 source "http://rubygems.org"
     37 
     38 gem 'jekyll'
     39 gem 'guard'
     40 gem 'guard-jekyll2'
     41 gem 'guard-shell'
     42 gem 'guard-bundler'
     43 #+end_src
     44 
     45 * Guard
     46    :PROPERTIES:
     47    :CUSTOM_ID: guard
     48    :END:
     49 
     50 #+BEGIN_QUOTE
     51   Guard is a command line tool to easily handle events on file system
     52   modifications.
     53 #+END_QUOTE
     54 
     55 Guard will be watching file we told him and run action in consequence ;
     56 The file is name =Guardfile=.
     57 
     58 #+begin_src ruby
     59 guard 'jekyll2' do
     60   watch %r{.*}
     61 end
     62 
     63 guard :bundler do
     64   watch('Gemfile')
     65 end
     66 # vim:filetype=ruby
     67 #+end_src
     68 
     69 * Foreman
     70    :PROPERTIES:
     71    :CUSTOM_ID: foreman
     72    :END:
     73 
     74 Finally, foreman will let us declare our processes and will handle the
     75 start, forward the output and handle the shutdown. It can then export
     76 its configuration into more /production-ready/ file (=init=, =upstard=,
     77 ...) ; It uses a file named =Procfile=.
     78 
     79 We will tell foreman to run :
     80 
     81 - The jekyll build-in server : =jekyll --server=
     82 - Guard, to handle file changes /in background/.
     83 
     84 #+begin_src bash
     85 web: bundle exec jekyll --server
     86 guard: bundle exec guard
     87 #+end_src
     88 
     89 And that's all folk. Now, you just need to run foreman in the
     90 Jekyll-powered directory and edit your files.