CrowdFundingParser
TODO: Write a gem description
Installation
Add this line to your application's Gemfile:
gem 'crowd_funding_parser'
And then execute:
$ bundle
Or install it yourself as:
$ gem install crowd_funding_parser
Usage
You can use it to get single project's attributes, listed below (sometimes just some of them):
project id(platform_project_id)
title
category
creator_name
creator_id
creator_link
summary
start_date
end_date
region
currency_string
money_goal
money_pledged
backer_count
left_time
status
fb_count
following_count
by using:
flyingv_parser = CrowdFundingParser::Parser::Flyingv.new
project_data = flyingv_parser.get_project(PROJECT_URL)
Or you can use it to get all project's links, using
flyingv_parser = CrowdFundingParser::Parser::Flyingv.new
project_links = flyingv_parser.get_project_links(STATUS) # "finished" or "online"
Contributing
- Fork it ( https://github.com/[my-github-username]/crowd_funding_parser/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Add New Parser
1. Add Test
What to test
There should be 18 methods that need to be tested:
get_id
get_title
get_category
get_creator_name
get_creator_id
get_creator_link
get_summary
get_start_date
get_end_date
get_region
get_currency_string
get_money_goal
get_money_pledged
get_backer_count
get_left_time
get_status
get_fb_count
get_following_count
How to write a test
- Use
get_project_doc(campaign_page_url, platform_name)
to get test doc (please use a finished project). - Set expectations as the project's attributes (use
""
if can't get that attribute). - Example spec.
How to run test
We use Rspec
to run our test, so just run bundle exec rspec
.
Or you can run bundle exec guard
to automatically run tests whenever you changed spec.
Add Parser(only deal with single project's data parsing)
-
Place your parser in
lib/crowd_funding_parsers/parser
-
Naming your parser class after its platform's name
-
Write parser in
MethodBuilder.set_methods
block: -
use
insert_parser
method to register your parser class in method_builder -
use
set_variable
to set variables you need to use in parser methods, like@platform_url
-
use
set_method
to define method -
if you need to use methods you set in method_builder, call it with
@parser
variable.