-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathRakefile
125 lines (99 loc) · 3.47 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
require_relative './config/environment'
require_relative './instructions_data.rb'
require 'sinatra/activerecord/rake'
require 'colorize'
desc "Start our app console"
task :console do
ActiveRecord::Base.logger = Logger.new(STDOUT)
Pry.start
end
desc "start our app"
task :start do
app = nameOfYourApp.new
app.run
end
namespace :remind_me_about do
desc "🎁 process for adding a new table"
task :adding_table do
reminder_title("💧", "adding a table")
iterate_over_steps($adding_table, "🌱")
end
desc "🎁 process for adding a column"
task :adding_column do
reminder_title("🌬 ", "adding a column")
iterate_over_steps($adding_column, "🌴")
end
desc "🎁 process for rolling back a column"
task :rolling_back do
reminder_title("🍂 ", "rolling back")
iterate_over_steps($rolling_back, "🍁")
end
desc "🎁 process for creating an instance"
task :creating_an_instance do
reminder_title("🥚 ", "bringing new life")
iterate_over_steps($creating_instance, "🐣")
end
desc "🎁 process for reading instances"
task :reading_instances do
reminder_title("📚 ", "reading the instances")
iterate_over_steps($reading_instances, "🤓 ")
end
desc "🎁 process for updating an instance"
task :updating_an_instance do
reminder_title("🐛 ", "updating an instance")
iterate_over_steps($updating_instance, "🦋 ")
end
desc "🎁 process for updating all instances"
task :updating_all_instances do
reminder_title("⚡️ ", "updating all instances")
iterate_over_steps($updating_instances, "🔥 ")
end
desc "🎁 process for deleting an instance"
task :deleting_an_instance do
reminder_title("💀 ", "deleting an instance")
iterate_over_steps($deleting_instance, "👻 ")
end
desc "🎁 process for deleting all instances"
task :deleting_all_instances do
reminder_title("👽 ", "deleting all instances")
iterate_over_steps($deleting_instances, "🧟♀️ ")
end
end
def reminder_title(emoji, title)
puts "\n\n #{four(emoji)} INSTRUCTIONS FOR #{title.upcase} #{four(emoji)} \n\n"
end
def four(emoji)
"#{emoji} "*4
end
def iterate_over_steps(array_of_hashes, emoji)
array_of_hashes.each_with_index do |hash, index|
puts "#{four(emoji)} STEP #{index} #{four(emoji)} "
puts hash[:name].colorize(:grey)
code = hash[:code].empty? ? "no code!" : hash[:code].colorize(:green)
puts "code:".colorize(:red).underline + " " + code
puts "#{four("🛑")} NOTE: #{hash[:note]}" if hash[:note]
puts "\n\n"
end
end
######### REFACTORED / ABSTRACTED FOR THE CURIOUS SOULS
# desc "adding a new table"
# task :adding_table do
# task_body({title_emoji: "💧", title: "adding a table", global_var: $adding_table, steps_emoji: "🌱"})
# end
# desc "adding a column"
# task :adding_column do
# task_body({title_emoji: "🌬 ", title: "adding a column", global_var: $adding_column, steps_emoji: "🌴"})
# end
# desc "rolling back a column"
# task :rolling_back do
# task_body({title_emoji: "🍂 ", title: "rolling in the deep", global_var: $rolling_back, steps_emoji: "🍁"})
# end
# desc "creating instances"
# task :creating_instances do
# task_body({title_emoji: "🥚 ", title: "bringing new life", global_var: $creating_instances, steps_emoji: "🐣"})
# end
# end
# def task_body(args_hash)
# reminder_title(args_hash[:title_emoji], args_hash[:title])
# iterate_over_steps(args_hash[:global_var], args_hash[:steps_emoji])
# end