1 lib_path = File.join(File.dirname(__FILE__), 'lib')
2 $:.unshift(lib_path) unless $:.include?(lib_path)
4 load './tasks/bower.rake'
6 require 'rake/testtask'
7 Rake::TestTask.new do |t|
9 t.test_files = FileList['test/**/*_test.rb']
13 desc 'Test all Gemfiles from test/*.gemfile'
14 task :test_all_gemfiles do
15 require 'term/ansicolor'
18 cmd = 'bundle install --quiet && bundle exec rake --trace'
19 statuses = Dir.glob('./test/gemfiles/*{[!.lock]}').map do |gemfile|
20 env = {'BUNDLE_GEMFILE' => gemfile}
21 cmd_with_env = " (#{env.map { |k, v| "export #{k}=#{Shellwords.escape v}" } * ' '}; #{cmd})"
22 $stderr.puts Term::ANSIColor.cyan("Testing\n#{cmd_with_env}")
23 PTY.spawn(env, cmd) do |r, _w, pid|
25 r.each_line { |l| puts l }
27 # Errno:EIO error means that the process has finished giving output.
32 [$? && $?.exitstatus == 0, cmd_with_env]
34 failed_cmds = statuses.reject(&:first).map { |(_status, cmd_with_env)| cmd_with_env }
36 $stderr.puts Term::ANSIColor.green('Tests pass with all gemfiles')
38 $stderr.puts Term::ANSIColor.red("Failing (#{failed_cmds.size} / #{statuses.size})\n#{failed_cmds * "\n"}")
43 desc 'Dumps output to a CSS file for testing'
46 path = Bootstrap.stylesheets_path
47 %w(bootstrap).each do |file|
48 engine = Sass::Engine.for_file("#{path}/#{file}.scss", syntax: :scss, load_paths: [path])
49 File.open("./#{file}.css", 'w') { |f| f.write(engine.render) }
53 desc 'Convert bootstrap to bootstrap-sass'
54 task :convert, :branch do |t, args|
55 require './tasks/converter'
56 Converter.new(branch: args[:branch]).process_bootstrap
59 desc 'LESS to stdin -> Sass to stdout'
60 task :less_to_scss, :branch do |t, args|
61 require './tasks/converter'
62 puts Converter.new(branch: args[:branch]).convert_less(STDIN.read)
65 desc 'Compile bootstrap-sass to tmp/ (or first arg)'
66 task :compile, :css_path do |t, args|
68 require 'term/ansicolor'
70 path = 'assets/stylesheets'
71 css_path = args.with_defaults(css_path: 'tmp')[:css_path]
72 puts Term::ANSIColor.bold "Compiling SCSS in #{path}"
73 Dir.mkdir(css_path) unless File.directory?(css_path)
74 %w(_bootstrap bootstrap/_theme).each do |file|
75 save_path = "#{css_path}/#{file.sub(/(^|\/)?_+/, '\1').sub('/', '-')}.css"
76 puts Term::ANSIColor.cyan(" #{save_path}") + '...'
77 engine = Sass::Engine.for_file("#{path}/#{file}.scss", syntax: :scss, load_paths: [path])
79 File.open(save_path, 'w') { |f| f.write css }
83 desc 'Start a dummy (test) Rails app server'
86 require 'term/ansicolor'
87 port = ENV['PORT'] || 9292
88 puts %Q(Starting on #{Term::ANSIColor.cyan "http://localhost:#{port}"})
90 config: 'test/dummy_rails/config.ru',