cohesion 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,13 +15,34 @@ or you can just install without bundler with
15
15
 
16
16
  bc. gem install cohesion
17
17
 
18
-
19
18
  h2. Usage
20
19
 
20
+ h3. Executable
21
+
22
+ Running from the command line has the following syntax
23
+
24
+ bc. cohesion check http://your-site-to-check.com/
25
+
26
+
21
27
  h3. Checking an external site
22
28
 
23
29
  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
30
 
25
31
  bc. rake cohesion:check["http://your-site-to-check.com"]
26
32
 
33
+ h3. Checking your local development environment
34
+
35
+ Currently you can check your local development environment the same way as you do an external, but point to your local server:
36
+
37
+ bc. rake cohesion:check["http://localhost:3000/"]
38
+
39
+
40
+ h2. Future
41
+
42
+ 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.
43
+
44
+ h2. Contribute
45
+
46
+ 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
27
47
 
48
+ "DONATE!":https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=VDJK49HD3DNAS&lc=GB&item_name=stewartmckee&item_number=stewartmckee_donation&no_note=1&no_shipping=1&currency_code=GBP&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
4
+ $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
5
+
6
+ require 'cohesion'
7
+
8
+ args = ARGV.dup
9
+ ARGV.clear
10
+
11
+ case args[0]
12
+ when "check"
13
+ if args[1].nil?
14
+ puts
15
+ puts "Error, URL is not specified. You must specify the url you wish to check"
16
+ puts
17
+ else
18
+ failures = Cohesion::Check.site(args[1])
19
+
20
+ if failures.count == 0
21
+ exit(true)
22
+ else
23
+ exit(false)
24
+ end
25
+ end
26
+ else
27
+ puts "Usage: cohesion command options"
28
+ puts
29
+ puts " check"
30
+ puts " cohesion check http://your-site-to-check.com/"
31
+ puts
32
+ puts " help"
33
+ puts " Produces this information"
34
+ puts
35
+ end
36
+
@@ -13,11 +13,13 @@ Gem::Specification.new do |gem|
13
13
  gem.summary = %q{Gem to test the cohesion of links within a rails site.}
14
14
  gem.homepage = "http://github.com/stewartmckee/cohesion"
15
15
 
16
+ gem.executables << "cohesion"
17
+
16
18
  gem.files = `git ls-files`.split($/)
17
19
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
20
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
21
  gem.require_paths = ["lib"]
20
22
 
21
- #gem.add_dependency "cobweb"
23
+ gem.add_dependency "cobweb"
22
24
 
23
25
  end
@@ -1,8 +1,32 @@
1
1
  require "cohesion/version"
2
+ require 'cobweb'
2
3
 
3
4
  Dir["tasks/**/*.rake"].each { |ext| load ext } if defined?(Rake)
4
5
 
5
6
  module Cohesion
6
7
  class Check
8
+ def self.site(url)
9
+ errors = []
10
+ failures = []
11
+ CobwebCrawler.new(:cache => 600, :cache_type => :full, :crawl_linked_external => true).crawl(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
+ if failures.count == 0
22
+ puts "All links working!"
23
+ else
24
+ puts "Failed urls:"
25
+ failures.map{|f| puts " - #{f[:url]} [ #{f[:status_code]} ]"}
26
+ end
27
+ puts
28
+
29
+ failures
30
+ end
7
31
  end
8
32
  end
@@ -1,3 +1,3 @@
1
1
  module Cohesion
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -6,27 +6,7 @@ namespace :cohesion do
6
6
  puts
7
7
  puts "Usage: rake cohesion:check[url] (eg: check_links[\"http://rubyonrails.org/\"])"
8
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
9
+ Cohesion::Check.site(args[:url])
30
10
  end
31
11
  puts
32
12
  end
@@ -0,0 +1,4 @@
1
+ gem uninstall cohesion -x
2
+ rm cohesion-0.0.1.gem
3
+ gem build cohesion.gemspec
4
+ gem install cohesion-0.0.1.gem
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cohesion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,12 +10,24 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
  date: 2012-12-28 00:00:00.000000000 Z
13
- dependencies: []
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: cobweb
16
+ requirement: &70143145459080 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70143145459080
14
25
  description: Gem to test the cohesion of links within a rails site. The gem crawls
15
26
  the site and checks that external and internal links are valid
16
27
  email:
17
28
  - stewart@theizone.co.uk
18
- executables: []
29
+ executables:
30
+ - cohesion
19
31
  extensions: []
20
32
  extra_rdoc_files: []
21
33
  files:
@@ -26,10 +38,12 @@ files:
26
38
  - LICENSE.txt
27
39
  - README.textile
28
40
  - Rakefile
41
+ - bin/cohesion
29
42
  - cohesion.gemspec
30
43
  - lib/cohesion.rb
31
44
  - lib/cohesion/version.rb
32
45
  - lib/tasks/check.rake
46
+ - script/rebuild
33
47
  - spec/lib/cohesion_spec.rb
34
48
  - spec/spec_helper.rb
35
49
  homepage: http://github.com/stewartmckee/cohesion