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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c7fc51bd06351a5ae925a67ac1aa684a2d15ffbc59edd798d3f302ef360b56e
4
- data.tar.gz: 0e74c23606640b7eba1ad183720bfa2b847d52ee20ed49bbd47e60484377efac
3
+ metadata.gz: a71839ec326f5f762ebea46f47b74d4fccd94f80961ce24b1753e9a842c39cab
4
+ data.tar.gz: eaeaf9f0a5bf5f24780a05dd943277d657b6731a0b21512643deb4980c820af7
5
5
  SHA512:
6
- metadata.gz: c36db2f227e1a29144e5fbffbad8f9dcc277f514b67829b1824998d001da3839f04333c8f62d34be33fd48d70ac19f24823924dbbc5d9adea52e3befa177e235
7
- data.tar.gz: 46f4e35b88ff4558849bac03353147f65d7cb717b4d7c0e76a7dd57a17211cb96572c9f393deecf6cd3b5f193e2a8eb9bff1d054a2ca44223e999c06124cd7ac
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
- puts "Hm, I don't know this command 🤔"
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: "notes")
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, Time.now.strftime(date_format))
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
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "notes_folder": "%{notes_folder}",
3
3
  "date_format": "%d-%m-%Y",
4
+ "default_note_file_name: "notes",
4
5
  "editor_command": "code",
5
6
  "commit_message": "Added new notes"
6
7
  }
data/lib/note/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Note
2
- VERSION = "0.0.8".freeze
2
+ VERSION = "0.0.9".freeze
3
3
  end
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.8
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-06 00:00:00.000000000 Z
11
+ date: 2022-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler