rbnotes 0.4.19 → 0.4.21
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 +4 -6
- data/.gitignore +1 -0
- data/CHANGELOG.md +12 -1
- data/Gemfile +3 -3
- data/LICENSE +1 -1
- data/README.md +0 -1
- 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 +5 -3
- metadata +22 -9
- data/Gemfile.lock +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29c624241fbfb8377565617bbb8313a225bcade6dbbad9bc22711b1edc44588e
|
4
|
+
data.tar.gz: d91950eeeba599c6807860ebfd0c9dbaab235441bced620c1441abc7dbd710e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 992d4ac0aa2c1cef5413ecf6229569f9e080c38a439e548c7728b7e569f8e4e09521d3278041342edfa4e19a1bda2b2f90ce6597683da177cf25bff16baec04c
|
7
|
+
data.tar.gz: f9bc08bf6eab09f7183e9d0a8aeb4708ba660a99ceca3867d037f64f1602258aec01be11e2d71a35a78f2684d8f65074c356fe2a3caae2848f43020cb6d888d5
|
data/.github/workflows/main.yml
CHANGED
@@ -6,13 +6,11 @@ jobs:
|
|
6
6
|
build:
|
7
7
|
runs-on: ubuntu-latest
|
8
8
|
steps:
|
9
|
-
- uses: actions/checkout@
|
9
|
+
- uses: actions/checkout@v4
|
10
10
|
- name: Set up Ruby
|
11
11
|
uses: ruby/setup-ruby@v1
|
12
12
|
with:
|
13
|
-
ruby-version: 3.
|
13
|
+
ruby-version: 3.3
|
14
|
+
bundler-cache: true
|
14
15
|
- name: Run the default task
|
15
|
-
run:
|
16
|
-
gem install bundler -v 2.2.3
|
17
|
-
bundle install
|
18
|
-
bundle exec rake
|
16
|
+
run: bundle exec rake
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -5,7 +5,18 @@ 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
|
-
- (nothing
|
8
|
+
- (nothing)
|
9
|
+
|
10
|
+
## [0.4.21] - 2022-11-03
|
11
|
+
- Use ruby 3.3.5.
|
12
|
+
- Remove the codefactor badge from `README.md`
|
13
|
+
- Add copyright year (2024) to `LICENSE`.
|
14
|
+
- Fix issue #135: incomplete timestamp patterns are acceptable.
|
15
|
+
- Fix issue #133: some tests fail.
|
16
|
+
|
17
|
+
## [0.4.20] - 2022-12-03
|
18
|
+
### Added
|
19
|
+
- Add a new keyword, `recent`. (#131)
|
9
20
|
|
10
21
|
## [0.4.19] - 2021-05-24
|
11
22
|
### Added
|
data/Gemfile
CHANGED
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# Rbnotes
|
2
2
|
|
3
3
|
[![Build Status](https://github.com/mnbi/rbnotes/workflows/Build/badge.svg)](https://github.com/mnbi/rbnotes/actions?query=workflow%3A"Build")
|
4
|
-
[![CodeFactor](https://www.codefactor.io/repository/github/mnbi/rbnotes/badge)](https://www.codefactor.io/repository/github/mnbi/rbnotes)
|
5
4
|
|
6
5
|
Rbnotes is a simple utility to write a note in the single repository.
|
7
6
|
|
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
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.description = %q{Rbnotes allows you to write a note into a single repository.}
|
11
11
|
spec.homepage = "https://github.com/mnbi/rbnotes"
|
12
12
|
spec.license = "MIT"
|
13
|
-
spec.required_ruby_version = Gem::Requirement.new(">=
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 3.3.0")
|
14
14
|
|
15
15
|
spec.metadata["homepage_uri"] = spec.homepage
|
16
16
|
spec.metadata["source_code_uri"] = "https://github.com/mnbi/rbnotes"
|
@@ -25,6 +25,8 @@ 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", "~>
|
28
|
+
spec.add_dependency "textrepo", "~> 0.5.10"
|
29
|
+
spec.add_dependency "unicode-display_width", "~> 2.6"
|
30
|
+
|
31
|
+
spec.add_development_dependency "bundler", "~> 2.5"
|
30
32
|
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.21
|
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: 2024-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: textrepo
|
@@ -16,28 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.5.
|
19
|
+
version: 0.5.10
|
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.10
|
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: '
|
33
|
+
version: '2.6'
|
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: '
|
40
|
+
version: '2.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.5'
|
41
55
|
description: Rbnotes allows you to write a note into a single repository.
|
42
56
|
email:
|
43
57
|
- mnbi@users.noreply.github.com
|
@@ -50,7 +64,6 @@ files:
|
|
50
64
|
- ".gitignore"
|
51
65
|
- CHANGELOG.md
|
52
66
|
- Gemfile
|
53
|
-
- Gemfile.lock
|
54
67
|
- LICENSE
|
55
68
|
- README.md
|
56
69
|
- Rakefile
|
@@ -99,14 +112,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
99
112
|
requirements:
|
100
113
|
- - ">="
|
101
114
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
115
|
+
version: 3.3.0
|
103
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
117
|
requirements:
|
105
118
|
- - ">="
|
106
119
|
- !ruby/object:Gem::Version
|
107
120
|
version: '0'
|
108
121
|
requirements: []
|
109
|
-
rubygems_version: 3.
|
122
|
+
rubygems_version: 3.5.18
|
110
123
|
signing_key:
|
111
124
|
specification_version: 4
|
112
125
|
summary: A simple utility to write a note.
|
data/Gemfile.lock
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
rbnotes (0.4.19)
|
5
|
-
textrepo (~> 0.5.8)
|
6
|
-
unicode-display_width (~> 1.7)
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: https://rubygems.org/
|
10
|
-
specs:
|
11
|
-
minitest (5.14.4)
|
12
|
-
rake (13.0.3)
|
13
|
-
textrepo (0.5.8)
|
14
|
-
unicode-display_width (1.7.0)
|
15
|
-
|
16
|
-
PLATFORMS
|
17
|
-
ruby
|
18
|
-
|
19
|
-
DEPENDENCIES
|
20
|
-
minitest (~> 5.0)
|
21
|
-
rake (~> 13.0)
|
22
|
-
rbnotes!
|
23
|
-
textrepo (~> 0.5.8)
|
24
|
-
|
25
|
-
BUNDLED WITH
|
26
|
-
2.2.15
|