0.0
No commit activity in last 3 years
No release in over 3 years
convert html into activerecord
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
~> 2.0

Runtime

~> 3.2.0
 Project Readme

Html2record

This gem provide a simple way that bind html specific element to a record column

Installation

In Gemfile add follow line:

  gem 'html2record'

Get Start

init parser file

rails g parser Taobao

this command will generate a parser into folder app/parsers/

class TaobaoParser < Html2record::Parser::Base
end

you can add column binding in class

class TaobaoParser < Html2record::Parser::Base
	add :title, '#main .title'	
end

In model file include the class

include Html2record::ActiveRecord

Use the model:

 html =<<-page
     <html>
       <body>
         <div id="main">
           <div><span class="title">hello</span></div>
           <div><span class="content">world</span></div>
         </div>
       <body>
     </html>
 page

 good = Good.new 
 good.apply_html(Taobao,html) # good.title should be 'hello'

This project rocks and uses MIT-LICENSE.