This repository has been archived by the owner on Sep 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathRakefile
66 lines (49 loc) · 1.96 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
require 'yaml'
require "selenium-webdriver"
require 'middleman-gh-pages'
# copy pasted from config.rb
def filenameize(name)
"images/#{name.downcase.gsub(/[^0-9A-Za-z\-]/, '_')}.png"
end
task :screenshot_guides do
#ENV['webdriver.chrome.driver'] = 'bin/chromedriver'
driver = Selenium::WebDriver.for :chrome
driver.manage.window.resize_to(1440, 900)
YAML.load_file('data/styleguides.yml').each do |styleguide|
print "Screenshotting #{styleguide['name']} (#{styleguide['url']})"
$stdout.flush
filename = filenameize(styleguide['name'])
driver.navigate.to styleguide['url']
sleep(styleguide['screenshot_delay']) if styleguide['screenshot_delay']
driver.save_screenshot("source/#{filename}")
puts " -- Success"
end
driver.quit
print "Resizing images wuth ImageMagick"
`mogrify -resize 1200x source/images/*png`
puts " -- Success"
end
task :fill_data do
styleguides = YAML.load_file('data/styleguides.yml')
styleguides.each do |styleguide|
styleguide['filename'] = styleguide['name'].downcase.gsub(/\W/, '_') + '.png'
styleguide['classname'] = styleguide['name'].downcase.gsub(/\W/, '-')
end
File.open('data/styleguides.yml', 'w') { |f| f.write styleguides.to_yaml }
end
task :generate_readme do
readme = File.open('README.md', 'w')
readme.puts '# UI Styleguides'
readme.write 'A curated list of UI styleguides deployed to '\
'[http://kevinwuhoo.github.io/ui-styleguides/]'\
'(http://kevinwuhoo.github.io/ui-styleguides/).'\
' Selected styleguides contain some combination of '
descriptions = YAML.load_file('data/styleguides.yml').map do |guide|
guide['description'].split(',').map(&:strip) if guide['description']
end
descriptions = descriptions.flatten.compact.uniq.sort.join(', ')
readme.puts "#{descriptions}.\n\n"
YAML.load_file('data/styleguides.yml').each do |guide|
readme.puts "* [#{guide['name']}](#{guide['url']}) - #{guide['description']}"
end
end