note_taker 0.1.0 → 0.1.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.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Gemfile.lock +95 -0
- data/lib/note_taker/note.rb +120 -0
- data/lib/note_taker/version.rb +1 -1
- data/lib/note_taker.rb +6 -0
- data/note_taker.gemspec +6 -7
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c920d293e39282f7518864751291d0178d4dcf2f8fb31e24f2ea8b473f9c7bad
|
4
|
+
data.tar.gz: 713a93b2e268549d06ace68e02c9b1332fed5a90b77e1f6606ca78bb26c4cfe1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96000bbfecb3a4b7feb22069780706172af92223a1c69dcb795d190d2723122e19844fb0a96dc67d08008b4692e80ba5d30f08fd3c9a6c71f18b5631db256273
|
7
|
+
data.tar.gz: 808f60ec1c0fc659ec9acc914235cf7e5da0d86385451cff7f987090f3d4b53bd4d953d6d9a7bb66ce77539202d70944843793669e01344b433edff7c7b0d575
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
note_taker (0.1.0)
|
5
|
+
tty-editor
|
6
|
+
tty-markdown
|
7
|
+
tty-prompt
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
ast (2.4.2)
|
13
|
+
coderay (1.1.3)
|
14
|
+
diff-lcs (1.4.4)
|
15
|
+
kramdown (2.3.1)
|
16
|
+
rexml
|
17
|
+
method_source (1.0.0)
|
18
|
+
parallel (1.20.1)
|
19
|
+
parser (3.0.2.0)
|
20
|
+
ast (~> 2.4.1)
|
21
|
+
pastel (0.8.0)
|
22
|
+
tty-color (~> 0.5)
|
23
|
+
pry (0.14.1)
|
24
|
+
coderay (~> 1.1)
|
25
|
+
method_source (~> 1.0)
|
26
|
+
rainbow (3.0.0)
|
27
|
+
rake (13.0.6)
|
28
|
+
regexp_parser (2.1.1)
|
29
|
+
rexml (3.2.5)
|
30
|
+
rouge (3.26.0)
|
31
|
+
rspec (3.10.0)
|
32
|
+
rspec-core (~> 3.10.0)
|
33
|
+
rspec-expectations (~> 3.10.0)
|
34
|
+
rspec-mocks (~> 3.10.0)
|
35
|
+
rspec-core (3.10.1)
|
36
|
+
rspec-support (~> 3.10.0)
|
37
|
+
rspec-expectations (3.10.1)
|
38
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
39
|
+
rspec-support (~> 3.10.0)
|
40
|
+
rspec-mocks (3.10.2)
|
41
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
42
|
+
rspec-support (~> 3.10.0)
|
43
|
+
rspec-support (3.10.2)
|
44
|
+
rubocop (1.20.0)
|
45
|
+
parallel (~> 1.10)
|
46
|
+
parser (>= 3.0.0.0)
|
47
|
+
rainbow (>= 2.2.2, < 4.0)
|
48
|
+
regexp_parser (>= 1.8, < 3.0)
|
49
|
+
rexml
|
50
|
+
rubocop-ast (>= 1.9.1, < 2.0)
|
51
|
+
ruby-progressbar (~> 1.7)
|
52
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
53
|
+
rubocop-ast (1.11.0)
|
54
|
+
parser (>= 3.0.1.1)
|
55
|
+
ruby-progressbar (1.11.0)
|
56
|
+
strings (0.2.1)
|
57
|
+
strings-ansi (~> 0.2)
|
58
|
+
unicode-display_width (>= 1.5, < 3.0)
|
59
|
+
unicode_utils (~> 1.4)
|
60
|
+
strings-ansi (0.2.0)
|
61
|
+
tty-color (0.6.0)
|
62
|
+
tty-cursor (0.7.1)
|
63
|
+
tty-editor (0.7.0)
|
64
|
+
tty-prompt (~> 0.22)
|
65
|
+
tty-markdown (0.7.0)
|
66
|
+
kramdown (>= 1.16.2, < 3.0)
|
67
|
+
pastel (~> 0.8)
|
68
|
+
rouge (~> 3.14)
|
69
|
+
strings (~> 0.2.0)
|
70
|
+
tty-color (~> 0.5)
|
71
|
+
tty-screen (~> 0.8)
|
72
|
+
tty-prompt (0.23.1)
|
73
|
+
pastel (~> 0.8)
|
74
|
+
tty-reader (~> 0.8)
|
75
|
+
tty-reader (0.9.0)
|
76
|
+
tty-cursor (~> 0.7)
|
77
|
+
tty-screen (~> 0.8)
|
78
|
+
wisper (~> 2.0)
|
79
|
+
tty-screen (0.8.1)
|
80
|
+
unicode-display_width (2.0.0)
|
81
|
+
unicode_utils (1.4.0)
|
82
|
+
wisper (2.0.1)
|
83
|
+
|
84
|
+
PLATFORMS
|
85
|
+
x86_64-linux
|
86
|
+
|
87
|
+
DEPENDENCIES
|
88
|
+
note_taker!
|
89
|
+
pry
|
90
|
+
rake (~> 13.0)
|
91
|
+
rspec (~> 3.0)
|
92
|
+
rubocop (~> 1.7)
|
93
|
+
|
94
|
+
BUNDLED WITH
|
95
|
+
2.2.17
|
@@ -0,0 +1,120 @@
|
|
1
|
+
class Note
|
2
|
+
class << self
|
3
|
+
def create
|
4
|
+
prompt.say('What is the filename of the note you want to create? (or press ctrl+c to abort)')
|
5
|
+
input = prompt.ask('‣') do |q|
|
6
|
+
q.required true
|
7
|
+
end
|
8
|
+
|
9
|
+
filepath = "#{ENV['HOME']}/#{dir}/#{input}.md".shellescape
|
10
|
+
`touch #{filepath}`
|
11
|
+
new(input)
|
12
|
+
end
|
13
|
+
|
14
|
+
def search(prompt_message: 'Choose a note.')
|
15
|
+
if filenames.empty?
|
16
|
+
prompt.puts('Folder currently empty')
|
17
|
+
return
|
18
|
+
end
|
19
|
+
|
20
|
+
input = prompt.select(
|
21
|
+
prompt_message,
|
22
|
+
filenames,
|
23
|
+
filter: true,
|
24
|
+
per_page: 40,
|
25
|
+
help: '(or press ctrl+c to abort)',
|
26
|
+
show_help: :always
|
27
|
+
)
|
28
|
+
new(input)
|
29
|
+
end
|
30
|
+
|
31
|
+
def dir
|
32
|
+
NoteApplication.config['general']['directory']
|
33
|
+
end
|
34
|
+
|
35
|
+
def prompt
|
36
|
+
@prompt ||= TTY::Prompt.new(quiet: true, interrupt: -> { throw(:quit) })
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def filenames
|
42
|
+
`ls ~/#{dir}`.split("\n").map { |file| file.chomp('.md') }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
attr_reader :filename, :location
|
47
|
+
|
48
|
+
def initialize(filename)
|
49
|
+
@filename = filename
|
50
|
+
end
|
51
|
+
|
52
|
+
def view
|
53
|
+
catch(:note_quit) do
|
54
|
+
loop do
|
55
|
+
NoteApplication.header unless NoteApplication.inline?
|
56
|
+
parsed = TTY::Markdown.parse_file(file_path)
|
57
|
+
NoteApplication.options[:inline] ? puts(parsed) : prompt.puts(parsed)
|
58
|
+
prompt.puts("\n")
|
59
|
+
|
60
|
+
break if NoteApplication.inline?
|
61
|
+
|
62
|
+
note_menu
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def edit
|
68
|
+
TTY::Editor.open(file_path)
|
69
|
+
end
|
70
|
+
|
71
|
+
def delete
|
72
|
+
return unless prompt.yes?("Are you sure you want to delete '#{filename}'")
|
73
|
+
|
74
|
+
`rm #{file_path.shellescape}`
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def note_menu
|
80
|
+
choices = [
|
81
|
+
{ key: 'e', name: 'edit', value: :edit },
|
82
|
+
{ key: 'r', name: 'rename', value: :rename },
|
83
|
+
{ key: 'd', name: 'delete', value: :delete },
|
84
|
+
{ key: 'q', name: 'quit', value: :quit }
|
85
|
+
]
|
86
|
+
input = prompt.expand('Action:', choices)
|
87
|
+
|
88
|
+
case input
|
89
|
+
when :edit
|
90
|
+
edit
|
91
|
+
when :rename
|
92
|
+
rename
|
93
|
+
when :delete
|
94
|
+
delete
|
95
|
+
throw(:note_quit)
|
96
|
+
when :quit
|
97
|
+
throw(:note_quit)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def rename
|
102
|
+
input = prompt.ask('What is the new filename?')
|
103
|
+
|
104
|
+
new_filename = input.shellescape
|
105
|
+
`mv #{file_path.shellescape} #{path}#{new_filename}.md"`
|
106
|
+
@filename = input
|
107
|
+
end
|
108
|
+
|
109
|
+
def path
|
110
|
+
"#{ENV['HOME']}/#{self.class.dir}/"
|
111
|
+
end
|
112
|
+
|
113
|
+
def file_path
|
114
|
+
"#{path}#{filename}.md"
|
115
|
+
end
|
116
|
+
|
117
|
+
def prompt
|
118
|
+
self.class.prompt
|
119
|
+
end
|
120
|
+
end
|
data/lib/note_taker/version.rb
CHANGED
data/lib/note_taker.rb
CHANGED
data/note_taker.gemspec
CHANGED
@@ -18,18 +18,17 @@ Gem::Specification.new do |spec|
|
|
18
18
|
|
19
19
|
# Specify which files should be added to the gem when it is released.
|
20
20
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
|
-
spec.files =
|
22
|
-
|
23
|
-
|
24
|
-
# end
|
21
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
22
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
23
|
+
end
|
25
24
|
spec.bindir = "exe"
|
26
25
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
27
26
|
spec.require_paths = ["lib"]
|
28
27
|
|
29
28
|
# Uncomment to register a new dependency of your gem
|
30
|
-
spec.
|
31
|
-
spec.
|
32
|
-
spec.
|
29
|
+
spec.add_runtime_dependency "tty-editor"
|
30
|
+
spec.add_runtime_dependency "tty-markdown"
|
31
|
+
spec.add_runtime_dependency "tty-prompt"
|
33
32
|
|
34
33
|
spec.add_development_dependency "pry"
|
35
34
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: note_taker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Harry Venables
|
@@ -79,12 +79,14 @@ files:
|
|
79
79
|
- ".rubocop.yml"
|
80
80
|
- CHANGELOG.md
|
81
81
|
- Gemfile
|
82
|
+
- Gemfile.lock
|
82
83
|
- README.md
|
83
84
|
- Rakefile
|
84
85
|
- bin/console
|
85
86
|
- bin/setup
|
86
87
|
- exe/note_taker
|
87
88
|
- lib/note_taker.rb
|
89
|
+
- lib/note_taker/note.rb
|
88
90
|
- lib/note_taker/version.rb
|
89
91
|
- note_taker.gemspec
|
90
92
|
homepage: https://github.com/hvenables/note_taker
|
@@ -108,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
110
|
- !ruby/object:Gem::Version
|
109
111
|
version: '0'
|
110
112
|
requirements: []
|
111
|
-
rubygems_version: 3.
|
113
|
+
rubygems_version: 3.2.27
|
112
114
|
signing_key:
|
113
115
|
specification_version: 4
|
114
116
|
summary: A Note taking gem
|