Skip to content

Commit

Permalink
[system] Automatic internal links checking
Browse files Browse the repository at this point in the history
  • Loading branch information
roolo committed Feb 26, 2014
1 parent b88891c commit 7e591d1
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 4 deletions.
11 changes: 9 additions & 2 deletions Gemfile
@@ -1,6 +1,13 @@
source 'http://rubygems.org'
source 'https://rubygems.org'

gem 'github-pages', '~> 10'
gem 'rack-jekyll'
gem 'iconv', '~> 1.0.3'
gem 'rake'
gem 'rake'

group :testing do
gem 'nokogiri'
gem 'rack-test'
gem 'guard-minitest'
gem 'guard-jekyll'
end
34 changes: 33 additions & 1 deletion Gemfile.lock
@@ -1,14 +1,16 @@
GEM
remote: http://rubygems.org/
remote: https://rubygems.org/
specs:
RedCloth (4.2.9)
classifier (1.3.3)
fast-stemmer (>= 1.0.0)
coderay (1.1.0)
colorator (0.1)
commander (4.1.5)
highline (~> 1.6.11)
fast-stemmer (1.0.2)
ffi (1.9.3)
formatador (0.2.4)
github-pages (10)
RedCloth (= 4.2.9)
jekyll (= 1.3.0)
Expand All @@ -17,6 +19,18 @@ GEM
maruku (= 0.6.1)
rdiscount (= 2.1.7)
redcarpet (= 2.3.0)
guard (1.8.3)
formatador (>= 0.2.4)
listen (~> 1.3)
lumberjack (>= 1.0.2)
pry (>= 0.9.10)
thor (>= 0.14.6)
guard-jekyll (1.4.0)
guard (>= 1.1.0)
jekyll
guard-minitest (1.3.1)
guard (>= 1.8)
minitest (>= 2.1)
highline (1.6.20)
iconv (1.0.3)
jekyll (1.3.0)
Expand All @@ -35,16 +49,28 @@ GEM
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
rb-kqueue (>= 0.2)
lumberjack (1.0.4)
maruku (0.6.1)
syntax (>= 1.0.0)
method_source (0.8.2)
mini_portile (0.5.2)
minitest (5.3.0)
nokogiri (1.6.1)
mini_portile (~> 0.5.0)
posix-spawn (0.3.6)
pry (0.9.12.6)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
pygments.rb (0.5.4)
posix-spawn (~> 0.3.6)
yajl-ruby (~> 1.1.0)
rack (1.5.2)
rack-jekyll (0.4.1)
jekyll (>= 0.12.0, < 2.0)
rack (~> 1.5.0)
rack-test (0.6.2)
rack (>= 1.0)
rake (10.1.0)
rb-fsevent (0.9.3)
rb-inotify (0.9.2)
Expand All @@ -54,14 +80,20 @@ GEM
rdiscount (2.1.7)
redcarpet (2.3.0)
safe_yaml (0.9.7)
slop (3.4.7)
syntax (1.0.0)
thor (0.18.1)
yajl-ruby (1.1.0)

PLATFORMS
ruby

DEPENDENCIES
github-pages (~> 10)
guard-jekyll
guard-minitest
iconv (~> 1.0.3)
nokogiri
rack-jekyll
rack-test
rake
14 changes: 14 additions & 0 deletions Guardfile
@@ -0,0 +1,14 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme

guard :minitest, cli: '--pride' do
# with Minitest::Spec
watch(%r{^spec/(.*)_spec\.rb})
watch(%r{^_posts/.*}) { |m| "spec/*_spec.rb" }
watch(%r{^spec/spec_helper\.rb}) { 'spec' }
end

guard 'jekyll' do
watch /_.*/
ignore /_site/
end
2 changes: 1 addition & 1 deletion _config.yml
Expand Up @@ -6,4 +6,4 @@ timezone: '+01:00'

disqus_shortname: mailuv-blog-rooland

exclude: [CNAME, Gemfile, Gemfile.lock, Rakefile.rb, README, tasks]
exclude: [CNAME, Gemfile, Gemfile.lock, Rakefile.rb, README, tasks, config.ru, spec, tmp, Guardfile]
2 changes: 2 additions & 0 deletions config.ru
@@ -0,0 +1,2 @@
require 'rack/jekyll'
run Rack::Jekyll.new
29 changes: 29 additions & 0 deletions spec/spec_helper.rb
@@ -0,0 +1,29 @@
require 'bundler/setup'
require 'minitest/autorun'
require 'rack/test'
require 'rack/jekyll'
require 'nokogiri'


def app
Rack::Jekyll.new
end

def try_access url, processed = []
get url
assert_equal last_response.status,
200,
url

document = Nokogiri::HTML last_response.body

links = document.xpath('//a').map{|node| node['href']}

unless links.empty?
links.each do |link|
try_access link, processed.push(link) unless link =~ /^(http|itpc)/ || processed.include?(link)
end
end

end

10 changes: 10 additions & 0 deletions spec/urls_spec.rb
@@ -0,0 +1,10 @@
require 'spec_helper'

describe 'Urls on this blog' do
include Rack::Test::Methods

it 'should be accessible localy' do
try_access '/'
end
end

0 comments on commit 7e591d1

Please sign in to comment.