Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 57 lines (42 sloc) 1.257 kb
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
require 'bundler'
Bundler.setup :development

require 'mg'
MG.new "rails_apps_composer.gemspec"

require 'rspec/core/rake_task'

desc "run specs"
RSpec::Core::RakeTask.new

task :default => :spec


desc "Remove the test_run Rails app (if it's there)"
task :clean do
  system 'rm -rf test_run'
end

desc "Execute a test run with the specified recipes."
task :run => :clean do
  recipes = ENV['RECIPES'].split(',')

  require 'tempfile'
  require 'rails_wizard'

  template = RailsWizard::Template.new(recipes)

  begin
    dir = Dir.mktmpdir "rails_template"
    Dir.chdir(dir) do
      file = File.open('template.rb', 'w')
      file.write template.compile
      file.close

      system "rails new test_run -m template.rb #{template.args.join(' ')}"

      puts "\n\n cd #{dir} # look at the app"
    end
  end
end

desc "Prints out a template from the provided recipes."
task :print do
  require 'rails_wizard'

  recipes = ENV['RECIPES'].split(',')
  puts RailsWizard::Template.new(recipes).compile
end

desc "uninstall rails_apps_composer gem and install a new version"
task :reinstall do
  Rake::Task['clobber'].invoke
  Rake::Task['gem'].invoke
  Rake::Task['gem:install'].invoke
  puts "installed new rails_apps_composer #{RailsWizard::VERSION}"
end
Something went wrong with that request. Please try again.