rbnotes 0.4.17 → 0.4.18

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 65aec23d03fa8672d8aada42a39d6d0f97643ca3481050926ae11aa2a05dc433
4
- data.tar.gz: c28a9209d1374f351a87e0a0a696312bdc37f70b2d55c97e5e2920703c83643b
3
+ metadata.gz: 8a831d67abfd0bae05156f047b6baf44428bc4940058e43bfb9825b5d91c4177
4
+ data.tar.gz: 7fb70e39e9feb75edfabe3461697ddfb0145cf449205c25068471687952908d0
5
5
  SHA512:
6
- metadata.gz: 285b05aee90d97dcf11fca4d753e2265ae11253d504e9a787b34f4d64a74e47486cd6a127d652f6f746b934f90c6c699342ea8621b13ef06da2816ef3f91eb98
7
- data.tar.gz: 581f9192f023a4a50f43ea475b72aa5a145c054520c6b25f9a59c2f758f980c81259df788c34c47c08b7a901b55f6f77ae60e39de0e5e230727d990fcd9f54d3
6
+ metadata.gz: 7ea3b1ea6517130e5ba5ece651da8f3e30f1013aaa40aa375ad16fb09a7e07a033c7da4e59a721fade178ed4720cf804cb60cc843ea42cbcb177fdf81f947f01
7
+ data.tar.gz: 6a19760bdecd4b967717c30bed0974a8098d5b3f9e9df9a90bd81cd6b1498a6ba226f2e5654547f1ec67da9beb3d54c740ab9895163d8488df9801b74539f8aa
data/CHANGELOG.md CHANGED
@@ -5,7 +5,21 @@ 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 to record here.
8
+ - (nothing to record here)
9
+
10
+ ## [0.4.18] - 2021-04-29
11
+ ### Added
12
+ - Use ERB to generate the initial content of a new note from the
13
+ template file (`add`) (#125)
14
+
15
+ ### Fixed
16
+ - Add info about template feature of `add`: (#124)
17
+ - update help text of `add`,
18
+ - update `README.md`.
19
+ - Add description about `ugrep` to `README.md`. (#122)
20
+ - Fix issue #118: help text of `list` is wrong.
21
+ - Fix issue #119: a test for `Rbnotes::Utils` may fails.
22
+ - fix the test.
9
23
 
10
24
  ## [0.4.17] - 2021-04-21
11
25
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rbnotes (0.4.17)
4
+ rbnotes (0.4.18)
5
5
  textrepo (~> 0.5.8)
6
6
  unicode-display_width (~> 1.7)
7
7
 
data/README.md CHANGED
@@ -149,6 +149,7 @@ The short-hand notation of the home directory ("~") is usable.
149
149
 
150
150
  ##### Miscellaneous variables (optional)
151
151
 
152
+ - :template : specify a template file for `add` command
152
153
  - :pager : specify a pager program
153
154
  - :editor : specify a editor program
154
155
  - :searcher: specify a program to perform search
@@ -170,13 +171,15 @@ don't have to set `:searcher_options` for them.
170
171
  | `ggrep` | `["-i", "-n", "-H", "-R", "-E"]` |
171
172
  | `gegrep` | `["-i", "-n", "-H", "-R"]` |
172
173
  | `rg` | `["-S", "-n", "--no-heading", "--color", "never"]` |
174
+ | `ugrep` | `["-i", "-n", "-H", "-R", "--color=never"]` |
173
175
 
174
176
  Those searcher names are used in macOS (with Homebrew). Any other OS
175
177
  might use different names.
176
178
 
177
179
  - `grep` and `egrep` -> BSD grep (macOS default)
178
- - `ggrep` and `gegrep` -> GNU grep
179
- - `rg` -> ripgrep
180
+ - `ggrep` and `gegrep` -> [GNU grep](https://www.gnu.org/software/grep/)
181
+ - `rg` -> [BurntSushi/ripgrep](https://github.com/BurntSushi/ripgrep)
182
+ - `ugrep` -> [Genivia/ugrep](https://github.com/Genivia/ugrep)
180
183
 
181
184
  If the name is different, `:searcher_options` should be set with the
182
185
  same value. For example, if you system use the name `gnugrep` as GNU
@@ -184,6 +187,48 @@ grep, and you want to use it as the searcher (that is, set `gnugrep`
184
187
  to `:searcher`), you should set `:searcher_options` value with `["-i",
185
188
  "-n", "-R", "-E"]`.
186
189
 
190
+ ##### Template file for `add` command
191
+
192
+ `Add` command always searches a template file in the default
193
+ directory. The default directory is,
194
+
195
+ - `$XDG_CONIFG_HOME/rbnotes/templates` (if `$XDG_CONFIG_HOME` is defined)
196
+
197
+ or
198
+
199
+ - `$HOME/.config/rbnotes/templates`
200
+
201
+ If a file which named as `default.md` is found in the above directory,
202
+ it will use as a template file to generate the initial content of a
203
+ new note.
204
+
205
+ When a command line option or a setting of the configuration file is
206
+ specified to use a template file, `add` command will read it instead
207
+ of the default template file.
208
+
209
+ Command line option of `add` to specify a template file is:
210
+
211
+ ``` shell
212
+ > rbntoes add -f /somewhere/template.md
213
+ ```
214
+
215
+ See the above section about the configuration file setting to specify
216
+ a template file.
217
+
218
+ Though a template file can be written any format of text (markdown,
219
+ HTML, plain text, or ...), `add` command will process the content
220
+ using ERB. So, using ERB syntax, you can mix Ruby code in a template
221
+ file.
222
+
223
+ Here is a very simple and short example to use ERB syntax:
224
+
225
+ ``` markdown
226
+ ## <%= Time.now.strftime("%Y-%m-%d") %>
227
+ ```
228
+
229
+ It just insert a date string like "2021-04-29" at the top of a new
230
+ note which generates by `add` command.
231
+
187
232
  ##### Default values for mandatory variables
188
233
 
189
234
  All mandatory variables have their default values. Here is the list
@@ -1,5 +1,7 @@
1
1
  module Rbnotes::Commands
2
2
 
3
+ require "erb"
4
+
3
5
  ##
4
6
  # Adds a new note to the repository. If no options, a new timestamp
5
7
  # is generated at the execution time, then it is attached to the
@@ -16,15 +18,39 @@ module Rbnotes::Commands
16
18
  # "202011041722" : year, date and time (omit second part)
17
19
  # "11041722" : date and time (omit year and second part)
18
20
  #
21
+ # Also accepts an option with `-f FILENAME` (or `--template-file`)
22
+ # to specify a template file which will be the initial content of a
23
+ # new note.
24
+ #
19
25
  # This command starts the external editor program to prepare text to
20
26
  # store. The editor program will be searched in the following order:
21
27
  #
22
- # 1. conf[:editor] (conf is the 1st arg of execute method)
23
- # 2. ENV["EDITOR"]
24
- # 3. "nano"
25
- # 4. "vi"
28
+ # 1. conf[:editor] (conf is the 1st arg of execute method)
29
+ # 2. ENV["EDITOR"]
30
+ # 3. "nano"
31
+ # 4. "vi"
26
32
  #
27
33
  # If none of the above editor is available, the command fails.
34
+ #
35
+ # TEMPLATE FILE:
36
+ #
37
+ # This command search a file as its template which will be the initial
38
+ # conent of a new note when an option or a setting in the configuration
39
+ # file (`:template`) is specified a template file.
40
+ #
41
+ # Or, even if neither an option nor a setting about a template file is
42
+ # specified, it always searches the default directory to read a template
43
+ # file. The directory is:
44
+ #
45
+ # - $XDG_CONIFG_HOME/rbnotes/templates (if $XDG_CONFIG_HOME is defined)
46
+ # or
47
+ # - $HOME/.config/rbnotes/templates
48
+ #
49
+ # If a file, `default.md` exists in the above directory, it will used as
50
+ # a template.
51
+ #
52
+ # A template file can be written in ERB syntax. See ERB manual to know
53
+ # about how to mix ruby code and text content in ERB syntax.
28
54
 
29
55
  class Add < Command
30
56
 
@@ -78,16 +104,26 @@ usage:
78
104
  Add a new note to the repository. If no options, a new timestamp is
79
105
  generated at the execution time, then it is attached to the note.
80
106
 
107
+ OPTIONS:
108
+ -t, --timestamp STAMP_PATTERN
109
+ -f, --template-file FILENAME
110
+
81
111
  Accept an option with `-t STAMP_PATTERN` (or `--timestamp`), a
82
- timestamp is generated according to `STAMP_PATTERN`.
112
+ timestamp of a new note is generated according to `STAMP_PATTERN`.
83
113
 
84
- STAMP_PATTERN could be one of followings:
114
+ Also accepts an option with `-f FILENAME` (or `--template-file`) to
115
+ specify a template file which will be the initial content of a new
116
+ note. See below section more about a template file.
117
+
118
+ STAMP_PATTERN could be:
85
119
 
86
120
  "20201104172230_078" : full qualified timestamp string
87
121
  "20201104172230" : full qualified timestamp string (no suffix)
88
122
  "202011041722" : year, date and time (omit second part)
89
123
  "11041722" : date and time (omit year and second part)
90
124
 
125
+ EDITOR:
126
+
91
127
  This command starts the external editor program to prepare text to
92
128
  store. The editor program will be searched in the following order:
93
129
 
@@ -97,6 +133,29 @@ store. The editor program will be searched in the following order:
97
133
  4. "vi"
98
134
 
99
135
  If none of the above editor is available, the execution fails.
136
+
137
+ TEMPLATE FILE:
138
+
139
+ This command search a file as its template which will be the initial
140
+ conent of a new note when an option or a setting in the configuration
141
+ file (`:template`) is specified a template file.
142
+
143
+ Or, even if neither an option nor a setting about a template file is
144
+ specified, it always searches the default directory to read a template
145
+ file. The directory is:
146
+
147
+ - $XDG_CONIFG_HOME/rbnotes/templates (if $XDG_CONFIG_HOME is defined)
148
+
149
+ or
150
+
151
+ - $HOME/.config/rbnotes/templates
152
+
153
+ If a file, `default.md` exists in the above directory, it will used as
154
+ a template.
155
+
156
+ A template file can be written in ERB syntax. See ERB manual to know
157
+ about how to mix ruby code and text content in ERB syntax.
158
+
100
159
  HELP
101
160
  end
102
161
 
@@ -144,10 +203,15 @@ HELP
144
203
 
145
204
  if template_path
146
205
  raise Rbnotes::NoTemplateFileError, template_path unless FileTest.exist?(template_path)
147
- template = File.readlines(template_path, chomp: true)
148
206
  else
149
207
  template_path = default_template_file(conf)
150
- template = File.readlines(template_path, chomp: true) if FileTest.exist?(template_path)
208
+ return nil unless FileTest.exist?(template_path)
209
+ end
210
+
211
+ erb_source = File.read(template_path)
212
+ if erb_source and !erb_source.empty?
213
+ erb = ERB.new(erb_source)
214
+ template = erb.result.split("\n")
151
215
  end
152
216
 
153
217
  template
@@ -92,11 +92,16 @@ module Rbnotes::Commands
92
92
  usage:
93
93
  #{Rbnotes::NAME} list [OPTIONS] [STAMP_PATTERN|KEYWORD]
94
94
 
95
- Show a list of notes. When no arguments, make a list with all notes
96
- in the repository. When specified STAMP_PATTERN, only those match the
97
- pattern are listed. Instead of STAMP_PATTERN, some KEYWORDs could be
95
+ Show a list of notes. When specified several STAMP_PATTERNs, only
96
+ those match the pattern are listed. Also, some KEYWORDs could be
98
97
  used.
99
98
 
99
+ When no STAMP_PATTERN or KEYWORD was specified, the behavior of this
100
+ command could be specified with a configuration setting,
101
+ ":list_default:". The value must be one of valid keywords. If no
102
+ settings was also given, this command would behave like "today" was
103
+ specified as the setting.
104
+
100
105
  OPTIONS:
101
106
  -v, --verbose
102
107
  -w, --week
@@ -130,12 +135,6 @@ like as follows:
130
135
  20210418125353: Hoge
131
136
  :
132
137
 
133
- When no STAMP_PATTERN or KEYWORD was specified, the behavior of this
134
- command could be specified with a configuration setting,
135
- ":list_default:". The value must be one of valid keywords. If no
136
- settings was also given, this command would behave like "today" was
137
- specified as the setting.
138
-
139
138
  An option "--week" is also acceptable. It specifies to enumerate all
140
139
  days of a week. Typically, the option is used with a STAMP_PATTERN
141
140
  which specifies a date, such "20201117", then it enumerates all days
@@ -1,4 +1,4 @@
1
1
  module Rbnotes
2
- VERSION = "0.4.17"
3
- RELEASE = "2021-04-21"
2
+ VERSION = "0.4.18"
3
+ RELEASE = "2021-04-29"
4
4
  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.17
4
+ version: 0.4.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - mnbi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-20 00:00:00.000000000 Z
11
+ date: 2021-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: textrepo