noter 0.3.0 → 0.4.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 +4 -4
- data/README.md +7 -1
- data/bin/noter +11 -1
- data/lib/noter.rb +4 -4
- data/lib/noter/file_maker.rb +7 -0
- data/lib/noter/version.rb +1 -1
- data/lib/noter/viewer.rb +2 -2
- data/spec/lib/noter/file_maker_spec.rb +25 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df93071a114bb69942082e92abeef1d6dabfaa79
|
4
|
+
data.tar.gz: 678fb463a6cf14d4cd11e6d6a2e0981c785f3658
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b44bc6e60ce37a6731a001f9041496ca1d315ebbdbd02404f2989238e187826a6ffe522945f53b3ace9a4a60e20d473548b8f006af0435a92354c3cd8b2b1ece
|
7
|
+
data.tar.gz: 5c88605525be9902a6f25ddc1aa0f77c0f8871968827e0c1bdd271a3490aef8ee8cef639f6a0d8c8d9268c32847d0daa0e2ce60894aa03e0c7f7bbeab5965a88
|
data/README.md
CHANGED
@@ -22,9 +22,15 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
Usage: noter [options]
|
24
24
|
-f, --file FILE Create a note using the given file
|
25
|
+
-g, --grep STRING Only show files that contain a specific string
|
25
26
|
-l, --one-line Show first line of each note file
|
26
|
-
-n, --name Show first line of each note file, with filename
|
27
27
|
-m, --message MESSAGE Create a note using the given string
|
28
|
+
-n, --name Include names when showing files
|
29
|
+
--no-color Don't colorize output
|
30
|
+
-s, --search STRING Show a file with the given index
|
31
|
+
-t, --tail COUNT Show the last n files
|
32
|
+
-u, --unpaged Don't page the output
|
33
|
+
-v, --view INDEX View a file with the given index
|
28
34
|
|
29
35
|
## Contributing
|
30
36
|
|
data/bin/noter
CHANGED
@@ -25,11 +25,21 @@ class NoteRunner
|
|
25
25
|
Noter::FileMaker.new(@message).save_file
|
26
26
|
when :make_from_file
|
27
27
|
Noter::FileMaker.new.make_from_file(@filename)
|
28
|
+
when :create_with_vim
|
29
|
+
maker = Noter::FileMaker.new
|
30
|
+
filename = maker.create_empty_file
|
31
|
+
system "vim #{filename}"
|
32
|
+
else
|
33
|
+
Noter::Viewer.new(@options).show_first_lines(:with_filename => @show_names)
|
28
34
|
end
|
29
35
|
end
|
30
36
|
|
31
37
|
def run_parser
|
32
38
|
parser = OptionParser.new do |opts|
|
39
|
+
opts.on("-c", "--create", "Create a note using vim") do
|
40
|
+
@command = :create_with_vim
|
41
|
+
end
|
42
|
+
|
33
43
|
opts.on("-f", "--file FILE", "Create a note using the given file") do |filename|
|
34
44
|
@command = :make_from_file
|
35
45
|
@filename = filename
|
@@ -63,7 +73,7 @@ class NoteRunner
|
|
63
73
|
@command = :show_files
|
64
74
|
end
|
65
75
|
|
66
|
-
opts.on("-t", "--tail COUNT", "the last n files") do |count|
|
76
|
+
opts.on("-t", "--tail COUNT", "Show the last n files") do |count|
|
67
77
|
@command = :show_files
|
68
78
|
@options[:tail_count] = count
|
69
79
|
end
|
data/lib/noter.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
require_relative "noter/version"
|
2
|
+
require_relative "noter/file_maker"
|
3
|
+
require_relative "noter/note_file"
|
4
|
+
require_relative "noter/viewer"
|
5
5
|
|
6
6
|
module Noter
|
7
7
|
|
data/lib/noter/file_maker.rb
CHANGED
data/lib/noter/version.rb
CHANGED
data/lib/noter/viewer.rb
CHANGED
@@ -21,7 +21,7 @@ module Noter
|
|
21
21
|
if @grep_string
|
22
22
|
@existing_files = `grep -l #{@grep_string} #{NoteFile.dir}/*`.split("\n")
|
23
23
|
else
|
24
|
-
@existing_files = Dir.glob("#{NoteFile.dir}/*")
|
24
|
+
@existing_files = Dir.glob("#{NoteFile.dir}/*").sort
|
25
25
|
end
|
26
26
|
if @tail_count
|
27
27
|
@existing_files = @existing_files.last(@tail_count)
|
@@ -30,7 +30,7 @@ module Noter
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def show_first_lines(options = {})
|
33
|
-
existing_files.each do |filename|
|
33
|
+
existing_files.sort.reverse.each do |filename|
|
34
34
|
file = NoteFile.new(filename)
|
35
35
|
filename_string = ""
|
36
36
|
if options[:with_filename]
|
@@ -9,6 +9,25 @@ module Noter
|
|
9
9
|
describe FileMaker do
|
10
10
|
let(:maker) { FileMaker.new }
|
11
11
|
|
12
|
+
before do
|
13
|
+
allow(File).to receive(:write)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#create_empty_file" do
|
17
|
+
it "creates a new file" do
|
18
|
+
Timecop.freeze(Time.local(2014,9,20,22,14,0,0)) do
|
19
|
+
expect(File).to receive(:write).with(maker.new_filename, "")
|
20
|
+
maker.create_empty_file
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it "returns the filename" do
|
25
|
+
Timecop.freeze(Time.local(2014,9,20,22,14,0,0)) do
|
26
|
+
expect(maker.create_empty_file).to eq maker.new_filename
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
12
31
|
describe "#new_filename" do
|
13
32
|
it "generates a new filename" do
|
14
33
|
Timecop.freeze(Time.local(2014,9,20,22,14,0,0)) do
|
@@ -49,13 +68,15 @@ module Noter
|
|
49
68
|
unless Dir.exist?(maker.dir)
|
50
69
|
FileUtils.mkdir maker.dir
|
51
70
|
end
|
52
|
-
File.write("foo.txt", "some content")
|
53
71
|
end
|
54
72
|
|
55
73
|
it "saves to a file" do
|
56
|
-
|
57
|
-
|
58
|
-
|
74
|
+
filename = "foo.txt"
|
75
|
+
Timecop.freeze(Time.local(2014,9,20,22,14,0,0)) do
|
76
|
+
expect(File).to receive(:read).with(filename).and_return("some content")
|
77
|
+
expect(File).to receive(:write).with(maker.new_filename, "some content")
|
78
|
+
maker.make_from_file(filename)
|
79
|
+
end
|
59
80
|
end
|
60
81
|
end
|
61
82
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: noter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Roush
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -180,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
180
|
version: '0'
|
181
181
|
requirements: []
|
182
182
|
rubyforge_project:
|
183
|
-
rubygems_version: 2.
|
183
|
+
rubygems_version: 2.6.12
|
184
184
|
signing_key:
|
185
185
|
specification_version: 4
|
186
186
|
summary: Creates timestamped notes.
|