standup_md 0.3.0 → 0.3.5
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/Gemfile.lock +2 -2
- data/README.md +37 -19
- data/doc/README_md.html +35 -30
- data/doc/StandupMD.html +3 -7
- data/doc/StandupMD/Cli/Helpers.html +4 -4
- data/doc/StandupMD/Config.html +1 -1
- data/doc/StandupMD/Config/Cli.html +29 -20
- data/doc/StandupMD/Config/Entry.html +26 -14
- data/doc/StandupMD/Config/EntryList.html +26 -11
- data/doc/StandupMD/Config/File.html +30 -26
- data/doc/StandupMD/Entry.html +7 -7
- data/doc/StandupMD/EntryList.html +116 -194
- data/doc/StandupMD/File.html +51 -11
- data/doc/created.rid +15 -15
- data/doc/index.html +33 -30
- data/doc/js/search_index.js +1 -1
- data/doc/js/search_index.js.gz +0 -0
- data/doc/table_of_contents.html +41 -44
- data/lib/standup_md.rb +2 -2
- data/lib/standup_md/cli/helpers.rb +29 -5
- data/lib/standup_md/config.rb +2 -0
- data/lib/standup_md/config/cli.rb +25 -22
- data/lib/standup_md/config/entry.rb +15 -8
- data/lib/standup_md/config/entry_list.rb +10 -5
- data/lib/standup_md/config/file.rb +26 -16
- data/lib/standup_md/entry.rb +2 -1
- data/lib/standup_md/entry_list.rb +23 -40
- data/lib/standup_md/file.rb +14 -3
- data/lib/standup_md/version.rb +2 -4
- metadata +2 -2
data/lib/standup_md.rb
CHANGED
@@ -8,12 +8,12 @@ require_relative 'standup_md/cli'
|
|
8
8
|
require_relative 'standup_md/config'
|
9
9
|
|
10
10
|
##
|
11
|
-
# The
|
11
|
+
# The main module for the gem. Provides access to configuration classes.
|
12
12
|
module StandupMD
|
13
13
|
@config_file_loaded = false
|
14
14
|
|
15
15
|
##
|
16
|
-
#
|
16
|
+
# Method for accessing the configuration.
|
17
17
|
#
|
18
18
|
# @return [StanupMD::Cli]
|
19
19
|
def self.config
|
@@ -18,11 +18,11 @@ module StandupMD
|
|
18
18
|
puts "No record found for #{StandupMD.config.cli.date}"
|
19
19
|
return
|
20
20
|
end
|
21
|
-
puts
|
22
|
-
StandupMD.config.file.sub_header_order.each do |
|
23
|
-
tasks = entry.
|
21
|
+
puts header(entry)
|
22
|
+
StandupMD.config.file.sub_header_order.each do |header_type|
|
23
|
+
tasks = entry.public_send(header_type)
|
24
24
|
next if !tasks || tasks.empty?
|
25
|
-
puts
|
25
|
+
puts sub_header(header_type)
|
26
26
|
tasks.each { |task| puts StandupMD.config.file.bullet_character + ' ' + task }
|
27
27
|
end
|
28
28
|
puts
|
@@ -137,7 +137,9 @@ module StandupMD
|
|
137
137
|
#
|
138
138
|
# @return [Array]
|
139
139
|
def set_previous_entry(file)
|
140
|
-
|
140
|
+
unless StandupMD.config.cli.auto_fill_previous
|
141
|
+
return Standup.config.entry.previous_entry
|
142
|
+
end
|
141
143
|
return prev_entry(prev_file.load.entries) if file.new? && prev_file
|
142
144
|
prev_entry(file.entries)
|
143
145
|
end
|
@@ -160,6 +162,28 @@ module StandupMD
|
|
160
162
|
def prev_file
|
161
163
|
StandupMD::File.find_by_date(Date.today.prev_month)
|
162
164
|
end
|
165
|
+
|
166
|
+
##
|
167
|
+
# The header.
|
168
|
+
#
|
169
|
+
# @param [StandupMD::Entry] entry
|
170
|
+
#
|
171
|
+
# @return [String]
|
172
|
+
def header(entry)
|
173
|
+
'#' * StandupMD.config.file.header_depth + ' ' +
|
174
|
+
entry.date.strftime(StandupMD.config.file.header_date_format)
|
175
|
+
end
|
176
|
+
|
177
|
+
##
|
178
|
+
# The sub-header.
|
179
|
+
#
|
180
|
+
# @param [String] header_type
|
181
|
+
#
|
182
|
+
# @return [String]
|
183
|
+
def sub_header(header_type)
|
184
|
+
'#' * StandupMD.config.file.sub_header_depth + ' ' +
|
185
|
+
StandupMD.config.file.public_send("#{header_type}_header").capitalize
|
186
|
+
end
|
163
187
|
end
|
164
188
|
end
|
165
189
|
end
|
data/lib/standup_md/config.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'date'
|
3
4
|
|
4
5
|
module StandupMD
|
@@ -7,6 +8,23 @@ module StandupMD
|
|
7
8
|
##
|
8
9
|
# The configuration class for StandupMD::Cli
|
9
10
|
class Cli
|
11
|
+
|
12
|
+
##
|
13
|
+
# The default options.
|
14
|
+
#
|
15
|
+
# @return [Hash]
|
16
|
+
DEFAULTS = {
|
17
|
+
date: Date.today,
|
18
|
+
editor: ENV['VISUAL'] || ENV['EDITOR'] || 'vim',
|
19
|
+
verbose: false,
|
20
|
+
edit: true,
|
21
|
+
write: true,
|
22
|
+
print: false,
|
23
|
+
auto_fill_previous: true,
|
24
|
+
preference_file:
|
25
|
+
::File.expand_path(::File.join(ENV['HOME'], '.standuprc')),
|
26
|
+
}
|
27
|
+
|
10
28
|
##
|
11
29
|
# The editor to use when opening standup files. If one is not set, the
|
12
30
|
# first of $VISUAL, $EDITOR, or vim will be used, in that order.
|
@@ -33,7 +51,7 @@ module StandupMD
|
|
33
51
|
attr_accessor :edit
|
34
52
|
|
35
53
|
##
|
36
|
-
# Should the cli write the file?
|
54
|
+
# Should the cli automatically write the new entry to the file?
|
37
55
|
#
|
38
56
|
# @param [Boolean] write
|
39
57
|
#
|
@@ -41,7 +59,7 @@ module StandupMD
|
|
41
59
|
attr_accessor :write
|
42
60
|
|
43
61
|
##
|
44
|
-
# Should the cli print the entry?
|
62
|
+
# Should the cli print the entry to the command line?
|
45
63
|
#
|
46
64
|
# @param [Boolean] print
|
47
65
|
#
|
@@ -49,7 +67,7 @@ module StandupMD
|
|
49
67
|
attr_accessor :print
|
50
68
|
|
51
69
|
##
|
52
|
-
# The date to use to find the
|
70
|
+
# The date to use to find the entry.
|
53
71
|
#
|
54
72
|
# @param [Date] date
|
55
73
|
#
|
@@ -76,30 +94,15 @@ module StandupMD
|
|
76
94
|
##
|
77
95
|
# Initializes the config with default values.
|
78
96
|
def initialize
|
79
|
-
|
97
|
+
reset
|
80
98
|
end
|
81
99
|
|
82
100
|
##
|
83
101
|
# Sets all config values back to their defaults.
|
84
102
|
#
|
85
|
-
# @return [
|
86
|
-
def
|
87
|
-
|
88
|
-
@editor = set_editor
|
89
|
-
@verbose = false
|
90
|
-
@edit = true
|
91
|
-
@write = true
|
92
|
-
@print = false
|
93
|
-
@auto_fill_previous = true
|
94
|
-
@preference_file = ::File.expand_path(::File.join(ENV['HOME'], '.standuprc'))
|
95
|
-
end
|
96
|
-
|
97
|
-
private
|
98
|
-
|
99
|
-
def set_editor # :nodoc:
|
100
|
-
return ENV['VISUAL'] if ENV['VISUAL']
|
101
|
-
return ENV['EDITOR'] if ENV['EDITOR']
|
102
|
-
'vim'
|
103
|
+
# @return [Hash]
|
104
|
+
def reset
|
105
|
+
DEFAULTS.each { |k, v| instance_variable_set("@#{k}", v) }
|
103
106
|
end
|
104
107
|
end
|
105
108
|
end
|
@@ -7,6 +7,17 @@ module StandupMD
|
|
7
7
|
# The configuration class for StandupMD::Entry
|
8
8
|
class Entry
|
9
9
|
|
10
|
+
##
|
11
|
+
# The default options.
|
12
|
+
#
|
13
|
+
# @return [Hash]
|
14
|
+
DEFAULTS = {
|
15
|
+
current: ["<!-- ADD TODAY'S WORK HERE -->"],
|
16
|
+
previous: [],
|
17
|
+
impediments: ['None'],
|
18
|
+
notes: [],
|
19
|
+
}
|
20
|
+
|
10
21
|
##
|
11
22
|
# Tasks for "Current" section.
|
12
23
|
#
|
@@ -42,19 +53,15 @@ module StandupMD
|
|
42
53
|
##
|
43
54
|
# Initializes the config with default values.
|
44
55
|
def initialize
|
45
|
-
|
56
|
+
reset
|
46
57
|
end
|
47
58
|
|
48
59
|
##
|
49
60
|
# Sets all config values back to their defaults.
|
50
61
|
#
|
51
|
-
# @return [
|
52
|
-
def
|
53
|
-
|
54
|
-
@previous = []
|
55
|
-
@impediments = ['None']
|
56
|
-
@notes = []
|
57
|
-
true
|
62
|
+
# @return [Hash]
|
63
|
+
def reset
|
64
|
+
DEFAULTS.each { |k, v| instance_variable_set("@#{k}", v) }
|
58
65
|
end
|
59
66
|
end
|
60
67
|
end
|
@@ -7,19 +7,24 @@ module StandupMD
|
|
7
7
|
# The configuration class for StandupMD::EntryList
|
8
8
|
class EntryList
|
9
9
|
|
10
|
+
##
|
11
|
+
# The default options.
|
12
|
+
#
|
13
|
+
# @return [Hash]
|
14
|
+
DEFAULTS = {}
|
15
|
+
|
10
16
|
##
|
11
17
|
# Initializes the config with default values.
|
12
18
|
def initalize
|
13
|
-
|
19
|
+
reset
|
14
20
|
end
|
15
21
|
|
16
22
|
##
|
17
23
|
# Sets all config values back to their defaults.
|
18
24
|
#
|
19
|
-
# @return [
|
20
|
-
def
|
21
|
-
|
22
|
-
true
|
25
|
+
# @return [Hash]
|
26
|
+
def reset
|
27
|
+
DEFAULTS.each { |k, v| instance_variable_set("@#{k}", v) }
|
23
28
|
end
|
24
29
|
end
|
25
30
|
end
|
@@ -1,9 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module StandupMD
|
2
4
|
class Config
|
3
5
|
|
4
6
|
##
|
5
7
|
# The configuration class for StandupMD::File
|
6
8
|
class File
|
9
|
+
|
10
|
+
##
|
11
|
+
# The default options.
|
12
|
+
#
|
13
|
+
# @return [Hash]
|
14
|
+
DEFAULTS = {
|
15
|
+
header_date_format: '%Y-%m-%d',
|
16
|
+
header_depth: 1,
|
17
|
+
sub_header_depth: 2,
|
18
|
+
current_header: 'Current',
|
19
|
+
previous_header: 'Previous',
|
20
|
+
impediments_header: 'Impediments',
|
21
|
+
notes_header: 'Notes',
|
22
|
+
sub_header_order: %w[previous current impediments notes],
|
23
|
+
directory: ::File.join(ENV['HOME'], '.cache', 'standup_md'),
|
24
|
+
bullet_character: '-',
|
25
|
+
name_format: '%Y_%m.md',
|
26
|
+
create: true,
|
27
|
+
}
|
28
|
+
|
7
29
|
##
|
8
30
|
# Number of octothorps that should preface entry headers.
|
9
31
|
#
|
@@ -116,27 +138,15 @@ module StandupMD
|
|
116
138
|
##
|
117
139
|
# Initializes the config with default values.
|
118
140
|
def initialize
|
119
|
-
|
141
|
+
reset
|
120
142
|
end
|
121
143
|
|
122
144
|
##
|
123
145
|
# Sets all config values back to their defaults.
|
124
146
|
#
|
125
|
-
# @return [
|
126
|
-
def
|
127
|
-
|
128
|
-
@header_depth = 1
|
129
|
-
@sub_header_depth = 2
|
130
|
-
@current_header = 'Current'
|
131
|
-
@previous_header = 'Previous'
|
132
|
-
@impediments_header = 'Impediments'
|
133
|
-
@notes_header = 'Notes'
|
134
|
-
@sub_header_order = %w[previous current impediments notes]
|
135
|
-
@directory = ::File.join(ENV['HOME'], '.cache', 'standup_md')
|
136
|
-
@bullet_character = '-'
|
137
|
-
@name_format = '%Y_%m.md'
|
138
|
-
@create = true
|
139
|
-
true
|
147
|
+
# @return [Hash]
|
148
|
+
def reset
|
149
|
+
DEFAULTS.each { |k, v| instance_variable_set("@#{k}", v) }
|
140
150
|
end
|
141
151
|
|
142
152
|
##
|
data/lib/standup_md/entry.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'json'
|
3
4
|
|
4
5
|
module StandupMD
|
@@ -38,7 +39,7 @@ module StandupMD
|
|
38
39
|
attr_accessor :previous
|
39
40
|
|
40
41
|
##
|
41
|
-
#
|
42
|
+
# Impediments for this entry.
|
42
43
|
#
|
43
44
|
# @return [Array]
|
44
45
|
attr_accessor :impediments
|
@@ -1,10 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
require 'forwardable'
|
2
3
|
|
3
4
|
module StandupMD
|
4
5
|
|
5
6
|
##
|
6
7
|
# Enumerable list of entries.
|
7
8
|
class EntryList
|
9
|
+
extend Forwardable
|
8
10
|
include Enumerable
|
9
11
|
|
10
12
|
##
|
@@ -29,12 +31,6 @@ module StandupMD
|
|
29
31
|
@entries = entries
|
30
32
|
end
|
31
33
|
|
32
|
-
##
|
33
|
-
# Iterate over the list and yield each entry.
|
34
|
-
def each(&block)
|
35
|
-
@entries.each(&block)
|
36
|
-
end
|
37
|
-
|
38
34
|
##
|
39
35
|
# Appends entries to list.
|
40
36
|
#
|
@@ -51,24 +47,12 @@ module StandupMD
|
|
51
47
|
##
|
52
48
|
# Finds an entry based on date. This method assumes the list has already
|
53
49
|
# been sorted.
|
54
|
-
def find(key)
|
55
|
-
to_a.bsearch { |e| e.date == key }
|
56
|
-
end
|
57
|
-
|
58
|
-
##
|
59
|
-
# How many entries are in the list.
|
60
50
|
#
|
61
|
-
# @
|
62
|
-
def size
|
63
|
-
@entries.size
|
64
|
-
end
|
65
|
-
|
66
|
-
##
|
67
|
-
# Is the list empty?
|
51
|
+
# @param [Date] date
|
68
52
|
#
|
69
|
-
# @return [
|
70
|
-
def
|
71
|
-
|
53
|
+
# @return [StandupMD::Entry]
|
54
|
+
def find(date)
|
55
|
+
entries.bsearch { |e| e.date == date }
|
72
56
|
end
|
73
57
|
|
74
58
|
##
|
@@ -124,24 +108,6 @@ module StandupMD
|
|
124
108
|
self
|
125
109
|
end
|
126
110
|
|
127
|
-
##
|
128
|
-
# The first entry in the list. This method assumes the list has
|
129
|
-
# already been sorted.
|
130
|
-
#
|
131
|
-
# @return [StandupMD::Entry]
|
132
|
-
def first
|
133
|
-
to_a.first
|
134
|
-
end
|
135
|
-
|
136
|
-
##
|
137
|
-
# The last entry in the list. This method assumes the list has
|
138
|
-
# already been sorted.
|
139
|
-
#
|
140
|
-
# @return [StandupMD::Entry]
|
141
|
-
def last
|
142
|
-
to_a.last
|
143
|
-
end
|
144
|
-
|
145
111
|
##
|
146
112
|
# The list as a hash, with the dates as keys.
|
147
113
|
#
|
@@ -162,5 +128,22 @@ module StandupMD
|
|
162
128
|
def to_json
|
163
129
|
to_h.to_json
|
164
130
|
end
|
131
|
+
|
132
|
+
# :section: Delegators
|
133
|
+
|
134
|
+
##
|
135
|
+
# The following are forwarded to @entries, which is the underly array of
|
136
|
+
# entries.
|
137
|
+
#
|
138
|
+
# +each+:: Iterate over each entry.
|
139
|
+
#
|
140
|
+
# +empty?+:: Is the list empty?
|
141
|
+
#
|
142
|
+
# +size+:: How many items are in the list?
|
143
|
+
#
|
144
|
+
# +first+:: The first record in the list.
|
145
|
+
#
|
146
|
+
# +last+:: The last record in the list.
|
147
|
+
def_delegators :@entries, :each, :empty?, :size, :first, :last
|
165
148
|
end
|
166
149
|
end
|
data/lib/standup_md/file.rb
CHANGED
@@ -19,6 +19,16 @@ module StandupMD
|
|
19
19
|
@config ||= StandupMD.config.file
|
20
20
|
end
|
21
21
|
|
22
|
+
##
|
23
|
+
# Convenience method for calling File.find(file_name).load
|
24
|
+
#
|
25
|
+
# @param [String] file_name
|
26
|
+
#
|
27
|
+
# @return [StandupMD::File]
|
28
|
+
def self.load(file_name)
|
29
|
+
new(file_name).load
|
30
|
+
end
|
31
|
+
|
22
32
|
##
|
23
33
|
# Find standup file in directory by file name.
|
24
34
|
#
|
@@ -138,6 +148,7 @@ module StandupMD
|
|
138
148
|
entry_list << new_entry(record) unless record.empty?
|
139
149
|
@loaded = true
|
140
150
|
@entries = entry_list.sort
|
151
|
+
self
|
141
152
|
rescue => e
|
142
153
|
raise "File malformation: #{e}"
|
143
154
|
end
|
@@ -147,7 +158,7 @@ module StandupMD
|
|
147
158
|
# This method is destructive; if a file for entries in the date range
|
148
159
|
# already exists, it will be clobbered with the entries in the range.
|
149
160
|
#
|
150
|
-
# @param [Hash]
|
161
|
+
# @param [Hash] {start_date: Date, end_date: Date}
|
151
162
|
#
|
152
163
|
# @return [Boolean] true if successful
|
153
164
|
def write(dates = {})
|
@@ -158,9 +169,9 @@ module StandupMD
|
|
158
169
|
sorted_entries.filter(start_date, end_date).sort_reverse.each do |entry|
|
159
170
|
f.puts header(entry.date)
|
160
171
|
@config.sub_header_order.each do |attr|
|
161
|
-
tasks = entry.
|
172
|
+
tasks = entry.public_send(attr)
|
162
173
|
next if !tasks || tasks.empty?
|
163
|
-
f.puts sub_header(@config.
|
174
|
+
f.puts sub_header(@config.public_send("#{attr}_header").capitalize)
|
164
175
|
tasks.each { |task| f.puts @config.bullet_character + ' ' + task }
|
165
176
|
end
|
166
177
|
f.puts
|