Project

cakery

0.0
No commit activity in last 3 years
No release in over 3 years
Combine many files into one intelligently. Cakery has a simple *DSL* that allows you to glob directories and pass strings to an **erb** file. You can also add **macros** to a cakery pipeline. Think about it as a more generic version of [Sprockets](https://github.com/sstephenson/sprockets).
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
~> 0.10
~> 10.3
~> 3.2
 Project Readme

cakery: Say goodbye to file path issues

Gem Version Build Status Bitdeli Badge License

##What is this?

Combine many files into one intelligently. Cakery has a simple DSL that allows you to glob directories and pass strings to an erb file. You can also add macros to a cakery pipeline. Think about it as a more generic version of Sprockets.

Quick Start

###Combine many js files in the ./spec directory into one file In your ruby code:

#Create a new recipe
recipe = Cakery.new('test.js.erb') do |r|
  #The << operator means to glob the directory into a string in @spec
  #The << operator accepts any unix style glob operator, e.g. /**/* for recursive
  r.spec << "./spec/*_spec.js"

  #The < operator means assignment
  r.debug < true
  r.foo < "bar"

  #You can also append to things that are already set
  r.foo < "bar2"
  r.foo << "./foo/*"
end

#Build using the current directory
cake = recipe.bake

#Get the concatenated result of the build
puts cake.src

Create a test.js.erb with:

<%= @spec %>

<!-- Announce whether we are in debug or release -->
<% if @debug %>
  console.log("Debug!");
<% end %>
  console.log("Release :(");
<% end %>

###Macros Macros receive a block of text and then do something with that text. A macro is a subclass of Cakery::Macro that implements def process(str) and returns a String. You can also stack macros.

In your ruby code:

#Create a new recipe
class MyMacro < Cakery::Macro
  def process str
    out = ""
    str.split("\n").each do |line|
      if line =~ /hello/
        out += line.gsub(/hello/, "goodbye")
      else
        out += line
      end
      out += "\n"
    end
    out
  end
end

recipe = Cakery.new('test.js.erb') do |r|
  #The << operator means to glob the directory into a string in @spec
  r.spec << MyMacro << "./spec/*_spec.js"
  r.spec << MyMacro < "hello"
  
  #Additionally, you can stack macros. Macros always use the << operator intra macros
  #The last operator may either be < or <<
  r.spec << MyMacro << MyOtherMacro < "Hello"
  r.spec << MyMacro << MyOtherMacro << "./spec/*_spec.js"
  
  #The < operator means assignment
  r.debug < true
  r.foo < "bar"
end

#Build using the current directory
cake = recipe.bake

#Get the concatenated result of the build
puts cake.src

Create a test.js.erb with:

<%= @spec %>

<!-- Announce whether we are in debug or release -->
<% if @debug %>
  console.log("Debug!");
<% end %>
  console.log("Release :(");
<% end %>

Requirements

  • Modern nix (FreeBSD, Mac, or Linux)
  • Ruby 2.1 or Higher

Communication

  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Installation

RVM users: Run gem install cakery

System ruby installation: Run sudo gem install cakery


FAQ

When should I use cakery?

Todo

What's Fittr?

Fittr is a SaaS company that focuses on providing personalized workouts and health information to individuals and corporations through phenomenal interfaces and algorithmic data-collection and processing.


Creator

License

cakery is released under the MIT license. See LICENSE for details.