checkin_self 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/checkin_self.rb +19 -368
- data/lib/emotion_list.rb +70 -56
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0d80b523c7dac84fede03faeef63fdb0f4ca24c
|
4
|
+
data.tar.gz: 17d2088e0b041a272785dc9c8e9eb4d8cc0b0835
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae4c7837fc4a9bf2e40586024d8c856b0cb4914265e1a59dc839c0c0f718139a4eaf777fd11965996f1d200771a36041e765e75dd78b520c4b4c15a27062cf86
|
7
|
+
data.tar.gz: e1b82db2326b4d44a5224f600b5447d5b842a22ae4719f73625e69eb53a1160ba7fd736e555d19ac03489869570522abcbfeb9512a5434d62b1fe6d6ebc0dc1f
|
data/lib/checkin_self.rb
CHANGED
@@ -1,166 +1,14 @@
|
|
1
|
-
#
|
2
|
-
# Wording, advice, and structure for this mindfulness exercise were largely pulled from "SOS for Emotions" by the NYU Student Health Center, authored by Reji Mathew, PhD, NYU Counseling and Wellness Services, Dialectical Behavior Therapy Clinical Team (https://www.nyu.edu/content/dam/nyu/studentHealthServices/documents/PDFs/mental-health/CWS_SOS_for_Emotions_Booklet.pdf).
|
3
|
-
# To use this program, call it without arguments. If you call it with the argument 'log', you can get a report on your previous checkins.
|
1
|
+
# checkin_self - a tool to integrate mindful checkins into your git workflow
|
4
2
|
|
5
3
|
# BUSINESS LOGIC
|
6
4
|
|
7
5
|
require 'sqlite3'
|
8
6
|
require_relative 'emotion_list'
|
7
|
+
require_relative 'checkin'
|
8
|
+
require_relative 'checkins_db'
|
9
|
+
require_relative 'githooker'
|
9
10
|
|
10
|
-
db = SQLite3::Database.new(File.join(Dir.home, ".checkins.db"))
|
11
|
-
|
12
|
-
# SQL command to make the tables if they don't exist.
|
13
|
-
create_tables_cmd = <<-SQL
|
14
|
-
CREATE TABLE IF NOT EXISTS emotions(
|
15
|
-
id INT PRIMARY KEY,
|
16
|
-
name VARCHAR(32)
|
17
|
-
);
|
18
|
-
CREATE TABLE IF NOT EXISTS states(
|
19
|
-
id INT PRIMARY KEY,
|
20
|
-
name VARCHAR(32),
|
21
|
-
emotionID INT,
|
22
|
-
FOREIGN KEY (emotionID) REFERENCES emotions(id)
|
23
|
-
);
|
24
|
-
CREATE TABLE IF NOT EXISTS checkins(
|
25
|
-
time VARCHAR(32) PRIMARY KEY,
|
26
|
-
emotionID INT,
|
27
|
-
stateID INT,
|
28
|
-
intensity INT,
|
29
|
-
trigger VARCHAR(255),
|
30
|
-
noteToSelf BLOB,
|
31
|
-
FOREIGN KEY (emotionID) REFERENCES emotions(id),
|
32
|
-
FOREIGN KEY (stateID) REFERENCES state(id)
|
33
|
-
);
|
34
|
-
SQL
|
35
|
-
|
36
|
-
db.execute_batch(create_tables_cmd)
|
37
|
-
|
38
|
-
# Check if the emotions and states tables have been populated, and, if not, do so.
|
39
|
-
unless db.execute("SELECT name FROM emotions;").any? { |row| row[0] == "joy" }
|
40
|
-
populate_emotional_states_cmd = <<-SQL
|
41
|
-
INSERT OR IGNORE INTO emotions (id, name) VALUES (1, "anger");
|
42
|
-
INSERT OR IGNORE INTO emotions (id, name) VALUES (2, "joy");
|
43
|
-
INSERT OR IGNORE INTO emotions (id, name) VALUES (3, "sadness");
|
44
|
-
INSERT OR IGNORE INTO emotions (id, name) VALUES (4, "hurt");
|
45
|
-
INSERT OR IGNORE INTO emotions (id, name) VALUES (5, "fear");
|
46
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (1, "bothered", 1);
|
47
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (2, "annoyed", 1);
|
48
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (3, "bitter", 1);
|
49
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (4, "angry", 1);
|
50
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (5, "irritated", 1);
|
51
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (6, "disgusted", 1);
|
52
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (7, "frustrated", 1);
|
53
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (8, "exasperated", 1);
|
54
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (9, "furious", 1);
|
55
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (10, "content", 2);
|
56
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (11, "peaceful", 2);
|
57
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (12, "relaxed", 2);
|
58
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (13, "cheerful", 2);
|
59
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (14, "satisfied", 2);
|
60
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (15, "joyous", 2);
|
61
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (16, "excited", 2);
|
62
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (17, "ecstatic", 2);
|
63
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (18, "happy", 2);
|
64
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (19, "sad", 3);
|
65
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (20, "depressed", 3);
|
66
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (21, "distraught", 3);
|
67
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (22, "despair", 3);
|
68
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (23, "melancholy", 3);
|
69
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (24, "grief", 3);
|
70
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (25, "helpless", 3);
|
71
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (26, "hopeless", 3);
|
72
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (27, "miserable", 3);
|
73
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (28, "lonely", 4);
|
74
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (29, "homesick", 4);
|
75
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (30, "abandoned", 4);
|
76
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (31, "embarrassed", 4);
|
77
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (32, "shame", 4);
|
78
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (33, "guilt", 4);
|
79
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (34, "foolish", 4);
|
80
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (35, "humiliated", 4);
|
81
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (36, "uncertain", 5);
|
82
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (37, "worried", 5);
|
83
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (38, "anxious", 5);
|
84
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (39, "frightened", 5);
|
85
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (40, "scared", 5);
|
86
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (41, "nervous", 5);
|
87
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (42, "afraid", 5);
|
88
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (43, "terrified", 5);
|
89
|
-
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (44, "overwhelmed", 5);
|
90
|
-
SQL
|
91
|
-
db.execute_batch(populate_emotional_states_cmd)
|
92
|
-
end
|
93
|
-
|
94
|
-
# Print list of emotions, stored in emotion_list.rb for easier reference
|
95
|
-
def print_emotion_list
|
96
|
-
EMOTION_LIST.each do |emotion, states|
|
97
|
-
puts emotion.upcase + ":"
|
98
|
-
puts " " + states.join(", ")
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
# Breathing exercise to be run if the intensity of negative emotions is greater than 5
|
103
|
-
def breathing_exercise
|
104
|
-
4.times do
|
105
|
-
4.times { |n| puts "BREATHE IN " + (">" * (n+1)) + ("." * (3-n)); sleep 1 }
|
106
|
-
4.times { |n| puts " HOLD " + ("=" * 4); sleep 1 }
|
107
|
-
4.times { |n| puts "BREATHE OUT " + ("<" * (4 - n)) + ("." * n); sleep 1 }
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
# Add this checkin into the checkins database in checkins.db
|
112
|
-
def add_checkin(db, emotional_state, intensity, trigger_note, note_to_self)
|
113
|
-
# look up the emotion ID and state ID for a given emotion and state contained in emotional_state hash
|
114
|
-
emotion_id = db.get_first_value("SELECT id FROM emotions WHERE name = ?", emotional_state[:emotion])
|
115
|
-
if emotional_state[:state]
|
116
|
-
state_id = db.get_first_value("SELECT id FROM states WHERE name = ?", emotional_state[:state])
|
117
|
-
else
|
118
|
-
state_id = nil
|
119
|
-
end
|
120
|
-
|
121
|
-
# format current time as a string and note_to_self as a blob
|
122
|
-
time_now = Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
123
|
-
note_to_self = note_to_self.to_blob if note_to_self
|
124
|
-
|
125
|
-
db.execute("INSERT INTO checkins (time, emotionID, stateID, intensity, trigger, noteToSelf) VALUES (?, ?, ?, ?, ?, ?)", [time_now, emotion_id, state_id, intensity ||= nil, trigger_note ||= nil, note_to_self ||= nil])
|
126
|
-
end
|
127
|
-
|
128
|
-
# used to add some mindful wait time so user can observe emotions
|
129
|
-
def pause_for(seconds)
|
130
|
-
seconds.times { |s| print ((seconds - s).to_s + "... ") ; sleep 1 }
|
131
|
-
puts
|
132
|
-
end
|
133
|
-
|
134
|
-
# used to put the feeling that the user feels into terms readable for our databases
|
135
|
-
def categorize_feeling(feeling)
|
136
|
-
if feeling.downcase == "more"
|
137
|
-
puts
|
138
|
-
print_emotion_list
|
139
|
-
puts
|
140
|
-
puts "Pick a word from the list above that describes how you're feeling right now."
|
141
|
-
return categorize_feeling(STDIN.gets.chomp)
|
142
|
-
elsif EMOTION_LIST.keys.include?(feeling.downcase)
|
143
|
-
# emotion named by user, but not a secondary state
|
144
|
-
categorized = { emotion: feeling.downcase, state: nil }
|
145
|
-
else
|
146
|
-
matching_emotion = EMOTION_LIST.select {|emotion, states| states.include? feeling.downcase}
|
147
|
-
categorized = { emotion: matching_emotion.keys[0], state: feeling.downcase }
|
148
|
-
end
|
149
|
-
return categorized if defined? categorized
|
150
|
-
# User gave invalid input, run again
|
151
|
-
return categorize_feeling("more")
|
152
|
-
end
|
153
|
-
|
154
|
-
# Read in list of tasks that the user wants to remember for later.
|
155
|
-
def get_tasks
|
156
|
-
note_to_self = ""
|
157
|
-
task = STDIN.gets.chomp
|
158
|
-
until task.downcase == "done"
|
159
|
-
note_to_self += " o " + task + "\n"
|
160
|
-
task = STDIN.gets.chomp
|
161
|
-
end
|
162
|
-
return note_to_self.chomp
|
163
|
-
end
|
11
|
+
db = CheckinsDB.new(SQLite3::Database.new(File.join(Dir.home, ".checkins.db")))
|
164
12
|
|
165
13
|
# Help page to be run when given the argument 'help', 'h', '--h' or '--help'
|
166
14
|
def display_help
|
@@ -183,110 +31,6 @@ def display_help
|
|
183
31
|
puts
|
184
32
|
puts "hook, or --hook, with optional hook name"
|
185
33
|
puts "Attaches this checkin to a githook in the current git repository, so that checkin_self is automatically called every time you run a specific git command for the current repository. Defaults to post-checkout hook if no argument given. See this page for further documentation on githooks: https://git-scm.com/docs/githooks."
|
186
|
-
exit
|
187
|
-
end
|
188
|
-
|
189
|
-
def print_log(db, limit=Float::INFINITY)
|
190
|
-
# generate SQL query that can pull the log, replace the ids from each table with the emotion/state names, etc
|
191
|
-
qry_checkins_cmd = <<-SQL
|
192
|
-
SELECT time, emotions.name, states.name, intensity
|
193
|
-
FROM (checkins LEFT JOIN emotions ON checkins.emotionID = emotions.id) LEFT JOIN states
|
194
|
-
ON checkins.stateID = states.id;
|
195
|
-
SQL
|
196
|
-
|
197
|
-
# make header row
|
198
|
-
puts "Checkin time | Emotion | Emotional state | Intensity "
|
199
|
-
puts "---------------------|--------------|------------------|-----------"
|
200
|
-
|
201
|
-
# initialize incrementer to test if going past limit
|
202
|
-
i = 1
|
203
|
-
|
204
|
-
# print that SQL query for each row, going back as long as incrementer is less than limit
|
205
|
-
rows = db.execute(qry_checkins_cmd)
|
206
|
-
rows.reverse_each do |row|
|
207
|
-
next if i > limit
|
208
|
-
|
209
|
-
# turn all null or nil values and all numbers into strings
|
210
|
-
row.map!(&:to_s)
|
211
|
-
puts row[0].ljust(21) + "| " + row[1].ljust(13) + "| " + row[2].ljust(17) + "| " + row[3].ljust(9)
|
212
|
-
i += 1
|
213
|
-
end
|
214
|
-
exit
|
215
|
-
end
|
216
|
-
|
217
|
-
def review_notes_to_self(db)
|
218
|
-
# generate SQL queries that pull the times and all from the noteToSelf attribute, numbered
|
219
|
-
|
220
|
-
pull_notes_cmd = <<-SQL
|
221
|
-
SELECT time, emotions.name, states.name, trigger, noteToSelf
|
222
|
-
FROM (checkins JOIN emotions ON checkins.emotionID = emotions.id) LEFT JOIN states
|
223
|
-
ON checkins.stateID = states.id;
|
224
|
-
SQL
|
225
|
-
entries = db.execute(pull_notes_cmd)
|
226
|
-
puts
|
227
|
-
entries.each do |entry|
|
228
|
-
next unless entry[3] or entry[4]
|
229
|
-
puts "Date and time: " + entry[0]
|
230
|
-
print "Emotional state: " + entry[1]
|
231
|
-
print ", " + entry[2] if entry[2] # checking if state is nil
|
232
|
-
print "\n"
|
233
|
-
puts "Trigger: " + entry[3] if entry[3]
|
234
|
-
puts
|
235
|
-
puts "Note to self: \n\n" + entry[4] if entry[4]
|
236
|
-
puts
|
237
|
-
puts " -=- -=- -=- -=- -=- -=- -=- -=- "
|
238
|
-
puts
|
239
|
-
end
|
240
|
-
exit
|
241
|
-
end
|
242
|
-
|
243
|
-
def githook(hook_name="post-checkout")
|
244
|
-
git_dir = find_git_dir
|
245
|
-
hook_filename = hook_name || "post-checkout"
|
246
|
-
acceptable_hooks = ["applypatch-msg","pre-applypatch","post-applypatch","pre-commit","prepare-commit-msg","commit-msg","post-commit","pre-rebase","post-checkout","post-merge","pre-push","pre-receive","update","post-receive","post-update","push-to-checkout","pre-auto-gc","post-rewrite","rebase"]
|
247
|
-
unless acceptable_hooks.include? hook_filename
|
248
|
-
puts "Please provide an acceptable hook name. Refer to this page for information:"
|
249
|
-
puts "https://git-scm.com/docs/githooks"
|
250
|
-
exit
|
251
|
-
end
|
252
|
-
if git_dir
|
253
|
-
# check if .git/hooks contains file matching current hook
|
254
|
-
hooks_dir = File.join(git_dir, "hooks")
|
255
|
-
hook_full_path = File.join(hooks_dir, hook_filename)
|
256
|
-
unless File.exist? hook_full_path
|
257
|
-
hook_file = File.open(hook_full_path, "w") do |file|
|
258
|
-
file.puts "#!/usr/bin/env ruby"
|
259
|
-
file.puts "require 'checkin_self'"
|
260
|
-
end
|
261
|
-
system("chmod +x #{hook_full_path}")
|
262
|
-
puts "Added githook on hook #{hook_filename}, located in hooks folder #{hooks_dir}"
|
263
|
-
exit
|
264
|
-
else
|
265
|
-
puts "Githook for this action (#{hook_filename}) already exists... exiting..."
|
266
|
-
puts "See this stackoverflow answer on attaching multiple scripts to same hook:\nhttp://stackoverflow.com/questions/30104343/multiple-git-hooks-for-the-same-trigger"
|
267
|
-
exit
|
268
|
-
end
|
269
|
-
else
|
270
|
-
puts "No git repository found... exiting... "
|
271
|
-
exit
|
272
|
-
end
|
273
|
-
end
|
274
|
-
|
275
|
-
def find_git_dir
|
276
|
-
# find .git directory
|
277
|
-
if File.exist? ".git"
|
278
|
-
return File.join(Dir.pwd,".git")
|
279
|
-
else
|
280
|
-
# find path to parent directory
|
281
|
-
index_of_parent_separator = Dir.pwd.rindex(File::SEPARATOR)
|
282
|
-
parent_dir_name = Dir.pwd[0...index_of_parent_separator]
|
283
|
-
|
284
|
-
if File.exist? parent_dir_name
|
285
|
-
Dir.chdir(parent_dir_name) { find_git_dir }
|
286
|
-
else
|
287
|
-
return false
|
288
|
-
end
|
289
|
-
end
|
290
34
|
end
|
291
35
|
|
292
36
|
# DRIVER CODE
|
@@ -299,115 +43,22 @@ if ARGV[0]
|
|
299
43
|
display_help
|
300
44
|
when "log", "l"
|
301
45
|
if ARGV[1]
|
302
|
-
|
46
|
+
puts db.log(ARGV[1].to_i)
|
303
47
|
else
|
304
|
-
|
48
|
+
puts db.log(Float::INFINITY)
|
305
49
|
end
|
306
50
|
when "pull", "p"
|
307
|
-
|
51
|
+
puts db.review_notes
|
308
52
|
when "hook", "--hook"
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
puts "OBSERVE how you're feeling."
|
317
|
-
puts "No need to judge it, let's just pause and notice it."
|
318
|
-
|
319
|
-
pause_for(25)
|
320
|
-
|
321
|
-
puts "DESCRIBE how you're feeling. Which of these emotions would you say it falls under?"
|
322
|
-
puts
|
323
|
-
puts "anger -=- joy -=- sadness -=- hurt -=- fear"
|
324
|
-
puts
|
325
|
-
puts "Type 'more' for a list of more words to help you figure out what you're feeling and how we'll categorize it."
|
326
|
-
|
327
|
-
emotional_state = categorize_feeling(STDIN.gets.chomp)
|
328
|
-
puts
|
329
|
-
|
330
|
-
puts "How strong is that feeling on a scale of 0 to 10?"
|
331
|
-
intensity = STDIN.gets.chomp.to_i
|
332
|
-
intensity = 0 if intensity < 0
|
333
|
-
intsensity = 10 if intensity > 10
|
334
|
-
puts
|
335
|
-
|
336
|
-
# begin intervention due to high negative emotions
|
337
|
-
if intensity > 5 and emotional_state[:emotion] != "joy"
|
338
|
-
puts "Okay, let's take a couple of breaths, then let's talk about our options."
|
339
|
-
puts
|
340
|
-
breathing_exercise
|
341
|
-
puts
|
342
|
-
puts "Now, let's talk about your options for right now, before you start your work."
|
343
|
-
puts "-= You can CHANGE your situation, environment or reactions."
|
344
|
-
puts "-= You can ACCEPT that this is how you'll be feeling while you're working."
|
345
|
-
puts "-= Or you can choose to try and LET GO of this feeling before you start your work."
|
346
|
-
puts
|
347
|
-
puts "What do you want to do right now? Type 'change', 'accept' or 'let go', or anything else to skip this."
|
348
|
-
intervention = STDIN.gets.chomp
|
349
|
-
puts
|
350
|
-
puts "Think for a minute about what prompted or triggered this feeling. Think for a minute. Type a quick note to yourself about it to remind you later if you'd like, or press enter when ready."
|
351
|
-
trigger_note = STDIN.gets.chomp
|
352
|
-
puts
|
353
|
-
case intervention.downcase
|
354
|
-
when "change"
|
355
|
-
puts "Think about your environment, your situation, or your reactions. You can change each of those, even in small ways."
|
356
|
-
puts
|
357
|
-
puts "Think for a minute about what you want to change, and what you'd need to make that change."
|
358
|
-
|
359
|
-
pause_for(25)
|
360
|
-
|
361
|
-
puts "You probably aren't going to make this change all at once right now. But let's jot down some next steps you want to take in the near future. We'll store those away for after you've finished your work."
|
362
|
-
puts
|
363
|
-
puts "When you're done listing things you want to do later, type 'done'."
|
364
|
-
note_to_self = get_tasks
|
365
|
-
puts
|
366
|
-
puts "Now before we move on, let's make a small change to your situation right now. Here are some ideas:"
|
367
|
-
puts "- Take a quick exercise break."
|
368
|
-
puts "- Go for a walk around the block."
|
369
|
-
puts "- Clean up a part of this room right now, or your desk."
|
370
|
-
puts "- Grab a healthy snack, or drink a glass of water."
|
371
|
-
puts
|
372
|
-
puts "When you've done that, come back and hit 'enter' so we can start coding."
|
373
|
-
STDIN.gets.chomp
|
374
|
-
puts
|
375
|
-
when "accept"
|
376
|
-
puts "Here are some things you might want to remind yourself about this trigger and your reaction to it:"
|
377
|
-
puts "- It is as it is."
|
378
|
-
puts "- I don’t have to agree with it or judge it as good or bad."
|
379
|
-
puts "- I can always come back to this feeling later."
|
380
|
-
puts "- I can keep my options open."
|
381
|
-
puts "- This is a normal body reaction."
|
382
|
-
puts "- I don’t have to fight it or try to stop it."
|
383
|
-
puts "- It is as it is, but it won't stay that way. It will pass."
|
384
|
-
puts
|
385
|
-
puts "Jot down a thought about what accepting this means to you, so you can remember this later."
|
386
|
-
note_to_self = STDIN.gets.chomp
|
387
|
-
puts
|
388
|
-
|
389
|
-
when "let go"
|
390
|
-
puts "Think about this trigger and your emotions from it. Ask yourself:"
|
391
|
-
puts "- Is it worth it?"
|
392
|
-
puts "- Is this something I can leave or let go of and move on from this experience?"
|
393
|
-
puts "- Can I learn from this experience?"
|
394
|
-
puts "- What would I want to do differently next time?"
|
395
|
-
puts
|
396
|
-
puts "Jot a note to yourself about this. Hit enter when done."
|
397
|
-
note_to_self = STDIN.gets.chomp
|
398
|
-
puts
|
399
|
-
puts "Now that you've logged how you're feeling and what might have caused it, think about how you don't have to hold onto that trigger anymore if you don't want to."
|
400
|
-
puts
|
401
|
-
else
|
402
|
-
note_to_self = nil
|
53
|
+
hook_name = ARGV[1] ||= "post-checkout"
|
54
|
+
file_contents = ""
|
55
|
+
file_contents += "#!/usr/bin/env ruby"
|
56
|
+
file_contents += "\n"
|
57
|
+
file_contents += "require 'checkin_self'"
|
58
|
+
file_contents += "\n"
|
59
|
+
Githooker.hook(hook_name, file_contents)
|
403
60
|
end
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
if note_to_self != nil
|
409
|
-
puts "And to check the note you left yourself just now or in previous checkins, open this file with the argument 'pull'."
|
410
|
-
end
|
411
|
-
|
412
|
-
# store checkin to database
|
413
|
-
add_checkin(db, emotional_state, intensity, trigger_note, note_to_self)
|
61
|
+
else
|
62
|
+
checkin = Checkin.new
|
63
|
+
db.add(checkin.to_h)
|
64
|
+
end
|
data/lib/emotion_list.rb
CHANGED
@@ -1,56 +1,70 @@
|
|
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
|
-
|
1
|
+
class EmotionList
|
2
|
+
attr_reader :list
|
3
|
+
def initialize
|
4
|
+
@list = {
|
5
|
+
"anger" => [
|
6
|
+
"bothered",
|
7
|
+
"annoyed",
|
8
|
+
"bitter",
|
9
|
+
"angry",
|
10
|
+
"irritated",
|
11
|
+
"disgusted",
|
12
|
+
"frustrated",
|
13
|
+
"exasperated",
|
14
|
+
"furious"
|
15
|
+
],
|
16
|
+
"joy" => [
|
17
|
+
"content",
|
18
|
+
"peaceful",
|
19
|
+
"relaxed",
|
20
|
+
"cheerful",
|
21
|
+
"satisfied",
|
22
|
+
"joyous",
|
23
|
+
"excited",
|
24
|
+
"ecstatic",
|
25
|
+
"happy"
|
26
|
+
],
|
27
|
+
"sadness" => [
|
28
|
+
"sad",
|
29
|
+
"depressed",
|
30
|
+
"distraught",
|
31
|
+
"despair",
|
32
|
+
"melancholy",
|
33
|
+
"grief",
|
34
|
+
"helpless",
|
35
|
+
"hopeless",
|
36
|
+
"miserable"
|
37
|
+
],
|
38
|
+
"hurt" => [
|
39
|
+
"lonely",
|
40
|
+
"homesick",
|
41
|
+
"abandoned",
|
42
|
+
"embarrassed",
|
43
|
+
"shame",
|
44
|
+
"guilt",
|
45
|
+
"foolish",
|
46
|
+
"humiliated"
|
47
|
+
],
|
48
|
+
"fear" => [
|
49
|
+
"uncertain",
|
50
|
+
"worried",
|
51
|
+
"anxious",
|
52
|
+
"frightened",
|
53
|
+
"scared",
|
54
|
+
"nervous",
|
55
|
+
"afraid",
|
56
|
+
"terrified",
|
57
|
+
"overwhelmed"
|
58
|
+
]
|
59
|
+
}
|
60
|
+
end
|
61
|
+
def to_s
|
62
|
+
result = ""
|
63
|
+
@list.each do |emotion, states|
|
64
|
+
result += emotion.upcase + ":\n"
|
65
|
+
result += " " + states.join(", ")
|
66
|
+
result += "\n"
|
67
|
+
end
|
68
|
+
return result
|
69
|
+
end
|
70
|
+
end
|