Skip to content
Permalink
Browse files

Cleanup Ruby (with RuboCop)

  • Loading branch information
MikeMcQuaid committed Feb 13, 2018
1 parent 7072091 commit ec1be6c1d4e4d912a4e22b9bfca397be600a84ea
Showing with 18 additions and 23 deletions.
  1. +1 βˆ’1 Rakefile
  2. +10 βˆ’9 script/html-proofer
  3. +2 βˆ’2 test/helper.rb
  4. +5 βˆ’11 test/lint_test.rb
@@ -6,4 +6,4 @@ Rake::TestTask.new do |t|
t.verbose = false
end

task :default => :test
task default: :test
@@ -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
@@ -8,7 +8,7 @@ class << self
end

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

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

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

def site
@@ -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"])
@@ -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

4 comments on commit ec1be6c

@mitchaka

This comment has been minimized.

Copy link

@mitchaka mitchaka replied Mar 19, 2020

Helle

@mitchaka

This comment has been minimized.

Copy link

@mitchaka mitchaka replied Mar 19, 2020

Hi

@mitchaka

This comment has been minimized.

Copy link

@mitchaka mitchaka replied Mar 19, 2020

Thanks for your help

@mitchaka

This comment has been minimized.

Copy link

@mitchaka mitchaka replied Mar 19, 2020

Yes sir πŸ‘

Please sign in to comment.
You can’t perform that action at this time.