checkin_self 0.2.0 → 0.2.1
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/README.md +12 -2
- data/lib/checkin_self.rb +65 -11
- 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: 57dccfc36b1536412a5b8e4f7694418a553d1f67
|
4
|
+
data.tar.gz: '059a9efe90da3ee503de910bd826986742e9d699'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e8624538fdb14137d3e931f676ff76d28b2219eecf17f6329092b8094101ba74bea7d70bd2b9ecdbae3cc32c868ac7294e0701be7c2e71ae512cb621a3a869c
|
7
|
+
data.tar.gz: 8d2c075f1492d482b65cf0bd3e5b9eb928e0fca6b89ecbb8404aad30ee7a3afb471c14cb2eb660a24ce99d5d39755eec3d8a224535e09ec6d1f2881f7c7f1d4c
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# checkin-project
|
2
2
|
|
3
|
-
|
3
|
+
checkin_self - a tool to integrate mindful checkins into your git workflow
|
4
4
|
|
5
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
6
|
|
@@ -20,4 +20,14 @@ This program has three optional arguments:
|
|
20
20
|
|
21
21
|
- Review your previous notes to self made through this program.
|
22
22
|
|
23
|
-
|
23
|
+
- hook, or --hook, with optional hook name as second argument
|
24
|
+
|
25
|
+
- 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.
|
26
|
+
|
27
|
+
If you've installed this as a gem, you should be able to run it just by typing `checkin_self' into bash, with optional arguments.
|
28
|
+
|
29
|
+
Future changes to be made:
|
30
|
+
|
31
|
+
- Changing from a sqlite database to some flatter data storage?
|
32
|
+
- making a gemfile to alert sqlite dependencies
|
33
|
+
- making more object-oriented, and splitting into multiple files
|
data/lib/checkin_self.rb
CHANGED
@@ -138,7 +138,7 @@ def categorize_feeling(feeling)
|
|
138
138
|
print_emotion_list
|
139
139
|
puts
|
140
140
|
puts "Pick a word from the list above that describes how you're feeling right now."
|
141
|
-
return categorize_feeling(gets.chomp)
|
141
|
+
return categorize_feeling(STDIN.gets.chomp)
|
142
142
|
elsif EMOTION_LIST.keys.include?(feeling.downcase)
|
143
143
|
# emotion named by user, but not a secondary state
|
144
144
|
categorized = { emotion: feeling.downcase, state: nil }
|
@@ -154,10 +154,10 @@ end
|
|
154
154
|
# Read in list of tasks that the user wants to remember for later.
|
155
155
|
def get_tasks
|
156
156
|
note_to_self = ""
|
157
|
-
task = gets.chomp
|
157
|
+
task = STDIN.gets.chomp
|
158
158
|
until task.downcase == "done"
|
159
159
|
note_to_self += " o " + task + "\n"
|
160
|
-
task = gets.chomp
|
160
|
+
task = STDIN.gets.chomp
|
161
161
|
end
|
162
162
|
return note_to_self.chomp
|
163
163
|
end
|
@@ -170,7 +170,7 @@ def display_help
|
|
170
170
|
puts
|
171
171
|
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."
|
172
172
|
puts
|
173
|
-
puts "This program has
|
173
|
+
puts "This program has four optional arguments:"
|
174
174
|
puts
|
175
175
|
puts "help, h, --help, or --h"
|
176
176
|
puts "Displays this help screen."
|
@@ -180,6 +180,9 @@ def display_help
|
|
180
180
|
puts
|
181
181
|
puts "pull, or p"
|
182
182
|
puts "Review your previous notes to self made through this program."
|
183
|
+
puts
|
184
|
+
puts "hook, or --hook, with optional hook name"
|
185
|
+
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."
|
183
186
|
exit
|
184
187
|
end
|
185
188
|
|
@@ -237,6 +240,55 @@ def review_notes_to_self(db)
|
|
237
240
|
exit
|
238
241
|
end
|
239
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
|
+
end
|
291
|
+
|
240
292
|
# DRIVER CODE
|
241
293
|
|
242
294
|
# parse arguments passed to program
|
@@ -253,6 +305,8 @@ if ARGV[0]
|
|
253
305
|
end
|
254
306
|
when "pull", "p"
|
255
307
|
review_notes_to_self(db)
|
308
|
+
when "hook", "--hook"
|
309
|
+
githook(ARGV[1])
|
256
310
|
end
|
257
311
|
end
|
258
312
|
|
@@ -270,11 +324,11 @@ puts "anger -=- joy -=- sadness -=- hurt -=- fear"
|
|
270
324
|
puts
|
271
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."
|
272
326
|
|
273
|
-
emotional_state = categorize_feeling(gets.chomp)
|
327
|
+
emotional_state = categorize_feeling(STDIN.gets.chomp)
|
274
328
|
puts
|
275
329
|
|
276
330
|
puts "How strong is that feeling on a scale of 0 to 10?"
|
277
|
-
intensity = gets.chomp.to_i
|
331
|
+
intensity = STDIN.gets.chomp.to_i
|
278
332
|
intensity = 0 if intensity < 0
|
279
333
|
intsensity = 10 if intensity > 10
|
280
334
|
puts
|
@@ -291,10 +345,10 @@ if intensity > 5 and emotional_state[:emotion] != "joy"
|
|
291
345
|
puts "-= Or you can choose to try and LET GO of this feeling before you start your work."
|
292
346
|
puts
|
293
347
|
puts "What do you want to do right now? Type 'change', 'accept' or 'let go', or anything else to skip this."
|
294
|
-
intervention = gets.chomp
|
348
|
+
intervention = STDIN.gets.chomp
|
295
349
|
puts
|
296
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."
|
297
|
-
trigger_note = gets.chomp
|
351
|
+
trigger_note = STDIN.gets.chomp
|
298
352
|
puts
|
299
353
|
case intervention.downcase
|
300
354
|
when "change"
|
@@ -316,7 +370,7 @@ if intensity > 5 and emotional_state[:emotion] != "joy"
|
|
316
370
|
puts "- Grab a healthy snack, or drink a glass of water."
|
317
371
|
puts
|
318
372
|
puts "When you've done that, come back and hit 'enter' so we can start coding."
|
319
|
-
gets.chomp
|
373
|
+
STDIN.gets.chomp
|
320
374
|
puts
|
321
375
|
when "accept"
|
322
376
|
puts "Here are some things you might want to remind yourself about this trigger and your reaction to it:"
|
@@ -329,7 +383,7 @@ if intensity > 5 and emotional_state[:emotion] != "joy"
|
|
329
383
|
puts "- It is as it is, but it won't stay that way. It will pass."
|
330
384
|
puts
|
331
385
|
puts "Jot down a thought about what accepting this means to you, so you can remember this later."
|
332
|
-
note_to_self = gets.chomp
|
386
|
+
note_to_self = STDIN.gets.chomp
|
333
387
|
puts
|
334
388
|
|
335
389
|
when "let go"
|
@@ -340,7 +394,7 @@ if intensity > 5 and emotional_state[:emotion] != "joy"
|
|
340
394
|
puts "- What would I want to do differently next time?"
|
341
395
|
puts
|
342
396
|
puts "Jot a note to yourself about this. Hit enter when done."
|
343
|
-
note_to_self = gets.chomp
|
397
|
+
note_to_self = STDIN.gets.chomp
|
344
398
|
puts
|
345
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."
|
346
400
|
puts
|