rbnotes 0.4.6 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +1 -1
- data/exe/rbnotes +5 -0
- data/lib/rbnotes/commands/search.rb +43 -4
- data/lib/rbnotes/utils.rb +3 -4
- data/lib/rbnotes/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6625e8e9365a5c69cb9fd1f9d227e04247edda6ddbb9f5d3d442e0e7f87ac96
|
4
|
+
data.tar.gz: 5b00c1ecef74b47957112de785c57e249aa35b07c8809401872f75dec392f4c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d6e047ed738940dcbadd14bc8c176c486404951e4349eebe82c8bfbd92c1ad09fe996adb7c5db8bfdbf20ca364b6cebabd5dad3a2edbd9a597a2ad373a658ec
|
7
|
+
data.tar.gz: 504add631c2960e0b12eabce1075ba6d90745db531ebb95b1721a46bee236d7906d489169e0161d9e6213627cd28ceea59a8db1bb0e9c3f5ab0ba8878befb3c7
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
7
7
|
## [Unreleased]
|
8
8
|
Nothing to record here.
|
9
9
|
|
10
|
+
## [0.4.7] - 2020-11-15
|
11
|
+
### Changed
|
12
|
+
- Beautify output of the `search` command. (#63)
|
13
|
+
|
14
|
+
### Fixed
|
15
|
+
- Fix issue #61: `list` command fails in pipeline.
|
16
|
+
|
10
17
|
## [0.4.6] - 2020-11-13
|
11
18
|
### Added
|
12
19
|
- Add a new command `pick` to select a note with picker program. (#59)
|
data/Gemfile.lock
CHANGED
data/exe/rbnotes
CHANGED
@@ -48,6 +48,11 @@ app = App.new
|
|
48
48
|
begin
|
49
49
|
app.parse_global_options(ARGV)
|
50
50
|
app.run(ARGV)
|
51
|
+
rescue Errno::EPIPE => e
|
52
|
+
# Fix issue #61: When the pipeline which rbnotes connects is
|
53
|
+
# discarded by the other program, the execption was raised. It does
|
54
|
+
# not end abnormally for rbnotes. So, just ignores the exception.
|
55
|
+
exit 0
|
51
56
|
rescue MissingArgumentError, MissingTimestampError,
|
52
57
|
NoEditorError, ProgramAbortError,
|
53
58
|
Textrepo::InvalidTimestampStringError,
|
@@ -39,11 +39,8 @@ module Rbnotes::Commands
|
|
39
39
|
result = repo.search(pattern, timestamp_pattern)
|
40
40
|
rescue Textrepo::InvalidSearchResultError => e
|
41
41
|
puts e.message
|
42
|
-
else
|
43
|
-
result.each { |stamp, num, match|
|
44
|
-
puts "#{stamp}:#{num}:#{match}"
|
45
|
-
}
|
46
42
|
end
|
43
|
+
print_search_result(result.map{ |e| SearchEntry.new(*e) })
|
47
44
|
end
|
48
45
|
|
49
46
|
def help # :nodoc:
|
@@ -63,5 +60,47 @@ STAMP_PATTERN must be:
|
|
63
60
|
(e) date part only: "1030"
|
64
61
|
HELP
|
65
62
|
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
# Each entry of search result is:
|
67
|
+
#
|
68
|
+
# [<timestamp>, <line_number>, <matched_text>]
|
69
|
+
#
|
70
|
+
# The sort must be done in;
|
71
|
+
#
|
72
|
+
# - descending order for <timestamp>,
|
73
|
+
# - ascending ordier for <line_number>.
|
74
|
+
#
|
75
|
+
|
76
|
+
SearchEntry = Struct.new(:timestamp, :line_number, :matched_text) {
|
77
|
+
def timestamp_size
|
78
|
+
timestamp.to_s.size
|
79
|
+
end
|
80
|
+
}
|
81
|
+
|
82
|
+
def print_search_result(entries)
|
83
|
+
maxcol_stamp = entries.map(&:timestamp_size).max
|
84
|
+
maxcol_num = entries.map(&:line_number).max
|
85
|
+
|
86
|
+
sort(entries).each { |e|
|
87
|
+
stamp_display = "%- *s" % [maxcol_stamp, e.timestamp]
|
88
|
+
num_display = "%*d" % [maxcol_num, e.line_number]
|
89
|
+
|
90
|
+
puts "#{stamp_display}: #{num_display}: #{e.matched_text}"
|
91
|
+
}
|
92
|
+
end
|
93
|
+
|
94
|
+
def sort(search_result)
|
95
|
+
search_result.sort { |a, b|
|
96
|
+
stamp_comparison = (b.timestamp <=> a.timestamp)
|
97
|
+
if stamp_comparison == 0
|
98
|
+
a.line_number <=> b.line_number
|
99
|
+
else
|
100
|
+
stamp_comparison
|
101
|
+
end
|
102
|
+
}
|
103
|
+
end
|
104
|
+
|
66
105
|
end
|
67
106
|
end
|
data/lib/rbnotes/utils.rb
CHANGED
@@ -203,11 +203,12 @@ module Rbnotes
|
|
203
203
|
def make_headline(timestamp, text)
|
204
204
|
_, column = IO.console_size
|
205
205
|
delimiter = ": "
|
206
|
-
|
206
|
+
timestamp_width = timestamp.to_s.size
|
207
|
+
subject_width = column - timestamp_width - delimiter.size - 1
|
207
208
|
|
208
209
|
subject = remove_heading_markup(text[0])
|
209
210
|
|
210
|
-
ts_part = "#{timestamp.to_s} "[0..(
|
211
|
+
ts_part = "#{timestamp.to_s} "[0..(timestamp_width - 1)]
|
211
212
|
sj_part = truncate_str(subject, subject_width)
|
212
213
|
|
213
214
|
ts_part + delimiter + sj_part
|
@@ -285,8 +286,6 @@ module Rbnotes
|
|
285
286
|
dates
|
286
287
|
end
|
287
288
|
|
288
|
-
TIMESTAMP_STR_MAX_WIDTH = "yyyymoddhhmiss_sfx".size
|
289
|
-
|
290
289
|
def truncate_str(str, size)
|
291
290
|
count = 0
|
292
291
|
result = ""
|
data/lib/rbnotes/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbnotes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mnbi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: textrepo
|