Module: Modules::ResourceUtils
- Included in:
- NoteCreator, NoteDeleter, NoteLister, Workspace
- Defined in:
- lib/notes_cli/modules/resource_utils.rb
Instance Method Summary collapse
- #config ⇒ Object
- #create?(resource) ⇒ Boolean
- #current_workspace ⇒ Object
- #notebook_exists?(notebook) ⇒ Boolean
- #notebook_path(notebook) ⇒ Object
- #notes_folder ⇒ Object
- #workspace_exists?(workspace) ⇒ Boolean
- #workspace_path ⇒ Object
Instance Method Details
#config ⇒ Object
5 6 7 |
# File 'lib/notes_cli/modules/resource_utils.rb', line 5 def config YAML.safe_load(File.read(NotesCli::CONFIG_PATH)) end |
#create?(resource) ⇒ Boolean
17 18 19 20 21 |
# File 'lib/notes_cli/modules/resource_utils.rb', line 17 def create?(resource) puts "This #{resource} does not currently exist and will be created, "\ 'do you wish to continue? [y/N]' STDIN.gets.chomp == 'y' end |
#current_workspace ⇒ Object
23 24 25 26 27 |
# File 'lib/notes_cli/modules/resource_utils.rb', line 23 def current_workspace return config['workspace'] if config && config['workspace'] raise StandardError, 'Please set your workspace' end |
#notebook_exists?(notebook) ⇒ Boolean
9 10 11 |
# File 'lib/notes_cli/modules/resource_utils.rb', line 9 def notebook_exists?(notebook) Dir.exist?(File.join(notes_folder, current_workspace, notebook)) end |
#notebook_path(notebook) ⇒ Object
35 36 37 |
# File 'lib/notes_cli/modules/resource_utils.rb', line 35 def notebook_path(notebook) @notebook_path ||= File.join(notes_folder, current_workspace, notebook) end |
#notes_folder ⇒ Object
29 30 31 32 33 |
# File 'lib/notes_cli/modules/resource_utils.rb', line 29 def notes_folder return config['notes_folder'] if config && config['notes_folder'] raise StandardError, 'Please set your notes_folder' end |
#workspace_exists?(workspace) ⇒ Boolean
13 14 15 |
# File 'lib/notes_cli/modules/resource_utils.rb', line 13 def workspace_exists?(workspace) Dir.exist?(File.join(notes_folder, workspace)) end |
#workspace_path ⇒ Object
39 40 41 |
# File 'lib/notes_cli/modules/resource_utils.rb', line 39 def workspace_path File.join(notes_folder, current_workspace) end |