rbnotes 0.4.19 → 0.4.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +1 -1
- data/CHANGELOG.md +5 -1
- data/Gemfile +1 -1
- data/Gemfile.lock +10 -10
- data/exe/rbnotes +1 -0
- data/lib/rbnotes/commands/export.rb +1 -0
- data/lib/rbnotes/commands/list.rb +9 -3
- data/lib/rbnotes/commands/pick.rb +2 -1
- data/lib/rbnotes/commands/show.rb +4 -3
- data/lib/rbnotes/conf.rb +7 -0
- data/lib/rbnotes/utils.rb +51 -5
- data/lib/rbnotes/version.rb +2 -2
- data/rbnotes.gemspec +2 -2
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c983ec2e16d7e384a8b1ba50cd79ed327a1b69cf415c471becfb19dfd71ba5a2
|
4
|
+
data.tar.gz: 2147e0b2c7564fc18f664dbd39ee597dbb642a8e6b42575d71078c5cc85cc8c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2389e447037b2b9a5a9f2136b435c44cc86bc8f1b84da057ffe9b1474132564034baf539e946dc74aeafa7ba609cd81bd32c1036c60991b1959e691523a3ad9
|
7
|
+
data.tar.gz: 257fd944e264ae91780b63a9b37bfca1658943e2098ca4a007e49f05b875e4c496d475e10299496c4d397ffaa6cefe23549267bd3a0a07c8a5d6f658a37e2941
|
data/.github/workflows/main.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -5,7 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/)
|
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/).
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
|
-
-
|
8
|
+
- Fix issue #133: some tests fail.
|
9
|
+
|
10
|
+
## [0.4.20] - 2022-12-03
|
11
|
+
### Added
|
12
|
+
- Add a new keyword, `recent`. (#131)
|
9
13
|
|
10
14
|
## [0.4.19] - 2021-05-24
|
11
15
|
### Added
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,26 +1,26 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rbnotes (0.4.
|
5
|
-
textrepo (~> 0.5.
|
6
|
-
unicode-display_width (~> 1.
|
4
|
+
rbnotes (0.4.20)
|
5
|
+
textrepo (~> 0.5.9)
|
6
|
+
unicode-display_width (~> 1.8)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
minitest (5.
|
12
|
-
rake (13.0.
|
13
|
-
textrepo (0.5.
|
14
|
-
unicode-display_width (1.
|
11
|
+
minitest (5.16.3)
|
12
|
+
rake (13.0.6)
|
13
|
+
textrepo (0.5.9)
|
14
|
+
unicode-display_width (1.8.0)
|
15
15
|
|
16
16
|
PLATFORMS
|
17
|
-
|
17
|
+
x86_64-darwin-22
|
18
18
|
|
19
19
|
DEPENDENCIES
|
20
20
|
minitest (~> 5.0)
|
21
21
|
rake (~> 13.0)
|
22
22
|
rbnotes!
|
23
|
-
textrepo (~> 0.5.
|
23
|
+
textrepo (~> 0.5.9)
|
24
24
|
|
25
25
|
BUNDLED WITH
|
26
|
-
2.
|
26
|
+
2.3.11
|
data/exe/rbnotes
CHANGED
@@ -33,6 +33,7 @@ module Rbnotes::Commands
|
|
33
33
|
# - "last_week" (or "lw")
|
34
34
|
# - "this_month" (or "tm")
|
35
35
|
# - "last_month" (or "lm")
|
36
|
+
# - "recent" (or "re")
|
36
37
|
# - "all"
|
37
38
|
#
|
38
39
|
# Here is several examples of timestamp patterns.
|
@@ -67,9 +68,11 @@ module Rbnotes::Commands
|
|
67
68
|
|
68
69
|
utils = Rbnotes.utils
|
69
70
|
patterns = utils.read_timestamp_patterns(args, enum_week: @opts[:enum_week])
|
70
|
-
|
71
71
|
repo = Textrepo.init(conf)
|
72
|
-
|
72
|
+
|
73
|
+
num_of_notes = utils.specified_recent?(args) ? conf[:number_of_recent_notes] : 0
|
74
|
+
stamps = utils.find_notes(patterns, repo, num_of_notes)
|
75
|
+
|
73
76
|
output = []
|
74
77
|
if @opts[:verbose]
|
75
78
|
collect_timestamps_by_date(stamps).each { |date, timestamps|
|
@@ -146,9 +149,12 @@ KEYWORD:
|
|
146
149
|
- "last_week" (or "lw")
|
147
150
|
- "this_month" (or "tm")
|
148
151
|
- "last_month" (or "lm")
|
152
|
+
- "recent" (or "re")
|
149
153
|
- "all"
|
150
154
|
|
151
|
-
The keyword, "
|
155
|
+
The keyword, "recent" specifies to enumerate recent notes in the
|
156
|
+
repository. The keyword, "all" specifies to enumerate all notes in
|
157
|
+
the repository.
|
152
158
|
|
153
159
|
HELP
|
154
160
|
end
|
@@ -25,7 +25,8 @@ module Rbnotes::Commands
|
|
25
25
|
|
26
26
|
repo = Textrepo.init(conf)
|
27
27
|
|
28
|
-
|
28
|
+
num_of_notes = utils.specified_recent?(args) ? conf[:number_of_recent_notes] : 0
|
29
|
+
stamps = utils.find_notes(patterns, repo, num_of_notes)
|
29
30
|
return if stamps.empty?
|
30
31
|
|
31
32
|
list = []
|
@@ -22,7 +22,7 @@ module Rbnotes::Commands
|
|
22
22
|
parse_opts(args)
|
23
23
|
|
24
24
|
repo = Textrepo.init(conf)
|
25
|
-
stamps = read_timestamps(args, repo)
|
25
|
+
stamps = read_timestamps(args, repo, conf)
|
26
26
|
return if stamps.empty?
|
27
27
|
|
28
28
|
content = stamps.map { |stamp|
|
@@ -98,13 +98,14 @@ HELP
|
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
101
|
-
def read_timestamps(args, repo)
|
101
|
+
def read_timestamps(args, repo, conf)
|
102
102
|
utils = Rbnotes.utils
|
103
103
|
if args.empty?
|
104
104
|
stamps = utils.read_multiple_timestamps(args)
|
105
105
|
else
|
106
106
|
patterns = utils.read_timestamp_patterns(args)
|
107
|
-
|
107
|
+
num_of_notes = utils.specified_recent?(args) ? conf[:number_of_recent_notes] : 0
|
108
|
+
stamps = utils.find_notes(patterns, repo, num_of_notes)
|
108
109
|
end
|
109
110
|
stamps
|
110
111
|
end
|
data/lib/rbnotes/conf.rb
CHANGED
@@ -31,6 +31,12 @@ module Rbnotes
|
|
31
31
|
|
32
32
|
DIRNAME_COMMON_CONF = ".config"
|
33
33
|
|
34
|
+
##
|
35
|
+
# Name of the number of notes to enumerate. The values is
|
36
|
+
# referred only to enumerate the recent notes.
|
37
|
+
|
38
|
+
NUMBER_OF_RECENT_NOTES = 10
|
39
|
+
|
34
40
|
def initialize(path = nil) # :nodoc:
|
35
41
|
@conf = {}
|
36
42
|
|
@@ -90,6 +96,7 @@ module Rbnotes
|
|
90
96
|
:repository_type => :file_system,
|
91
97
|
:repository_name => "notes",
|
92
98
|
:repository_base => "~",
|
99
|
+
:number_of_recent_notes => 10,
|
93
100
|
}
|
94
101
|
|
95
102
|
MODE_POSTFIX = {
|
data/lib/rbnotes/utils.rb
CHANGED
@@ -125,6 +125,8 @@ module Rbnotes
|
|
125
125
|
# read_timestamp(args) -> String
|
126
126
|
|
127
127
|
def read_timestamp(args)
|
128
|
+
args = args.dup
|
129
|
+
|
128
130
|
str = args.shift || read_arg($stdin)
|
129
131
|
raise NoArgumentError if str.nil?
|
130
132
|
|
@@ -163,6 +165,9 @@ module Rbnotes
|
|
163
165
|
# Commands::Pick#execute.
|
164
166
|
#
|
165
167
|
def read_timestamp_patterns(args, enum_week: false)
|
168
|
+
args = args.dup
|
169
|
+
|
170
|
+
validate_arguments(args)
|
166
171
|
patterns = nil
|
167
172
|
if enum_week
|
168
173
|
args.unshift(Time.now.strftime("%Y%m%d")) if args.size == 0
|
@@ -254,12 +259,13 @@ module Rbnotes
|
|
254
259
|
# expand_keyword_in_args(Array of Strings) -> Array of Strings
|
255
260
|
#
|
256
261
|
def expand_keyword_in_args(args)
|
262
|
+
args = args.dup
|
257
263
|
patterns = []
|
258
264
|
while args.size > 0
|
259
265
|
arg = args.shift
|
260
|
-
if arg == "all"
|
266
|
+
if arg == "all" or arg == "recent" or arg == "re"
|
261
267
|
return [nil]
|
262
|
-
elsif
|
268
|
+
elsif valid_keyword?(arg)
|
263
269
|
patterns.concat(expand_keyword(arg))
|
264
270
|
else
|
265
271
|
patterns << arg
|
@@ -304,13 +310,27 @@ module Rbnotes
|
|
304
310
|
# given repository. Returns an Array contains Timestamp objects.
|
305
311
|
# The returned Array is sorted by Timestamp.
|
306
312
|
#
|
313
|
+
# When a positive number was specified as the 3rd argument, the
|
314
|
+
# number was used as the limitation count of enumerated notes.
|
315
|
+
#
|
307
316
|
# :call-seq:
|
308
|
-
# find_notes(Array of timestamp patterns, Textrepo::Repository)
|
317
|
+
# find_notes(Array of timestamp patterns, Textrepo::Repository, Integer)
|
309
318
|
|
310
|
-
def find_notes(timestamp_patterns, repo)
|
311
|
-
timestamp_patterns.map { |pat|
|
319
|
+
def find_notes(timestamp_patterns, repo, num_of_notes = 0)
|
320
|
+
notes = timestamp_patterns.map { |pat|
|
312
321
|
repo.entries(pat)
|
313
322
|
}.flatten.sort{ |a, b| b <=> a }.uniq
|
323
|
+
|
324
|
+
if num_of_notes > 0
|
325
|
+
notes[0,num_of_notes]
|
326
|
+
else
|
327
|
+
notes
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
def specified_recent?(args)
|
332
|
+
validate_arguments(args)
|
333
|
+
args.include?("recent") or args.include?("re")
|
314
334
|
end
|
315
335
|
|
316
336
|
# :stopdoc:
|
@@ -360,6 +380,30 @@ module Rbnotes
|
|
360
380
|
str
|
361
381
|
end
|
362
382
|
|
383
|
+
##
|
384
|
+
# Validates arguments as timestamp strings or keywords. If all
|
385
|
+
# arguments are valid as timestamp strings or keywords, do
|
386
|
+
# nothing. Otherwise, raise an error.
|
387
|
+
#
|
388
|
+
# :call-seq:
|
389
|
+
# validate_arguments(an array of strings) -> nil
|
390
|
+
#
|
391
|
+
def validate_arguments(args)
|
392
|
+
args.each { |arg|
|
393
|
+
unless valid_keyword?(arg) or valid_timestamp_pattern?(arg)
|
394
|
+
raise InvalidTimestampPatternError, arg
|
395
|
+
end
|
396
|
+
}
|
397
|
+
end
|
398
|
+
|
399
|
+
def valid_keyword?(arg)
|
400
|
+
KEYWORDS.include?(arg)
|
401
|
+
end
|
402
|
+
|
403
|
+
def valid_timestamp_pattern?(arg)
|
404
|
+
!/[^_\d]/.match(arg)
|
405
|
+
end
|
406
|
+
|
363
407
|
##
|
364
408
|
# Expands a keyword to timestamp strings.
|
365
409
|
#
|
@@ -388,6 +432,8 @@ module Rbnotes
|
|
388
432
|
end
|
389
433
|
|
390
434
|
KEYWORDS = %w(
|
435
|
+
all
|
436
|
+
recent re
|
391
437
|
today to yesterday ye
|
392
438
|
this_week tw last_week lw
|
393
439
|
this_month tm last_month lm
|
data/lib/rbnotes/version.rb
CHANGED
data/rbnotes.gemspec
CHANGED
@@ -25,6 +25,6 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
26
|
spec.require_paths = ["lib"]
|
27
27
|
|
28
|
-
spec.add_dependency "textrepo", "~> 0.5.
|
29
|
-
spec.add_dependency "unicode-display_width", "~> 1.
|
28
|
+
spec.add_dependency "textrepo", "~> 0.5.9"
|
29
|
+
spec.add_dependency "unicode-display_width", "~> 1.8"
|
30
30
|
end
|
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.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mnbi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: textrepo
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.5.
|
19
|
+
version: 0.5.9
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.5.
|
26
|
+
version: 0.5.9
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: unicode-display_width
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.8'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
40
|
+
version: '1.8'
|
41
41
|
description: Rbnotes allows you to write a note into a single repository.
|
42
42
|
email:
|
43
43
|
- mnbi@users.noreply.github.com
|
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
106
|
- !ruby/object:Gem::Version
|
107
107
|
version: '0'
|
108
108
|
requirements: []
|
109
|
-
rubygems_version: 3.
|
109
|
+
rubygems_version: 3.3.11
|
110
110
|
signing_key:
|
111
111
|
specification_version: 4
|
112
112
|
summary: A simple utility to write a note.
|