rbnotes 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/Gemfile.lock +1 -1
- data/lib/rbnotes/commands.rb +1 -1
- data/lib/rbnotes/commands/list.rb +55 -6
- 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: a04bd4d45d7c2f4227f355672baa860602ae3b9e481e7a384daf4283f4ad6754
|
4
|
+
data.tar.gz: bc707b20ea91ab655f6e355026164c01844c82ea3869c18fd5ca1040c968934d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d93df0df9e002a8bae26b7d9e1e89acf19d84551635d58f3ec747c78f3764ac004a784977a3d9940783a8b4661b2caafd2b55502644bca4bb69947d91593bd79
|
7
|
+
data.tar.gz: 913c240b04215cb5502146f4d1edcd5c1ddc273de31baace3f0d8dff600dcf759e5983aee5cce72fb5079dc26e1a22b43c0aad46e1cc766c4127697090fb0037
|
data/CHANGELOG.md
CHANGED
@@ -7,9 +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.4] - 2020-11-09
|
11
|
+
###
|
12
|
+
- Add a feature to use a keyword as an argument for `list`. (#47)
|
13
|
+
|
10
14
|
## [0.4.3] - 2020-11-08
|
11
15
|
### Added
|
12
|
-
- Add a new command `export` to write out a note into a file (#51)
|
16
|
+
- Add a new command `export` to write out a note into a file. (#51)
|
13
17
|
- Add individual help for each command. (#42)
|
14
18
|
|
15
19
|
### Fixed
|
data/Gemfile.lock
CHANGED
data/lib/rbnotes/commands.rb
CHANGED
@@ -61,7 +61,7 @@ Example usage:
|
|
61
61
|
#{Rbnotes::NAME} delete [TIMESTAMP]
|
62
62
|
#{Rbnotes::NAME} export [TIMESTAMP [FILENAME]]
|
63
63
|
#{Rbnotes::NAME} import FILE
|
64
|
-
#{Rbnotes::NAME} list [STAMP_PATTERN]
|
64
|
+
#{Rbnotes::NAME} list [STAMP_PATTERN|KEYWORD]
|
65
65
|
#{Rbnotes::NAME} search PATTERN [STAMP_PATTERN]
|
66
66
|
#{Rbnotes::NAME} show [TIMESTAMP]
|
67
67
|
#{Rbnotes::NAME} update [TIMESTAMP]
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require "date"
|
1
2
|
require "unicode/display_width"
|
2
3
|
require "io/console/size"
|
3
4
|
|
@@ -20,8 +21,7 @@ module Rbnotes::Commands
|
|
20
21
|
# timestamp pattern is a string which would match several
|
21
22
|
# Timestamp objects.
|
22
23
|
#
|
23
|
-
# Here is
|
24
|
-
# several examples of timestamp patterns.
|
24
|
+
# Here is several examples of timestamp patterns.
|
25
25
|
#
|
26
26
|
# "20201027093600_012": a complete string to represent a timestamp
|
27
27
|
# - this pattern would match exactly one Timestamp object
|
@@ -43,11 +43,28 @@ module Rbnotes::Commands
|
|
43
43
|
# execute(Array, Rbnotes::Conf or Hash) -> nil
|
44
44
|
|
45
45
|
def execute(args, conf)
|
46
|
-
|
46
|
+
arg = args.shift
|
47
|
+
patterns = []
|
48
|
+
|
49
|
+
case arg.to_s
|
50
|
+
when "today", "to"
|
51
|
+
patterns << Textrepo::Timestamp.new(Time.now).to_s[0..7]
|
52
|
+
when "yesterday", "ye"
|
53
|
+
t = Time.now
|
54
|
+
patterns << Date.new(t.year, t.mon, t.day).prev_day.strftime("%Y%m%d")
|
55
|
+
when "this_week", "tw"
|
56
|
+
patterns.concat(dates_in_this_week)
|
57
|
+
when "last_week", "lw"
|
58
|
+
patterns.concat(dates_in_last_week)
|
59
|
+
else
|
60
|
+
patterns << arg
|
61
|
+
end
|
47
62
|
|
48
63
|
@repo = Textrepo.init(conf)
|
64
|
+
stamps = patterns.map { |pat|
|
65
|
+
@repo.entries(pat).sort{|a, b| b <=> a}
|
66
|
+
}.flatten
|
49
67
|
# newer stamp shoud be above
|
50
|
-
stamps = @repo.entries(pattern).sort{|a, b| b <=> a}
|
51
68
|
stamps.each { |timestamp|
|
52
69
|
puts make_headline(timestamp)
|
53
70
|
}
|
@@ -56,11 +73,12 @@ module Rbnotes::Commands
|
|
56
73
|
def help # :nodoc:
|
57
74
|
puts <<HELP
|
58
75
|
usage:
|
59
|
-
#{Rbnotes::NAME} list [STAMP_PATTERN]
|
76
|
+
#{Rbnotes::NAME} list [STAMP_PATTERN|KEYWORD]
|
60
77
|
|
61
78
|
Show a list of notes. When no arguments, make a list with all notes
|
62
79
|
in the repository. When specified STAMP_PATTERN, only those match the
|
63
|
-
pattern are listed.
|
80
|
+
pattern are listed. Instead of STAMP_PATTERN, some KEYWORDs could be
|
81
|
+
used.
|
64
82
|
|
65
83
|
STAMP_PATTERN must be:
|
66
84
|
|
@@ -69,6 +87,14 @@ STAMP_PATTERN must be:
|
|
69
87
|
(c) year and month part: "202010"
|
70
88
|
(d) year part only: "2020"
|
71
89
|
(e) date part only: "1030"
|
90
|
+
|
91
|
+
KEYWORD:
|
92
|
+
|
93
|
+
- "today" (or "to")
|
94
|
+
- "yeasterday" (or "ye")
|
95
|
+
- "this_week" (or "tw")
|
96
|
+
- "last_week" (or "lw")
|
97
|
+
|
72
98
|
HELP
|
73
99
|
end
|
74
100
|
|
@@ -119,6 +145,29 @@ HELP
|
|
119
145
|
str.sub(/^#+ +/, '')
|
120
146
|
end
|
121
147
|
|
148
|
+
# week day for Monday start calendar
|
149
|
+
def wday(time)
|
150
|
+
(time.wday - 1) % 7
|
151
|
+
end
|
152
|
+
|
153
|
+
def dates_in_this_week
|
154
|
+
to = Time.now
|
155
|
+
start = Date.new(to.year, to.mon, to.day).prev_day(wday(to))
|
156
|
+
dates_in_week(start)
|
157
|
+
end
|
158
|
+
|
159
|
+
def dates_in_last_week
|
160
|
+
to = Time.now
|
161
|
+
start_of_this_week = Date.new(to.year, to.mon, to.day).prev_day(wday(to))
|
162
|
+
dates_in_week(start_of_this_week.prev_day(7))
|
163
|
+
end
|
164
|
+
|
165
|
+
def dates_in_week(start_date)
|
166
|
+
dates = [start_date]
|
167
|
+
1.upto(6) { |i| dates << start_date.next_day(i) }
|
168
|
+
dates.map { |d| d.strftime("%Y%m%d") }
|
169
|
+
end
|
170
|
+
|
122
171
|
# :startdoc:
|
123
172
|
end
|
124
173
|
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.4
|
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-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: textrepo
|