Skip to content

Instantly share code, notes, and snippets.

@juliocesar
Created August 13, 2012 04:56
Show Gist options
  • Save juliocesar/3337086 to your computer and use it in GitHub Desktop.
Save juliocesar/3337086 to your computer and use it in GitHub Desktop.
Ain't over 'till it's over
# Oldie but goodie, forward slash path chaining, by _why.
describe '#compile_to_build' do
it "with a template not index.*, it simply copies it over to build/<path> if the extension is .html" do
@compiler.compile_to_build 'article.html'
(Anagen.templates/'article.html').read.should == (Anagen.build_templates/'article.html').read
end
it "with templates/index.*, compiles to build/index.html" do
@compiler.compile_to_build 'index.haml'
(Anagen.build_templates/'index.html').read.should == (Anagen.templates/'index.haml').compiled
end
end
@Osseta
Copy link

Osseta commented Aug 13, 2012

I really like the "forward slash path chaining, by _why." haven't seen it before. Do you have a reference to the code/library that implements it? I'm assuming its as simple as:

class String
  def /(newstring)
    File.join(self, newstring ? newstring.to_s : '')
  end
end

@tj
Copy link

tj commented Aug 13, 2012

ew :p I left ruby because of obscure things like that, _why's code is horrid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment