-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "chore(specs): Remove CSS Critic"
This reverts commit 7de64e4.
- Loading branch information
Geoff Pleiss and Matt Royal
authored and
Geoff Pleiss and Matt Royal
committed
Jul 7, 2015
1 parent
3918e0f
commit 6c78ea3
Showing
7 changed files
with
172 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Source: https://gist.github.com/jdcantrell/b0ad9a6bcbfc2551713f | ||
|
||
require 'pry' | ||
|
||
class CssCriticTestGenerator < Hologram::Plugin | ||
attr :output_dir, :tests | ||
|
||
HTML_HEADER = <<-eos | ||
<html> | ||
<head> | ||
<meta name="viewport" content="width=device-width"> | ||
<link rel="stylesheet" href="pivotal-ui.css"> | ||
<link rel="stylesheet" href="styleguide/styleguide.css"> | ||
<link rel="stylesheet" href="styleguide/github.css"> | ||
<link rel="stylesheet" disabled href="prismjs/prism.css"> | ||
<link rel="stylesheet" href="prismjs/prism-okaidia.css"> | ||
</head> | ||
<body class="pam"> | ||
eos | ||
|
||
HTML_FOOTER = "\n\n</body>\n</html>" | ||
|
||
CODE_REGEX_HTML = /^\s*```html_example(?:_table)?(.*?)\s*```/m | ||
CODE_REGEX_WRAPPED_HTML = /^\s*```html_wrapped_example(.*?)\s*```/m | ||
|
||
def initialize(config, args) | ||
@name = 'css-test' | ||
@tests = [] | ||
|
||
super(config, args) | ||
|
||
if self.is_active? | ||
@output_dir = setup_dir(config) | ||
end | ||
end | ||
|
||
def plugin(text, block, file) | ||
write_test(block.config['name'], [text]) | ||
return '' | ||
end | ||
|
||
def block(comment_block, file, has_plugin) | ||
unwrapped_tests = comment_block.markdown.scan(CODE_REGEX_HTML).flatten | ||
wrapped_tests = comment_block.markdown.scan(CODE_REGEX_WRAPPED_HTML).flatten.map do |example| | ||
%Q(<div class="styleguide-component-wrapper">#{example}</div>) | ||
end | ||
tests = unwrapped_tests + wrapped_tests | ||
write_test(comment_block.config['name'], tests) unless tests.empty? | ||
end | ||
|
||
def finalize(pages) | ||
puts "Tests can be found in #{@output_dir}" | ||
end | ||
|
||
def is_active? | ||
true | ||
end | ||
|
||
private | ||
def write_test(name, content) | ||
test_name = "#{name}.html" | ||
|
||
fh = File.open("#{@output_dir}/#{test_name}", 'w') | ||
|
||
fh.write(HTML_HEADER) | ||
for fragment in content | ||
fh.write(fragment) | ||
end | ||
fh.write(HTML_FOOTER) | ||
|
||
fh.close | ||
|
||
@tests.push(test_name) | ||
end | ||
|
||
def setup_dir(config) | ||
destination = config['destination'] + '/../spec/css/components' | ||
FileUtils.mkdir_p(destination) | ||
return Pathname.new(destination).realpath | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,3 +32,6 @@ index: intro | |
nav_level: section | ||
|
||
exit_on_warnings: true | ||
|
||
plugins: | ||
- ./hologram/css_critic_test_generator.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Regression Runner</title> | ||
<meta charset="utf-8"/> | ||
|
||
<!-- TODO: is there a better way to load csscritic.js? --> | ||
<script src="../../node_modules/csscritic/csscritic.js"></script> | ||
<script src="regressionRunner.js"></script> | ||
</head> | ||
<body> | ||
<button onclick="localStorage.clear(); window.location.reload();">Reset all tests</button> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters