rbnotes 0.4.8 → 0.4.9
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/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/rbnotes/commands/list.rb +39 -2
- data/lib/rbnotes/error.rb +13 -2
- data/lib/rbnotes/utils.rb +17 -2
- 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: 4e4e20e7274cc9e4f9d013340447f7fb06a7dcf45d8536d71e6c6f456a29d310
|
4
|
+
data.tar.gz: e41d785998768d9b4655575ae5303240de437243b6349ecd4ce147a5a051359b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b2f313ceab8c9a18205189235d72f13c48b7724ba8b15e2651bfb79e1af62e55e1fc1d855eaa0b6eadb3b715e3fd85bd70fe692bbf18d706191a81532a27b0d
|
7
|
+
data.tar.gz: 430276b6461f3502e8f74463451c67a4ddfe40fe7abd5a676abbb6f0ac24980890de6f6ac22f5a7dd64827283c7b101323d4c21b6b210e8c99a577823244885f
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
7
7
|
## [Unreleased]
|
8
8
|
Nothing to record here.
|
9
9
|
|
10
|
+
## [0.4.9] - 2020-11-17
|
11
|
+
### Added
|
12
|
+
- Add a new option `--week` to the `list` command. (#67)
|
13
|
+
|
10
14
|
## [0.4.8] - 2020-11-16
|
11
15
|
### Fixed
|
12
16
|
- Fix issue #65: messy output of the `search` command.
|
data/Gemfile.lock
CHANGED
@@ -51,7 +51,34 @@ module Rbnotes::Commands
|
|
51
51
|
# execute(Array, Rbnotes::Conf or Hash) -> nil
|
52
52
|
|
53
53
|
def execute(args, conf)
|
54
|
-
|
54
|
+
@opts = {}
|
55
|
+
while args.size > 0
|
56
|
+
arg = args.shift
|
57
|
+
case arg
|
58
|
+
when "-w", "--week"
|
59
|
+
@opts[:enum_week] = true
|
60
|
+
else
|
61
|
+
args.unshift(arg)
|
62
|
+
break
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
patterns = nil
|
67
|
+
if @opts[:enum_week]
|
68
|
+
arg = args.shift || Textrepo::Timestamp.now[0, 8]
|
69
|
+
case arg.size
|
70
|
+
when "yyyymodd".size, "yyyymoddhhmiss".size, "yyyymoddhhmiss_sfx".size
|
71
|
+
stamp_str = "#{arg}000000"[0, 14]
|
72
|
+
timestamp = Textrepo::Timestamp.parse_s(stamp_str)
|
73
|
+
patterns = Rbnotes.utils.timestamp_patterns_in_week(timestamp)
|
74
|
+
else
|
75
|
+
raise InvalidTimestampPatternError,
|
76
|
+
"cannot convert to a date [%s]" % args.unshift(arg)
|
77
|
+
end
|
78
|
+
else
|
79
|
+
patterns = Rbnotes.utils.expand_keyword_in_args(args)
|
80
|
+
end
|
81
|
+
|
55
82
|
@repo = Textrepo.init(conf)
|
56
83
|
# newer stamp shoud be above
|
57
84
|
Rbnotes.utils.find_notes(patterns, @repo).each { |timestamp|
|
@@ -62,7 +89,7 @@ module Rbnotes::Commands
|
|
62
89
|
def help # :nodoc:
|
63
90
|
puts <<HELP
|
64
91
|
usage:
|
65
|
-
#{Rbnotes::NAME} list [STAMP_PATTERN|KEYWORD]
|
92
|
+
#{Rbnotes::NAME} list [-w|--week][STAMP_PATTERN|KEYWORD]
|
66
93
|
|
67
94
|
Show a list of notes. When no arguments, make a list with all notes
|
68
95
|
in the repository. When specified STAMP_PATTERN, only those match the
|
@@ -84,6 +111,16 @@ KEYWORD:
|
|
84
111
|
- "this_week" (or "tw")
|
85
112
|
- "last_week" (or "lw")
|
86
113
|
|
114
|
+
An option "--week" is also acceptable. It specifies to enumerate all
|
115
|
+
days of a week. Typically, the option is used with a STAMP_PATTERN
|
116
|
+
which specifies a date, such "20201117", then it enumerates all days
|
117
|
+
of the week which contains "17th November 2020".
|
118
|
+
|
119
|
+
A STAMP_PATTERN other than (a) and (b) causes an error if it was used
|
120
|
+
with "--week" option.
|
121
|
+
|
122
|
+
When no STAMP_PATTERN was specified with "--week" option, the output
|
123
|
+
would be as same as the KEYWORD, "this_week" was specified.
|
87
124
|
HELP
|
88
125
|
end
|
89
126
|
|
data/lib/rbnotes/error.rb
CHANGED
@@ -7,11 +7,12 @@ module Rbnotes
|
|
7
7
|
# :stopdoc:
|
8
8
|
|
9
9
|
module ErrMsg
|
10
|
-
MISSING_ARGUMENT = "
|
11
|
-
MISSING_TIMESTAMP = "
|
10
|
+
MISSING_ARGUMENT = "Missing argument: %s"
|
11
|
+
MISSING_TIMESTAMP = "Missing timestamp: %s"
|
12
12
|
NO_EDITOR = "No editor is available: %s"
|
13
13
|
PROGRAM_ABORT = "External program was aborted: %s"
|
14
14
|
UNKNOWN_KEYWORD = "Unknown keyword: %s"
|
15
|
+
INVALID_TIMESTAMP_PATTERN = "Invalid timestamp pattern: %s"
|
15
16
|
end
|
16
17
|
|
17
18
|
# :startdoc:
|
@@ -64,4 +65,14 @@ module Rbnotes
|
|
64
65
|
super(ErrMsg::UNKNOWN_KEYWORD % keyword)
|
65
66
|
end
|
66
67
|
end
|
68
|
+
|
69
|
+
##
|
70
|
+
# An error raised when an invalid timestamp pattern was specified.
|
71
|
+
|
72
|
+
class InvalidTimestampPatternError < Error
|
73
|
+
def initialize(pattern)
|
74
|
+
super(ErrMsg::INVALID_TIMESTAMP_PATTERN % pattern)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
67
78
|
end
|
data/lib/rbnotes/utils.rb
CHANGED
@@ -227,6 +227,17 @@ module Rbnotes
|
|
227
227
|
}.flatten.sort{ |a, b| b <=> a }.uniq
|
228
228
|
end
|
229
229
|
|
230
|
+
##
|
231
|
+
# Enumerates all timestamp patterns in a week which contains a
|
232
|
+
# given timestamp as a day of the week.
|
233
|
+
#
|
234
|
+
# :call-seq:
|
235
|
+
# timestamp_patterns_in_week(timestamp) -> [Array of Strings]
|
236
|
+
|
237
|
+
def timestamp_patterns_in_week(timestamp)
|
238
|
+
dates_in_week(start_date_in_the_week(timestamp.time)).map { |date| timestamp_pattern(date) }
|
239
|
+
end
|
240
|
+
|
230
241
|
# :stopdoc:
|
231
242
|
|
232
243
|
private
|
@@ -268,14 +279,18 @@ module Rbnotes
|
|
268
279
|
end
|
269
280
|
|
270
281
|
def start_date_in_this_week
|
271
|
-
|
272
|
-
Date.new(today.year, today.mon, today.day).prev_day(wday(today))
|
282
|
+
start_date_in_the_week(Time.now)
|
273
283
|
end
|
274
284
|
|
275
285
|
def start_date_in_last_week
|
276
286
|
start_date_in_this_week.prev_day(7)
|
277
287
|
end
|
278
288
|
|
289
|
+
def start_date_in_the_week(time)
|
290
|
+
parts = [:year, :mon, :day].map { |sym| time.send(sym) }
|
291
|
+
Date.new(*parts).prev_day(wday(time))
|
292
|
+
end
|
293
|
+
|
279
294
|
def wday(time)
|
280
295
|
(time.wday - 1) % 7
|
281
296
|
end
|
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.9
|
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-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: textrepo
|