checkin_self 0.2.2 → 0.2.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.
- checksums.yaml +4 -4
- data/README.md +7 -6
- data/lib/checkin.rb +190 -0
- data/lib/checkins_db.rb +173 -0
- data/lib/githooker.rb +48 -0
- metadata +12 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 504f2a87604869c9fe43aa1e6f49ec9d524acc27
|
4
|
+
data.tar.gz: bc116d3bddb368498fe92f1d45e6d10931c58a3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 446e8ea3a238a2bd13ac45a9b16b47c23cd9860bd42e19dd7e1ab643eb9072de713a3fddf457f2613ccad0dbf88869d4fc9f773b49e69e80da035944f42d7b88
|
7
|
+
data.tar.gz: 043122836ec90702ed8e2a453c7a70f83adbab372df72b28f4693798b2f9786e459ecfdd8da25fdbcdffb5fcb0bdbb1cec4408aeda186842b1162749b42ecb77
|
data/README.md
CHANGED
@@ -6,11 +6,11 @@ Wording, advice, and structure for this mindfulness exercise were largely pulled
|
|
6
6
|
|
7
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
8
|
|
9
|
-
This program has
|
9
|
+
This program has four optional arguments:
|
10
10
|
|
11
|
-
-
|
11
|
+
- hook, or --hook, with optional hook name as second argument
|
12
12
|
|
13
|
-
-
|
13
|
+
- 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.
|
14
14
|
|
15
15
|
- log, or l, with optional integer
|
16
16
|
|
@@ -20,9 +20,9 @@ This program has three optional arguments:
|
|
20
20
|
|
21
21
|
- Review your previous notes to self made through this program.
|
22
22
|
|
23
|
-
-
|
23
|
+
- help, h, --help, or --h
|
24
24
|
|
25
|
-
-
|
25
|
+
- Displays help screen.
|
26
26
|
|
27
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
28
|
|
@@ -30,4 +30,5 @@ Future changes to be made:
|
|
30
30
|
|
31
31
|
- Changing from a sqlite database to some flatter data storage?
|
32
32
|
- making a gemfile to alert sqlite dependencies
|
33
|
-
-
|
33
|
+
- improving object-oriented design
|
34
|
+
- Use highline to improve the readability of the text in command-line
|
data/lib/checkin.rb
ADDED
@@ -0,0 +1,190 @@
|
|
1
|
+
class Checkin
|
2
|
+
def initialize
|
3
|
+
el = EmotionList.new()
|
4
|
+
|
5
|
+
@time = Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
6
|
+
|
7
|
+
observe_feeling
|
8
|
+
@emotional_state = describe_feeling(el)
|
9
|
+
@intensity = describe_feeling_instensity
|
10
|
+
if @intensity > 5 and @emotional_state[:emotion] != "joy"
|
11
|
+
@intervention = choose_intervention
|
12
|
+
@trigger = describe_trigger
|
13
|
+
case @intervention
|
14
|
+
when "change"
|
15
|
+
@note = change_self
|
16
|
+
when "accept"
|
17
|
+
@note = accept_self
|
18
|
+
when "let go"
|
19
|
+
@note = let_go_self
|
20
|
+
else
|
21
|
+
@note = nil
|
22
|
+
end
|
23
|
+
end
|
24
|
+
close_checkin
|
25
|
+
end
|
26
|
+
|
27
|
+
def observe_feeling
|
28
|
+
puts
|
29
|
+
puts "OBSERVE how you're feeling."
|
30
|
+
puts "No need to judge it, let's just pause and notice it."
|
31
|
+
pause_for(25)
|
32
|
+
end
|
33
|
+
|
34
|
+
def describe_feeling(el)
|
35
|
+
puts "DESCRIBE how you're feeling. Which of these emotions would you say it falls under?"
|
36
|
+
puts
|
37
|
+
puts "anger -=- joy -=- sadness -=- hurt -=- fear"
|
38
|
+
puts
|
39
|
+
puts "Type 'more' for a list of more words to help you figure out what you're feeling and how we'll categorize it."
|
40
|
+
return categorize_feeling(STDIN.gets.chomp, el)
|
41
|
+
end
|
42
|
+
|
43
|
+
def describe_feeling_instensity
|
44
|
+
puts
|
45
|
+
puts "How strong is that feeling on a scale of 0 to 10?"
|
46
|
+
intensity = STDIN.gets.chomp.to_i
|
47
|
+
return 0 if intensity < 0
|
48
|
+
return 10 if intensity > 10
|
49
|
+
return intensity
|
50
|
+
end
|
51
|
+
|
52
|
+
# Give choice of possible interventions due to high negative emotions
|
53
|
+
def choose_intervention
|
54
|
+
puts
|
55
|
+
puts "Okay, let's take a couple of breaths, then let's talk about our options."
|
56
|
+
puts
|
57
|
+
breathing_exercise
|
58
|
+
puts
|
59
|
+
puts "Now, let's talk about your options for right now, before you start your work."
|
60
|
+
puts "-= You can CHANGE your situation, environment or reactions."
|
61
|
+
puts "-= You can ACCEPT that this is how you'll be feeling while you're working."
|
62
|
+
puts "-= Or you can choose to try and LET GO of this feeling before you start your work."
|
63
|
+
puts
|
64
|
+
puts "What do you want to do right now? Type 'change', 'accept' or 'let go', or anything else to skip this."
|
65
|
+
return STDIN.gets.chomp.downcase
|
66
|
+
end
|
67
|
+
|
68
|
+
def describe_trigger
|
69
|
+
puts
|
70
|
+
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."
|
71
|
+
return STDIN.gets.chomp
|
72
|
+
end
|
73
|
+
|
74
|
+
def change_self
|
75
|
+
puts "Think about your environment, your situation, or your reactions. You can change each of those, even in small ways."
|
76
|
+
puts
|
77
|
+
puts "Think for a minute about what you want to change, and what you'd need to make that change."
|
78
|
+
pause_for(25)
|
79
|
+
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."
|
80
|
+
puts
|
81
|
+
puts "When you're done listing things you want to do later, type 'done'."
|
82
|
+
tasks = get_tasks
|
83
|
+
puts
|
84
|
+
puts "Now before we move on, let's make a small change to your situation right now. Here are some ideas:"
|
85
|
+
puts "- Take a quick exercise break."
|
86
|
+
puts "- Go for a walk around the block."
|
87
|
+
puts "- Clean up a part of this room right now, or your desk."
|
88
|
+
puts "- Grab a healthy snack, or drink a glass of water."
|
89
|
+
puts
|
90
|
+
puts "When you've done that, come back and hit 'enter' so we can start coding."
|
91
|
+
STDIN.gets.chomp
|
92
|
+
puts
|
93
|
+
return tasks
|
94
|
+
end
|
95
|
+
|
96
|
+
def accept_self
|
97
|
+
puts "Here are some things you might want to remind yourself about this trigger and your reaction to it:"
|
98
|
+
puts "- It is as it is."
|
99
|
+
puts "- I don’t have to agree with it or judge it as good or bad."
|
100
|
+
puts "- I can always come back to this feeling later."
|
101
|
+
puts "- I can keep my options open."
|
102
|
+
puts "- This is a normal body reaction."
|
103
|
+
puts "- I don’t have to fight it or try to stop it."
|
104
|
+
puts "- It is as it is, but it won't stay that way. It will pass."
|
105
|
+
puts
|
106
|
+
puts "Jot down a thought about what accepting this means to you, so you can remember this later."
|
107
|
+
return STDIN.gets.chomp
|
108
|
+
end
|
109
|
+
|
110
|
+
def let_go_self
|
111
|
+
puts "Think about this trigger and your emotions from it. Ask yourself:"
|
112
|
+
puts "- Is it worth it?"
|
113
|
+
puts "- Is this something I can leave or let go of and move on from this experience?"
|
114
|
+
puts "- Can I learn from this experience?"
|
115
|
+
puts "- What would I want to do differently next time?"
|
116
|
+
puts
|
117
|
+
puts "Jot a note to yourself about this. Hit enter when done."
|
118
|
+
note_to_self = STDIN.gets.chomp
|
119
|
+
puts
|
120
|
+
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."
|
121
|
+
puts
|
122
|
+
return note_to_self
|
123
|
+
end
|
124
|
+
|
125
|
+
def close_checkin()
|
126
|
+
puts "Thanks for checking in with yourself!"
|
127
|
+
puts "If you want to see a log of your checkins, open this file again with the argument 'log'."
|
128
|
+
if @note != nil
|
129
|
+
puts "And to check the note you left yourself just now or in previous checkins, open this file with the argument 'pull'."
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
# Breathing exercise to be run if the intensity of negative emotions is greater than 5
|
134
|
+
def breathing_exercise
|
135
|
+
4.times do
|
136
|
+
4.times { |n| puts "BREATHE IN " + (">" * (n+1)) + ("." * (3-n)); sleep 1 }
|
137
|
+
4.times { |n| puts " HOLD " + ("=" * 4); sleep 1 }
|
138
|
+
4.times { |n| puts "BREATHE OUT " + ("<" * (4 - n)) + ("." * n); sleep 1 }
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
# used to add some mindful wait time so user can observe emotions
|
143
|
+
def pause_for(seconds)
|
144
|
+
seconds.times { |s| print ((seconds - s).to_s + "... ") ; sleep 1 }
|
145
|
+
puts
|
146
|
+
end
|
147
|
+
|
148
|
+
# used to put the feeling that the user feels into terms readable for our databases
|
149
|
+
def categorize_feeling(feeling, emotion_list)
|
150
|
+
if feeling.downcase == "more"
|
151
|
+
puts
|
152
|
+
puts emotion_list
|
153
|
+
puts
|
154
|
+
puts "Pick a word from the list above that describes how you're feeling right now."
|
155
|
+
return categorize_feeling(STDIN.gets.chomp, emotion_list)
|
156
|
+
elsif emotion_list.list.keys.include?(feeling.downcase)
|
157
|
+
# emotion named by user, but not a secondary state
|
158
|
+
categorized = { emotion: feeling.downcase, state: nil }
|
159
|
+
else
|
160
|
+
matching_emotion = emotion_list.list.select {|emotion, states| states.include? feeling.downcase}
|
161
|
+
categorized = { emotion: matching_emotion.keys[0], state: feeling.downcase }
|
162
|
+
end
|
163
|
+
return categorized if defined? categorized
|
164
|
+
# User gave invalid input, run again
|
165
|
+
return categorize_feeling("more", emotion_list)
|
166
|
+
end
|
167
|
+
|
168
|
+
# Read in list of tasks that the user wants to remember for later.
|
169
|
+
def get_tasks
|
170
|
+
note_to_self = ""
|
171
|
+
task = STDIN.gets.chomp
|
172
|
+
until task.downcase == "done"
|
173
|
+
note_to_self += " o " + task + "\n"
|
174
|
+
task = STDIN.gets.chomp
|
175
|
+
end
|
176
|
+
return note_to_self.chomp
|
177
|
+
end
|
178
|
+
|
179
|
+
# Display checkin as a hash
|
180
|
+
def to_h
|
181
|
+
return {
|
182
|
+
time: @time,
|
183
|
+
emotion: @emotional_state[:emotion],
|
184
|
+
state: @emotional_state[:state],
|
185
|
+
intensity: @intensity ||= nil,
|
186
|
+
trigger: @trigger ||= nil,
|
187
|
+
note: @note ||= nil
|
188
|
+
}
|
189
|
+
end
|
190
|
+
end
|
data/lib/checkins_db.rb
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
class CheckinsDB
|
2
|
+
def initialize(db)
|
3
|
+
@db = db
|
4
|
+
@db.execute_batch(create_tables_cmd)
|
5
|
+
# Check if the emotions and states tables have been populated, and, if not, do so.
|
6
|
+
unless @db.execute("SELECT name FROM emotions;").any? { |row| row[0] == "joy" }
|
7
|
+
@db.execute_batch(populate_emotional_states_cmd)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def create_tables_cmd
|
12
|
+
# SQL command to make the tables if they don't exist.
|
13
|
+
return <<-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
|
+
end
|
36
|
+
def populate_emotional_states_cmd
|
37
|
+
return <<-SQL
|
38
|
+
INSERT OR IGNORE INTO emotions (id, name) VALUES (1, "anger");
|
39
|
+
INSERT OR IGNORE INTO emotions (id, name) VALUES (2, "joy");
|
40
|
+
INSERT OR IGNORE INTO emotions (id, name) VALUES (3, "sadness");
|
41
|
+
INSERT OR IGNORE INTO emotions (id, name) VALUES (4, "hurt");
|
42
|
+
INSERT OR IGNORE INTO emotions (id, name) VALUES (5, "fear");
|
43
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (1, "bothered", 1);
|
44
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (2, "annoyed", 1);
|
45
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (3, "bitter", 1);
|
46
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (4, "angry", 1);
|
47
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (5, "irritated", 1);
|
48
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (6, "disgusted", 1);
|
49
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (7, "frustrated", 1);
|
50
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (8, "exasperated", 1);
|
51
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (9, "furious", 1);
|
52
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (10, "content", 2);
|
53
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (11, "peaceful", 2);
|
54
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (12, "relaxed", 2);
|
55
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (13, "cheerful", 2);
|
56
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (14, "satisfied", 2);
|
57
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (15, "joyous", 2);
|
58
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (16, "excited", 2);
|
59
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (17, "ecstatic", 2);
|
60
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (18, "happy", 2);
|
61
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (19, "sad", 3);
|
62
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (20, "depressed", 3);
|
63
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (21, "distraught", 3);
|
64
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (22, "despair", 3);
|
65
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (23, "melancholy", 3);
|
66
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (24, "grief", 3);
|
67
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (25, "helpless", 3);
|
68
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (26, "hopeless", 3);
|
69
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (27, "miserable", 3);
|
70
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (28, "lonely", 4);
|
71
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (29, "homesick", 4);
|
72
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (30, "abandoned", 4);
|
73
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (31, "embarrassed", 4);
|
74
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (32, "shame", 4);
|
75
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (33, "guilt", 4);
|
76
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (34, "foolish", 4);
|
77
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (35, "humiliated", 4);
|
78
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (36, "uncertain", 5);
|
79
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (37, "worried", 5);
|
80
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (38, "anxious", 5);
|
81
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (39, "frightened", 5);
|
82
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (40, "scared", 5);
|
83
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (41, "nervous", 5);
|
84
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (42, "afraid", 5);
|
85
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (43, "terrified", 5);
|
86
|
+
INSERT OR IGNORE INTO states (id, name, emotionID) VALUES (44, "overwhelmed", 5);
|
87
|
+
SQL
|
88
|
+
end
|
89
|
+
|
90
|
+
# Add a checkin to the database
|
91
|
+
def add(checkin_entry)
|
92
|
+
# replace emotion name with matching id
|
93
|
+
emotion_id = lookup_emotion_id(checkin_entry[:emotion])
|
94
|
+
checkin_entry[:emotion] = emotion_id
|
95
|
+
|
96
|
+
# replace state name with matching id, if exists
|
97
|
+
if checkin_entry[:state]
|
98
|
+
state_id = lookup_state_id(checkin_entry[:state])
|
99
|
+
checkin_entry[:state] = state_id
|
100
|
+
end
|
101
|
+
|
102
|
+
# turn note to self into blob, if exists
|
103
|
+
if checkin_entry[:note]
|
104
|
+
checkin_entry[:note] = checkin_entry[:note].to_blob
|
105
|
+
end
|
106
|
+
|
107
|
+
@db.execute("INSERT INTO checkins (time, emotionID, stateID, intensity, trigger, noteToSelf) VALUES (?, ?, ?, ?, ?, ?)", checkin_entry[:time], checkin_entry[:emotion], checkin_entry[:state], checkin_entry[:intensity], checkin_entry[:trigger], checkin_entry[:note])
|
108
|
+
end
|
109
|
+
|
110
|
+
# look up the emotion ID in this DB for a given emotion name
|
111
|
+
def lookup_emotion_id(emotion)
|
112
|
+
emotion_id = @db.get_first_value("SELECT id FROM emotions WHERE name = ?", emotion)
|
113
|
+
end
|
114
|
+
|
115
|
+
# look up the state ID in this DB for a given state name
|
116
|
+
def lookup_state_id(state)
|
117
|
+
state_id = @db.get_first_value("SELECT id FROM states WHERE name = ?", state)
|
118
|
+
end
|
119
|
+
|
120
|
+
# generate SQL query that can pull the log, replace the ids from each table with the emotion/state names, etc
|
121
|
+
def log(limit)
|
122
|
+
qry_checkins_cmd = <<-SQL
|
123
|
+
SELECT time, emotions.name, states.name, intensity
|
124
|
+
FROM (checkins LEFT JOIN emotions ON checkins.emotionID = emotions.id) LEFT JOIN states
|
125
|
+
ON checkins.stateID = states.id;
|
126
|
+
SQL
|
127
|
+
rows = @db.execute(qry_checkins_cmd)
|
128
|
+
|
129
|
+
result = ""
|
130
|
+
# make header row
|
131
|
+
result += "Checkin time | Emotion | Emotional state | Intensity \n"
|
132
|
+
result += "---------------------|--------------|------------------|-----------\n"
|
133
|
+
# initialize incrementer to test if going past limit
|
134
|
+
i = 1
|
135
|
+
|
136
|
+
# print that SQL query for each row, going back as long as incrementer is less than limit
|
137
|
+
rows.reverse_each do |row|
|
138
|
+
next if i > limit
|
139
|
+
# turn all null or nil values and all numbers into strings
|
140
|
+
row.map!(&:to_s)
|
141
|
+
result += row[0].ljust(21) + "| " + row[1].ljust(13) + "| " + row[2].ljust(17) + "| " + row[3].ljust(9) + "\n"
|
142
|
+
i += 1
|
143
|
+
end
|
144
|
+
return result
|
145
|
+
end
|
146
|
+
|
147
|
+
def review_notes
|
148
|
+
# generate SQL queries that pull the times and all from the noteToSelf attribute, numbered
|
149
|
+
pull_notes_cmd = <<-SQL
|
150
|
+
SELECT time, emotions.name, states.name, trigger, noteToSelf
|
151
|
+
FROM (checkins JOIN emotions ON checkins.emotionID = emotions.id) LEFT JOIN states
|
152
|
+
ON checkins.stateID = states.id;
|
153
|
+
SQL
|
154
|
+
entries = @db.execute(pull_notes_cmd)
|
155
|
+
result = ""
|
156
|
+
|
157
|
+
entries.each do |entry|
|
158
|
+
next unless entry[3] or entry[4]
|
159
|
+
result += "Date and time: " + entry[0] + "\n"
|
160
|
+
result += "Emotional state: " + entry[1]
|
161
|
+
result += ", " + entry[2] if entry[2] # checking if state is nil
|
162
|
+
result += "\n"
|
163
|
+
result += "Trigger: " + entry[3] + "\n" if entry[3]
|
164
|
+
result += "\n"
|
165
|
+
result += "Note to self: \n\n" + entry[4] + "\n" if entry[4]
|
166
|
+
result += "\n"
|
167
|
+
result += " -=- -=- -=- -=- -=- -=- -=- -=- \n"
|
168
|
+
result += "\n"
|
169
|
+
end
|
170
|
+
return result
|
171
|
+
end
|
172
|
+
|
173
|
+
end
|
data/lib/githooker.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
module Githooker
|
2
|
+
def self.hook(hook_name, file_contents)
|
3
|
+
git_dir = self.find_git_dir
|
4
|
+
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"]
|
5
|
+
unless acceptable_hooks.include? hook_name
|
6
|
+
puts "Please provide an acceptable hook name. Acceptable hooks are as follows:"
|
7
|
+
acceptable_hooks.each {|hook| puts " - '" + hook + "'"}
|
8
|
+
puts "Refer to git docs for more information."
|
9
|
+
exit(1)
|
10
|
+
end
|
11
|
+
|
12
|
+
if git_dir
|
13
|
+
# check if .git/hooks contains file matching current hook
|
14
|
+
hooks_dir = File.join(git_dir, "hooks")
|
15
|
+
hook_full_path = File.join(hooks_dir, hook_name)
|
16
|
+
unless File.exist? hook_full_path
|
17
|
+
hook_file = File.open(hook_full_path, "w") do |file|
|
18
|
+
file_contents.each_line { |line| file.puts line }
|
19
|
+
end
|
20
|
+
system("chmod +x #{hook_full_path}")
|
21
|
+
puts "Added githook on hook #{hook_name}, located in hooks folder #{hooks_dir}"
|
22
|
+
else
|
23
|
+
puts "Githook for this action (#{hook_name}) already exists. This script is unable to manage duplicate executables for the same githook. Exiting..."
|
24
|
+
exit(1)
|
25
|
+
end
|
26
|
+
else
|
27
|
+
puts "No git repository found... exiting... "
|
28
|
+
exit(1)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.find_git_dir
|
33
|
+
# find .git directory
|
34
|
+
if File.exist? ".git"
|
35
|
+
return File.join(Dir.pwd,".git")
|
36
|
+
else
|
37
|
+
# find path to parent directory
|
38
|
+
index_of_parent_separator = Dir.pwd.rindex(File::SEPARATOR)
|
39
|
+
parent_dir_name = Dir.pwd[0...index_of_parent_separator]
|
40
|
+
|
41
|
+
if File.exist? parent_dir_name
|
42
|
+
Dir.chdir(parent_dir_name) { self.find_git_dir }
|
43
|
+
else
|
44
|
+
return false
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: checkin_self
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Swartzman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sqlite3
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
description: A tool to integrate mindful checkins into your git workflow
|
@@ -31,10 +31,13 @@ executables:
|
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
|
-
- README.md
|
35
|
-
- bin/checkin_self
|
36
34
|
- lib/checkin_self.rb
|
37
35
|
- lib/emotion_list.rb
|
36
|
+
- lib/checkin.rb
|
37
|
+
- lib/checkins_db.rb
|
38
|
+
- lib/githooker.rb
|
39
|
+
- README.md
|
40
|
+
- bin/checkin_self
|
38
41
|
homepage: https://github.com/rtzm/checkin-project
|
39
42
|
licenses:
|
40
43
|
- MIT
|
@@ -45,17 +48,17 @@ require_paths:
|
|
45
48
|
- lib
|
46
49
|
required_ruby_version: !ruby/object:Gem::Requirement
|
47
50
|
requirements:
|
48
|
-
- -
|
51
|
+
- - '>='
|
49
52
|
- !ruby/object:Gem::Version
|
50
53
|
version: '0'
|
51
54
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
55
|
requirements:
|
53
|
-
- -
|
56
|
+
- - '>='
|
54
57
|
- !ruby/object:Gem::Version
|
55
58
|
version: '0'
|
56
59
|
requirements: []
|
57
60
|
rubyforge_project:
|
58
|
-
rubygems_version: 2.
|
61
|
+
rubygems_version: 2.0.14.1
|
59
62
|
signing_key:
|
60
63
|
specification_version: 4
|
61
64
|
summary: checkin_self
|