notenote 0.0.8 → 0.0.9
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 +27 -4
- data/lib/note/config.json.template +1 -0
- data/lib/note/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a71839ec326f5f762ebea46f47b74d4fccd94f80961ce24b1753e9a842c39cab
|
4
|
+
data.tar.gz: eaeaf9f0a5bf5f24780a05dd943277d657b6731a0b21512643deb4980c820af7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f0da4b7681d4680f0b81d2bad79f649304cb7c8a065f50a241f8bc6d00ca3baf2d30a01ca5341b3fa30b5cfdd08817b4254a0d6072c8f4778456d6cb05571a4
|
7
|
+
data.tar.gz: d953b1120e9cfcf957622a92985546d79916e4b725baaf5705737f289ffad146e189cba24ea1fa1b4b93ddd5e1bd009c9a0c9b3c885f786c4f276500ad13aee6
|
data/lib/note/cli.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require "optparse"
|
4
4
|
require "json"
|
5
|
+
require "date"
|
5
6
|
|
6
7
|
$LOAD_PATH << File.expand_path(__dir__)
|
7
8
|
|
@@ -64,6 +65,8 @@ module Note
|
|
64
65
|
END
|
65
66
|
|
66
67
|
0
|
68
|
+
elsif args.first == "pull"
|
69
|
+
pull_notes
|
67
70
|
elsif args.first == "push"
|
68
71
|
push_notes
|
69
72
|
|
@@ -73,7 +76,16 @@ module Note
|
|
73
76
|
|
74
77
|
0
|
75
78
|
else
|
76
|
-
|
79
|
+
notes_folder = notenote_config["notes_folder"]
|
80
|
+
|
81
|
+
today_folder = File.join(notes_folder, formatted_todays_date)
|
82
|
+
today_note_file = File.join(today_folder, "#{notenote_config["default_note_file_name"]}.md")
|
83
|
+
|
84
|
+
if File.exist?(today_note_file)
|
85
|
+
open_editor(path: today_note_file)
|
86
|
+
else
|
87
|
+
create_note_file
|
88
|
+
end
|
77
89
|
|
78
90
|
0
|
79
91
|
end
|
@@ -109,11 +121,10 @@ module Note
|
|
109
121
|
end
|
110
122
|
end
|
111
123
|
|
112
|
-
def create_note_file(note_name: "
|
124
|
+
def create_note_file(note_name: "#{notenote_config["default_note_file_name"]}.md")
|
113
125
|
notes_folder = notenote_config["notes_folder"]
|
114
|
-
date_format = notenote_config["date_format"]
|
115
126
|
|
116
|
-
today_folder = File.join(notes_folder,
|
127
|
+
today_folder = File.join(notes_folder, formatted_todays_date)
|
117
128
|
|
118
129
|
Dir.mkdir(today_folder) unless Dir.exist?(today_folder)
|
119
130
|
|
@@ -212,6 +223,12 @@ module Note
|
|
212
223
|
puts "Pushed. ✅"
|
213
224
|
end
|
214
225
|
|
226
|
+
def pull_notes
|
227
|
+
Dir.chdir(notenote_config["notes_folder"])
|
228
|
+
|
229
|
+
system "git pull --ff-only"
|
230
|
+
end
|
231
|
+
|
215
232
|
# A custom string format method to avoid type
|
216
233
|
# errors when using str % hash.
|
217
234
|
def safe_tt(str, hash)
|
@@ -223,5 +240,11 @@ module Note
|
|
223
240
|
|
224
241
|
str_copy
|
225
242
|
end
|
243
|
+
|
244
|
+
def formatted_todays_date
|
245
|
+
date_format = notenote_config["date_format"]
|
246
|
+
|
247
|
+
Date.today.strftime(date_format)
|
248
|
+
end
|
226
249
|
end
|
227
250
|
end
|
data/lib/note/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: notenote
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anatoli Makarevich
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-11-
|
11
|
+
date: 2022-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|