Skip to content

Commit

Permalink
Cleanup Ruby (with RuboCop)
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeMcQuaid committed Feb 13, 2018
1 parent 7072091 commit ec1be6c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -6,4 +6,4 @@ Rake::TestTask.new do |t|
t.verbose = false
end

task :default => :test
task default: :test
19 changes: 10 additions & 9 deletions script/html-proofer
Expand Up @@ -5,15 +5,16 @@ require "html-proofer"

url_ignores = [
%r{^https://github.com/github/opensource.guide},
'https://karissa.github.io/post/okf-de',
'https://this-week-in-rust.org/',
'https://www.vagrantup.com/',
'https://www.quora.com/'
"https://karissa.github.io/post/okf-de",
"https://this-week-in-rust.org/",
"https://www.vagrantup.com/",
"https://www.quora.com/",
]

HTMLProofer::Runner.new(["_site"],
:type => :directory,
:url_ignore => url_ignores,
:verbose => !!ENV["VERBOSE"],
:check_html => true
HTMLProofer::Runner.new(
["_site"],
type: :directory,
url_ignore: url_ignores,
verbose: !!ENV["VERBOSE"],
check_html: true
).run
4 changes: 2 additions & 2 deletions test/helper.rb
Expand Up @@ -8,7 +8,7 @@ class << self
end

def source
File.expand_path('../', File.dirname(__FILE__))
File.expand_path("../", File.dirname(__FILE__))
end

def config
Expand All @@ -20,7 +20,7 @@ def docs
end

def pages
docs.map { |doc| doc.to_liquid }
docs.map(&:to_liquid)
end

def site
Expand Down
16 changes: 5 additions & 11 deletions test/lint_test.rb
@@ -1,14 +1,11 @@
require_relative "./helper"

describe "lint test" do

pages.each do |page|
next unless page["path"].match(/\.md$/)
next unless page["path"].match?(/\.md$/)

describe page["path"] do

describe "frontmatter" do

before do
# Load raw metadata to skip defaults
@data = SafeYAML.load_file(page["path"])
Expand All @@ -26,19 +23,16 @@ def assert_valid_fields(data, fields)
assert extra_fields.empty?, "Unexpected metadata: #{extra_fields.inspect}"

fields.each do |name, attrs|
if attrs["required"]
assert data.key?(name), "#{name} is required"
end
assert data.key?(name), "#{name} is required" if attrs["required"]

if attrs["type"] && @data[name]
assert_kind_of Kernel.const_get(attrs["type"]), @data[name]
end

# Check subfields
if attrs["fields"] && @data[name]
@data[name].each do |d|
assert_valid_fields(d, attrs["fields"])
end
next unless attrs["fields"] && @data[name]
@data[name].each do |d|
assert_valid_fields(d, attrs["fields"])
end
end
end
Expand Down

4 comments on commit ec1be6c

@mitchaka
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Helle

@mitchaka
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi

@mitchaka
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your help

@mitchaka
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes sir 👍

Please sign in to comment.