notenote 0.0.7 → 0.0.8
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 +18 -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: 9c7fc51bd06351a5ae925a67ac1aa684a2d15ffbc59edd798d3f302ef360b56e
|
4
|
+
data.tar.gz: 0e74c23606640b7eba1ad183720bfa2b847d52ee20ed49bbd47e60484377efac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c36db2f227e1a29144e5fbffbad8f9dcc277f514b67829b1824998d001da3839f04333c8f62d34be33fd48d70ac19f24823924dbbc5d9adea52e3befa177e235
|
7
|
+
data.tar.gz: 46f4e35b88ff4558849bac03353147f65d7cb717b4d7c0e76a7dd57a17211cb96572c9f393deecf6cd3b5f193e2a8eb9bff1d054a2ca44223e999c06124cd7ac
|
data/lib/note/cli.rb
CHANGED
@@ -37,9 +37,8 @@ module Note
|
|
37
37
|
0
|
38
38
|
elsif args.first == "on"
|
39
39
|
note_name = args[1..-1].join(" ") # "tax return" for `note on tax return``
|
40
|
-
file_name = note_name.gsub(/[^a-z0-9\-]+/, "_")
|
41
40
|
|
42
|
-
create_note_file(
|
41
|
+
create_note_file(note_name: note_name)
|
43
42
|
|
44
43
|
0
|
45
44
|
elsif args.first == "all"
|
@@ -110,7 +109,7 @@ module Note
|
|
110
109
|
end
|
111
110
|
end
|
112
111
|
|
113
|
-
def create_note_file(
|
112
|
+
def create_note_file(note_name: "notes")
|
114
113
|
notes_folder = notenote_config["notes_folder"]
|
115
114
|
date_format = notenote_config["date_format"]
|
116
115
|
|
@@ -118,9 +117,24 @@ module Note
|
|
118
117
|
|
119
118
|
Dir.mkdir(today_folder) unless Dir.exist?(today_folder)
|
120
119
|
|
120
|
+
file_name = note_name.strip.downcase.
|
121
|
+
gsub(/[^a-z0-9\-]+/, "_").
|
122
|
+
gsub(/\A\_+/, "").
|
123
|
+
gsub(/\_+\z/, "").
|
124
|
+
concat(".md")
|
121
125
|
note_file = File.join(today_folder, file_name)
|
122
126
|
|
123
|
-
|
127
|
+
if File.exist?(note_file)
|
128
|
+
puts "This note already exists. ⚠️"
|
129
|
+
else
|
130
|
+
File.open(note_file, "w") do |file|
|
131
|
+
file.puts unindent <<-TEXT
|
132
|
+
# #{note_name}
|
133
|
+
|
134
|
+
|
135
|
+
TEXT
|
136
|
+
end
|
137
|
+
end
|
124
138
|
|
125
139
|
open_editor(path: note_file)
|
126
140
|
end
|
data/lib/note/version.rb
CHANGED