notenote 0.0.7 → 0.0.8

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 +18 -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: 7e739b649898fe2b3cd03fef0dc45bd728ffbce50c3ee5cb6f7d1918bf59612f
4
- data.tar.gz: e23ae24148d1ef7666fd26430f3f5413b228d4a9c8563ec039c6878ef542326d
3
+ metadata.gz: 9c7fc51bd06351a5ae925a67ac1aa684a2d15ffbc59edd798d3f302ef360b56e
4
+ data.tar.gz: 0e74c23606640b7eba1ad183720bfa2b847d52ee20ed49bbd47e60484377efac
5
5
  SHA512:
6
- metadata.gz: a129c33ebc60c59500cac01472a99f71889579797adddc746c6b1177c9b4bbc60c1a38736b9c235d9b38df35d5091b43e84ec8da2ec98b556010b3e5b4f54924
7
- data.tar.gz: aed23da98e1307fd318300a518b5c70381bb294f25b9488c850fa57ed65d235019f7793e7c7adfea97a3515ae8404fd0a694d7238c6cd0e5d76cbb1fae4305c8
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(file_name: "#{file_name}.md")
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(file_name: "notes.md")
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
- FileUtils.touch(note_file)
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
@@ -1,3 +1,3 @@
1
1
  module Note
2
- VERSION = "0.0.7".freeze
2
+ VERSION = "0.0.8".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.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anatoli Makarevich