Code Monkey home page Code Monkey logo

birkirb / link-checker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from endymion/link-checker

0.0 2.0 0.0 450 KB

A Ruby gem for checking the links in a web site. Can either scan files or crawl pages. Multi-threaded, with red/green colored output, support for SSL, and support for following redirects. Works great with Octopress, Jekyll, or any collection of static HTML files. With 100% RSpec coverage.

Home Page: https://rubygems.org/gems/link-checker

License: MIT License

Ruby 31.93% Shell 0.04% CSS 19.93% JavaScript 48.10%

link-checker's Introduction

Link Checker

This Ruby gem enables you to easily check the links in your web site. It will scan each .html or .htm file and then check each external link within each file.

It will print the file path in green if all of the external links check out, and red if there are any problems. If there are any problems then it will list each problem URL. It will display yellow warnings for URLs that redirect to other URLs that are good, or red errors if the redirect does not lead to a good URL.

For more detailed information, please see the article Introducing the link-checker Ruby gem on ryanalynporter.com.

Features

  • Scans files for links, or
  • Crawls web pages for links
  • Multi-threaded (fast) with a --max-threads parameter
  • Warnings for links that redirect to valid links
  • red/green/yellow colored output
  • 100% test coverage
  • Works great with Octopress or Jekyll

Installation

Add the link-checker gem to your project's Gemfile:

gem "link-checker"

Then bundle install to install the gem.

Usage

You can use the check-links [PATH] command to specify any directory to scan for HTML files. The default path is ./.

For example, to check the links for an Octopress site:

check-links 'public'

To check the links for a Jekyll site:

check-links

To crawl a live web site:

check-links 'http://your-site.com'

Return value

The check-links command will return a successful return value if there are no problems, or it will return an not-successful return code if it finds errors. So you can use the return code to make decisions on the command line. For example:

check-links 'public' && echo 'SUCCESS'

Parameters

If you don't want to see yellow warnings for URLs that redirect to valid URLs, then pass the --no-warnings parameter:

check-links 'public' --no-warnings

If you want those redirects to be considered errors, even if they redirect to good URLs, then pass the --warnings-are-errors parameter:

check-links 'public' --warnings-are-errors

The link checker will spawn a new thread for each HTML file, and a new thread for each link within each HTML file. That will get out of hand very quickly if you have a large site, so there is a maximum number of threads. When the maximum number is reached, it will block and wait for an existing thread to complete before spawning a new one. The default maximum threads setting is 100, but you can control that number with the --max-threads parameter:

check-links 'public' --max-threads 500

...or:

check-links 'public' --max-threads 1

Testing

The link-checker gem uses RSpec for testing and has 100% test coverage, verified using simplecov.

Run the specs with:

rake spec

API Documentation

The Yardoc documenation is hosted on RubyDoc.info.

link-checker's People

Contributors

birkirb avatar endymion avatar mttrb avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.