notenote 0.0.5 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/note/cli.rb +20 -4
  3. data/lib/note/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ecfda3937a0ea3defb410fab57624938d0d3b1c6d1396c9f26ba8fe43d092e03
4
- data.tar.gz: 0ae3216b3fa3b55c1717f9e7667344285c2416217c4f3069e5e3032a96ad5080
3
+ metadata.gz: 7e739b649898fe2b3cd03fef0dc45bd728ffbce50c3ee5cb6f7d1918bf59612f
4
+ data.tar.gz: e23ae24148d1ef7666fd26430f3f5413b228d4a9c8563ec039c6878ef542326d
5
5
  SHA512:
6
- metadata.gz: 7d4d126d852699215f245f83ee14dec71e0e1fee91bda9bead8ea9b7c1a5631fe5fc60149271fd2639e6a2377fb3ffe4e982ef09c1511c3e55d0439694a09059
7
- data.tar.gz: 45a92cfbc51472c916481172c5434df36d296273b7e09dba62b2b8b795717027070fc218d6c8ed5e052400c0309c0508718a898ec4c2d56997ee852d872e09d8
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
@@ -1,3 +1,3 @@
1
1
  module Note
2
- VERSION = "0.0.5".freeze
2
+ VERSION = "0.0.7".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notenote
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anatoli Makarevich