Project

habakiri

0.0
No commit activity in last 3 years
No release in over 3 years
Habariki is a template match engine for strings that can extract part of text by template keywords.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 5.14
~> 12.0
~> 0.89

Runtime

~> 1.4
 Project Readme

Habakiri

Habariki is a template match engine for strings that can extract part of text by template keywords.

Installation

Add this line to your application's Gemfile:

gem 'habakiri'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install habakiri

Usage

require 'habakiri'

template = <<TEMPLATE
YOUR NAME:{{name}}
EMAIL:{{email}}
TELEPHONE NUMBER:{{tel}}
Website URL:{{url}}
ZIP CODE:{{zipcode}}
ADDRESS:{{address}}
NOTE:{{note}}
TEMPLATE

text = <<TEXT
YOUR NAME:John
EMAIL:email@email.com
TELEPHONE NUMBER:+199999999
Website URL:https://example.com/website/url
ZIP CODE:000-0000
ADDRESS:San Francisco, CA 94107 United States
NOTE:
Hello, world!
Hello, ruby!
Hello, habakiri!
TEXT

result = Habakiri.exec(template, text)
pp result
# =>
# {"name"=>"John",
#  "email"=>"email@email.com",
#  "tel"=>"+199999999",
#  "url"=>"https://example.com/website/url",
#  "zipcode"=>"000-0000",
#  "address"=>"San Francisco, CA 94107 United States",
#  "note"=>"Hello, world!\n" + "Hello, ruby!\n" + "Hello, habakiri!"}

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/diaphragm/habakiri.

License

The gem is available as open source under the terms of the MIT License.