notenote 0.0.5 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/note/cli.rb +20 -4
- data/lib/note/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e739b649898fe2b3cd03fef0dc45bd728ffbce50c3ee5cb6f7d1918bf59612f
|
4
|
+
data.tar.gz: e23ae24148d1ef7666fd26430f3f5413b228d4a9c8563ec039c6878ef542326d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a129c33ebc60c59500cac01472a99f71889579797adddc746c6b1177c9b4bbc60c1a38736b9c235d9b38df35d5091b43e84ec8da2ec98b556010b3e5b4f54924
|
7
|
+
data.tar.gz: aed23da98e1307fd318300a518b5c70381bb294f25b9488c850fa57ed65d235019f7793e7c7adfea97a3515ae8404fd0a694d7238c6cd0e5d76cbb1fae4305c8
|
data/lib/note/cli.rb
CHANGED
@@ -68,6 +68,10 @@ module Note
|
|
68
68
|
elsif args.first == "push"
|
69
69
|
push_notes
|
70
70
|
|
71
|
+
0
|
72
|
+
elsif args.first == "push!"
|
73
|
+
push_notes(force: true)
|
74
|
+
|
71
75
|
0
|
72
76
|
else
|
73
77
|
puts "Hm, I don't know this command 🤔"
|
@@ -95,9 +99,9 @@ module Note
|
|
95
99
|
def create_config_file(notes_folder:)
|
96
100
|
config_template = File.read(File.join(File.dirname(__FILE__), "config.json.template"))
|
97
101
|
|
98
|
-
config = config_template
|
102
|
+
config = safe_tt(config_template, {
|
99
103
|
notes_folder: notes_folder
|
100
|
-
}
|
104
|
+
})
|
101
105
|
|
102
106
|
config_file = File.join(Dir.home, ".notenote")
|
103
107
|
|
@@ -177,8 +181,8 @@ module Note
|
|
177
181
|
diff_stat.member?("-") || diff_stat.member?("!")
|
178
182
|
end
|
179
183
|
|
180
|
-
def push_notes
|
181
|
-
if notes_changed_or_deleted?
|
184
|
+
def push_notes(force: false)
|
185
|
+
if !force && notes_changed_or_deleted?
|
182
186
|
puts "Some of the notes were mofified or deleted. Please, check them up and push manually."
|
183
187
|
return
|
184
188
|
end
|
@@ -193,5 +197,17 @@ module Note
|
|
193
197
|
|
194
198
|
puts "Pushed. ✅"
|
195
199
|
end
|
200
|
+
|
201
|
+
# A custom string format method to avoid type
|
202
|
+
# errors when using str % hash.
|
203
|
+
def safe_tt(str, hash)
|
204
|
+
str_copy = str
|
205
|
+
|
206
|
+
hash.each do |key, value|
|
207
|
+
str_copy.gsub!("%{#{key}}", value.to_s)
|
208
|
+
end
|
209
|
+
|
210
|
+
str_copy
|
211
|
+
end
|
196
212
|
end
|
197
213
|
end
|
data/lib/note/version.rb
CHANGED