note_taker 0.1.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 66c0a9996a137b4d8e35553ebab9d2d76d7254d3c9c5574e4fd09c1fdad4dd01
4
+ data.tar.gz: dac633f42847f9e0ed7153bbca9f2e64d3979dc56fba818f4fa3a15493d4c376
5
+ SHA512:
6
+ metadata.gz: dc30637358a48a1a9777735da7347db0c56ab33a582da360bf8fff081cac0c02d5edb99d089fb1eb60ddd081d5db36a4ef4b38535c9cf27cd1c9cd2ea0173029
7
+ data.tar.gz: 2eac992cd31dddab6e1ceddfb2d0a6f04c4185b2703f572c740683555e2495fcf8da256b88141544e8577d6662b90d1636d74d636b851e9750a49f37380ff062
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.4
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2021-09-03
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in note_taker.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.7"
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # NoteTaker
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/note_taker`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'note_taker'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install note_taker
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/note_taker.
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "note_taker"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/note_taker ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ $LOAD_PATH.unshift("#{__dir__}/../lib")
5
+
6
+ require 'note_taker'
7
+
8
+ NoteTaker.run
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NoteTaker
4
+ VERSION = "0.1.0"
5
+ end
data/lib/note_taker.rb ADDED
@@ -0,0 +1,135 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "note_taker/version"
4
+ require_relative 'note_taker/note.rb'
5
+
6
+ module NoteTaker
7
+ class Error < StandardError; end
8
+
9
+ HELP_TEXT = <<~HELP.freeze
10
+ hello [OPTION] ... DIR
11
+
12
+ -h, --help:
13
+ show help
14
+
15
+ --quick, -q:
16
+ Open note for quick editing note taker exits after
17
+
18
+ --view, -v:
19
+ Output contents of selected note
20
+ HELP
21
+
22
+ DEFAULT_CONFIG = { 'general' => { 'directory' => 'work_notes' } }.freeze
23
+ @config = begin
24
+ YAML.safe_load(File.read("#{ENV['HOME']}/.note_config.yaml"))
25
+ rescue Errno::ENOENT
26
+ DEFAULT_CONFIG
27
+ end
28
+
29
+ class << self
30
+ attr_reader :config, :options
31
+
32
+ def run
33
+ fetch_options
34
+
35
+ catch(:app_quit) { inline? ? run_inline : run_fullscreen }
36
+
37
+ return puts("\n") if inline?
38
+
39
+ puts("\nGoodbye\n")
40
+ end
41
+
42
+ def inline?
43
+ options[:inline]
44
+ end
45
+
46
+ def header
47
+ system("clear && printf '\e[3J'")
48
+ puts('+------------------------------------------------------------------------------+')
49
+ puts('| Note Taker |')
50
+ puts('+------------------------------------------------------------------------------+')
51
+ end
52
+
53
+ private
54
+
55
+ def fetch_options
56
+ opts = GetoptLong.new(
57
+ ['--help', '-h', GetoptLong::NO_ARGUMENT],
58
+ ['--quick-edit', '-q', GetoptLong::NO_ARGUMENT],
59
+ ['--view', '-v', GetoptLong::NO_ARGUMENT]
60
+ )
61
+
62
+ quick_edit = false
63
+ help = false
64
+ view = false
65
+ inline = false
66
+
67
+ opts.each do |opt, _arg|
68
+ case opt
69
+ when '--help'
70
+ puts HELP_TEXT
71
+ exit 0
72
+ when '--quick-edit'
73
+ quick_edit = true
74
+ inline = true
75
+ when '--view'
76
+ view = true
77
+ inline = true
78
+ end
79
+ end
80
+
81
+ @options = { help: help, quick_edit: quick_edit, view: view, inline: inline }
82
+ end
83
+
84
+ def run_inline
85
+ catch(:quit) do
86
+ note = Note.search
87
+
88
+ if options[:view]
89
+ note.view
90
+ elsif options[:quick_edit]
91
+ note.edit
92
+ end
93
+ end
94
+ end
95
+
96
+ def main_prompt
97
+ @main_prompt ||= TTY::Prompt.new(quiet: true, interrupt: -> { throw(:app_quit) })
98
+ end
99
+
100
+ def main_menu
101
+ header
102
+ main_prompt.select('Main menu:') do |menu|
103
+ menu.choice(name: 'View/Edit Notes', value: 1)
104
+ menu.choice(name: 'Create Notes', value: 2)
105
+ menu.choice(name: 'Delete Notes', value: 3)
106
+ end
107
+ end
108
+
109
+ def run_fullscreen
110
+ loop do
111
+ choice = main_menu
112
+
113
+ catch(:quit) do
114
+ loop do
115
+ header
116
+
117
+ case choice
118
+ when 1
119
+ note = Note.search
120
+ note.view
121
+ when 2
122
+ note = Note.create
123
+ note.edit
124
+ note.view
125
+ choice = 1 # jump back to search mode
126
+ when 3
127
+ note = Note.search(prompt_message: 'Which note do you want to delete?')
128
+ note.delete
129
+ end
130
+ end
131
+ end
132
+ end
133
+ end
134
+ end
135
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/note_taker/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "note_taker"
7
+ spec.version = NoteTaker::VERSION
8
+ spec.authors = ["Harry Venables"]
9
+ spec.email = ["harry.venables@immersivelabs.com"]
10
+
11
+ spec.summary = "A Note taking gem"
12
+ spec.homepage = "https://github.com/hvenables/note_taker"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
14
+
15
+ spec.metadata["homepage_uri"] = spec.homepage
16
+ spec.metadata["source_code_uri"] = "https://github.com/hvenables/note_taker"
17
+ spec.metadata["changelog_uri"] = "https://github.com/hvenables/note_taker/blob/main/CHANGELOG.md"
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files = [".gitignore", ".rspec", ".rubocop.yml", "CHANGELOG.md", "Gemfile", "README.md", "Rakefile", "bin/console", "bin/setup", "exe/note_taker", "lib/note_taker.rb", "lib/note_taker/version.rb", "note_taker.gemspec"]
22
+ # spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
+ # `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
24
+ # end
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ # Uncomment to register a new dependency of your gem
30
+ spec.add_dependency "tty-editor"
31
+ spec.add_dependency "tty-markdown"
32
+ spec.add_dependency "tty-prompt"
33
+
34
+ spec.add_development_dependency "pry"
35
+
36
+ # For more information and examples about making a new gem, checkout our
37
+ # guide at: https://bundler.io/guides/creating_gem.html
38
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: note_taker
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Harry Venables
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-09-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: tty-editor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: tty-markdown
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: tty-prompt
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description:
70
+ email:
71
+ - harry.venables@immersivelabs.com
72
+ executables:
73
+ - note_taker
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".rubocop.yml"
80
+ - CHANGELOG.md
81
+ - Gemfile
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/setup
86
+ - exe/note_taker
87
+ - lib/note_taker.rb
88
+ - lib/note_taker/version.rb
89
+ - note_taker.gemspec
90
+ homepage: https://github.com/hvenables/note_taker
91
+ licenses: []
92
+ metadata:
93
+ homepage_uri: https://github.com/hvenables/note_taker
94
+ source_code_uri: https://github.com/hvenables/note_taker
95
+ changelog_uri: https://github.com/hvenables/note_taker/blob/main/CHANGELOG.md
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: 2.4.0
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubygems_version: 3.1.4
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: A Note taking gem
115
+ test_files: []