An open API service indexing awesome lists of open source software.

https://github.com/stephencelis/scantron

Rule-based string scanning and scrubbing.
https://github.com/stephencelis/scantron

Last synced: 3 months ago
JSON representation

Rule-based string scanning and scrubbing.

Awesome Lists containing this project

README

          

= Scantron

http://github.com/stephencelis/scantron

A simple, but powerful, rule-based string scanner and scrubber.

== Examples

==== NumberScanner

require "scantron"
require "number_scanner"

NumberScanner.scan "A one, 2, 3.0, 4 1/2..."
# => [1, 2, 3.0, (9/2)]

number_scanner = NumberScanner.new < [99, 99, 1, (197/2)]

puts number_scanner.scrub { |n| "#{n}" }
Ninety-nine bottles of beer on the wall.
Ninety-nine bottles of beer.
Take one down, pass it around,
Ninety-eight and a half bottles of beer on the wall.

==== RangeScanner

require "scantron"
require "range_scanner"

RangeScanner.scan "100-150 degrees"
# => [100..150]

RangeScanner.scan "Twelve or thirteen rolls for five or six people"
# => [12..13, 5..6]

=== Build Your Own

TODO

== Install

% [sudo] gem install scantron

Or, with {Bundler}[http://gembundler.com/], add gem "scantron" to your
Gemfile and run bundle install.

== License

(The MIT License)

(c) 2010 Stephen Celis

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.