Last active
          April 6, 2016 12:22 
        
      - 
      
- 
        Save mlafeldt/4e5268b7024d1aaeb4aa to your computer and use it in GitHub Desktop. 
    Rake task I use for starting a new article for Production Ready
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | require "stringex" | |
| desc "Create a new letter" | |
| task :new_letter, :title do |t, args| | |
| title = args[:title] || "New Letter" | |
| num = File::basename(Dir['letters/*'].last)[0,3].to_i + 1 | |
| filename = "letters/%03d-%s.md" % [num, title.to_url] | |
| date = Time.now.strftime("%Y-%m-%d") | |
| puts "==> Creating new letter: #{filename}" | |
| content = <<EOS | |
| --- | |
| title: "#{title.to_html(true)}" | |
| subtitle: | |
| date: #{date} | |
| tags: [] | |
| medium: | |
| photo: | |
| mentions: | |
| --- | |
| Add awesome content here. | |
| EOS | |
| File.write(filename, content) | |
| git "checkout", "-b", title.to_url | |
| git "add", filename | |
| git "commit", "-m", "Add draft: #{title}" | |
| open_in_editor(filename) | |
| end | |
| def open_in_editor(filename) | |
| sh "open", "-a", "/Applications/Byword.app", filename | |
| end | |
| def git(*args) | |
| sh "git", *args | |
| end | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment