Meta code commenter (mcc)
Comments your meta code.
Usage
require 'mcc'
params = ARGV.inject({}) do |hash, arg|
key, value = arg.split(/=/)
hash[key] = value
hash
end
puts MetaCodeCommenter.comment(STDIN.readlines)
Command line
$ mcc key1=value key2=value < my_meta_code
Example
$ cat code
def #{name}(proc=nil, &blk)
proc ||= blk
@#{name} = Proc.new do |ptr,data,len|
if data
proc.call(data.get_string(0, len))
else
proc.call
end
@abort ? 1 : 0
end
@parser[:#{name}] = @#{name}
end
$ mcc name=on_headers < code
def #{name}(proc=nil, &blk) # def name(proc=nil, &blk)
proc ||= blk # proc ||= blk
@#{name} = Proc.new do |ptr,data,len| # @name = Proc.new do |ptr,data,len|
if data # if data
proc.call(data.get_string(0, len)) # proc.call(data.get_string(0, len))
else # else
proc.call # proc.call
end # end
@abort ? 1 : 0 # @abort ? 1 : 0
end # end
@parser[:#{name}] = @#{name} # @parser[:name] = @name
end # end
Installation (not yet)
gem install
Authors
-
Peter Suschlik
TODO
-
Fix failing test (double quotes don’t work yet)
-
Use thor or something or mcc