standup_md 0.3.1 → 0.3.6
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 +77 -43
- data/Rakefile +3 -1
- data/doc/README_md.html +63 -59
- data/doc/StandupMD.html +4 -23
- data/doc/StandupMD/Cli.html +11 -11
- data/doc/StandupMD/Cli/Helpers.html +8 -7
- 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 +1 -1
- data/doc/StandupMD/EntryList.html +116 -194
- data/doc/StandupMD/File.html +67 -25
- data/doc/StandupMD/Version.html +176 -0
- data/doc/created.rid +15 -15
- data/doc/index.html +62 -58
- 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 +66 -59
- data/lib/standup_md.rb +4 -3
- data/lib/standup_md/cli.rb +2 -3
- data/lib/standup_md/cli/helpers.rb +66 -34
- data/lib/standup_md/config.rb +2 -2
- data/lib/standup_md/config/cli.rb +24 -23
- data/lib/standup_md/config/entry.rb +14 -9
- 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 -2
- data/lib/standup_md/entry_list.rb +24 -41
- data/lib/standup_md/file.rb +42 -15
- data/lib/standup_md/file/helpers.rb +13 -15
- data/lib/standup_md/version.rb +23 -6
- data/standup_md.gemspec +12 -16
- metadata +7 -6
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
|
@@ -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
|
##
|
@@ -52,6 +52,7 @@ module StandupMD
|
|
52
52
|
def self.load_config_file(file)
|
53
53
|
file = ::File.expand_path(file)
|
54
54
|
raise "File #{file} does not exist." unless ::File.file?(file)
|
55
|
+
|
55
56
|
@config_file_loaded = true
|
56
57
|
load file
|
57
58
|
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
|
@@ -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
|
-
puts
|
22
|
-
|
23
|
-
tasks = entry.
|
19
|
+
puts header(entry)
|
20
|
+
config.file.sub_header_order.each do |header_type|
|
21
|
+
tasks = entry.public_send(header_type)
|
24
22
|
next if !tasks || tasks.empty?
|
25
|
-
|
26
|
-
|
23
|
+
|
24
|
+
puts sub_header(header_type)
|
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,16 +123,16 @@ module StandupMD
|
|
116
123
|
# The entry for today.
|
117
124
|
#
|
118
125
|
# @return [StandupMD::Entry]
|
119
|
-
def
|
120
|
-
entry = file.entries.find(
|
121
|
-
if entry.nil? &&
|
126
|
+
def new_entry(file)
|
127
|
+
entry = file.entries.find(config.cli.date)
|
128
|
+
if entry.nil? && config.cli.date == Date.today
|
122
129
|
previous_entry = set_previous_entry(file)
|
123
130
|
entry = StandupMD::Entry.new(
|
124
|
-
|
125
|
-
|
131
|
+
config.cli.date,
|
132
|
+
config.entry.current,
|
126
133
|
previous_entry,
|
127
|
-
|
128
|
-
|
134
|
+
config.entry.impediments,
|
135
|
+
config.entry.notes
|
129
136
|
)
|
130
137
|
file.entries << entry
|
131
138
|
end
|
@@ -137,8 +144,10 @@ module StandupMD
|
|
137
144
|
#
|
138
145
|
# @return [Array]
|
139
146
|
def set_previous_entry(file)
|
140
|
-
return
|
147
|
+
return config.entry.previous_entry unless config.cli.auto_fill_previous
|
148
|
+
|
141
149
|
return prev_entry(prev_file.load.entries) if file.new? && prev_file
|
150
|
+
|
142
151
|
prev_entry(file.entries)
|
143
152
|
end
|
144
153
|
|
@@ -150,6 +159,7 @@ module StandupMD
|
|
150
159
|
# @return [StandupMD::Entry]
|
151
160
|
def prev_entry(entries)
|
152
161
|
return [] if entries.empty?
|
162
|
+
|
153
163
|
entries.last.current
|
154
164
|
end
|
155
165
|
|
@@ -160,6 +170,28 @@ module StandupMD
|
|
160
170
|
def prev_file
|
161
171
|
StandupMD::File.find_by_date(Date.today.prev_month)
|
162
172
|
end
|
173
|
+
|
174
|
+
##
|
175
|
+
# The header.
|
176
|
+
#
|
177
|
+
# @param [StandupMD::Entry] entry
|
178
|
+
#
|
179
|
+
# @return [String]
|
180
|
+
def header(entry)
|
181
|
+
'#' * config.file.header_depth + ' ' +
|
182
|
+
entry.date.strftime(config.file.header_date_format)
|
183
|
+
end
|
184
|
+
|
185
|
+
##
|
186
|
+
# The sub-header.
|
187
|
+
#
|
188
|
+
# @param [String] header_type
|
189
|
+
#
|
190
|
+
# @return [String]
|
191
|
+
def sub_header(header_type)
|
192
|
+
'#' * config.file.sub_header_depth + ' ' +
|
193
|
+
config.file.public_send("#{header_type}_header").capitalize
|
194
|
+
end
|
163
195
|
end
|
164
196
|
end
|
165
197
|
end
|
data/lib/standup_md/config.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'config/cli'
|
2
4
|
require_relative 'config/file'
|
3
5
|
require_relative 'config/entry'
|
4
6
|
require_relative 'config/entry_list'
|
5
7
|
|
6
8
|
module StandupMD
|
7
|
-
|
8
9
|
##
|
9
10
|
# This class provides a connector from StandupMD to the configuration classes.
|
10
11
|
class Config
|
11
|
-
|
12
12
|
##
|
13
13
|
# Reader for Cli config.
|
14
14
|
#
|
@@ -1,12 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'date'
|
3
4
|
|
4
5
|
module StandupMD
|
5
6
|
class Config
|
6
|
-
|
7
7
|
##
|
8
8
|
# The configuration class for StandupMD::Cli
|
9
9
|
class Cli
|
10
|
+
##
|
11
|
+
# The default options.
|
12
|
+
#
|
13
|
+
# @return [Hash]
|
14
|
+
DEFAULTS = {
|
15
|
+
date: Date.today,
|
16
|
+
editor: ENV['VISUAL'] || ENV['EDITOR'] || 'vim',
|
17
|
+
verbose: false,
|
18
|
+
edit: true,
|
19
|
+
write: true,
|
20
|
+
print: false,
|
21
|
+
auto_fill_previous: true,
|
22
|
+
preference_file:
|
23
|
+
::File.expand_path(::File.join(ENV['HOME'], '.standuprc'))
|
24
|
+
}.freeze
|
25
|
+
|
10
26
|
##
|
11
27
|
# The editor to use when opening standup files. If one is not set, the
|
12
28
|
# first of $VISUAL, $EDITOR, or vim will be used, in that order.
|
@@ -33,7 +49,7 @@ module StandupMD
|
|
33
49
|
attr_accessor :edit
|
34
50
|
|
35
51
|
##
|
36
|
-
# Should the cli write the file?
|
52
|
+
# Should the cli automatically write the new entry to the file?
|
37
53
|
#
|
38
54
|
# @param [Boolean] write
|
39
55
|
#
|
@@ -41,7 +57,7 @@ module StandupMD
|
|
41
57
|
attr_accessor :write
|
42
58
|
|
43
59
|
##
|
44
|
-
# Should the cli print the entry?
|
60
|
+
# Should the cli print the entry to the command line?
|
45
61
|
#
|
46
62
|
# @param [Boolean] print
|
47
63
|
#
|
@@ -49,7 +65,7 @@ module StandupMD
|
|
49
65
|
attr_accessor :print
|
50
66
|
|
51
67
|
##
|
52
|
-
# The date to use to find the
|
68
|
+
# The date to use to find the entry.
|
53
69
|
#
|
54
70
|
# @param [Date] date
|
55
71
|
#
|
@@ -76,30 +92,15 @@ module StandupMD
|
|
76
92
|
##
|
77
93
|
# Initializes the config with default values.
|
78
94
|
def initialize
|
79
|
-
|
95
|
+
reset
|
80
96
|
end
|
81
97
|
|
82
98
|
##
|
83
99
|
# Sets all config values back to their defaults.
|
84
100
|
#
|
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'
|
101
|
+
# @return [Hash]
|
102
|
+
def reset
|
103
|
+
DEFAULTS.each { |k, v| instance_variable_set("@#{k}", v) }
|
103
104
|
end
|
104
105
|
end
|
105
106
|
end
|
@@ -2,10 +2,19 @@
|
|
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
|
8
|
+
##
|
9
|
+
# The default options.
|
10
|
+
#
|
11
|
+
# @return [Hash]
|
12
|
+
DEFAULTS = {
|
13
|
+
current: ["<!-- ADD TODAY'S WORK HERE -->"],
|
14
|
+
previous: [],
|
15
|
+
impediments: ['None'],
|
16
|
+
notes: []
|
17
|
+
}.freeze
|
9
18
|
|
10
19
|
##
|
11
20
|
# Tasks for "Current" section.
|
@@ -42,19 +51,15 @@ module StandupMD
|
|
42
51
|
##
|
43
52
|
# Initializes the config with default values.
|
44
53
|
def initialize
|
45
|
-
|
54
|
+
reset
|
46
55
|
end
|
47
56
|
|
48
57
|
##
|
49
58
|
# Sets all config values back to their defaults.
|
50
59
|
#
|
51
|
-
# @return [
|
52
|
-
def
|
53
|
-
|
54
|
-
@previous = []
|
55
|
-
@impediments = ['None']
|
56
|
-
@notes = []
|
57
|
-
true
|
60
|
+
# @return [Hash]
|
61
|
+
def reset
|
62
|
+
DEFAULTS.each { |k, v| instance_variable_set("@#{k}", v) }
|
58
63
|
end
|
59
64
|
end
|
60
65
|
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
|