Dat workflow

Friday 22 November 2013 Tagged with: rake, ruby, automation, and profanities

An interesting look through my jekyll workflow of creating a new entry ala Thug Kitchen

Creating a new post? Lets gather what we will need before we even put pen hand to keyboard:

  • today’s date
  • post title
  • YAML properties
  • awkward as fuck file name

Ain’t nobody got time for that.

rake post

task :post do
  post__name =  ask "New post title:"
  # ...

This fucker is so minimal he don’t even need arguments. post__name comes up in this handy ass prompt. Simple as shit command line input, hells yeah. Quicker than you can hit ‘enter’, template(post__name) has already been called to drop some efficiency on your punk ass.


def template(post__name)
  date = Time.new.strftime('%Y-%m-%d')
  extension = "md"
  dir = "_posts/"
  fileName = post__name.downcase.gsub( /[^a-zA-Z0-9_\.]/, '-')
  newFile = dir + date + "-#{fileName}." + extension

  if File.exists? newFile then
    puts "#{newFile} already exists. cheese it!"

Creating files like a fucking bawse. He takes your post__name, drops a fucking downcase on him while making it a valid web address1. Multi-talented shit right there. Don’t even worry about making the same post twice, this crafty fucker has your back.

  File.open(newFile, "wb") do |post|
    post.puts("layout : default")
    post.puts("title: #{post__name}")
    post.puts("excerpt : !required")
    post.puts("comments : true")
    post.puts("!required intro text")
    post.puts("<!-- /intro -->")
    post.puts("\n!required content")

Whoa, where are you going? Shit hasn’t even started to get real. Mother effing boilerplate is what’s going on here. Son this function lives for that shit. Gets some scaffolding all up your face, ready for some mad blogging to go down.

Better find that file and open your text editor. Wat, hells no! Back the fuck up now. sh "subl -w #{newFile}:10" opens sublime with your newly created post in a flash. You’re fucking welcome. Write the shit out of that post, save and close. BAM! Instantly back in the terminal. Hardcore shit right there if you ask me.

Back to rake post

isRunSite = ask "Run site too? (y/n):"
if isRunSite.downcase == "y" then

All this and we are only up to the third line of :post. This son of a bitch has one more card to play. Another terminal prompt, answer with a mother fucking yes and your wish of more automation shall be granted. rake local steps in to build the site for your lazy ass. Evens open the damn browser for you. Respect.

An entire post created by simply runing one rake post2

Efficient. As. Fuck.

  1. Literally pulled from David Lynch’s work

  2. The rake file can be seen in full on the githubs

Estes artigos são recentes

  1. Aug 25 2017
    Entrega de Certificado de Dispensa de Incorporação no Gama
    Como todos sabem, no Brasil a apresentação de jovens ao serviço militar é obrigatório. Nesta sexta-feira (25) houve uma solenidade na praça cívica do Gama para dispensa dos jovens e entrega do CDI (Certificado de Dispensa de Incorporação). Foram dispensados apróximadamente 300 jovens.
  2. Jan 15 2017
    Bandido bom é bandido morto
    ![bandido jpg](/content/images/bandido bom é bandido morto.jpg)
  3. Nov 08 2016
    Roubo de Água dos rios da Amazônia!
    ![navio rouba água](/content/images/navioRouboAmazonas.jpg)