This repository has been archived by the owner on Feb 15, 2024. It is now read-only.
forked from humpyard/humpyard
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRakefile
166 lines (144 loc) · 6.13 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
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
157
158
159
160
161
162
163
164
165
166
# encoding: UTF-8
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/test/rails/config/environment")
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'rake/gempackagetask'
#Rails::Application.railties.all.each do |test|
# test.load_tasks if test.class == Rails::TestUnitRailtie
#end
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'HumpYard'
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('doc/**/*.rdoc', 'lib/**/*.rb', 'app/*/humpyard/**/*.rb')
rdoc.rdoc_files.exclude('lib/generators/**/templates/**/*.rb')
end
begin
require 'rspec'
require 'rspec/core/rake_task'
Rspec::Core::RakeTask.new(:spec)
namespace :spec do
desc "Run specs to generate coverage"
Rspec::Core::RakeTask.new(:rcov) do |spec|
spec.rcov = true
spec.rcov_opts = %[--exclude "core,expectations,gems/*,spec/resources,spec/spec,spec/spec_helper.rb,db/*,/Library/Ruby/*,config/*" --text-summary --sort coverage]
end
end
task :spec => [:'db:test:reset']
rescue
task :spec do
abort 'Spec is not available. In order to run cucumber, you must: sudo gem install rspec'
end
end
begin
require 'cucumber/rake/task'
Cucumber::Rake::Task.new(:cucumber)
namespace :cucumber do
desc "Run cucumber to generate coverage"
Cucumber::Rake::Task.new(:rcov) do |cucumber|
cucumber.rcov = true
cucumber.rcov_opts = %w{--rails --exclude osx\/objc,gems\/,spec\/,features\/,test\/ --aggregate coverage.data}
cucumber.rcov_opts << %[-o "coverage"]
end
end
task :cucumber => [:'db:test:reset']
rescue LoadError
task :cucumber do
abort 'Cucumber is not available. In order to run cucumber, you must: sudo gem install cucumber'
end
end
desc "Run RSpec and Cucumber tests"
task :test => [:spec, :cucumber]
task :default => :test
desc "Run both rspec and cucumber tests to generate aggregated coverage"
task :rcov do |t|
rm "coverage.data" if File.exist?("coverage.data")
Rake::Task['spec:rcov'].invoke
Rake::Task["cucumber:rcov"].invoke
`open #{File.dirname(__FILE__)}/coverage/index.html`
end
namespace :db do
namespace :test do
desc "Migrate the test database through scripts in db/migrate. Target specific version with VERSION=x. Turn off output with VERBOSE=false."
task :prepare do
ActiveRecord::Base.configurations = Rails::Application.config.database_configuration
class ActiveRecord::Base
self.table_name_prefix = "#{::ActiveRecord::Base.table_name_prefix}#{Humpyard::config.table_name_prefix}"
end
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test'])
ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
ActiveRecord::Migrator.migrate("#{File.dirname(__FILE__)}/db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
end
desc "Remove the test database"
task :drop do
require 'pathname'
config = Rails::Application.config.database_configuration['test']
path = Pathname.new(config['database'])
file = path.absolute? ? path.to_s : File.join(Rails.root, path)
FileUtils.rm(file)
end
desc "Reset the test database and prepare it through scripts in db/migrate"
task :reset => [:drop, :prepare]
end
end
desc 'Print out all defined routes in match order, with names. Target specific controller with CONTROLLER=x.'
task :routes do
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/config/environment")
Rails::Application.reload_routes!
all_routes = ENV['CONTROLLER'] ? ActionController::Routing::Routes.routes.select { |route| route.defaults[:controller] == ENV['CONTROLLER'] } : ActionController::Routing::Routes.routes
routes = all_routes.collect do |route|
name = ActionController::Routing::Routes.named_routes.routes.index(route).to_s
reqs = route.requirements.empty? ? "" : route.requirements.inspect
{:name => name, :verb => route.verb.to_s, :path => route.path, :reqs => reqs}
end
routes.reject!{ |r| r[:path] == "/rails/info/properties" } # skip the route if it's internal info route
name_width = routes.collect {|r| r[:name]}.collect {|n| n.length}.max
verb_width = routes.collect {|r| r[:verb]}.collect {|v| v.length}.max
path_width = routes.collect {|r| r[:path]}.collect {|s| s.length}.max
routes.each do |r|
puts "#{r[:name].rjust(name_width)} #{r[:verb].ljust(verb_width)} #{r[:path].ljust(path_width)} #{r[:reqs]}"
end
end
spec = Gem::Specification.new do |s|
s.name = "humpyard"
s.summary = %Q{Humpyard is a Rails CMS}
s.description = %Q{Humpyard is a Rails CMS}
s.email = '[email protected]'
s.homepage = 'http://humpyard.org/'
s.authors = ['Sven G. Broenstrup']
s.files = Dir["{lib}/**/*", "{app}/*/humpyard/**/*", "{config}/routes.rb", "{config}/locales/*", "{db}/migrate/*", "{compass}/**/*", "VERSION", "README*", "LICENCE", "Gemfile"]
s.version = ::File.read(::File.join(::File.dirname(__FILE__), "VERSION")).strip
# s.add_development_dependency 'rspec', '>= 1.2.9'
# s.add_development_dependency 'cucumber', '>= 0.6.3'
# s.add_development_dependency 'cucumber-rails', '>= 0.3.0'
# s.add_development_dependency 'pickle', '>= 0.2.4'
# s.add_development_dependency 'capybara', '>= 0.3.5'
# s.add_development_dependency 'factory_girl', '>= 1.2.3'
# s.add_development_dependency 'markup_validity', '>= 1.1.0'
s.add_dependency 'builder'
s.add_dependency 'rails', '>= 3.0.0'
s.add_dependency 'haml', '>= 2.2.20'
s.add_dependency 'acts_as_tree', '>= 0.1.1'
s.add_dependency 'cancan', '>= 1.1.1'
s.add_dependency 'globalize3', '>= 0.0.7'
s.add_dependency 'humpyard_form', '>= 0.0.2'
end
Rake::GemPackageTask.new(spec) do |pkg|
end
desc "Create a stand-alone gemspec"
task :gemspec do
open("#{spec.name}.gemspec", "w") do |f|
f.puts "# Generated by rake\n# DO NOT EDIT THIS FILE DIRECTLY\n"
f.puts spec.to_ruby
end
end
task :gem => [:gemspec]
desc "Install the gem #{spec.name}-#{spec.version}.gem"
task :install do
system("gem install pkg/#{spec.name}-#{spec.version}.gem --no-ri --no-rdoc")
end
task :install => [:gem]