Sha256: 2cef41cacb9af0b81e2f8ddea4d2de13f082e8c26392819e8606caa2cdc0cc06

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

#!/usr/bin/env ruby

lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
$LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)

require 'cohesion'
require 'slop'

opts = Slop.parse(:help => true) do
  banner 'Usage: cohesion [options]'

  on 'url=', 'URL to start crawl from'
  on 'internal_urls=', 'Url patterns to include', :as => Array
  on 'external_urls=', 'Url patterns to exclude', :as => Array
  on 'seed_urls=', "Seed urls", :as => Array
  on 'crawl_limit=', 'Limit the crawl to a number of urls', :as => Integer
  on 'thread_count=', "Set the number of threads used", :as => Integer
  on 'timeout=', "Sets the timeout for http requests", :as => Integer

  on 'output=', 'Path to output data to'

  on 'v', 'verbose', 'Display crawl information'
  on 'd', 'debug', 'Display debug information'
  on 'w', 'web_statistics', 'Start web stats server'
end

if opts[:url]

  options = opts.to_hash.delete_if { |k, v| v.nil? || k == :url}
  ap options

  failures = Cohesion::Check.site(opts[:url], options)
  if failures.count == 0
    exit(true)
  else
    if opts[:output]
      File.open(opts[:output], 'w') do |f|
        f.write failures.to_json
      end
    end
    exit(false)
  end
else
  puts
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cohesion-0.0.6 bin/cohesion