https://github.com/quark-zju/rbprocessor
RbProcessor is a CodeProcessor plug-in that use Ruby script to preprocess and postprocess code.
https://github.com/quark-zju/rbprocessor
Last synced: 3 months ago
JSON representation
RbProcessor is a CodeProcessor plug-in that use Ruby script to preprocess and postprocess code.
- Host: GitHub
- URL: https://github.com/quark-zju/rbprocessor
- Owner: quark-zju
- License: epl-1.0
- Created: 2012-09-09T19:25:26.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-02-23T16:59:39.000Z (over 12 years ago)
- Last Synced: 2025-01-08T08:45:52.695Z (5 months ago)
- Language: Ruby
- Homepage:
- Size: 137 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
RbProcessor is a CodeProcessor plug-in that use Ruby script to preprocess and postprocess code.
[CodeProcessor](http://community.topcoder.com/contest/classes/CodeProcessor/CodeProcessor.jar) is a [TopCoder Arena plug-in](http://community.topcoder.com/tc?module=Static&d1=applet&d2=plugins).
Installation
============
1. Download `rbprocessor.jar` from [download page](/quark-zju/rbprocessor/downloads).
2. Append `rbprocessor.jar` to CodeProcessor class path.
* Use ':' as separator in Linux.
3. Configure CodeProcessor
* Use 'popsedit.EntryPoint' or Standard Editor as the Editor
* [Poopsedit](http://community.topcoder.com/contest/classes/PopsEdit/PopsEdit.jar) is a standalone plugin.
* Standard Editor's highlighting may not work. It seems it is caused by some bug of CodeProcessor.
* Use FileEdit if you known what happens.
* Use 'rbprocessor.RbProcessor' as the CodeProcessor.
4. Write `$HOME/.config/rbprocessor.rb` or `$HOME/.rbprocessor.rb`.
rbprocessor.rb
==============Location
--------
`rbprocessor.rb` can be located at:* $PWD/rbprocessor.rb
* $HOME/.config/rbprocessor.rb
* $HOME/.rbprocessor.rbOther location is possible by editing `contestapplet.conf`, see below.
Builtin
-------
If RbProcessor can not find any of above files, a builtin script will be used.Note: the builtin script is still a working-in-progress, may contain bugs.
The builtin script does:
* Code templates for C++, C#, Java and VB
* Append problem description to code automatically. This can be disabled by
`NO_PROBLEMDESC=true`
* Test code templates for C++, C#, Java and VB
* Colorful output by default, can be disabled by `USE_COLOR=false`
* [Fileedit](http://community.topcoder.com/contest/classes/FileEdit/FileEdit.htm)-like external editor support
* Can be disabled by `NO_CODE_DIR=true`. Do this if you use internal
editor.
* Code will be saved to `/tmp/tc/` by default, can be changed by `CODE_DIR`
environment variable.
* Do not overwrite code by default, set `CODE_OVERWRITE=true` to
always overwrite external code.
* Postprocessor code (remove code between $BEGINCUT$ and $ENDCUT$)It is recommended to read [the source](/quark-zju/rbprocessor/blob/master/lib/rbprocessor.rb) to see how it works.
Reload
------
`rbprocessor.rb` will be reloaded on the fly if change detected.Content
------
`rbprocessor.rb` is Ruby 1.9 script, and should have two methods:```ruby
def preprocess(src, lang, prob, render)
# $src, $lang, $prob, $render are available too# Makes $HELLO$ tag available
user_tags = { hello: 'world' }# If you want to use FileEdit's code template,
# set processed_src to ''
processed_src = "main() {\n\n}"[processed_src, user_tags]
enddef postprocess(src, lang)
processed_src = src.gsub(/^\s+$/, '')# postprocess only process code, no user tags
processed_src
end
```See [CodeProcess Documentation](http://community.topcoder.com/contest/classes/CodeProcessor/How%20to%20use%20CodeProcessor%20v2.htm) for details.
contestapplet.conf
==================
You can change some options by editing this file:* `rbprocessor.scriptpath=/path/to/rbprocessor.rb`: Load `rbprocessor.rb` from alternative path.
* `rbprocessor.poweredby=false`: Hide "Powered by" line.
* `rbprocessor.debug=true`: Print debug messages to stderr.Dependencies
============
Common
------
* Java 1.7
* Topcoder Arena 6.5Use
---
* CodeProcessor Arena plug-inBuild
-----
* JRuby 1.7 jruby-complete.jarBuilding from Source
====================
`make` and you will get `rbprocessor.jar`.Links in `Makefile` may expire, in that case you may need to manually find `jruby-complete.jar` and `ContestApplet.jar`.