Skip to content
This repository
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 157 lines (143 sloc) 5.761 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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
$:.unshift('lib')
# Add your own tasks in files placed in lib/tasks ending in .rake, for example
# lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require(File.join(File.dirname(__FILE__), 'config', 'boot'))

require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'rake/gempackagetask'

require 'tasks/rails'
require 'fileutils'

spec = Gem::Specification.new do |s|
  s.name = 'wizardly'
  s.version = '0.1.8.9'
  s.platform = Gem::Platform::RUBY
  s.description = 'Create wizards from any model in three steps'
  s.summary = 'Produces controllers and wizard scaffolding for models with validation_groups'

  #move all files in lib/generators -> rails_generators
  FileUtils.rm_rf "rails_generators"
  FileUtils.mkdir "rails_generators"
  FileUtils.cp_r "lib/generators/.", "rails_generators"
  exclude_files = FileList['**/*.log'] + FileList['lib/generators/**/*'] + FileList['lib/tasks/**/*']
  s.files = FileList['{lib,rails_generators}/**/*'] + %w(CHANGELOG.rdoc init.rb LICENSE README.rdoc) - exclude_files
  s.require_path = 'lib'
  s.has_rdoc = true
  #s.test_files = Dir['spec/*_spec.rb']

  s.author = 'Jeff Patmon'
  s.email = 'jpatmon@yahoo.com'
  s.homepage = 'http://github.com/jeffp/wizardly/tree/master'
end

require 'spec/version'
require 'spec/rake/spectask'

namespace :spec do
  desc "Run all specs"
  task :all=>[:macro, :gen, :scaffold, :callback, :callback2, :callback3, :persist, :sandbox, :session]
  desc "Test the AvatarController"
  Spec::Rake::SpecTask.new(:avatar) do |t|
    t.spec_files = FileList['spec/integrations/avatar_spec.rb']
    t.libs << 'lib' << 'spec' << 'spec/integrations'
    t.spec_opts = ['--options', 'spec/spec.opts']
    t.rcov = false
  end
  desc "Test the MacroController"
  Spec::Rake::SpecTask.new(:macro) do |t|
    t.spec_files = FileList['spec/integrations/macro_spec.rb']
    t.libs << 'lib' << 'spec' << 'spec/integrations'
    t.spec_opts = ['--options', 'spec/spec.opts']
    t.rcov = false
  end
  desc "Test the DataModes2Controller"
  Spec::Rake::SpecTask.new(:persist2) do |t|
    t.spec_files = FileList['spec/integrations/data_modes2_spec.rb']
    t.libs << 'lib' << 'spec' << 'spec/integrations'
    t.spec_opts = ['--options', 'spec/spec.opts']
    t.rcov = false
  end
  desc "Test the DataModesController"
  Spec::Rake::SpecTask.new(:persist) do |t|
    t.spec_files = FileList['spec/integrations/data_modes_spec.rb']
    t.libs << 'lib' << 'spec' << 'spec/integrations'
    t.spec_opts = ['--options', 'spec/spec.opts']
    t.rcov = false
  end
  desc "Test the SandboxController"
  Spec::Rake::SpecTask.new(:sandbox) do |t|
    t.spec_files = FileList['spec/integrations/sandbox_spec.rb']
    t.libs << 'lib' << 'spec' << 'spec/integrations'
    t.spec_opts = ['--options', 'spec/spec.opts']
    t.rcov = false
  end
  desc "Test the SessionController"
  Spec::Rake::SpecTask.new(:session) do |t|
    t.spec_files = FileList['spec/integrations/session_spec.rb']
    t.libs << 'lib' << 'spec' << 'spec/integrations'
    t.spec_opts = ['--options', 'spec/spec.opts']
    t.rcov = false
  end
  desc "Test the GeneratedController"
  Spec::Rake::SpecTask.new(:gen=>[:generate_controller]) do |t|
    t.spec_files = FileList['spec/integrations/generated_spec.rb']
    t.libs << 'lib' << 'spec' << 'spec/integrations'
    t.spec_opts = ['--options', 'spec/spec.opts']
    t.rcov = false
  end
  desc "Generate GeneratedController for spec test"
  task :generate_controller=>[:environment] do
    require 'rails_generator'
    require 'rails_generator/scripts/generate'
    gen_argv = []
    gen_argv << "wizardly_controller" << "generated" << "user" << "/main/finished" << "/main/canceled" << "--force"
    Rails::Generator::Scripts::Generate.new.run(gen_argv)
  end
  desc "Test the ScaffoldTestController"
  Spec::Rake::SpecTask.new(:scaffold) do |t|
    t.spec_files = FileList['spec/integrations/scaffold_test_spec.rb']
    t.libs << 'lib' << 'spec' << 'spec/integrations'
    t.spec_opts = ['--options', 'spec/spec.opts']
    t.rcov = false
  end
  desc "Test the CallbacksController"
  Spec::Rake::SpecTask.new(:callback) do |t|
    t.spec_files = FileList['spec/controllers/callbacks_spec.rb']
    t.libs << 'lib' << 'spec' << 'spec/integrations'
    t.spec_opts = ['--options', 'spec/spec.opts']
    t.rcov = false
  end
  desc "Test the Callbacks2Controller"
  Spec::Rake::SpecTask.new(:callback2) do |t|
    t.spec_files = FileList['spec/controllers/callbacks2_spec.rb']
    t.libs << 'lib' << 'spec' << 'spec/integrations'
    t.spec_opts = ['--options', 'spec/spec.opts']
    t.rcov = false
  end
  desc "Test the Callbacks3Controller"
  Spec::Rake::SpecTask.new(:callback3) do |t|
    t.spec_files = FileList['spec/controllers/callbacks3_spec.rb']
    t.libs << 'lib' << 'spec' << 'spec/integrations'
    t.spec_opts = ['--options', 'spec/spec.opts']
    t.rcov = false
  end
end


desc "Generate documentation for the #{spec.name} plugin."
Rake::RDocTask.new(:rdoc) do |rdoc|
  rdoc.rdoc_dir = 'rdoc'
  rdoc.title = spec.name
  # #rdoc.template = '../rdoc_template.rb'
  rdoc.options << '--line-numbers' << '--inline-source'
  rdoc.rdoc_files.include('README.rdoc', 'CHANGELOG.rdoc', 'LICENSE', 'lib/wizardly.rb', 'lib/wizardly/**/*.rb')
end

desc 'Generate a gemspec file.'
task :gemspec do
  File.open("#{spec.name}.gemspec", 'w') do |f|
    f.write spec.to_ruby
  end
end

Rake::GemPackageTask.new(spec) do |p|
  FileUtils.rm_rf "rails_generators"
  FileUtils.mkdir "rails_generators"
  FileUtils.cp_r "lib/generators/.", "rails_generators"
  p.gem_spec = spec
  p.need_tar = RUBY_PLATFORM =~ /mswin/ ? false : true
  p.need_zip = true
end

Dir['tasks/**/*.rake'].each {|rake| load rake}
Something went wrong with that request. Please try again.