]> git.wincent.com - walrus.git/log
walrus.git
8 years agoSimplify remaining spec_helper requires master
Greg Hurrell [Tue, 21 Oct 2014 15:02:56 +0000 (08:02 -0700)] 
Simplify remaining spec_helper requires

For the same reason as the previous commit, `ag` didn't catch these
files in its sweep.

8 years agoFix copyright headers missed in previous sweep
Greg Hurrell [Tue, 21 Oct 2014 14:56:13 +0000 (07:56 -0700)] 
Fix copyright headers missed in previous sweep

Turns out that `ag` ignores the files in the spec/acceptance directory
due to a bug in its handling of `.gitignore` files. The upstream issue
is:

https://github.com/ggreer/the_silver_searcher/issues/168

8 years agoUse refinements to avoid core class pollution
Greg Hurrell [Tue, 21 Oct 2014 02:47:19 +0000 (19:47 -0700)] 
Use refinements to avoid core class pollution

This is just the Walrus part; I may have to do additional work when I
make the corresponding change in Walrat.

8 years agoUnconditionally override String#each
Greg Hurrell [Tue, 21 Oct 2014 01:57:46 +0000 (18:57 -0700)] 
Unconditionally override String#each

This is ok because we're targeting a specific version of Ruby now, and
will soon switch to using refinements to keep the monkey patching
somewhat clean.

It would be nice to just use `#each_line` directly, but elsewhere we
rely on being able to call `#each` uniformly on objects that might be
arrays or strings. (Duck typing, hmph...)

8 years agoFix executable bit on library files
Greg Hurrell [Tue, 21 Oct 2014 01:46:58 +0000 (18:46 -0700)] 
Fix executable bit on library files

8 years agoUpdate to RSpec 3.1.0
Greg Hurrell [Tue, 21 Oct 2014 01:35:27 +0000 (18:35 -0700)] 
Update to RSpec 3.1.0

Performed the conversion with the transpec gem; ie. added it to the
Gemfile, then:

  bundle
  RUBYLIB=./lib:./vendor/walrat/lib bin/transpec -f

And then removed it from the bundle. And checked the spec suite was
still green:

  RUBYLIB=./lib:./vendor/walrat/lib bin/rspec

Here's the relevant output

  734 conversions
    from: obj.should
      to: expect(obj).to
  351 conversions
    from: == expected
      to: eq(expected)
  40 conversions
    from: lambda { }.should
      to: expect { }.to
  1 conversion
    from: =~ /pattern/
      to: match(/pattern/)
  1 conversion
    from: obj.should_not
      to: expect(obj).not_to

  1127 conversions, 0 incompletes, 0 warnings, 0 errors

8 years agoPut license boilerplate on a diet
Greg Hurrell [Tue, 21 Oct 2014 01:20:25 +0000 (18:20 -0700)] 
Put license boilerplate on a diet

For similar reasons to those stated in commit
6cd8d28d57e991d2db17196f5d2ec214df85ee1c in the Command-T repo.

8 years agoUpdate authorship and year in copyright headers
Greg Hurrell [Tue, 21 Oct 2014 01:14:49 +0000 (18:14 -0700)] 
Update authorship and year in copyright headers

8 years agoSimplify spec helper requires
Greg Hurrell [Tue, 21 Oct 2014 01:08:31 +0000 (18:08 -0700)] 
Simplify spec helper requires

RSpec takes care of the load path for us, so this absolute path stuff
isn't necessary; but note, you still need to run these specs with
`RUBYLIB` appropriately set; ie:

  RUBYLIB=./lib:./vendor/walrat/lib bin/spec spec

8 years agoSimplify RawText implementation
Greg Hurrell [Mon, 20 Oct 2014 16:08:46 +0000 (09:08 -0700)] 
Simplify RawText implementation

These are equivalent, because `Node#to_s` returns the lexeme that was
passed to `Node#initialize`, with `#to_s` already applied to it.

8 years agoPrepare to run under Ruby 2.1.3
Greg Hurrell [Mon, 20 Oct 2014 16:05:04 +0000 (09:05 -0700)] 
Prepare to run under Ruby 2.1.3

The array change is necessary because the `#to_s` behavior on `Array`
changed from 1.8.7:

  `['foo', 'bar']` -> "foobar"

to 2.1.3:

  `['foo', 'bar']` -> "[\"foo\", \"bar\"]"

With this commit, the spec suite is green under 2.1.3.

8 years agoSilence Gemfile warnings
Greg Hurrell [Mon, 20 Oct 2014 04:05:10 +0000 (21:05 -0700)] 
Silence Gemfile warnings

8 years agoSwitch Walrat to a submodule at vendor/walrat
Greg Hurrell [Mon, 20 Oct 2014 04:03:46 +0000 (21:03 -0700)] 
Switch Walrat to a submodule at vendor/walrat

This will make for easier development (ie. without having to push Walrat
changes to a remote before testing them locally with Walrus).

12 years agoUpdate link to Walrus repo
Wincent Colaiuta [Mon, 30 Aug 2010 10:49:29 +0000 (12:49 +0200)] 
Update link to Walrus repo

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoGemfile: depend on Git version of Walrat, separate from gemspec
Wincent Colaiuta [Sun, 29 Aug 2010 23:38:49 +0000 (01:38 +0200)] 
Gemfile: depend on Git version of Walrat, separate from gemspec

While Bundler's "gemspec" directive is very convenient, it obviously
doesn't allow for the specification of special dependencies like ":path"
or ":git" based gems, because those can't be specified in the gemspec.

Neither can we pull in the gemspec dependencies with "gemspec" and then
redefine them in the Gemfile, because Bundler will complain.

So, the necessary evil here is to repeat our dependencies in both the
gemspec file and the Gemfile. This is the only way to practically
develop a project like Walrus, which has such a tight coupling to
another gem (in this case, Walrat); sometimes changes in Walrat are
required, and it would be insane to have to be able to test them with
Walrus only after publishing a new release of the Walrat gem (because
Bundler tries to force you to use an "isolated" environment, it makes it
very difficult to, for example, install a local copy of the Walrat
development gem to the system, and then reuse that in the Bundle; it
always wants to check rubygems.org to find out what the official latest
release is).

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoAvoid spawning a separate Ruby process during "fill" and "compile"
Wincent Colaiuta [Sun, 29 Aug 2010 23:00:42 +0000 (01:00 +0200)] 
Avoid spawning a separate Ruby process during "fill" and "compile"

This is more efficient as it avoids unnecessary forking, but it requires
that the user does not pass conflicting templates in a single batch (for
example, two templates which attempt to define the same class).

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoRemove special runtime/eval handling from Walrus::Document
Wincent Colaiuta [Sun, 29 Aug 2010 20:52:09 +0000 (22:52 +0200)] 
Remove special runtime/eval handling from Walrus::Document

As Walrus::Document is an abstract superclass, it will never be
separately run from the command-line, nor read and dynamically
evaluated, so this special handling can be removed.

Actual subclasses, however, can and will use this handling; see the
Walrus::Compiler class which inserts the necessary statements in every
compiled template.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoMake compiled templates usefully evalable
Wincent Colaiuta [Sun, 29 Aug 2010 20:47:36 +0000 (22:47 +0200)] 
Make compiled templates usefully evalable

Compiled templates were previously useful when run like so:

  ./my_template.html.rb # prints the output to standard out

With this commit they are also useful when evaled in Ruby:

  require 'rubygems'
  require 'pathname'
  puts eval(Pathname.new('my_template.html.rb').read)

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoDrop unnecessary explicit receiver
Wincent Colaiuta [Sun, 29 Aug 2010 20:42:27 +0000 (22:42 +0200)] 
Drop unnecessary explicit receiver

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoDon't require 'pathname' in Walrus::Document
Wincent Colaiuta [Sun, 29 Aug 2010 20:35:39 +0000 (22:35 +0200)] 
Don't require 'pathname' in Walrus::Document

Way back in ancient history (see commit 3607c37 on the Subversion
"trunk" import), the Pathname class was pulled into the Walrus::Document
class because it was needed to implement the new
Walrus::Document.require method:

   Make 'Document' subclass requires work more easily for users
   without explicit knowledge of Ruby's load path mechanism;
   inheritance acceptance specs and changes to get them working

Soon after that (see commit 78bf4e4, still in the Subversion "trunk"
import), the Walrus::Document.require method was ripped out, removing
all dependence on the Pathname class:

   Modify '#import' and '#extends' directives to take string literal
   parameters instead of constants for consistency with Ruby's '
   require' style; this also enables the specification of relative
   paths; alternative method for loading templates that aren't in the
   load path

The require should have been removed at the same time, but it was
overlooked.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoDrop unnecessary parens
Wincent Colaiuta [Sun, 29 Aug 2010 20:21:45 +0000 (22:21 +0200)] 
Drop unnecessary parens

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoDon't require 'walrus' in Walrus::Document
Wincent Colaiuta [Sun, 29 Aug 2010 20:17:07 +0000 (22:17 +0200)] 
Don't require 'walrus' in Walrus::Document

Compiled documents should depend only on Walrus::Document, and nothing
else in Walrus.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoMake Wopen3 a development dependency instead of a runtime one
Wincent Colaiuta [Sun, 29 Aug 2010 19:34:40 +0000 (21:34 +0200)] 
Make Wopen3 a development dependency instead of a runtime one

This makes Walrus "fork free" and therefore is a step towards
compatibility with JRuby. (Previously "walrus compile" would run but
"walrus fill" would not, because JRuby does not and probably never will
support forking.)

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoRuby 1.9: use Object.class_eval instead of eval
Wincent Colaiuta [Sun, 29 Aug 2010 18:49:18 +0000 (20:49 +0200)] 
Ruby 1.9: use Object.class_eval instead of eval

This commit takes the fix that was originally applied in commit af2a030
and extends it to the entire spec suite. With this change there are only
3 failing specs under 1.9 in the entire suite, and notably, all of the
acceptance specs pass, leaving only a couple of "edge cases".

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoRuby 1.9: can no long feed Pathname into Wopen3
Wincent Colaiuta [Sun, 29 Aug 2010 18:24:10 +0000 (20:24 +0200)] 
Ruby 1.9: can no long feed Pathname into Wopen3

Just as with Pathname.glob(...), we can no longer pass Pathname
instances into Wopen3.system. This is because the arguments are passed
to the "exec" method under the hood, and "exec" complains about them
being non-strings.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoRuby 1.9: Pathname.glob(pathname) chokes
Wincent Colaiuta [Sun, 29 Aug 2010 18:07:53 +0000 (20:07 +0200)] 
Ruby 1.9: Pathname.glob(pathname) chokes

Pathname on 1.9 no longer responds to "to_str", which means that it
can't be passed in to places which expect a string parameter.

Ironically this means that you can't even pass it into all of its own
methods anymore, such as glob:

  Pathname.glob(Pathname.new('.')) # => raises with "can't convert"

This is because under the covers it is delegating to Dir#glob, Dir#glob
complains about the non-string argument.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoDrop some unnecessary parens
Wincent Colaiuta [Sun, 29 Aug 2010 18:01:45 +0000 (20:01 +0200)] 
Drop some unnecessary parens

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoMore tidying of grammar
Wincent Colaiuta [Sun, 29 Aug 2010 17:58:59 +0000 (19:58 +0200)] 
More tidying of grammar

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoAdd some regression specs for bin/walrus
Wincent Colaiuta [Sun, 29 Aug 2010 17:53:23 +0000 (19:53 +0200)] 
Add some regression specs for bin/walrus

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoChange RUBYLIB order to ensure local version is prioritized
Wincent Colaiuta [Sun, 29 Aug 2010 17:38:25 +0000 (19:38 +0200)] 
Change RUBYLIB order to ensure local version is prioritized

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoCode comment consistency
Wincent Colaiuta [Sun, 29 Aug 2010 17:26:20 +0000 (19:26 +0200)] 
Code comment consistency

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoFix a typo in the changelog
Wincent Colaiuta [Sun, 29 Aug 2010 17:23:53 +0000 (19:23 +0200)] 
Fix a typo in the changelog

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoChangelog updates
Wincent Colaiuta [Sun, 29 Aug 2010 17:22:20 +0000 (19:22 +0200)] 
Changelog updates

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoWork around variable __FILE__ madness
Wincent Colaiuta [Sun, 29 Aug 2010 17:16:02 +0000 (19:16 +0200)] 
Work around variable __FILE__ madness

The value of __FILE__ in a spec will vary depending on how it was
invoked, which can wreak havoc with specs that are sensitive to whether
they are working with relative or absolute paths.

The acceptance specs are one example of such sensitive specs, and they
were broken when run as "spec spec" or "spec acceptance", but not as
"spec spec/acceptance/complete_application_spec.rb".

Work around this by first converting to absolute path, and then back to
absolute, so that we know we are always working with relative paths no
matter how we were in invoked.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoAvoid re-running compiles/fills in acceptance specs
Wincent Colaiuta [Sun, 29 Aug 2010 16:38:07 +0000 (18:38 +0200)] 
Avoid re-running compiles/fills in acceptance specs

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoAdd missing comma in command line option parser
Wincent Colaiuta [Sun, 29 Aug 2010 15:33:53 +0000 (17:33 +0200)] 
Add missing comma in command line option parser

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoFix typo in specs (RUBY_LIB -> RUBYLIB)
Wincent Colaiuta [Sun, 29 Aug 2010 15:33:12 +0000 (17:33 +0200)] 
Fix typo in specs (RUBY_LIB -> RUBYLIB)

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoFor directory arguments, only process files matching --input-extension
Wincent Colaiuta [Sun, 29 Aug 2010 15:15:08 +0000 (17:15 +0200)] 
For directory arguments, only process files matching --input-extension

This commit fixes the concerns mentioned in commit 6d23968. Now, given
a directory containing files like these:

  foo.html.tmpl   bar.html.tmpl   baz.html.tmpl
  foo.html.rb     bar.html.rb     baz.html.rb
  foo.html        bar.html        baz.html

We can now useful do:

  walrus compile path/to/dir

And have it do the right thing (ie. compile only the *.tmpl files rather
than everything in the directory).

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoAdd --[no-]recurse long form option
Wincent Colaiuta [Sun, 29 Aug 2010 15:14:06 +0000 (17:14 +0200)] 
Add --[no-]recurse long form option

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoFix broken handling of directory arguments
Wincent Colaiuta [Sun, 29 Aug 2010 15:05:35 +0000 (17:05 +0200)] 
Fix broken handling of directory arguments

Recursing into directories was broken due to infinite recursion, leading
to "stack level too deep" errors.

On fixing this bug and testing it, I've come to see that the ability to
pass in directories is of limited usefulness anyway, because Walrus
expects all files in the directory to be templates. Seeing as compiled
templates are by default written alongside their inputs, this condition
(of all files in a directory being input templates) will fall apart as
soon as you do a "walrus compile" on the directory.

So I am thinking of removing the "-R" switch and the processing of
directory arguments entirely.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoBugfix: "non-fatal" errors weren't producing non-zero exit codes
Wincent Colaiuta [Sun, 29 Aug 2010 14:29:55 +0000 (16:29 +0200)] 
Bugfix: "non-fatal" errors weren't producing non-zero exit codes

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoRefresh buildtools templates as part of acceptance spec
Wincent Colaiuta [Sun, 29 Aug 2010 11:13:20 +0000 (13:13 +0200)] 
Refresh buildtools templates as part of acceptance spec

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoAdd "complete application" specs
Wincent Colaiuta [Sun, 29 Aug 2010 10:53:10 +0000 (12:53 +0200)] 
Add "complete application" specs

These currently work, but may need to look at using Bundler to simplify
the invocation of the "walrus" command-line tool here (although that may
itself be opening up a can of worms).

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoRemove unused parser
Wincent Colaiuta [Sun, 29 Aug 2010 10:09:49 +0000 (12:09 +0200)] 
Remove unused parser

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoAdd initial snapshot of expected HTML output
Wincent Colaiuta [Sun, 29 Aug 2010 09:47:58 +0000 (11:47 +0200)] 
Add initial snapshot of expected HTML output

These HTML files were produced using:

  # compile buildtools templates
  cd spec/acceptance/complete_application/buildtools/help
  rake

  # compile/fill web help
  find . -name '*.tmpl' -and -not -path '*/autogen/*' -exec \
    env WALRUS_STYLE=web RUBYLIB=/absolute/path/to/walrus/lib RUBYOPT=rrubygems \
    ../../../../../bin/walrus fill -e web.html {} \;

  # compile/fill app help
  # (all files except the "autogen" directory already compiled in previous step)
  find . -name '*.tmpl' -exec \
    env RUBYLIB=/absolute/path/to/walrus/lib RUBYOPT=rrubygems \
    ../../../../../bin/walrus fill -e app.html {} \;

  # run through tidy to reduce "noise"
  find . -name '*.html' -exec tidy -utf8 -wrap 0 --fix-uri no --tidy-mark no -quiet -o {} {} \;

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoAdd Hextrapolate template files to acceptance spec area
Wincent Colaiuta [Sun, 29 Aug 2010 00:26:06 +0000 (02:26 +0200)] 
Add Hextrapolate template files to acceptance spec area

This is a snapshot of the templates that are used to generate the
Hextrapolate application documentation. It is only a snapshot as there
is no need to keep them current with the latest version of the
application; their only purpose is to provide us with a large body of
template files that we can run different versions of Walrus on, on
different Ruby implementations, and confirm that the generated output is
unchanging.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoAdd buildtools as a submodule
Wincent Colaiuta [Sun, 29 Aug 2010 00:23:59 +0000 (02:23 +0200)] 
Add buildtools as a submodule

In preparation for using a complete set of application documentation as
part of the acceptance specs, add buildtools as a submodule (the
application in question depends on buildtools for certain parent
templates and other supporting files).

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoRename "complex" spec files to "tmpl"
Wincent Colaiuta [Sun, 29 Aug 2010 00:19:48 +0000 (02:19 +0200)] 
Rename "complex" spec files to "tmpl"

Now that we have separate directories, it is no longer necessary to use
file extensions to distinguish between the two types of acceptance spec
inputs.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoSplit acceptance tests into subdirectories
Wincent Colaiuta [Sun, 29 Aug 2010 00:08:25 +0000 (02:08 +0200)] 
Split acceptance tests into subdirectories

What was formerly all lumped together under:

  spec/acceptance

Now is split into two subdirectories:

  spec/acceptance/single_file
  spec/acceptance/multi_file

This is in preparation for the addition of a third type of acceptance
test, which will take an existing template set (eg the Hextrapolate
docs) and run Walrus over that, checking that the output is constant
across versions of Ruby and Walrus.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoRemove out-of-date Ruby 1.9 notes
Wincent Colaiuta [Sat, 28 Aug 2010 23:27:38 +0000 (01:27 +0200)] 
Remove out-of-date Ruby 1.9 notes

Now testing via RVM anyway.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoRuby 1.9: workaround changes in Array#to_s behavior
Wincent Colaiuta [Sat, 28 Aug 2010 20:16:08 +0000 (22:16 +0200)] 
Ruby 1.9: workaround changes in Array#to_s behavior

There are plenty of places in the codebase where this behavior change
has impact, but this commit picks off some of the low-hanging fruit.

The problem is that Array, and therefore Walrat::ArrayResult, under 1.9
behavior like this:

  [].to_s      # => "[]"
  [1,2,3].to_s # => "[1, 2, 3]"

(Compare this to 1.8.7 where they returned "" an "123" respectively.)

In other words, Array#to_s is really now a debugging tool more than
anything else, behaving like #inspect. To fix this issue entirely will
probably have to make a number of changes in various parts of the
codebase, including in Walrat itself (particularly the Node class, which
does #to_s internally).

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoRuby 1.9: fix some broken specs
Wincent Colaiuta [Sat, 28 Aug 2010 20:15:40 +0000 (22:15 +0200)] 
Ruby 1.9: fix some broken specs

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoRuby 1.9: make sure compiled templates with non-ASCII in them are handled
Wincent Colaiuta [Sat, 28 Aug 2010 19:32:42 +0000 (21:32 +0200)] 
Ruby 1.9: make sure compiled templates with non-ASCII in them are handled

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoRuby 1.9: String#each no longer exists
Wincent Colaiuta [Sat, 28 Aug 2010 19:32:06 +0000 (21:32 +0200)] 
Ruby 1.9: String#each no longer exists

This is probably not the nicest way to fix this under Ruby 1.9, but it
certainly is the easiest way. Given that Walrus is effectively its own
little sandbox doing this kind of meddling with a core class like
String is perhaps a little more justifiable; nevertheless, I'd like to
later on come up with an alternative compatibility fix.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoAdd changelog file, for user-visible changes
Wincent Colaiuta [Sat, 28 Aug 2010 18:14:25 +0000 (20:14 +0200)] 
Add changelog file, for user-visible changes

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoAdd YARD-related tasks to Rakefile
Wincent Colaiuta [Sat, 28 Aug 2010 17:59:41 +0000 (19:59 +0200)] 
Add YARD-related tasks to Rakefile

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoCosmetic tweeks to compiler class
Wincent Colaiuta [Sat, 28 Aug 2010 17:59:17 +0000 (19:59 +0200)] 
Cosmetic tweeks to compiler class

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoFix unwanted extra lines after compiled tempalte_body
Wincent Colaiuta [Sat, 28 Aug 2010 17:17:40 +0000 (19:17 +0200)] 
Fix unwanted extra lines after compiled tempalte_body

Previously when there was no "outside" content of a template (ie. no
block definitions) we would end up with compiled output like this:

  def template_body
    ...
  end

  if __FILE__ == $0
    ...
  end

With this commit the unwanted blank line will no longer appear. This
works fine because the DefDirective, which is responsible for producing
the "outside" content, returns it with two trailing newlines when it is
present. So templates with "outside" content continue to look like this:

  def template_body
    ...
  end

  def something_outside
    ...
  end

  if __FILE__ == $0
    ...
  end

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoAvoid possible excess trailing line in compiled template_body
Wincent Colaiuta [Sat, 28 Aug 2010 16:59:42 +0000 (18:59 +0200)] 
Avoid possible excess trailing line in compiled template_body

Prior to this chomp, the method typical compiled thusly:

  def template_body
    # compiled line 1
    # compiled line 2

  end

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoEvaluate multiple expressions in same context
Wincent Colaiuta [Sat, 28 Aug 2010 16:42:17 +0000 (18:42 +0200)] 
Evaluate multiple expressions in same context

Prior to this commit, the following didn't work:

  #echo foo = 1; foo + 1

Because it was effectively compiled down to:

  instance_eval { foo = 1 } # foo visible only in this scope
  instance_eval { foo + 1 } # foo not visible here => exception

Now the directive above would would without throwing an exception
because it effectively compiles to:

  instance_eval {
    foo = 1
    foo + 1
  }

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoAccumulate only last expression in list in an #echo directive
Wincent Colaiuta [Sat, 28 Aug 2010 16:19:50 +0000 (18:19 +0200)] 
Accumulate only last expression in list in an #echo directive

Previously given:

  #echo "foo"; "bar"; "baz"

we echoed "foobarbaz" to the template. Now we evaluate all expressions
in the list but only accumulate the last one (ie. the output is "baz"
although "foo" and "bar" are silently evaluated first).

This means that:

   #echo @foo = 1 + 2; @foo = @foo + 3; @foo

Now prints "6" whereas previously it would have emitted "366".

This brings us into line with most other template languages and also
with Ruby itself:

  #!/usr/bin/env ruby
  puts "result is #{@foo = 1 + 2; @foo = @foo + 3; @foo}"

prints "result is 6", not "result is 366".

Similar examples could be illustrated using Haml and ERB.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoTighten up spec descriptions in acceptance spec
Wincent Colaiuta [Sat, 28 Aug 2010 15:56:06 +0000 (17:56 +0200)] 
Tighten up spec descriptions in acceptance spec

Edit for brevity, and always show the path to the file under testing.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoClean up inner loop in SilentDirective#compile
Wincent Colaiuta [Sat, 28 Aug 2010 13:52:28 +0000 (15:52 +0200)] 
Clean up inner loop in SilentDirective#compile

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoWhitespace fix
Wincent Colaiuta [Sat, 28 Aug 2010 13:46:03 +0000 (15:46 +0200)] 
Whitespace fix

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoFix cosmetic code comment typo
Wincent Colaiuta [Sat, 28 Aug 2010 13:45:00 +0000 (15:45 +0200)] 
Fix cosmetic code comment typo

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoMake use of extracted :line and :here_document_marker rules
Wincent Colaiuta [Sat, 28 Aug 2010 13:38:14 +0000 (15:38 +0200)] 
Make use of extracted :line and :here_document_marker rules

These rules snuck into an earlier commit, 1fdfcf8, "Rewrapping and
reformatting for display on narrow terminals". By extracting them and
reusing them here we avoid repeated calls to to_parseable and the
corresponding creation of RegexpParslet instances.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoRemove explicit references to vertical tabs
Wincent Colaiuta [Sat, 28 Aug 2010 13:29:51 +0000 (15:29 +0200)] 
Remove explicit references to vertical tabs

I'm inclined to agree with this post:

  'No one is actually using the vertical tab escape sequence.

  And I truly mean "no one".'

  http://prog21.dadgum.com/76.html

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoMove documentation comments from grammar to their respective classes
Wincent Colaiuta [Sat, 28 Aug 2010 13:27:05 +0000 (15:27 +0200)] 
Move documentation comments from grammar to their respective classes

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoRewrapping and reformatting for display on narrow terminals
Wincent Colaiuta [Sat, 28 Aug 2010 12:39:33 +0000 (14:39 +0200)] 
Rewrapping and reformatting for display on narrow terminals

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoExtract short and long forms for #echo and #silent directives
Wincent Colaiuta [Sat, 28 Aug 2010 12:26:47 +0000 (14:26 +0200)] 
Extract short and long forms for #echo and #silent directives

This makes it easier to wrap the grammar and make it more readable on
narrow terminals.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoAdditional reformatting for narrow terminals
Wincent Colaiuta [Sat, 28 Aug 2010 00:47:23 +0000 (02:47 +0200)] 
Additional reformatting for narrow terminals

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoReplace a ternary with simple or expression
Wincent Colaiuta [Sat, 28 Aug 2010 00:46:19 +0000 (02:46 +0200)] 
Replace a ternary with simple or expression

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoUse shorter raise syntax and rewrap
Wincent Colaiuta [Fri, 27 Aug 2010 15:42:31 +0000 (17:42 +0200)] 
Use shorter raise syntax and rewrap

For better readability on narrow terminals.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoRemove some unnecessary parens
Wincent Colaiuta [Fri, 27 Aug 2010 15:40:54 +0000 (17:40 +0200)] 
Remove some unnecessary parens

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoReplace unnecessary ternary operator with simple boolean expression
Wincent Colaiuta [Fri, 27 Aug 2010 15:24:01 +0000 (17:24 +0200)] 
Replace unnecessary ternary operator with simple boolean expression

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoFlesh out Walrus::Runner documentation
Wincent Colaiuta [Tue, 24 Aug 2010 09:08:09 +0000 (11:08 +0200)] 
Flesh out Walrus::Runner documentation

It is now mostly complete.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoInitial Walrus::Runner documentation (description of options)
Wincent Colaiuta [Tue, 24 Aug 2010 00:53:40 +0000 (02:53 +0200)] 
Initial Walrus::Runner documentation (description of options)

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoConvert README.txt to README.rdoc (YARD formatting)
Wincent Colaiuta [Tue, 24 Aug 2010 00:45:22 +0000 (02:45 +0200)] 
Convert README.txt to README.rdoc (YARD formatting)

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoVarious style and consistency fixes in Walrus::Runner
Wincent Colaiuta [Tue, 24 Aug 2010 00:02:39 +0000 (02:02 +0200)] 
Various style and consistency fixes in Walrus::Runner

- drop some unnecessary parens
- drop unnecessary #to_s calls
- rewrap some long lines
- reword for consistency
- use shorter syntax for raising (ie. "Class, message" rather than
  "Class.new message")

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoUse Wopen3::system for convenience
Wincent Colaiuta [Tue, 24 Aug 2010 00:02:09 +0000 (02:02 +0200)] 
Use Wopen3::system for convenience

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoBump wopen3 dependency to version 0.3
Wincent Colaiuta [Tue, 24 Aug 2010 00:00:44 +0000 (02:00 +0200)] 
Bump wopen3 dependency to version 0.3

This will allow us to use the Wopen3::system method, which is quite a bit
more convenient than manually managing threads.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoDrop unused/unimplemented --debug switch
Wincent Colaiuta [Mon, 23 Aug 2010 23:38:02 +0000 (01:38 +0200)] 
Drop unused/unimplemented --debug switch

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoDrop unnecessary #to_s calls
Wincent Colaiuta [Mon, 23 Aug 2010 23:37:07 +0000 (01:37 +0200)] 
Drop unnecessary #to_s calls

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoIndent error 'here' doc for nicer formatting
Wincent Colaiuta [Mon, 23 Aug 2010 23:36:54 +0000 (01:36 +0200)] 
Indent error 'here' doc for nicer formatting

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoWhitespace fixes and re-wrapping (cosmetic)
Wincent Colaiuta [Mon, 23 Aug 2010 23:36:30 +0000 (01:36 +0200)] 
Whitespace fixes and re-wrapping (cosmetic)

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoMark most Walrus::Runner methods as private
Wincent Colaiuta [Mon, 23 Aug 2010 23:31:24 +0000 (01:31 +0200)] 
Mark most Walrus::Runner methods as private

So that they don't clutter up the YARD documentation.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoAvoid emitting trailing whitespace when compiling #set directive
Wincent Colaiuta [Mon, 23 Aug 2010 18:16:58 +0000 (20:16 +0200)] 
Avoid emitting trailing whitespace when compiling #set directive

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoRemove an unnecessary clone
Wincent Colaiuta [Mon, 23 Aug 2010 17:47:51 +0000 (19:47 +0200)] 
Remove an unnecessary clone

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoInitial cut at README
Wincent Colaiuta [Mon, 23 Aug 2010 17:40:12 +0000 (19:40 +0200)] 
Initial cut at README

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoUse absolute paths in requires to avoid possible double requires
Wincent Colaiuta [Mon, 23 Aug 2010 17:07:27 +0000 (19:07 +0200)] 
Use absolute paths in requires to avoid possible double requires

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoRemove unnecessary '.rb' in require statements
Wincent Colaiuta [Mon, 23 Aug 2010 16:59:23 +0000 (18:59 +0200)] 
Remove unnecessary '.rb' in require statements

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoBump version number post-release
Wincent Colaiuta [Mon, 23 Aug 2010 16:40:15 +0000 (18:40 +0200)] 
Bump version number post-release

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoBump version number prior to 0.4 release 0.4
Wincent Colaiuta [Mon, 23 Aug 2010 16:39:07 +0000 (18:39 +0200)] 
Bump version number prior to 0.4 release

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoSet default output extension to empty string
Wincent Colaiuta [Mon, 23 Aug 2010 16:27:22 +0000 (18:27 +0200)] 
Set default output extension to empty string

This is an important change because it may break existing workflows.
Previously the default input extension was "tmpl" and the default
output extension was "html".

This meant that given input file:

  hello.tmpl

Compilation would yield:

  hello.rb

And filling would yield:

  hello.html

For these commands:

  walrus compile hello.tmpl
  walrus fill hello.tmpl

This approach isn't ideal because Walrus is agnostic about the language
that will be used for filled templates. It shouldn't make people who
want to target different languages work harder.

So now we maintain the default input extension of "tmpl" but set the
default output extension to "". This means that given input file:

  hello.tmpl

And command line:

  walrus compile hello.tmpl
  walrus fill hello.tmpl

We now get:

  hello.rb (compiled template)
  hello (filled template)

This is the behavior change which may break existing workflows. To get
the old workflow back we instead have to pass the -e or
--output-extension switches to "walrus fill":

  walrus fill -e html hello.tmpl

Or, alternatively, change the source template name:

  hello.html.tmpl

Which will cause:

  walrus compile hello.html.tmpl
  walrus fill hello.html.tmpl

To yield:

  hello.html.rb
  hello.html

One benefit of using multiple extensions like this is that we can now
point Walrus at a folder containing multiple file types; eg:

  display.css.tmpl
  index.html.tmpl

And have it produce the filled output with different extensions:

  display.css
  index.html

Another benefit is that smart text editors can provide better syntax
coloring for files (consider the classic example of a PHP file which
contains HTML text with PHP "islands" embedded inside it).

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoFix minor code comment typo and rewrap
Wincent Colaiuta [Mon, 23 Aug 2010 16:15:15 +0000 (18:15 +0200)] 
Fix minor code comment typo and rewrap

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoMake --recurse default to true
Wincent Colaiuta [Mon, 23 Aug 2010 16:10:56 +0000 (18:10 +0200)] 
Make --recurse default to true

This brings the actual default in line with the documentation.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoRemove a reference to the now-gone ext directory
Wincent Colaiuta [Mon, 23 Aug 2010 15:46:33 +0000 (17:46 +0200)] 
Remove a reference to the now-gone ext directory

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoBump version number post-release
Wincent Colaiuta [Sat, 21 Aug 2010 20:30:54 +0000 (22:30 +0200)] 
Bump version number post-release

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoBump version for 0.3 release 0.3
Wincent Colaiuta [Sat, 21 Aug 2010 20:29:43 +0000 (22:29 +0200)] 
Bump version for 0.3 release

Signed-off-by: Wincent Colaiuta <win@wincent.com>
12 years agoRakefile: add yard and upload_yard tasks
Wincent Colaiuta [Sat, 21 Aug 2010 15:55:54 +0000 (17:55 +0200)] 
Rakefile: add yard and upload_yard tasks

Signed-off-by: Wincent Colaiuta <win@wincent.com>