cohesion 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.rvmrc +52 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +22 -0
- data/README.textile +27 -0
- data/Rakefile +5 -0
- data/cohesion.gemspec +23 -0
- data/lib/cohesion.rb +8 -0
- data/lib/cohesion/version.rb +3 -0
- data/lib/tasks/check.rake +33 -0
- data/spec/lib/cohesion_spec.rb +18 -0
- data/spec/spec_helper.rb +23 -0
- metadata +61 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
+
# development environment upon cd'ing into the directory
|
5
|
+
|
6
|
+
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
|
7
|
+
# Only full ruby name is supported here, for short names use:
|
8
|
+
# echo "rvm use 1.9.3" > .rvmrc
|
9
|
+
environment_id="ruby-1.9.3-p125@cohesion"
|
10
|
+
|
11
|
+
# Uncomment the following lines if you want to verify rvm version per project
|
12
|
+
# rvmrc_rvm_version="1.10.3" # 1.10.1 seams as a safe start
|
13
|
+
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
|
14
|
+
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
|
15
|
+
# return 1
|
16
|
+
# }
|
17
|
+
|
18
|
+
# First we attempt to load the desired environment directly from the environment
|
19
|
+
# file. This is very fast and efficient compared to running through the entire
|
20
|
+
# CLI and selector. If you want feedback on which environment was used then
|
21
|
+
# insert the word 'use' after --create as this triggers verbose mode.
|
22
|
+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
|
23
|
+
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
24
|
+
then
|
25
|
+
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
26
|
+
[[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
|
27
|
+
\. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
|
28
|
+
if [[ $- == *i* ]] # check for interactive shells
|
29
|
+
then echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green
|
30
|
+
else echo "Using: $GEM_HOME" # don't use colors in non-interactive shells
|
31
|
+
fi
|
32
|
+
else
|
33
|
+
# If the environment file has not yet been created, use the RVM CLI to select.
|
34
|
+
rvm --create use "$environment_id" || {
|
35
|
+
echo "Failed to create RVM environment '${environment_id}'."
|
36
|
+
return 1
|
37
|
+
}
|
38
|
+
fi
|
39
|
+
|
40
|
+
# If you use bundler, this might be useful to you:
|
41
|
+
# if [[ -s Gemfile ]] && {
|
42
|
+
# ! builtin command -v bundle >/dev/null ||
|
43
|
+
# builtin command -v bundle | grep $rvm_path/bin/bundle >/dev/null
|
44
|
+
# }
|
45
|
+
# then
|
46
|
+
# printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
|
47
|
+
# gem install bundler
|
48
|
+
# fi
|
49
|
+
# if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
|
50
|
+
# then
|
51
|
+
# bundle install | grep -vE '^Using|Your bundle is complete'
|
52
|
+
# fi
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Stewart McKee
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.textile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
h1. Cohesion
|
3
|
+
|
4
|
+
h2. Intro
|
5
|
+
|
6
|
+
Cohesion is a group of tasks that allow you to check link cohesion in a site.
|
7
|
+
|
8
|
+
h2. Installation
|
9
|
+
|
10
|
+
Add to your Gemfile
|
11
|
+
|
12
|
+
bc. gem 'cohesion'
|
13
|
+
|
14
|
+
or you can just install without bundler with
|
15
|
+
|
16
|
+
bc. gem install cohesion
|
17
|
+
|
18
|
+
|
19
|
+
h2. Usage
|
20
|
+
|
21
|
+
h3. Checking an external site
|
22
|
+
|
23
|
+
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.
|
24
|
+
|
25
|
+
bc. rake cohesion:check["http://your-site-to-check.com"]
|
26
|
+
|
27
|
+
|
data/Rakefile
ADDED
data/cohesion.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cohesion/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "cohesion"
|
8
|
+
gem.version = Cohesion::VERSION
|
9
|
+
gem.authors = ["Stewart McKee"]
|
10
|
+
gem.email = ["stewart@theizone.co.uk"]
|
11
|
+
|
12
|
+
gem.description = %q{Gem to test the cohesion of links within a rails site. The gem crawls the site and checks that external and internal links are valid}
|
13
|
+
gem.summary = %q{Gem to test the cohesion of links within a rails site.}
|
14
|
+
gem.homepage = "http://github.com/stewartmckee/cohesion"
|
15
|
+
|
16
|
+
gem.files = `git ls-files`.split($/)
|
17
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
|
+
gem.require_paths = ["lib"]
|
20
|
+
|
21
|
+
#gem.add_dependency "cobweb"
|
22
|
+
|
23
|
+
end
|
data/lib/cohesion.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
namespace :cohesion do
|
3
|
+
desc 'cohesion rake task'
|
4
|
+
task :check, :url do | t, args |
|
5
|
+
if args[:url].nil?
|
6
|
+
puts
|
7
|
+
puts "Usage: rake cohesion:check[url] (eg: check_links[\"http://rubyonrails.org/\"])"
|
8
|
+
else
|
9
|
+
errors = []
|
10
|
+
failures = []
|
11
|
+
CobwebCrawler.new(:cache => 600, :cache_type => :full, :crawl_linked_external => true).crawl(args[:url]) do |page|
|
12
|
+
print page[:url]
|
13
|
+
if page[:status_code] > 399
|
14
|
+
puts " [#{page[:status_code]}] \e[31m\u2717\e[0m"
|
15
|
+
failures << page
|
16
|
+
else
|
17
|
+
puts " \e[32m\u2713\e[0m"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
puts
|
22
|
+
if failures.count == 0
|
23
|
+
puts "All links working!"
|
24
|
+
else
|
25
|
+
puts "Failed urls:"
|
26
|
+
|
27
|
+
failures.map{|f| puts " - #{f[:url]} [ #{f[:status_code]} ]"}
|
28
|
+
puts
|
29
|
+
end
|
30
|
+
end
|
31
|
+
puts
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
describe Cohesion do
|
5
|
+
before(:each) do
|
6
|
+
@cohesion = Cohesion::Check.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should be a Check class" do
|
10
|
+
@cohesion.should be_an_instance_of Cohesion::Check
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should run a check" do
|
14
|
+
|
15
|
+
Rake::Task['check'].invoke
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
# Sets up the environment as test so that exceptions are raised
|
3
|
+
ENVIRONMENT = "test"
|
4
|
+
APP_ROOT = File.expand_path(File.dirname(__FILE__) + '/../')
|
5
|
+
|
6
|
+
require "#{APP_ROOT}/lib/cohesion"
|
7
|
+
require 'ap'
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
|
11
|
+
|
12
|
+
config.before(:all) {
|
13
|
+
|
14
|
+
Mock::Application.initialize!
|
15
|
+
|
16
|
+
}
|
17
|
+
|
18
|
+
config.before(:each) {
|
19
|
+
|
20
|
+
}
|
21
|
+
|
22
|
+
end
|
23
|
+
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cohesion
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Stewart McKee
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-28 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Gem to test the cohesion of links within a rails site. The gem crawls
|
15
|
+
the site and checks that external and internal links are valid
|
16
|
+
email:
|
17
|
+
- stewart@theizone.co.uk
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- .gitignore
|
23
|
+
- .rspec
|
24
|
+
- .rvmrc
|
25
|
+
- Gemfile
|
26
|
+
- LICENSE.txt
|
27
|
+
- README.textile
|
28
|
+
- Rakefile
|
29
|
+
- cohesion.gemspec
|
30
|
+
- lib/cohesion.rb
|
31
|
+
- lib/cohesion/version.rb
|
32
|
+
- lib/tasks/check.rake
|
33
|
+
- spec/lib/cohesion_spec.rb
|
34
|
+
- spec/spec_helper.rb
|
35
|
+
homepage: http://github.com/stewartmckee/cohesion
|
36
|
+
licenses: []
|
37
|
+
post_install_message:
|
38
|
+
rdoc_options: []
|
39
|
+
require_paths:
|
40
|
+
- lib
|
41
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
none: false
|
49
|
+
requirements:
|
50
|
+
- - ! '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
requirements: []
|
54
|
+
rubyforge_project:
|
55
|
+
rubygems_version: 1.8.10
|
56
|
+
signing_key:
|
57
|
+
specification_version: 3
|
58
|
+
summary: Gem to test the cohesion of links within a rails site.
|
59
|
+
test_files:
|
60
|
+
- spec/lib/cohesion_spec.rb
|
61
|
+
- spec/spec_helper.rb
|