Every repository with this icon (
Every repository with this icon (
Run the following if you haven't already:
gem sources -a http://gems.github.com
Install the gem(s):
sudo gem install bahuvrihi-tap
How To...
Use an older version of Tap (or any gem)
Rubygems makes it very easy to use an older version of tap:
% tap _version_ ...
As you can see, all you have to do is specify the version in the first argument. This trick can also be useful for fixing the version of tap used if it gets called from another process.
% tap _0.10.3_
usage: tap {options} [args]
examples:
tap generate root . # generates a root dir
tap run taskname --option input # runs the 'taskname' task
help:
tap help # prints this help
tap command --help # prints help for 'command'
available commands:
console
destroy
generate
help
run
version 0.10.3 -- http://tap.rubyforge.org
Install SQLite3
Many of the tap libraries I’ve developed utilize SQLite3 because it is easy to get running. Here are the basic installation instructions.
Install the binaries
On Mac OSX/Unix, sqlite3 is usually pre-installed. Try calling sqlite3 from a command prompt to check (see below). If it isn’t installed, check the {sqlite website}[http://www.sqlite.org/] for installation instructions.
On Windows:
- Download the sqlite3 command line program and .dll from the {downloads page}[http://www.sqlite.org/download.html]. They will be named like ‘sqlite-3_version.zip’ and ‘sqlitedll-3_version.zip’ respectively.
- Extract/copy these files (sqlite3.exe and sqlite3.dll) into C:\ruby\bin, or the bin directory of wherever you installed ruby.
Now you should be able to access sqlite3 from a command prompt:
% sqlite3
SQLite version 3.[version]
Enter ".help" for instructions
sqlite>
Install the ruby bindings
% gem install sqlite3-ruby
And that’s it!
Enter newlines, escape characters into configurations
Sometimes you need escaped characters in a configuration, for instance when formatting csv output. To do so, use the string validation then write them in as you would in a script:
# StringConfig::manifest
class StringConfig < Tap::Task
config :a, "", &c.string
config :b, "", &c.string
config :c, "", &c.string
config :d, "", &c.string
config :e, "", &c.string
def process
[:a,:b,:c,:d,:e].each do |key|
type = case config[key]
when "\n" then 'newline'
when '\n' then 'backslash, n'
else 'other'
end
puts "#{key}: #{type}"
end
end
end
Now check out what happens:
% tap run -- string_config --a '\n' --b '\\n' --c "\n" --d "\\n" --e "\\\n"
a: newline
b: backslash, n
c: newline
d: newline
e: backslash, n





