-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
101 lines (93 loc) · 2.96 KB
/
Rakefile
File metadata and controls
101 lines (93 loc) · 2.96 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
$LOAD_PATH.unshift '.'
namespace :emerald do
desc 'Spawns an interactive console'
task :console => :environment do |t|
interactive_ruby = ENV.fetch('INTERACTIVE_RUBY', 'pry')
exec "bundle exec #{ interactive_ruby } -I. -r config/boot"
end
desc 'Setup environment'
task :environment do
require 'config/boot'
end
desc "Print out routes"
task :routes => :environment do
Emerald::Web::API.routes.each do |route|
info = route.instance_variable_get :@options
description = "%-40s..." % info[:description][0..39]
method = "%-7s" % info[:method]
puts "#{description} #{method}#{info[:path]}"
end
end
end
# namespace :db do
# desc "Run migrations"
# task :migrate, [:version] do |t, args|
# # Don't load models when executing DB migrations.
# # This is required, since some of the tables they refer to might not exist
# # yet. It also prevents accidentally using them within migrations - which
# # is asking for trouble anyway.
# ENV['EMERALD_SKIP_MODELS'] = '1'
# require 'config/boot'
#
# logger = Emerald.logger(program: 'migrations')
#
# Sequel.extension :migration
# db = Sequel::Model.db
# if args[:version]
# logger.info "Migrating to version #{args[:version]}"
# Sequel::Migrator.run(db, "db/migrations", target: args[:version].to_i)
# else
# logger.info "Migrating to latest"
# Sequel::Migrator.run(db, "db/migrations")
# end
# end
#
# desc 'Drop and recreate database'
# task :recreate do |t|
# ENV['EMERALD_SKIP_MODELS'] = '1'
# require 'config/boot'
#
# logger = Emerald.logger(program: 'migrations')
#
# application_db = Emerald::Config::Database::DATABASE
# # Reassigning a constant is a bit ugly - but less ugly than duplicating
# # `config/database.rb` for the purpose of getting a DB instance to work
# # with.
# Emerald::Config::Database::DATABASE = 'postgres'
# db = Emerald::Config::Database.database
#
# # Terminate existing connnections.
# Sequel::Model.db.disconnect
# logger.info "Resetting database #{ application_db }"
# db.execute("DROP DATABASE #{ application_db }")
# db.execute("CREATE DATABASE #{ application_db }")
# end
#
# desc 'Reset database and apply all migrations'
# task :reset => :recreate do |t|
# ENV['EMERALD_SKIP_MODELS'] = '1'
# require 'config/boot'
#
# logger = Emerald.logger(program: 'migrations')
#
# Sequel.extension :migration
# logger.info 'Migrating to latest'
# Sequel::Migrator.run(Sequel::Model.db, "db/migrations")
# end
# end
namespace :spec do
begin
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:all) do |t|
t.fail_on_error = false
t.rspec_opts = '--format doc'
end
RSpec::Core::RakeTask.new(:feature) do |t|
t.fail_on_error = false
t.pattern = 'spec/feature/**/*_spec.rb'
t.rspec_opts = '--format doc'
end
rescue LoadError
# no rspec available
end
end