Cohesion is a group of tasks that allow you to check link cohesion in a site.
Add to your Gemfile
gem 'cohesion'
or you can just install without bundler with
gem install cohesion
Running from the command line has the following syntax
cohesion --url http://your-site-to-check.com/
Cohesion allows you to control the crawl through various command line options. These are available through help (see below) and are listed here.
- —url Url to start crawl from
- —internal_urls <url1,url2 or filename> List of url patterns to include (comma seperated list or filename with url per line)
- —external_urls <exclude_url1, exclude_url2 or filename> List of url patterns to exclude (comma seperated list or filename with url per line)
- —seed_urls <seed_url1,seed_url2 or filename> Seed urls (comma seperated list or filename with url per line)
- —crawl_limit Limit the crawl to a number of urls
- —thread_count Set the number of threads used
- —cache Sets the timeout for the cache, leave blank for no cache
- —timeout Sets the timeout for http requests
- —output Path to output data to
- —output_format Output format, csv or json
- —authentication Authentication to use, currently only basic
- —username Username to use with authentication specified
- —password Password to use with authentication specified
- -v, —verbose Display crawl information
- -d, —debug Display debug information
- -w, —web_statistics Start web stats server (http://localhost:4567)
Help with available options is available with —help
cohesion --help
You can check an external site with the rake task below. This will crawl the site and check each link within the site, and will also check the links to external sites. It will also check image, stylesheet and javascript references from link tags.
rake cohesion:check["http://your-site-to-check.com"]
Originally the intention was to add this to your specs and render the rails templates from within the app, i’ve not completed this yet so currently you can check your local development environment the same way as you do an external, but point to your local server:
rake cohesion:check["http://localhost:3000/"]
k
I intend to add the ability to check the rails app without starting the server though, which would allow you to add it to your specs.
If you want to contribute, you can fork the github repository and submit pull requests, or you can donate me some development fuel… ie coffee/beer use this link