-
Notifications
You must be signed in to change notification settings - Fork 2
/
Rakefile
executable file
·78 lines (62 loc) · 1.59 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
#!/usr/bin/env rake
# frozen_string_literal: true
require 'bundler'
ENV['RAKE_ENV'] ||= 'development'
begin
Bundler.setup :default, ENV.fetch('RACK_ENV', nil)
rescue Bundler::BundlerError => e
warn e.message
warn 'Run `bundle install` to install missing gems'
exit e.status_code
end
require 'rake'
task :environment do # rubocop:disable Rake/Desc
require File.expand_path('config/environment.rb', __dir__)
end
# Don't bomb when running Rake tasks on something like fly.io.
begin
# RSpec
require 'rspec/core'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
# Rubocop
require 'rubocop/rake_task'
RuboCop::RakeTask.new(:rubocop)
# Bundler audit
require 'bundler/audit/task'
Bundler::Audit::Task.new
rescue LoadError
puts 'Not loading development only rake tasks.'
end
desc 'Lists all of the routes'
task routes: :environment do
GrapeApiBoilerplate::Api::Root.routes.each do |route|
method = route.request_method.ljust(10)
path = route.origin
puts " #{method} #{path}"
end
end
# ActiveRecord tasks
require 'bundler/setup'
load 'tasks/otr-activerecord.rake'
namespace :db do
task :environment do # rubocop:disable Rake/Desc
require_relative 'config/application'
end
end
# Create a new user
def prompt(message)
print(message)
$stdin.gets.chop
end
namespace :users do
desc 'Creates a new user'
task create: :environment do
email = prompt('Email: ')
username = prompt('Username: ')
password = prompt('Password: ')
user = User.new(username:, password:, email:)
user.save!
end
end
task default: %i[rubocop spec]