quick_note 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/quick_note.rb +160 -0
  3. metadata +43 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: cfc8bc07134f40c8a76fcc8c93bc524eff1299e4e1224483a5a1c5c33ceaf52b
4
+ data.tar.gz: 6a47e657444431aed8d93396b01cf91d7bf37e5af715dbd26d6a4926d5dd2f95
5
+ SHA512:
6
+ metadata.gz: 4501aea158b8066342a77a6c68aa554a894daf8abbaf4c1c048a907dcb0d4af4f9c417e3625b7ec4969ebbfb2fbdc8385dea3422b5a3301fd36f6e3c3af8b1c3
7
+ data.tar.gz: b80def83c50942c7ccc054a20426746d3fc476b068d090940bb8284d5f4c654a41c88083e3a2db835dca7336fcc410dd1e0bbee068879ca4441bd0764b1ed4da
@@ -0,0 +1,160 @@
1
+ # Author: Pedro Jafet Avalos Jimenez
2
+ # Date: 2019-12-22
3
+
4
+ class QuickNote
5
+ # Actual parent folder that is given by the user.
6
+ @@parent_folder = ''
7
+
8
+ # First command to use.
9
+ # Creates the directory at the given directory (or the default of c:/quick_notes).
10
+ def self.mkdir(directory='c:/quick_notes')
11
+ # Remove the '/' at the end of the directory if it was given by the user.
12
+ # Makes the strings in my code easier to read in my opinion.
13
+ directory = directory[0..-2] if directory[-1] == '/'
14
+
15
+ # Saves the given directory as the actual parent folder being used.
16
+ @@parent_folder = directory
17
+
18
+ # Create the directory if it doesn't already exist
19
+ Dir.mkdir(@@parent_folder) if !Dir.exist?(@@parent_folder)
20
+ # Creates the 'general' folder under the directory if it doesn't already exist.
21
+ Dir.mkdir("#{@@parent_folder}/general") if !Dir.exist?("#{@@parent_folder}/general")
22
+ end
23
+
24
+ # Same as opfolder, but more readable.
25
+ # In case the user wants to open the parent folder.
26
+ def self.opdir()
27
+ # Default parameter for opfolder() already opens the parent folder.
28
+ opfolder()
29
+ end
30
+
31
+ # Command to create a folder.
32
+ def self.mkfolder(folder)
33
+ # Check to make sure the parent folder exists (in case the user did not use mkdir first).
34
+ mkdir() if @@parent_folder == ''
35
+ # Create the folder if it doesn't exist.
36
+ Dir.mkdir("#{@@parent_folder}/#{folder}") if !Dir.exist?("#{@@parent_folder}/#{folder}")
37
+ end
38
+
39
+ # Command to list all the folders in the directory.
40
+ # Should print out the names of them.
41
+ def self.lstfolders()
42
+ # Check to make sure the parent folder exists (in case the user did not use mkdir first).
43
+ mkdir() if @@parent_folder == ''
44
+ # Make the directory the working directory.
45
+ Dir.chdir(@@parent_folder)
46
+
47
+ # The folders in the directory.
48
+ folders = Dir.glob('*').select {|f| File.directory?(f)}
49
+
50
+ # Make the terminal print out the various folders.
51
+ folders.each {|f| system "echo #{f}"}
52
+ end
53
+
54
+ # Create a todo-type of task in a default tasks.txt file in the directory.
55
+ def self.mktask(task, date=Time.now.strftime('%Y-%m-%d'), due_date=Time.now.strftime('%Y-%m-%d'))
56
+ # Check to make sure the parent folder exists (in case the user did not use mkdir first).
57
+ mkdir() if @@parent_folder == ''
58
+
59
+ # Open (or create) the file for tasks (tasks.txt under the general folder).
60
+ # Append the task to do in the tasks.txt file.
61
+ File.open("#{@@parent_folder}/general/tasks.txt", 'a') {|f| f.write "date: #{date} | due: #{due_date} | task: #{task}\n"}
62
+ end
63
+
64
+ # Check all the tasks to do.
65
+ # Opens the tasks.txt file with notepad.
66
+ # An easier to read option instead of opfile()
67
+ def self.optodo()
68
+ # The default parameters for opnote() are already tasks.txt and general
69
+ opnote()
70
+ end
71
+
72
+ # Create a note with the given name and in a given folder
73
+ # If it exists already, then open it.
74
+ # By default, the folder is general.
75
+ def self.mknote(name, folder='general')
76
+ # Check to make sure the parent folder exists (in case the user did not use mkdir first).
77
+ mkdir() if @@parent_folder == ''
78
+
79
+ if name != ''
80
+ # The note file to open.
81
+ file = "#{@@parent_folder}/#{folder}/#{name}.txt"
82
+
83
+ # Create the folder given if it doesn't already exist.
84
+ Dir.mkdir("#{@@parent_folder}/#{folder}") if !Dir.exist?("#{@@parent_folder}/#{folder}")
85
+ # Create the file with the given information if it doesn't already exist.
86
+ File.new("#{file}", File::CREAT) if !File.exist?("#{file}")
87
+
88
+ # Tell the terminal to start the file.
89
+ system %{cmd /c "start #{file}"}
90
+ end
91
+ end
92
+
93
+ # List all the notes in a folder (general by default).
94
+ def self.lstnotes(folder='general')
95
+ # Check to make sure the parent folder exists (in case the user did not use mkdir first).
96
+ mkdir() if @@parent_folder == ''
97
+
98
+ # Make the directory the working directory.
99
+ Dir.chdir("#{@@parent_folder}/#{folder}")
100
+
101
+ # The folders in the directory.
102
+ files = Dir.glob('*.txt')
103
+
104
+ # Make the terminal print out the various folders.
105
+ files.each {|f| system "echo #{f}"}
106
+ end
107
+
108
+ # Delete a note.
109
+ def self.delnote(name, folder='general')
110
+ # Check to make sure the parent folder exists (in case the user did not use mkdir first).
111
+ mkdir() if @@parent_folder == ''
112
+
113
+ # Delete the note if it exists.
114
+ File.delete("#{@@parent_folder}/#{folder}/#{name}.txt") if File.exist?("#{@@parent_folder}/#{folder}/#{name}.txt")
115
+ end
116
+
117
+ # Delete a folder.
118
+ def self.delfolder(folder='')
119
+ # Check to make sure the parent folder exists (in case the user did not use mkdir first).
120
+ mkdir() if @@parent_folder == ''
121
+
122
+ # Delete the folder if it exists, and if the user inputs something.
123
+ # Otherwise it would delete the whole directory.
124
+ Dir.delete("#{@@parent_folder}/#{folder}") if Dir.exist?("#{@@parent_folder}/#{folder}") && folder != ''
125
+ end
126
+
127
+ # Open a folder file explorer.
128
+ # If none is specified, then open the directory.
129
+ def self.opfolder(folder='')
130
+ # Check to make sure the parent folder exists (in case the user did not use mkdir first).
131
+ mkdir() if @@parent_folder == ''
132
+
133
+ # Terminal opens the folder with file explorer.
134
+ system %{cmd /c "start #{@@parent_folder}/#{folder}"}
135
+ end
136
+
137
+ # Open a file (tasks by default) in notepad if it exists.
138
+ def self.opnote(name='tasks', folder='general')
139
+ # Check to make sure the parent folder exists (in case the user did not use mkdir first).
140
+ mkdir() if @@parent_folder == ''
141
+
142
+ # The note file to open.
143
+ file = "#{@@parent_folder}/#{folder}/#{name}.txt"
144
+
145
+ # Tell the terminal to start the file if it exists.
146
+ system %{cmd /c "start #{file}"} if File.exist?(file)
147
+ end
148
+
149
+ # Clear all the tasks in the tasks.txt file.
150
+ def self.clrtodo()
151
+ # Check to make sure the parent folder exists (in case the user did not use mkdir first).
152
+ mkdir() if @@parent_folder == ''
153
+
154
+ # File directory.
155
+ file = "#{@@parent_folder}/general/tasks.txt"
156
+
157
+ # Clear the text file.
158
+ File.write(file, '')
159
+ end
160
+ end
metadata ADDED
@@ -0,0 +1,43 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: quick_note
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Pedro Avalos
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-12-22 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A simple gem to make txt notes
14
+ email: pavalos6401@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/quick_note.rb
20
+ homepage: https://rubygems.org/gems/quick_note
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubygems_version: 3.0.3
40
+ signing_key:
41
+ specification_version: 4
42
+ summary: Make Quick Notes
43
+ test_files: []