-
Notifications
You must be signed in to change notification settings - Fork 76
/
Rakefile
76 lines (56 loc) · 4.26 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
67
68
69
70
71
72
73
74
75
require 'rake/testtask'
#------------------------------------------------------------------------------
Rake::TestTask.new do |t|
t.test_files = FileList['test/**/*_test.rb']
t.verbose = true
end
#------------------------------------------------------------------------------
desc "run a console with SpriteFactory loaded"
task :console do
system "irb -r #{File.expand_path('lib/sprite_factory', File.dirname(__FILE__))}"
end
#------------------------------------------------------------------------------
desc "regenerate test reference images"
task :reference do
require File.expand_path('lib/sprite_factory', File.dirname(__FILE__))
regenerate = lambda do |input, options = {}, &block|
output = options[:output] || input
SpriteFactory.run!(input, {:report => true}.merge(options), &block)
FileUtils.mv(output + "." + ( :png).to_s, 'test/images/reference')
FileUtils.mv(output + "." + (options[:style] || :css).to_s, 'test/images/reference')
end
regenerate.call('test/images/regular')
regenerate.call('test/images/regular', :output => 'test/images/regular.horizontal', :selector => 'img.horizontal_', :layout => :horizontal)
regenerate.call('test/images/regular', :output => 'test/images/regular.vertical', :selector => 'img.vertical_', :layout => :vertical)
regenerate.call('test/images/regular', :output => 'test/images/regular.packed', :selector => 'img.packed_', :layout => :packed, :padding => 10, :margin => 10)
regenerate.call('test/images/regular', :output => 'test/images/regular.padded', :selector => 'img.padded_', :padding => 10)
regenerate.call('test/images/regular', :output => 'test/images/regular.margin', :selector => 'img.margin_', :margin => 10)
regenerate.call('test/images/regular', :output => 'test/images/regular.fixed', :selector => 'img.fixed_', :width => 100, :height => 100)
regenerate.call('test/images/regular', :output => 'test/images/regular.sassy', :selector => 'img.sassy_', :style => :sass)
regenerate.call('test/images/irregular')
regenerate.call('test/images/irregular', :output => 'test/images/irregular.horizontal', :selector => 'img.horizontal_', :layout => :horizontal)
regenerate.call('test/images/irregular', :output => 'test/images/irregular.vertical', :selector => 'img.vertical_', :layout => :vertical)
regenerate.call('test/images/irregular', :output => 'test/images/irregular.packed', :selector => 'img.packed_', :layout => :packed, :padding => 10, :margin => 10)
regenerate.call('test/images/irregular', :output => 'test/images/irregular.padded', :selector => 'img.padded_', :padding => 10)
regenerate.call('test/images/irregular', :output => 'test/images/irregular.margin', :selector => 'img.margin_', :margin => 10)
regenerate.call('test/images/irregular', :output => 'test/images/irregular.fixed', :selector => 'img.fixed_', :width => 100, :height => 100)
regenerate.call('test/images/irregular', :output => 'test/images/irregular.sassy', :selector => 'img.sassy_', :style => :sass)
regenerate.call('test/images/hover', :output => 'test/images/hover', :selector => 'div.hover ', :style => :css)
regenerate.call('test/images/glob', :output => 'test/images/glob', :glob => "included*")
regenerate.call('test/images/names', :output => 'test/images/sanitized', :sanitizer => true)
regenerate.call('test/images/names', :output => 'test/images/sanitized.custom', :sanitizer => lambda {|name| name.gsub(/[^\w]/, '_').downcase })
regenerate.call('test/images/custom', :output => 'test/images/custom') do |images|
rules = []
rules << "div.running img.button { cursor: pointer; #{images[:running][:style]} }"
rules << "div.stopped img.button { cursor: pointer; #{images[:stopped][:style]} }"
rules.join("\n")
end
regenerate.call('test/images/formats', :library => :rmagick)
end
#------------------------------------------------------------------------------
desc "convert reference test sass files to css"
task :sass do
`sass 'test/images/reference/regular.sassy.sass' 'test/images/reference/regular.sassy.css'`
`sass 'test/images/reference/irregular.sassy.sass' 'test/images/reference/irregular.sassy.css'`
end
#------------------------------------------------------------------------------