notenote 0.0.7 → 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 +44 -7
- 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
|
|
@@ -37,9 +38,8 @@ module Note
|
|
37
38
|
0
|
38
39
|
elsif args.first == "on"
|
39
40
|
note_name = args[1..-1].join(" ") # "tax return" for `note on tax return``
|
40
|
-
file_name = note_name.gsub(/[^a-z0-9\-]+/, "_")
|
41
41
|
|
42
|
-
create_note_file(
|
42
|
+
create_note_file(note_name: note_name)
|
43
43
|
|
44
44
|
0
|
45
45
|
elsif args.first == "all"
|
@@ -65,6 +65,8 @@ module Note
|
|
65
65
|
END
|
66
66
|
|
67
67
|
0
|
68
|
+
elsif args.first == "pull"
|
69
|
+
pull_notes
|
68
70
|
elsif args.first == "push"
|
69
71
|
push_notes
|
70
72
|
|
@@ -74,7 +76,16 @@ module Note
|
|
74
76
|
|
75
77
|
0
|
76
78
|
else
|
77
|
-
|
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
|
78
89
|
|
79
90
|
0
|
80
91
|
end
|
@@ -110,17 +121,31 @@ module Note
|
|
110
121
|
end
|
111
122
|
end
|
112
123
|
|
113
|
-
def create_note_file(
|
124
|
+
def create_note_file(note_name: "#{notenote_config["default_note_file_name"]}.md")
|
114
125
|
notes_folder = notenote_config["notes_folder"]
|
115
|
-
date_format = notenote_config["date_format"]
|
116
126
|
|
117
|
-
today_folder = File.join(notes_folder,
|
127
|
+
today_folder = File.join(notes_folder, formatted_todays_date)
|
118
128
|
|
119
129
|
Dir.mkdir(today_folder) unless Dir.exist?(today_folder)
|
120
130
|
|
131
|
+
file_name = note_name.strip.downcase.
|
132
|
+
gsub(/[^a-z0-9\-]+/, "_").
|
133
|
+
gsub(/\A\_+/, "").
|
134
|
+
gsub(/\_+\z/, "").
|
135
|
+
concat(".md")
|
121
136
|
note_file = File.join(today_folder, file_name)
|
122
137
|
|
123
|
-
|
138
|
+
if File.exist?(note_file)
|
139
|
+
puts "This note already exists. ⚠️"
|
140
|
+
else
|
141
|
+
File.open(note_file, "w") do |file|
|
142
|
+
file.puts unindent <<-TEXT
|
143
|
+
# #{note_name}
|
144
|
+
|
145
|
+
|
146
|
+
TEXT
|
147
|
+
end
|
148
|
+
end
|
124
149
|
|
125
150
|
open_editor(path: note_file)
|
126
151
|
end
|
@@ -198,6 +223,12 @@ module Note
|
|
198
223
|
puts "Pushed. ✅"
|
199
224
|
end
|
200
225
|
|
226
|
+
def pull_notes
|
227
|
+
Dir.chdir(notenote_config["notes_folder"])
|
228
|
+
|
229
|
+
system "git pull --ff-only"
|
230
|
+
end
|
231
|
+
|
201
232
|
# A custom string format method to avoid type
|
202
233
|
# errors when using str % hash.
|
203
234
|
def safe_tt(str, hash)
|
@@ -209,5 +240,11 @@ module Note
|
|
209
240
|
|
210
241
|
str_copy
|
211
242
|
end
|
243
|
+
|
244
|
+
def formatted_todays_date
|
245
|
+
date_format = notenote_config["date_format"]
|
246
|
+
|
247
|
+
Date.today.strftime(date_format)
|
248
|
+
end
|
212
249
|
end
|
213
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
|