standup_md 0.3.5 → 0.3.10
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 +11 -9
- data/README.md +45 -40
- data/Rakefile +3 -1
- data/doc/README_md.html +51 -65
- data/doc/StandupMD.html +16 -102
- data/doc/StandupMD/Cli.html +28 -170
- data/doc/StandupMD/Cli/Helpers.html +10 -31
- data/doc/StandupMD/Config.html +8 -45
- data/doc/StandupMD/Config/Cli.html +10 -78
- data/doc/StandupMD/Config/Entry.html +10 -66
- data/doc/StandupMD/Config/EntryList.html +7 -48
- data/doc/StandupMD/Config/File.html +11 -143
- data/doc/StandupMD/Entry.html +24 -135
- data/doc/StandupMD/EntryList.html +16 -198
- data/doc/StandupMD/File.html +48 -179
- data/doc/StandupMD/Version.html +143 -0
- data/doc/created.rid +14 -14
- data/doc/css/rdoc.css +1 -1
- data/doc/index.html +51 -77
- data/doc/js/navigation.js.gz +0 -0
- data/doc/js/search_index.js +1 -1
- data/doc/js/search_index.js.gz +0 -0
- data/doc/js/searcher.js.gz +0 -0
- data/doc/table_of_contents.html +36 -88
- data/lib/standup_md.rb +10 -6
- data/lib/standup_md/cli.rb +9 -10
- data/lib/standup_md/cli/helpers.rb +50 -45
- data/lib/standup_md/config.rb +0 -2
- data/lib/standup_md/config/cli.rb +2 -4
- data/lib/standup_md/config/entry.rb +2 -4
- data/lib/standup_md/config/file.rb +3 -3
- data/lib/standup_md/entry.rb +7 -10
- data/lib/standup_md/entry_list.rb +1 -1
- data/lib/standup_md/file.rb +29 -12
- data/lib/standup_md/file/helpers.rb +13 -15
- data/lib/standup_md/version.rb +45 -4
- data/standup_md.gemspec +12 -16
- metadata +7 -6
data/lib/standup_md.rb
CHANGED
@@ -17,7 +17,7 @@ module StandupMD
|
|
17
17
|
#
|
18
18
|
# @return [StanupMD::Cli]
|
19
19
|
def self.config
|
20
|
-
@config
|
20
|
+
@config || reset_config
|
21
21
|
end
|
22
22
|
|
23
23
|
##
|
@@ -34,7 +34,7 @@ module StandupMD
|
|
34
34
|
# @example
|
35
35
|
# StandupMD.configure { |s| s.cli.editor = 'mate' }
|
36
36
|
def self.configure
|
37
|
-
yield
|
37
|
+
yield config
|
38
38
|
end
|
39
39
|
|
40
40
|
##
|
@@ -49,10 +49,14 @@ module StandupMD
|
|
49
49
|
# Loads a config file.
|
50
50
|
#
|
51
51
|
# @param [String] file
|
52
|
+
#
|
53
|
+
# @return [String] file
|
52
54
|
def self.load_config_file(file)
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
55
|
+
::File.expand_path(file).tap do |file|
|
56
|
+
raise "File #{file} does not exist." unless ::File.file?(file)
|
57
|
+
|
58
|
+
@config_file_loaded = true
|
59
|
+
load file
|
60
|
+
end
|
57
61
|
end
|
58
62
|
end
|
data/lib/standup_md/cli.rb
CHANGED
@@ -4,7 +4,6 @@ require 'optparse'
|
|
4
4
|
require_relative 'cli/helpers'
|
5
5
|
|
6
6
|
module StandupMD
|
7
|
-
|
8
7
|
##
|
9
8
|
# Class for handing the command-line interface.
|
10
9
|
class Cli
|
@@ -29,13 +28,13 @@ module StandupMD
|
|
29
28
|
##
|
30
29
|
# Creates an instance of +StandupMD+ and runs what the user requested.
|
31
30
|
def self.execute(options = [])
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
31
|
+
new(options).tap do |exe|
|
32
|
+
exe.write_file if config.write
|
33
|
+
if config.print
|
34
|
+
exe.print(exe.entry)
|
35
|
+
elsif config.edit
|
36
|
+
exe.edit
|
37
|
+
end
|
39
38
|
end
|
40
39
|
end
|
41
40
|
|
@@ -66,10 +65,10 @@ module StandupMD
|
|
66
65
|
@preference_file_loaded = false
|
67
66
|
@options = options
|
68
67
|
load_preferences if load_config
|
69
|
-
|
68
|
+
load_runtime_preferences(options)
|
70
69
|
@file = StandupMD::File.find_by_date(@config.date)
|
71
70
|
@file.load
|
72
|
-
@entry =
|
71
|
+
@entry = new_entry(@file)
|
73
72
|
end
|
74
73
|
|
75
74
|
##
|
@@ -2,11 +2,9 @@
|
|
2
2
|
|
3
3
|
module StandupMD
|
4
4
|
class Cli
|
5
|
-
|
6
5
|
##
|
7
6
|
# Module responsible for reading and writing standup files.
|
8
7
|
module Helpers
|
9
|
-
|
10
8
|
##
|
11
9
|
# Print an entry to the command line.
|
12
10
|
#
|
@@ -15,99 +13,108 @@ module StandupMD
|
|
15
13
|
# @return [nil]
|
16
14
|
def print(entry)
|
17
15
|
if entry.nil?
|
18
|
-
puts "No record found for #{
|
16
|
+
puts "No record found for #{config.cli.date}"
|
19
17
|
return
|
20
18
|
end
|
21
19
|
puts header(entry)
|
22
|
-
|
20
|
+
config.file.sub_header_order.each do |header_type|
|
23
21
|
tasks = entry.public_send(header_type)
|
24
22
|
next if !tasks || tasks.empty?
|
23
|
+
|
25
24
|
puts sub_header(header_type)
|
26
|
-
tasks.each { |task| puts
|
25
|
+
tasks.each { |task| puts config.file.bullet_character + ' ' + task }
|
27
26
|
end
|
28
27
|
puts
|
29
28
|
end
|
30
29
|
|
31
30
|
private
|
32
31
|
|
32
|
+
##
|
33
|
+
# Helper for accessing config.
|
34
|
+
#
|
35
|
+
# @return [StandupMD::Config]
|
36
|
+
def config # :nodoc:
|
37
|
+
StandupMD.config
|
38
|
+
end
|
39
|
+
|
33
40
|
##
|
34
41
|
# Parses options passed at runtime and concatenates them with the options
|
35
42
|
# in the user's preferences file. Reveal source to see options.
|
36
43
|
#
|
37
44
|
# @return [Hash]
|
38
|
-
def
|
45
|
+
def load_runtime_preferences(options)
|
39
46
|
OptionParser.new do |opts|
|
40
47
|
opts.banner = 'The Standup Doctor'
|
41
|
-
opts.version = "[StandupMD] #{::StandupMD::
|
48
|
+
opts.version = "[StandupMD] #{::StandupMD::Version}"
|
42
49
|
opts.on(
|
43
50
|
'--current ARRAY', Array,
|
44
51
|
"List of current entry's tasks"
|
45
|
-
) { |v|
|
52
|
+
) { |v| config.entry.current = v }
|
46
53
|
|
47
54
|
opts.on(
|
48
55
|
'--previous ARRAY', Array,
|
49
56
|
"List of precious entry's tasks"
|
50
|
-
) { |v|
|
57
|
+
) { |v| config.entry.previous = v }
|
51
58
|
|
52
59
|
opts.on(
|
53
60
|
'--impediments ARRAY', Array,
|
54
61
|
'List of impediments for current entry'
|
55
|
-
) { |v|
|
62
|
+
) { |v| config.entry.impediments = v }
|
56
63
|
|
57
64
|
opts.on(
|
58
65
|
'--notes ARRAY', Array,
|
59
66
|
'List of notes for current entry'
|
60
|
-
) { |v|
|
67
|
+
) { |v| config.entry.notes = v }
|
61
68
|
|
62
69
|
opts.on(
|
63
70
|
'--sub-header-order ARRAY', Array,
|
64
71
|
'The order of the sub-headers when writing the file'
|
65
|
-
) { |v|
|
72
|
+
) { |v| config.file.sub_header_order = v }
|
66
73
|
|
67
74
|
opts.on(
|
68
75
|
'-f', '--file-name-format STRING',
|
69
76
|
'Date-formattable string to use for standup file name'
|
70
|
-
) { |v|
|
77
|
+
) { |v| config.file.name_format = v }
|
71
78
|
|
72
79
|
opts.on(
|
73
80
|
'-E', '--editor EDITOR',
|
74
81
|
'Editor to use for opening standup files'
|
75
|
-
) { |v|
|
82
|
+
) { |v| config.cli.editor = v }
|
76
83
|
|
77
84
|
opts.on(
|
78
85
|
'-d', '--directory DIRECTORY',
|
79
86
|
'The directories where standup files are located'
|
80
|
-
) { |v|
|
87
|
+
) { |v| config.file.directory = v }
|
81
88
|
|
82
89
|
opts.on(
|
83
90
|
'-w', '--[no-]write',
|
84
91
|
"Write current entry if it doesn't exist. Default is true"
|
85
|
-
) { |v|
|
92
|
+
) { |v| config.cli.write = v }
|
86
93
|
|
87
94
|
opts.on(
|
88
95
|
'-a', '--[no-]auto-fill-previous',
|
89
96
|
"Auto-generate 'previous' tasks for new entries. Default is true"
|
90
|
-
) { |v|
|
97
|
+
) { |v| config.cli.auto_fill_previous = v }
|
91
98
|
|
92
99
|
opts.on(
|
93
100
|
'-e', '--[no-]edit',
|
94
101
|
'Open the file in the editor. Default is true'
|
95
|
-
) { |v|
|
102
|
+
) { |v| config.cli.edit = v }
|
96
103
|
|
97
104
|
opts.on(
|
98
105
|
'-v', '--[no-]verbose',
|
99
106
|
'Verbose output. Default is false.'
|
100
|
-
) { |v|
|
107
|
+
) { |v| config.cli.verbose = v }
|
101
108
|
|
102
109
|
opts.on(
|
103
110
|
'-p', '--print [DATE]',
|
104
111
|
'Print current entry.',
|
105
112
|
'If DATE is passed, will print entry for DATE, if it exists.',
|
106
|
-
'DATE must be in the same format as file-name-format'
|
113
|
+
'DATE must be in the same format as file-name-format'
|
107
114
|
) do |v|
|
108
|
-
|
109
|
-
|
110
|
-
v.nil? ? Date.today : Date.strptime(v,
|
115
|
+
config.cli.print = true
|
116
|
+
config.cli.date =
|
117
|
+
v.nil? ? Date.today : Date.strptime(v, config.file.header_date_format)
|
111
118
|
end
|
112
119
|
end.parse!(options)
|
113
120
|
end
|
@@ -116,31 +123,28 @@ module StandupMD
|
|
116
123
|
# The entry for today.
|
117
124
|
#
|
118
125
|
# @return [StandupMD::Entry]
|
119
|
-
def
|
120
|
-
entry = file.entries.find(
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
file.entries << entry
|
131
|
-
end
|
132
|
-
entry
|
126
|
+
def new_entry(file)
|
127
|
+
entry = file.entries.find(config.cli.date)
|
128
|
+
return entry unless entry.nil? && config.cli.date == Date.today
|
129
|
+
|
130
|
+
StandupMD::Entry.new(
|
131
|
+
config.cli.date,
|
132
|
+
config.entry.current,
|
133
|
+
previous_entry(file),
|
134
|
+
config.entry.impediments,
|
135
|
+
config.entry.notes
|
136
|
+
).tap { |entry| file.entries << entry }
|
133
137
|
end
|
134
138
|
|
135
139
|
##
|
136
140
|
# The "previous" entries.
|
137
141
|
#
|
138
142
|
# @return [Array]
|
139
|
-
def
|
140
|
-
unless
|
141
|
-
|
142
|
-
end
|
143
|
+
def previous_entry(file)
|
144
|
+
return config.entry.previous_entry unless config.cli.auto_fill_previous
|
145
|
+
|
143
146
|
return prev_entry(prev_file.load.entries) if file.new? && prev_file
|
147
|
+
|
144
148
|
prev_entry(file.entries)
|
145
149
|
end
|
146
150
|
|
@@ -152,6 +156,7 @@ module StandupMD
|
|
152
156
|
# @return [StandupMD::Entry]
|
153
157
|
def prev_entry(entries)
|
154
158
|
return [] if entries.empty?
|
159
|
+
|
155
160
|
entries.last.current
|
156
161
|
end
|
157
162
|
|
@@ -170,8 +175,8 @@ module StandupMD
|
|
170
175
|
#
|
171
176
|
# @return [String]
|
172
177
|
def header(entry)
|
173
|
-
'#' *
|
174
|
-
entry.date.strftime(
|
178
|
+
'#' * config.file.header_depth + ' ' +
|
179
|
+
entry.date.strftime(config.file.header_date_format)
|
175
180
|
end
|
176
181
|
|
177
182
|
##
|
@@ -181,8 +186,8 @@ module StandupMD
|
|
181
186
|
#
|
182
187
|
# @return [String]
|
183
188
|
def sub_header(header_type)
|
184
|
-
'#' *
|
185
|
-
|
189
|
+
'#' * config.file.sub_header_depth + ' ' +
|
190
|
+
config.file.public_send("#{header_type}_header").capitalize
|
186
191
|
end
|
187
192
|
end
|
188
193
|
end
|
data/lib/standup_md/config.rb
CHANGED
@@ -4,11 +4,9 @@ require 'date'
|
|
4
4
|
|
5
5
|
module StandupMD
|
6
6
|
class Config
|
7
|
-
|
8
7
|
##
|
9
8
|
# The configuration class for StandupMD::Cli
|
10
9
|
class Cli
|
11
|
-
|
12
10
|
##
|
13
11
|
# The default options.
|
14
12
|
#
|
@@ -22,8 +20,8 @@ module StandupMD
|
|
22
20
|
print: false,
|
23
21
|
auto_fill_previous: true,
|
24
22
|
preference_file:
|
25
|
-
::File.expand_path(::File.join(ENV['HOME'], '.standuprc'))
|
26
|
-
}
|
23
|
+
::File.expand_path(::File.join(ENV['HOME'], '.standuprc'))
|
24
|
+
}.freeze
|
27
25
|
|
28
26
|
##
|
29
27
|
# The editor to use when opening standup files. If one is not set, the
|
@@ -2,11 +2,9 @@
|
|
2
2
|
|
3
3
|
module StandupMD
|
4
4
|
class Config
|
5
|
-
|
6
5
|
##
|
7
6
|
# The configuration class for StandupMD::Entry
|
8
7
|
class Entry
|
9
|
-
|
10
8
|
##
|
11
9
|
# The default options.
|
12
10
|
#
|
@@ -15,8 +13,8 @@ module StandupMD
|
|
15
13
|
current: ["<!-- ADD TODAY'S WORK HERE -->"],
|
16
14
|
previous: [],
|
17
15
|
impediments: ['None'],
|
18
|
-
notes: []
|
19
|
-
}
|
16
|
+
notes: []
|
17
|
+
}.freeze
|
20
18
|
|
21
19
|
##
|
22
20
|
# Tasks for "Current" section.
|
@@ -200,9 +200,9 @@ module StandupMD
|
|
200
200
|
#
|
201
201
|
# @return [String]
|
202
202
|
def directory=(directory)
|
203
|
-
directory = ::File.expand_path(directory)
|
204
|
-
|
205
|
-
|
203
|
+
@directory = ::File.expand_path(directory).tap do |directory|
|
204
|
+
FileUtils.mkdir_p(directory) unless ::File.directory?(directory)
|
205
|
+
end
|
206
206
|
end
|
207
207
|
end
|
208
208
|
end
|
data/lib/standup_md/entry.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
require 'json'
|
4
4
|
|
5
5
|
module StandupMD
|
6
|
-
|
7
6
|
##
|
8
7
|
# Class for handling single entries. Includes the comparable module, and
|
9
8
|
# compares by date.
|
@@ -56,15 +55,13 @@ module StandupMD
|
|
56
55
|
#
|
57
56
|
# @return [StandupMD::Entry]
|
58
57
|
def self.create
|
59
|
-
|
58
|
+
new(
|
60
59
|
Date.today,
|
61
60
|
config.current,
|
62
61
|
config.previous,
|
63
62
|
config.impediments,
|
64
63
|
config.notes
|
65
|
-
)
|
66
|
-
yield config if block_given?
|
67
|
-
entry
|
64
|
+
).tap { |entry| yield entry if block_given? }
|
68
65
|
end
|
69
66
|
|
70
67
|
##
|
@@ -83,11 +80,11 @@ module StandupMD
|
|
83
80
|
raise unless date.is_a?(Date)
|
84
81
|
@config = self.class.config
|
85
82
|
|
86
|
-
@date
|
87
|
-
@current
|
88
|
-
@previous
|
89
|
-
@impediments
|
90
|
-
@notes
|
83
|
+
@date = date
|
84
|
+
@current = current
|
85
|
+
@previous = previous
|
86
|
+
@impediments = impediments
|
87
|
+
@notes = notes
|
91
88
|
end
|
92
89
|
|
93
90
|
##
|
data/lib/standup_md/file.rb
CHANGED
@@ -5,7 +5,6 @@ require 'fileutils'
|
|
5
5
|
require_relative 'file/helpers'
|
6
6
|
|
7
7
|
module StandupMD
|
8
|
-
|
9
8
|
##
|
10
9
|
# Class for handling reading and writing standup files.
|
11
10
|
class File
|
@@ -26,6 +25,11 @@ module StandupMD
|
|
26
25
|
#
|
27
26
|
# @return [StandupMD::File]
|
28
27
|
def self.load(file_name)
|
28
|
+
unless ::File.directory?(config.directory)
|
29
|
+
raise "Dir #{config.directory} not found." unless config.create
|
30
|
+
|
31
|
+
FileUtils.mkdir_p(config.directory)
|
32
|
+
end
|
29
33
|
new(file_name).load
|
30
34
|
end
|
31
35
|
|
@@ -34,10 +38,14 @@ module StandupMD
|
|
34
38
|
#
|
35
39
|
# @param [String] File_naem
|
36
40
|
def self.find(file_name)
|
37
|
-
|
38
|
-
|
39
|
-
|
41
|
+
unless ::File.directory?(config.directory)
|
42
|
+
raise "Dir #{config.directory} not found." unless config.create
|
43
|
+
|
44
|
+
FileUtils.mkdir_p(config.directory)
|
40
45
|
end
|
46
|
+
file = Dir.entries(config.directory).bsearch { |f| f == file_name }
|
47
|
+
raise "File #{file_name} not found." if file.nil? && !config.create
|
48
|
+
|
41
49
|
new(file_name)
|
42
50
|
end
|
43
51
|
|
@@ -46,8 +54,12 @@ module StandupMD
|
|
46
54
|
#
|
47
55
|
# @param [Date] date
|
48
56
|
def self.find_by_date(date)
|
49
|
-
unless date.is_a?(Date)
|
50
|
-
|
57
|
+
raise ArgumentError, 'Must be a Date object' unless date.is_a?(Date)
|
58
|
+
|
59
|
+
unless ::File.directory?(config.directory)
|
60
|
+
raise "Dir #{config.directory} not found." unless config.create
|
61
|
+
|
62
|
+
FileUtils.mkdir_p(config.directory)
|
51
63
|
end
|
52
64
|
find(date.strftime(config.name_format))
|
53
65
|
end
|
@@ -79,6 +91,7 @@ module StandupMD
|
|
79
91
|
|
80
92
|
unless ::File.directory?(@config.directory)
|
81
93
|
raise "Dir #{@config.directory} not found." unless @config.create
|
94
|
+
|
82
95
|
FileUtils.mkdir_p(@config.directory)
|
83
96
|
end
|
84
97
|
|
@@ -86,6 +99,7 @@ module StandupMD
|
|
86
99
|
|
87
100
|
unless ::File.file?(@name)
|
88
101
|
raise "File #{@name} not found." unless @config.create
|
102
|
+
|
89
103
|
FileUtils.touch(@name)
|
90
104
|
end
|
91
105
|
|
@@ -124,21 +138,23 @@ module StandupMD
|
|
124
138
|
# @return [StandupMD::FileList]
|
125
139
|
def load
|
126
140
|
raise "File #{name} does not exist." unless ::File.file?(name)
|
141
|
+
|
127
142
|
entry_list = EntryList.new
|
128
143
|
record = {}
|
129
144
|
section_type = ''
|
130
145
|
::File.foreach(name) do |line|
|
131
146
|
line.chomp!
|
132
147
|
next if line.strip.empty?
|
133
|
-
|
148
|
+
|
149
|
+
if header?(line)
|
134
150
|
unless record.empty?
|
135
151
|
entry_list << new_entry(record)
|
136
152
|
record = {}
|
137
153
|
end
|
138
|
-
record['header'] = line.sub(
|
139
|
-
|
140
|
-
|
141
|
-
elsif
|
154
|
+
record['header'] = line.sub(/^\#{#{@config.header_depth}}\s*/, '')
|
155
|
+
section_type = @config.notes_header
|
156
|
+
record[section_type] = []
|
157
|
+
elsif sub_header?(line)
|
142
158
|
section_type = determine_section_type(line)
|
143
159
|
record[section_type] = []
|
144
160
|
else
|
@@ -161,7 +177,7 @@ module StandupMD
|
|
161
177
|
# @param [Hash] {start_date: Date, end_date: Date}
|
162
178
|
#
|
163
179
|
# @return [Boolean] true if successful
|
164
|
-
def write(dates
|
180
|
+
def write(**dates)
|
165
181
|
sorted_entries = entries.sort
|
166
182
|
start_date = dates.fetch(:start_date, sorted_entries.first.date)
|
167
183
|
end_date = dates.fetch(:end_date, sorted_entries.last.date)
|
@@ -171,6 +187,7 @@ module StandupMD
|
|
171
187
|
@config.sub_header_order.each do |attr|
|
172
188
|
tasks = entry.public_send(attr)
|
173
189
|
next if !tasks || tasks.empty?
|
190
|
+
|
174
191
|
f.puts sub_header(@config.public_send("#{attr}_header").capitalize)
|
175
192
|
tasks.each { |task| f.puts @config.bullet_character + ' ' + task }
|
176
193
|
end
|