standup_md 0.3.15 → 0.3.16

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b95cee87e34194f847a9830ccf56694e1c450c0bdbae04b8b0af0df7716daaaa
4
- data.tar.gz: 2d8466163ca2687ca156e62c12399b01a65454e57eb3d7376931908e0e39a61c
3
+ metadata.gz: 171d0b1fdd697049f52d50db4d1b0ccb95db648dc70b67957c612ebdf74c57b2
4
+ data.tar.gz: 1c2347af65439e1d8263715eeb3d9b45b4cbc020793ddb1a51dbbd71ee71159b
5
5
  SHA512:
6
- metadata.gz: 522d4e0c57d9887456210fb79ac5fd4920350ffd7265f8dd2bc40369405ed4ef624cd29425dae92e480b1e694ad9ff5e5733e36c0800527f8c692f3335128ee8
7
- data.tar.gz: 1229afe074eacb10dcf0b84dabd80d3a41695c604ade83e175739548bdebdf4d84fd5161f6f50bb9931239816fa885c78ff217b7950fdf31f4498919fccaee0a
6
+ metadata.gz: faca92ff7d839b8fb83c579bc203ba3477e975d225f2fd7ef5c3c8b37625a674ed6a7e89e7f9033c2169f5cc6f52c0e7ae9a046fb29880bd95f1ac7a56bc400c
7
+ data.tar.gz: f365e31e43288e039e9c35b887f905a5def1233200d34fead1a250df79215f107cc5ff16534e503d074f1e2b29620fad64b285f94ce68042226cc3a6a1e04fcf
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- standup_md (0.3.15)
4
+ standup_md (0.3.16)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -115,7 +115,7 @@ CHECKSUMS
115
115
  standard (1.54.0) sha256=7a4b08f83d9893083c8f03bc486f0feeb6a84d48233b40829c03ef4767ea0100
116
116
  standard-custom (1.0.2) sha256=424adc84179a074f1a2a309bb9cf7cd6bfdb2b6541f20c6bf9436c0ba22a652b
117
117
  standard-performance (1.9.0) sha256=49483d31be448292951d80e5e67cdcb576c2502103c7b40aec6f1b6e9c88e3f2
118
- standup_md (0.3.15)
118
+ standup_md (0.3.16)
119
119
  stringio (3.2.0) sha256=c37cb2e58b4ffbd33fe5cd948c05934af997b36e0b6ca6fdf43afa234cf222e1
120
120
  test-unit (3.7.8) sha256=689d1ca53f4d46f678b4e5d68d8e4294f87fc5e8b9238cc4de7c5727e8d65943
121
121
  tsort (0.2.0) sha256=9650a793f6859a43b6641671278f79cfead60ac714148aabe4e3f0060480089f
data/README.md CHANGED
@@ -6,10 +6,11 @@
6
6
 
7
7
  > The cure for all your standup woes.
8
8
 
9
- A highly customizable and automated way to keep track of daily standups in
10
- markdown files.
9
+ An automated, customizable way to keep track of daily standups in markdown
10
+ files.
11
11
 
12
- You can view the documentation [here](https://evanthegrayt.github.io/standup_md/).
12
+ You can view the documentation
13
+ [here](https://evanthegrayt.github.io/standup_md/).
13
14
 
14
15
  ## About
15
16
  I've now been at two separate companies where we post our daily standups in a
@@ -43,7 +44,7 @@ gem install standup_md
43
44
  To include in your project, add the following to your `Gemfile`.
44
45
 
45
46
  ```ruby
46
- gem 'standup_md'
47
+ gem "standup_md"
47
48
  ```
48
49
 
49
50
  ### Manual Installation
@@ -73,6 +74,14 @@ important; you may add new entries, but don't change any of the headers. Doing
73
74
  so will cause the parser to break. If you want to customize the headers, you can
74
75
  do so in the [configuration file](#available-config-file-options-and-defaults).
75
76
 
77
+ To open a previous month's standup file, pass the date as an argument. Both
78
+ `YYYY-MM` and `YYYY-MM-DD` are accepted, and both open the file for that month.
79
+
80
+ ```sh
81
+ standup 2026-06
82
+ standup 2026-06-18
83
+ ```
84
+
76
85
  ### CLI Examples
77
86
  #### Adding an entry for today via editor
78
87
  For example, if the standup entry from yesterday reads as follows:
@@ -150,36 +159,36 @@ rails project, create an initializer (`config/initializers/standup_md.rb`).
150
159
  StandupMD.configure do |c|
151
160
  # Defaults for how the file is formatted.
152
161
  # See https://evanthegrayt.github.io/standup_md/doc/StandupMD/Config/Cli.html
153
- c.file.header_date_format = '%Y-%m-%d'
162
+ c.file.header_date_format = "%Y-%m-%d"
154
163
  c.file.header_depth = 1
155
164
  c.file.sub_header_depth = 2
156
- c.file.current_header = 'Current'
157
- c.file.previous_header = 'Previous'
158
- c.file.impediments_header = 'Impediments'
159
- c.file.notes_header = 'Notes'
165
+ c.file.current_header = "Current"
166
+ c.file.previous_header = "Previous"
167
+ c.file.impediments_header = "Impediments"
168
+ c.file.notes_header = "Notes"
160
169
  c.file.sub_header_order = %w[previous current impediments notes]
161
- c.file.directory = ::File.join(ENV['HOME'], '.cache', 'standup_md')
162
- c.file.bullet_character = '-'
163
- c.file.name_format = '%Y_%m.md'
170
+ c.file.directory = ::File.join(ENV["HOME"], ".cache", "standup_md")
171
+ c.file.bullet_character = "-"
172
+ c.file.name_format = "%Y_%m.md"
164
173
  c.file.create = true
165
174
 
166
- # Defaults for entries
175
+ # Defaults for entries.
167
176
  # See https://evanthegrayt.github.io/standup_md/doc/StandupMD/Config/Entry.html
168
177
  c.entry.current = ["<!-- ADD TODAY'S WORK HERE -->"]
169
178
  c.entry.previous = []
170
- c.entry.impediments = ['None']
179
+ c.entry.impediments = ["None"]
171
180
  c.entry.notes = []
172
181
 
173
182
  # Defaults for executable runtime behavior.
174
183
  # See https://evanthegrayt.github.io/standup_md/doc/StandupMD/Config/Cli.html
175
184
  c.cli.date = Date.today
176
- c.cli.editor = 'vim' # Checks $VISUAL and $EDITOR first, in that order
185
+ c.cli.editor = "vim" # Checks $VISUAL and $EDITOR first, in that order
177
186
  c.cli.verbose = false
178
187
  c.cli.edit = true
179
188
  c.cli.write = true
180
189
  c.cli.print = false
181
190
  c.cli.auto_fill_previous = true
182
- c.cli.preference_file = ::File.expand_path(::File.join(ENV['HOME'], '.standuprc'))
191
+ c.cli.preference_file = ::File.expand_path(::File.join(ENV["HOME"], ".standuprc"))
183
192
  end
184
193
  ```
185
194
 
@@ -250,11 +259,11 @@ Your `~/.standuprc` should contain:
250
259
  StandupMD.configure do |c|
251
260
  c.file.header_depth = 2
252
261
  c.file.sub_header_depth = 3
253
- c.file.current_header = 'Today'
254
- c.file.previous_header = 'Yesterday'
255
- c.file.impediments_header = 'Hold-ups'
256
- c.file.bullet_character = '*'
257
- c.file.header_date_format = '%m/%d/%Y'
262
+ c.file.current_header = "Today"
263
+ c.file.previous_header = "Yesterday"
264
+ c.file.impediments_header = "Hold-ups"
265
+ c.file.bullet_character = "*"
266
+ c.file.header_date_format = "%m/%d/%Y"
258
267
  c.file.sub_header_order = %w[current previous impediments notes]
259
268
  end
260
269
  ```
@@ -270,14 +279,14 @@ new entry via code could look like the following:
270
279
  ### API Examples
271
280
  #### Adding an entry for today
272
281
  ```ruby
273
- require 'standup_md'
282
+ require "standup_md"
274
283
 
275
284
  StandupMD.configure do |c|
276
- c.file.current_header = 'Today',
285
+ c.file.current_header = "Today",
277
286
  end
278
287
 
279
288
  file = StandupMD::File.find_by_date(Date.today)
280
- entry = StandupMD::Entry.create { |e| e.current = ['Stuff I will do today'] }
289
+ entry = StandupMD::Entry.create { |e| e.current = ["Stuff I will do today"] }
281
290
  file.entries << entry
282
291
  file.write
283
292
  ```
@@ -286,11 +295,11 @@ The above example was written as such to show how the different pieces of the
286
295
  API fit together. The code can actually be simplified to the following.
287
296
 
288
297
  ```ruby
289
- require 'standup_md'
298
+ require "standup_md"
290
299
 
291
300
  StandupMD.configure do |c|
292
- c.file.current_header = 'Today',
293
- c.entry.current = ['Stuff I will do today']
301
+ c.file.current_header = "Today",
302
+ c.entry.current = ["Stuff I will do today"]
294
303
  end
295
304
 
296
305
  StandupMD::File.find_by_date(Date.today).load.write
@@ -298,7 +307,7 @@ StandupMD::File.find_by_date(Date.today).load.write
298
307
 
299
308
  #### Finding a past entry
300
309
  ```ruby
301
- require 'standup_md'
310
+ require "standup_md"
302
311
 
303
312
  date = Date.new(2020, 04, 15)
304
313
  file = StandupMD::File.find_by_date(date).load
data/Rakefile CHANGED
@@ -39,3 +39,48 @@ task :"standard:fix" do
39
39
  end
40
40
 
41
41
  task default: :test
42
+
43
+ namespace :version do
44
+ desc "Print the current version from the version.rb file"
45
+ task :current do
46
+ puts StandupMD::VERSION
47
+ end
48
+
49
+ namespace :increment do
50
+ desc "Increment the version's PATCH level"
51
+ task :patch do
52
+ File.join(__dir__, "lib", "standup_md", "version.rb").then do |version_file|
53
+ File.write(
54
+ version_file,
55
+ File.read(version_file).sub(/(PATCH\s=\s)(\d+)/) { "#{$1}#{$2.next}" }
56
+ )
57
+ end
58
+ system("bundle lock")
59
+ end
60
+ desc "Increment the version's MINOR level"
61
+ task :minor do
62
+ File.join(__dir__, "lib", "standup_md", "version.rb").then do |version_file|
63
+ File.write(
64
+ version_file,
65
+ File.read(version_file)
66
+ .sub(/(PATCH\s=\s)(\d+)/) { "#{$1}0" }
67
+ .sub(/(MINOR\s=\s)(\d+)/) { "#{$1}#{$2.next}" }
68
+ )
69
+ end
70
+ system("bundle lock")
71
+ end
72
+ desc "Increment the version's MAJOR level"
73
+ task :major do
74
+ File.join(__dir__, "lib", "standup_md", "version.rb").then do |version_file|
75
+ File.write(
76
+ version_file,
77
+ File.read(version_file)
78
+ .sub(/(PATCH\s=\s)(\d+)/) { "#{$1}0" }
79
+ .sub(/(MINOR\s=\s)(\d+)/) { "#{$1}0" }
80
+ .sub(/(MAJOR\s=\s)(\d+)/) { "#{$1}#{$2.next}" }
81
+ )
82
+ end
83
+ system("bundle lock")
84
+ end
85
+ end
86
+ end
@@ -115,6 +115,11 @@ module StandupMD
115
115
  v.nil? ? Date.today : Date.strptime(v, config.file.header_date_format)
116
116
  end
117
117
  end.parse!(options)
118
+ unless options.empty?
119
+ @file_date_argument = true
120
+ config.cli.date = parse_file_date(options.shift)
121
+ end
122
+ raise OptionParser::InvalidArgument, options.join(" ") unless options.empty?
118
123
  end
119
124
 
120
125
  ##
@@ -123,7 +128,7 @@ module StandupMD
123
128
  # @return [StandupMD::Entry]
124
129
  def new_entry(file)
125
130
  entry = file.entries.find(config.cli.date)
126
- return entry unless entry.nil? && config.cli.date == Date.today
131
+ return entry if read_only? || entry || config.cli.date != Date.today
127
132
 
128
133
  StandupMD::Entry.new(
129
134
  config.cli.date,
@@ -145,6 +150,25 @@ module StandupMD
145
150
  prev_entry(file.entries)
146
151
  end
147
152
 
153
+ ##
154
+ # Parses the optional file date argument.
155
+ #
156
+ # @param [String] value
157
+ #
158
+ # @return [Date]
159
+ def parse_file_date(value)
160
+ case value
161
+ when /\A\d{4}-\d{2}-\d{2}\z/
162
+ Date.strptime(value, "%Y-%m-%d")
163
+ when /\A\d{4}-\d{2}\z/
164
+ Date.strptime(value, "%Y-%m")
165
+ else
166
+ raise OptionParser::InvalidArgument, value
167
+ end
168
+ rescue ArgumentError
169
+ raise OptionParser::InvalidArgument, value
170
+ end
171
+
148
172
  ##
149
173
  # The previous entry.
150
174
  #
@@ -29,7 +29,7 @@ module StandupMD
29
29
  # Creates an instance of +StandupMD+ and runs what the user requested.
30
30
  def self.execute(options = [])
31
31
  new(options).tap do |exe|
32
- exe.write_file if config.write
32
+ exe.write_file if exe.write?
33
33
  if config.print
34
34
  exe.print(exe.entry)
35
35
  elsif config.edit
@@ -56,6 +56,14 @@ module StandupMD
56
56
  # @return [StandupMD::File]
57
57
  attr_reader :file
58
58
 
59
+ ##
60
+ # Was a file date argument passed?
61
+ #
62
+ # @return [Boolean]
63
+ def file_date_argument?
64
+ @file_date_argument
65
+ end
66
+
59
67
  ##
60
68
  # Constructor. Sets defaults.
61
69
  #
@@ -63,12 +71,13 @@ module StandupMD
63
71
  def initialize(options = [], load_config: true)
64
72
  @config = self.class.config
65
73
  @preference_file_loaded = false
74
+ @file_date_argument = false
66
75
  @options = options
67
76
  load_preferences if load_config
68
77
  load_runtime_preferences(options)
69
- @file = StandupMD::File.find_by_date(@config.date)
70
- @file.load
71
- @entry = new_entry(@file)
78
+ @file = find_file
79
+ @file&.load
80
+ @entry = @file.nil? ? nil : new_entry(@file)
72
81
  end
73
82
 
74
83
  ##
@@ -110,6 +119,14 @@ module StandupMD
110
119
  file.write
111
120
  end
112
121
 
122
+ ##
123
+ # Should the file be written?
124
+ #
125
+ # @return [Boolean]
126
+ def write?
127
+ !!(@config.write && !read_only? && entry)
128
+ end
129
+
113
130
  ##
114
131
  # Quick access to +Cli.echo+.
115
132
  #
@@ -117,5 +134,41 @@ module StandupMD
117
134
  def echo(msg)
118
135
  self.class.echo(msg)
119
136
  end
137
+
138
+ private
139
+
140
+ ##
141
+ # Is this a read-only action?
142
+ #
143
+ # @return [Boolean]
144
+ def read_only?
145
+ @config.print || file_date_argument?
146
+ end
147
+
148
+ ##
149
+ # Finds the file, avoiding file creation for read-only actions.
150
+ #
151
+ # @return [StandupMD::File, nil]
152
+ def find_file
153
+ return StandupMD::File.find_by_date(@config.date) unless read_only?
154
+
155
+ without_file_creation { StandupMD::File.find_by_date(@config.date) }
156
+ rescue
157
+ raise unless @config.print
158
+
159
+ nil
160
+ end
161
+
162
+ ##
163
+ # Temporarily disables file creation while looking for a file.
164
+ #
165
+ # @return [StandupMD::File]
166
+ def without_file_creation
167
+ original_create = config.file.create
168
+ config.file.create = false
169
+ yield
170
+ ensure
171
+ config.file.create = original_create
172
+ end
120
173
  end
121
174
  end
@@ -21,7 +21,7 @@ module StandupMD
21
21
  # Patch version.
22
22
  #
23
23
  # @return [Integer]
24
- PATCH = 15
24
+ PATCH = 16
25
25
 
26
26
  ##
27
27
  # Version as +[MAJOR, MINOR, PATCH]+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: standup_md
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.15
4
+ version: 0.3.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Gray