checkin-self 0.0.1 → 0.0.3

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.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +23 -21
  3. data/bin/checkin +3 -0
  4. data/lib/checkin.rb +362 -362
  5. data/lib/emotion_list.rb +55 -55
  6. metadata +10 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 25c59b38cc532e3ea986adedf5ecd3b2ce5c139d
4
- data.tar.gz: 184acb527c8597794a7100461a093b980f0e7a92
3
+ metadata.gz: 06679769dbee41c6493dbd5f975cb170f9b3b9ff
4
+ data.tar.gz: fc8e43be9f0bd03e120ce91207d4a5557005aef5
5
5
  SHA512:
6
- metadata.gz: ac21dd9adc7217e408c96e0a3ae193dd5ed329fd55e28a5e7eaad2872152745f537545d4fe318a95af4272e2d771c69ab5b961cc138c6bf05b3ba2ed90148af0
7
- data.tar.gz: c1896ed0a4da08f2ed777caa97c801d107b0728c3e48410647e1d445624b99b7fa3c1f7d03292d35325c1e5f6785247dbb4c5fc4357a9b1754582898704e130b
6
+ metadata.gz: 2acb6a0926540ce83c4eac17eb92b3fec419b812437c85c526b95fc0a7522520d891000889d27724d0fc55cc2b29998a9bebdf8f9d56ccd3013bb7f7092368fc
7
+ data.tar.gz: fb35c2d4ea6ed8af794d859758716f7474b8e5d82183b0b3333550dd2b6ce16944cd9d2f004cc64e85d3577bb39deef9a975a40e6c5679ca75073f786acd030d
data/README.md CHANGED
@@ -1,21 +1,23 @@
1
- # checkin-project
2
-
3
- checkin - a tool to integrate mindful checkins into your git workflow
4
-
5
- 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).
6
-
7
- This program is designed to be used when you checkout a git branch, so that you can checkin with yourself before you start on some coding work. If you're feeling somewhat to very intense negative emotions, you're encouraged to address those before you start your work, and leave a note to yourself to be reviewed later.
8
-
9
- This program has three optional arguments:
10
-
11
- - help, h, --help, or --h
12
-
13
- - Displays this help screen.
14
-
15
- - log, or l, with optional integer
16
-
17
- - Displays a chronological table of all of your previous checkins. Include an integer n to limit the checkins to the previous n, by date.
18
-
19
- - pull, or p
20
-
21
- - Review your previous notes to self made through this program.
1
+ # checkin-project
2
+
3
+ checkin - a tool to integrate mindful checkins into your git workflow
4
+
5
+ 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).
6
+
7
+ This program is designed to be used when you checkout a git branch, so that you can checkin with yourself before you start on some coding work. If you're feeling somewhat to very intense negative emotions, you're encouraged to address those before you start your work, and leave a note to yourself to be reviewed later.
8
+
9
+ This program has three optional arguments:
10
+
11
+ - help, h, --help, or --h
12
+
13
+ - Displays this help screen.
14
+
15
+ - log, or l, with optional integer
16
+
17
+ - Displays a chronological table of all of your previous checkins. Include an integer n to limit the checkins to the previous n, by date.
18
+
19
+ - pull, or p
20
+
21
+ - Review your previous notes to self made through this program.
22
+
23
+ If you've installed this as a gem, you should be able to run it just by typing `checkin' into bash, with optional arguments. However, this is my first attempt at making an executable gem, so there seem to be some issues. Such as an unalerted dependency on the ruby gem sqlite3.
data/bin/checkin ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'checkin'
data/lib/checkin.rb CHANGED
@@ -1,363 +1,363 @@
1
- # checkin - a tool to integrate mindful checkins into your git workflow
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.
4
-
5
- # BUSINESS LOGIC
6
-
7
- require 'sqlite3'
8
- require_relative 'emotion_list'
9
-
10
- db = SQLite3::Database.new("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(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
- EMOTION_LIST.each do |emotion, states|
147
- if states.include?(feeling.downcase)
148
- # emotion and state named by user
149
- categorized = { emotion: emotion, state: feeling.downcase }
150
- end
151
- end
152
- end
153
- return categorized if defined? categorized
154
- # User gave invalid input, run again
155
- return categorize_feeling("more")
156
- end
157
-
158
- # Read in list of tasks that the user wants to remember for later.
159
- def get_tasks
160
- note_to_self = ""
161
- task = gets.chomp
162
- until task.downcase == "done"
163
- note_to_self += " o " + task + "\n"
164
- task = gets.chomp
165
- end
166
- return note_to_self.chomp
167
- end
168
-
169
- # Help page to be run when given the argument 'help', 'h', '--h' or '--help'
170
- def display_help
171
- puts "checkin - a tool to integrate mindful checkins into your git workflow"
172
- puts
173
- puts "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)."
174
- puts
175
- puts "This program is designed to be used when you checkout a git branch, so that you can checkin with yourself before you start on some coding work. If you're feeling somewhat to very intense negative emotions, you're encouraged to address those before you start your work, and leave a note to yourself to be reviewed later."
176
- puts
177
- puts "This program has three optional arguments:"
178
- puts
179
- puts "help, h, --help, or --h"
180
- puts "Displays this help screen."
181
- puts
182
- puts "log, or l, with optional integer"
183
- puts "Displays a chronological table of all of your previous checkins. Include an integer n to limit the checkins to the previous n, by date."
184
- puts
185
- puts "pull, or p"
186
- puts "Review your previous notes to self made through this program."
187
- exit
188
- end
189
-
190
- def print_log(db, limit=Float::INFINITY)
191
- # generate SQL query that can pull the log, replace the ids from each table with the emotion/state names, etc
192
- qry_checkins_cmd = <<-SQL
193
- SELECT time, emotions.name, states.name, intensity
194
- FROM (checkins LEFT JOIN emotions ON checkins.emotionID = emotions.id) LEFT JOIN states
195
- ON checkins.stateID = states.id;
196
- SQL
197
-
198
- # make header row
199
- puts "Checkin time | Emotion | Emotional state | Intensity "
200
- puts "---------------------|--------------|------------------|-----------"
201
-
202
- # initialize incrementer to test if going past limit
203
- i = 1
204
-
205
- # print that SQL query for each row, going back as long as incrementer is less than limit
206
- rows = db.execute(qry_checkins_cmd)
207
- rows.reverse_each do |row|
208
- next if i > limit
209
-
210
- # turn all null or nil values and all numbers into strings
211
- row.map!(&:to_s)
212
- puts row[0].ljust(21) + "| " + row[1].ljust(13) + "| " + row[2].ljust(17) + "| " + row[3].ljust(9)
213
- i += 1
214
- end
215
- exit
216
- end
217
-
218
- def review_notes_to_self(db)
219
- # generate SQL queries that pull the times and all from the noteToSelf attribute, numbered
220
-
221
- pull_notes_cmd = <<-SQL
222
- SELECT time, emotions.name, states.name, trigger, noteToSelf
223
- FROM (checkins JOIN emotions ON checkins.emotionID = emotions.id) LEFT JOIN states
224
- ON checkins.stateID = states.id;
225
- SQL
226
- entries = db.execute(pull_notes_cmd)
227
- puts
228
- entries.each do |entry|
229
- next unless entry[3] or entry[4]
230
- puts "Date and time: " + entry[0]
231
- print "Emotional state: " + entry[1]
232
- print ", " + entry[2] if entry[2] # checking if state is nil
233
- print "\n"
234
- puts "Trigger: " + entry[3] if entry[3]
235
- puts
236
- puts "Note to self: \n\n" + entry[4] if entry[4]
237
- puts
238
- puts " -=- -=- -=- -=- -=- -=- -=- -=- "
239
- puts
240
- end
241
- exit
242
- end
243
-
244
- # DRIVER CODE
245
-
246
- # parse arguments passed to program
247
- if ARGV[0]
248
- option = ARGV[0]
249
- case option.downcase
250
- when "help", "h", "--help"
251
- display_help
252
- when "log", "l"
253
- if ARGV[1]
254
- print_log(db, ARGV[1].to_i)
255
- else
256
- print_log(db)
257
- end
258
- when "pull", "p"
259
- review_notes_to_self(db)
260
- end
261
- end
262
-
263
- # begin main checkin process
264
-
265
- puts
266
- puts "OBSERVE how you're feeling."
267
- puts "No need to judge it, let's just pause and notice it."
268
-
269
- pause_for(25)
270
-
271
- puts "DESCRIBE how you're feeling. Which of these emotions would you say it falls under?"
272
- puts
273
- puts "anger -=- joy -=- sadness -=- hurt -=- fear"
274
- puts
275
- puts "Type 'more' for a list of more words to help you figure out what you're feeling and how we'll categorize it."
276
-
277
- emotional_state = categorize_feeling(gets.chomp)
278
- puts
279
-
280
- puts "How strong is that feeling on a scale of 0 to 10?"
281
- intensity = gets.chomp.to_i
282
- intensity = 0 if intensity < 0
283
- intsensity = 10 if intensity > 10
284
- puts
285
-
286
- # begin intervention due to high negative emotions
287
- if intensity > 5 and emotional_state[:emotion] != "joy"
288
- puts "Okay, let's take a couple of breaths, then let's talk about our options."
289
- puts
290
- breathing_exercise
291
- puts
292
- puts "Now, let's talk about your options for right now, before you start your work."
293
- puts "-= You can CHANGE your situation, environment or reactions."
294
- puts "-= You can ACCEPT that this is how you'll be feeling while you're working."
295
- puts "-= Or you can choose to try and LET GO of this feeling before you start your work."
296
- puts
297
- puts "What do you want to do right now? Type 'change', 'accept' or 'let go', or anything else to skip this."
298
- intervention = gets.chomp
299
- puts
300
- 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."
301
- trigger_note = gets.chomp
302
- puts
303
- case intervention.downcase
304
- when "change"
305
- puts "Think about your environment, your situation, or your reactions. You can change each of those, even in small ways."
306
- puts
307
- puts "Think for a minute about what you want to change, and what you'd need to make that change."
308
-
309
- pause_for(25)
310
-
311
- 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."
312
- puts
313
- puts "When you're done listing things you want to do later, type 'done'."
314
- note_to_self = get_tasks
315
- puts
316
- puts "Now before we move on, let's make a small change to your situation right now. Here are some ideas:"
317
- puts "- Take a quick exercise break."
318
- puts "- Go for a walk around the block."
319
- puts "- Clean up a part of this room right now, or your desk."
320
- puts "- Grab a healthy snack, or drink a glass of water."
321
- puts
322
- puts "When you've done that, come back and hit 'enter' so we can start coding."
323
- gets.chomp
324
- puts
325
- when "accept"
326
- puts "Here are some things you might want to remind yourself about this trigger and your reaction to it:"
327
- puts "- It is as it is."
328
- puts "- I don’t have to agree with it or judge it as good or bad."
329
- puts "- I can always come back to this feeling later."
330
- puts "- I can keep my options open."
331
- puts "- This is a normal body reaction."
332
- puts "- I don’t have to fight it or try to stop it."
333
- puts "- It is as it is, but it won't stay that way. It will pass."
334
- puts
335
- puts "Jot down a thought about what accepting this means to you, so you can remember this later."
336
- note_to_self = gets.chomp
337
- puts
338
-
339
- when "let go"
340
- puts "Think about this trigger and your emotions from it. Ask yourself:"
341
- puts "- Is it worth it?"
342
- puts "- Is this something I can leave or let go of and move on from this experience?"
343
- puts "- Can I learn from this experience?"
344
- puts "- What would I want to do differently next time?"
345
- puts
346
- puts "Jot a note to yourself about this. Hit enter when done."
347
- note_to_self = gets.chomp
348
- puts
349
- 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."
350
- puts
351
- else
352
- note_to_self = nil
353
- end
354
- end
355
-
356
- puts "Thanks for checking in with yourself!"
357
- puts "If you want to see a log of your checkins, open this file again with the argument 'log'."
358
- if note_to_self != nil
359
- puts "And to check the note you left yourself just now or in previous checkins, open this file with the argument 'pull'."
360
- end
361
-
362
- # store checkin to database
1
+ # checkin - a tool to integrate mindful checkins into your git workflow
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.
4
+
5
+ # BUSINESS LOGIC
6
+
7
+ require 'sqlite3'
8
+ require_relative 'emotion_list'
9
+
10
+ db = SQLite3::Database.new("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(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
+ EMOTION_LIST.each do |emotion, states|
147
+ if states.include?(feeling.downcase)
148
+ # emotion and state named by user
149
+ categorized = { emotion: emotion, state: feeling.downcase }
150
+ end
151
+ end
152
+ end
153
+ return categorized if defined? categorized
154
+ # User gave invalid input, run again
155
+ return categorize_feeling("more")
156
+ end
157
+
158
+ # Read in list of tasks that the user wants to remember for later.
159
+ def get_tasks
160
+ note_to_self = ""
161
+ task = gets.chomp
162
+ until task.downcase == "done"
163
+ note_to_self += " o " + task + "\n"
164
+ task = gets.chomp
165
+ end
166
+ return note_to_self.chomp
167
+ end
168
+
169
+ # Help page to be run when given the argument 'help', 'h', '--h' or '--help'
170
+ def display_help
171
+ puts "checkin - a tool to integrate mindful checkins into your git workflow"
172
+ puts
173
+ puts "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)."
174
+ puts
175
+ puts "This program is designed to be used when you checkout a git branch, so that you can checkin with yourself before you start on some coding work. If you're feeling somewhat to very intense negative emotions, you're encouraged to address those before you start your work, and leave a note to yourself to be reviewed later."
176
+ puts
177
+ puts "This program has three optional arguments:"
178
+ puts
179
+ puts "help, h, --help, or --h"
180
+ puts "Displays this help screen."
181
+ puts
182
+ puts "log, or l, with optional integer"
183
+ puts "Displays a chronological table of all of your previous checkins. Include an integer n to limit the checkins to the previous n, by date."
184
+ puts
185
+ puts "pull, or p"
186
+ puts "Review your previous notes to self made through this program."
187
+ exit
188
+ end
189
+
190
+ def print_log(db, limit=Float::INFINITY)
191
+ # generate SQL query that can pull the log, replace the ids from each table with the emotion/state names, etc
192
+ qry_checkins_cmd = <<-SQL
193
+ SELECT time, emotions.name, states.name, intensity
194
+ FROM (checkins LEFT JOIN emotions ON checkins.emotionID = emotions.id) LEFT JOIN states
195
+ ON checkins.stateID = states.id;
196
+ SQL
197
+
198
+ # make header row
199
+ puts "Checkin time | Emotion | Emotional state | Intensity "
200
+ puts "---------------------|--------------|------------------|-----------"
201
+
202
+ # initialize incrementer to test if going past limit
203
+ i = 1
204
+
205
+ # print that SQL query for each row, going back as long as incrementer is less than limit
206
+ rows = db.execute(qry_checkins_cmd)
207
+ rows.reverse_each do |row|
208
+ next if i > limit
209
+
210
+ # turn all null or nil values and all numbers into strings
211
+ row.map!(&:to_s)
212
+ puts row[0].ljust(21) + "| " + row[1].ljust(13) + "| " + row[2].ljust(17) + "| " + row[3].ljust(9)
213
+ i += 1
214
+ end
215
+ exit
216
+ end
217
+
218
+ def review_notes_to_self(db)
219
+ # generate SQL queries that pull the times and all from the noteToSelf attribute, numbered
220
+
221
+ pull_notes_cmd = <<-SQL
222
+ SELECT time, emotions.name, states.name, trigger, noteToSelf
223
+ FROM (checkins JOIN emotions ON checkins.emotionID = emotions.id) LEFT JOIN states
224
+ ON checkins.stateID = states.id;
225
+ SQL
226
+ entries = db.execute(pull_notes_cmd)
227
+ puts
228
+ entries.each do |entry|
229
+ next unless entry[3] or entry[4]
230
+ puts "Date and time: " + entry[0]
231
+ print "Emotional state: " + entry[1]
232
+ print ", " + entry[2] if entry[2] # checking if state is nil
233
+ print "\n"
234
+ puts "Trigger: " + entry[3] if entry[3]
235
+ puts
236
+ puts "Note to self: \n\n" + entry[4] if entry[4]
237
+ puts
238
+ puts " -=- -=- -=- -=- -=- -=- -=- -=- "
239
+ puts
240
+ end
241
+ exit
242
+ end
243
+
244
+ # DRIVER CODE
245
+
246
+ # parse arguments passed to program
247
+ if ARGV[0]
248
+ option = ARGV[0]
249
+ case option.downcase
250
+ when "help", "h", "--help"
251
+ display_help
252
+ when "log", "l"
253
+ if ARGV[1]
254
+ print_log(db, ARGV[1].to_i)
255
+ else
256
+ print_log(db)
257
+ end
258
+ when "pull", "p"
259
+ review_notes_to_self(db)
260
+ end
261
+ end
262
+
263
+ # begin main checkin process
264
+
265
+ puts
266
+ puts "OBSERVE how you're feeling."
267
+ puts "No need to judge it, let's just pause and notice it."
268
+
269
+ pause_for(25)
270
+
271
+ puts "DESCRIBE how you're feeling. Which of these emotions would you say it falls under?"
272
+ puts
273
+ puts "anger -=- joy -=- sadness -=- hurt -=- fear"
274
+ puts
275
+ puts "Type 'more' for a list of more words to help you figure out what you're feeling and how we'll categorize it."
276
+
277
+ emotional_state = categorize_feeling(gets.chomp)
278
+ puts
279
+
280
+ puts "How strong is that feeling on a scale of 0 to 10?"
281
+ intensity = gets.chomp.to_i
282
+ intensity = 0 if intensity < 0
283
+ intsensity = 10 if intensity > 10
284
+ puts
285
+
286
+ # begin intervention due to high negative emotions
287
+ if intensity > 5 and emotional_state[:emotion] != "joy"
288
+ puts "Okay, let's take a couple of breaths, then let's talk about our options."
289
+ puts
290
+ breathing_exercise
291
+ puts
292
+ puts "Now, let's talk about your options for right now, before you start your work."
293
+ puts "-= You can CHANGE your situation, environment or reactions."
294
+ puts "-= You can ACCEPT that this is how you'll be feeling while you're working."
295
+ puts "-= Or you can choose to try and LET GO of this feeling before you start your work."
296
+ puts
297
+ puts "What do you want to do right now? Type 'change', 'accept' or 'let go', or anything else to skip this."
298
+ intervention = gets.chomp
299
+ puts
300
+ 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."
301
+ trigger_note = gets.chomp
302
+ puts
303
+ case intervention.downcase
304
+ when "change"
305
+ puts "Think about your environment, your situation, or your reactions. You can change each of those, even in small ways."
306
+ puts
307
+ puts "Think for a minute about what you want to change, and what you'd need to make that change."
308
+
309
+ pause_for(25)
310
+
311
+ 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."
312
+ puts
313
+ puts "When you're done listing things you want to do later, type 'done'."
314
+ note_to_self = get_tasks
315
+ puts
316
+ puts "Now before we move on, let's make a small change to your situation right now. Here are some ideas:"
317
+ puts "- Take a quick exercise break."
318
+ puts "- Go for a walk around the block."
319
+ puts "- Clean up a part of this room right now, or your desk."
320
+ puts "- Grab a healthy snack, or drink a glass of water."
321
+ puts
322
+ puts "When you've done that, come back and hit 'enter' so we can start coding."
323
+ gets.chomp
324
+ puts
325
+ when "accept"
326
+ puts "Here are some things you might want to remind yourself about this trigger and your reaction to it:"
327
+ puts "- It is as it is."
328
+ puts "- I don’t have to agree with it or judge it as good or bad."
329
+ puts "- I can always come back to this feeling later."
330
+ puts "- I can keep my options open."
331
+ puts "- This is a normal body reaction."
332
+ puts "- I don’t have to fight it or try to stop it."
333
+ puts "- It is as it is, but it won't stay that way. It will pass."
334
+ puts
335
+ puts "Jot down a thought about what accepting this means to you, so you can remember this later."
336
+ note_to_self = gets.chomp
337
+ puts
338
+
339
+ when "let go"
340
+ puts "Think about this trigger and your emotions from it. Ask yourself:"
341
+ puts "- Is it worth it?"
342
+ puts "- Is this something I can leave or let go of and move on from this experience?"
343
+ puts "- Can I learn from this experience?"
344
+ puts "- What would I want to do differently next time?"
345
+ puts
346
+ puts "Jot a note to yourself about this. Hit enter when done."
347
+ note_to_self = gets.chomp
348
+ puts
349
+ 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."
350
+ puts
351
+ else
352
+ note_to_self = nil
353
+ end
354
+ end
355
+
356
+ puts "Thanks for checking in with yourself!"
357
+ puts "If you want to see a log of your checkins, open this file again with the argument 'log'."
358
+ if note_to_self != nil
359
+ puts "And to check the note you left yourself just now or in previous checkins, open this file with the argument 'pull'."
360
+ end
361
+
362
+ # store checkin to database
363
363
  add_checkin(db, emotional_state, intensity, trigger_note, note_to_self)
data/lib/emotion_list.rb CHANGED
@@ -1,56 +1,56 @@
1
- EMOTION_LIST = {
2
- "anger" => [
3
- "bothered",
4
- "annoyed",
5
- "bitter",
6
- "angry",
7
- "irritated",
8
- "disgusted",
9
- "frustrated",
10
- "exasperated",
11
- "furious"
12
- ],
13
- "joy" => [
14
- "content",
15
- "peaceful",
16
- "relaxed",
17
- "cheerful",
18
- "satisfied",
19
- "joyous",
20
- "excited",
21
- "ecstatic",
22
- "happy"
23
- ],
24
- "sadness" => [
25
- "sad",
26
- "depressed",
27
- "distraught",
28
- "despair",
29
- "melancholy",
30
- "grief",
31
- "helpless",
32
- "hopeless",
33
- "miserable"
34
- ],
35
- "hurt" => [
36
- "lonely",
37
- "homesick",
38
- "abandoned",
39
- "embarrassed",
40
- "shame",
41
- "guilt",
42
- "foolish",
43
- "humiliated"
44
- ],
45
- "fear" => [
46
- "uncertain",
47
- "worried",
48
- "anxious",
49
- "frightened",
50
- "scared",
51
- "nervous",
52
- "afraid",
53
- "terrified",
54
- "overwhelmed"
55
- ]
1
+ EMOTION_LIST = {
2
+ "anger" => [
3
+ "bothered",
4
+ "annoyed",
5
+ "bitter",
6
+ "angry",
7
+ "irritated",
8
+ "disgusted",
9
+ "frustrated",
10
+ "exasperated",
11
+ "furious"
12
+ ],
13
+ "joy" => [
14
+ "content",
15
+ "peaceful",
16
+ "relaxed",
17
+ "cheerful",
18
+ "satisfied",
19
+ "joyous",
20
+ "excited",
21
+ "ecstatic",
22
+ "happy"
23
+ ],
24
+ "sadness" => [
25
+ "sad",
26
+ "depressed",
27
+ "distraught",
28
+ "despair",
29
+ "melancholy",
30
+ "grief",
31
+ "helpless",
32
+ "hopeless",
33
+ "miserable"
34
+ ],
35
+ "hurt" => [
36
+ "lonely",
37
+ "homesick",
38
+ "abandoned",
39
+ "embarrassed",
40
+ "shame",
41
+ "guilt",
42
+ "foolish",
43
+ "humiliated"
44
+ ],
45
+ "fear" => [
46
+ "uncertain",
47
+ "worried",
48
+ "anxious",
49
+ "frightened",
50
+ "scared",
51
+ "nervous",
52
+ "afraid",
53
+ "terrified",
54
+ "overwhelmed"
55
+ ]
56
56
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: checkin-self
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Swartzman
@@ -10,15 +10,18 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2017-03-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: A tool to integrate mindful checkins into your git workflow
13
+ description: 'Deprecated: this gem has been renamed to checkin_self, which can be
14
+ found at https://rubygems.org/gems/checkin_self. Sorry for the confusion!'
14
15
  email: simon.swartzman@gmail.com
15
- executables: []
16
+ executables:
17
+ - checkin
16
18
  extensions: []
17
19
  extra_rdoc_files: []
18
20
  files:
21
+ - README.md
22
+ - bin/checkin
19
23
  - lib/checkin.rb
20
24
  - lib/emotion_list.rb
21
- - README.md
22
25
  homepage: https://github.com/rtzm/checkin-project
23
26
  licenses:
24
27
  - MIT
@@ -29,17 +32,17 @@ require_paths:
29
32
  - lib
30
33
  required_ruby_version: !ruby/object:Gem::Requirement
31
34
  requirements:
32
- - - '>='
35
+ - - ">="
33
36
  - !ruby/object:Gem::Version
34
37
  version: '0'
35
38
  required_rubygems_version: !ruby/object:Gem::Requirement
36
39
  requirements:
37
- - - '>='
40
+ - - ">="
38
41
  - !ruby/object:Gem::Version
39
42
  version: '0'
40
43
  requirements: []
41
44
  rubyforge_project:
42
- rubygems_version: 2.0.14.1
45
+ rubygems_version: 2.4.5.2
43
46
  signing_key:
44
47
  specification_version: 4
45
48
  summary: checkin