standup_md 0.2.1 → 0.3.0
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/.gitignore +1 -0
- data/Gemfile.lock +7 -1
- data/README.md +142 -116
- data/bin/standup +1 -1
- data/doc/README_md.html +143 -96
- data/doc/StandupMD.html +96 -1322
- data/doc/StandupMD/Cli.html +124 -479
- data/doc/StandupMD/Cli/Helpers.html +167 -0
- data/doc/StandupMD/Config.html +230 -0
- data/doc/StandupMD/Config/Cli.html +355 -0
- data/doc/StandupMD/Config/Entry.html +284 -0
- data/doc/StandupMD/Config/EntryList.html +197 -0
- data/doc/StandupMD/Config/File.html +609 -0
- data/doc/StandupMD/Entry.html +478 -0
- data/doc/StandupMD/EntryList.html +759 -0
- data/doc/StandupMD/File.html +574 -0
- data/doc/created.rid +15 -5
- data/doc/index.html +153 -94
- data/doc/js/search_index.js +1 -1
- data/doc/js/search_index.js.gz +0 -0
- data/doc/table_of_contents.html +221 -72
- data/lib/standup_md.rb +27 -544
- data/lib/standup_md/cli.rb +63 -246
- data/lib/standup_md/cli/helpers.rb +165 -0
- data/lib/standup_md/config.rb +45 -0
- data/lib/standup_md/config/cli.rb +106 -0
- data/lib/standup_md/config/entry.rb +61 -0
- data/lib/standup_md/config/entry_list.rb +26 -0
- data/lib/standup_md/config/file.rb +199 -0
- data/lib/standup_md/entry.rb +121 -0
- data/lib/standup_md/entry_list.rb +166 -0
- data/lib/standup_md/file.rb +172 -0
- data/lib/standup_md/file/helpers.rb +62 -0
- data/lib/standup_md/version.rb +5 -3
- data/standup_md.gemspec +1 -0
- metadata +35 -2
@@ -0,0 +1,45 @@
|
|
1
|
+
require_relative 'config/cli'
|
2
|
+
require_relative 'config/file'
|
3
|
+
require_relative 'config/entry'
|
4
|
+
require_relative 'config/entry_list'
|
5
|
+
|
6
|
+
module StandupMD
|
7
|
+
|
8
|
+
##
|
9
|
+
# This class provides a connector from StandupMD to the configuration classes.
|
10
|
+
class Config
|
11
|
+
|
12
|
+
##
|
13
|
+
# Reader for Cli config.
|
14
|
+
#
|
15
|
+
# @return [StandupMD::Config::Cli]
|
16
|
+
attr_reader :cli
|
17
|
+
|
18
|
+
##
|
19
|
+
# Reader for File config.
|
20
|
+
#
|
21
|
+
# @return [StandupMD::Config::File]
|
22
|
+
attr_reader :file
|
23
|
+
|
24
|
+
##
|
25
|
+
# Reader for Entry config.
|
26
|
+
#
|
27
|
+
# @return [StandupMD::Config::Entry]
|
28
|
+
attr_reader :entry
|
29
|
+
|
30
|
+
##
|
31
|
+
# Reader for EntryList config.
|
32
|
+
#
|
33
|
+
# @return [StandupMD::Config::EntryList]
|
34
|
+
attr_reader :entry_list
|
35
|
+
|
36
|
+
##
|
37
|
+
# Builds the links to the configuration classes.
|
38
|
+
def initialize
|
39
|
+
@cli = StandupMD::Config::Cli.new
|
40
|
+
@file = StandupMD::Config::File.new
|
41
|
+
@entry = StandupMD::Config::Entry.new
|
42
|
+
@entry_list = StandupMD::Config::EntryList.new
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'date'
|
3
|
+
|
4
|
+
module StandupMD
|
5
|
+
class Config
|
6
|
+
|
7
|
+
##
|
8
|
+
# The configuration class for StandupMD::Cli
|
9
|
+
class Cli
|
10
|
+
##
|
11
|
+
# The editor to use when opening standup files. If one is not set, the
|
12
|
+
# first of $VISUAL, $EDITOR, or vim will be used, in that order.
|
13
|
+
#
|
14
|
+
# @param [String] editor
|
15
|
+
#
|
16
|
+
# @return [String]
|
17
|
+
attr_accessor :editor
|
18
|
+
|
19
|
+
##
|
20
|
+
# Should the cli print verbose output?
|
21
|
+
#
|
22
|
+
# @param [Boolean] verbose
|
23
|
+
#
|
24
|
+
# @return [Boolean]
|
25
|
+
attr_accessor :verbose
|
26
|
+
|
27
|
+
##
|
28
|
+
# Should the cli edit?
|
29
|
+
#
|
30
|
+
# @param [Boolean] edit
|
31
|
+
#
|
32
|
+
# @return [Boolean]
|
33
|
+
attr_accessor :edit
|
34
|
+
|
35
|
+
##
|
36
|
+
# Should the cli write the file?
|
37
|
+
#
|
38
|
+
# @param [Boolean] write
|
39
|
+
#
|
40
|
+
# @return [Boolean]
|
41
|
+
attr_accessor :write
|
42
|
+
|
43
|
+
##
|
44
|
+
# Should the cli print the entry?
|
45
|
+
#
|
46
|
+
# @param [Boolean] print
|
47
|
+
#
|
48
|
+
# @return [Boolean]
|
49
|
+
attr_accessor :print
|
50
|
+
|
51
|
+
##
|
52
|
+
# The date to use to find the file.
|
53
|
+
#
|
54
|
+
# @param [Date] date
|
55
|
+
#
|
56
|
+
# @return [Date]
|
57
|
+
attr_accessor :date
|
58
|
+
|
59
|
+
##
|
60
|
+
# The preference file for Cli.
|
61
|
+
#
|
62
|
+
# @param [String] preference
|
63
|
+
#
|
64
|
+
# @return [String]
|
65
|
+
attr_accessor :preference_file
|
66
|
+
|
67
|
+
##
|
68
|
+
# When writing a new entry, should 'previous' be pulled from the last
|
69
|
+
# entry?
|
70
|
+
#
|
71
|
+
# @param [Boolean] auto_fill_previous
|
72
|
+
#
|
73
|
+
# @return [Boolean]
|
74
|
+
attr_accessor :auto_fill_previous
|
75
|
+
|
76
|
+
##
|
77
|
+
# Initializes the config with default values.
|
78
|
+
def initialize
|
79
|
+
reset_values
|
80
|
+
end
|
81
|
+
|
82
|
+
##
|
83
|
+
# Sets all config values back to their defaults.
|
84
|
+
#
|
85
|
+
# @return [Boolean] true if successful
|
86
|
+
def reset_values
|
87
|
+
@date = Date.today
|
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
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module StandupMD
|
4
|
+
class Config
|
5
|
+
|
6
|
+
##
|
7
|
+
# The configuration class for StandupMD::Entry
|
8
|
+
class Entry
|
9
|
+
|
10
|
+
##
|
11
|
+
# Tasks for "Current" section.
|
12
|
+
#
|
13
|
+
# @param [Array] current
|
14
|
+
#
|
15
|
+
# @return [Array]
|
16
|
+
attr_accessor :current
|
17
|
+
|
18
|
+
##
|
19
|
+
# Tasks for "Previous" section.
|
20
|
+
#
|
21
|
+
# @param [Array] previous
|
22
|
+
#
|
23
|
+
# @return [Array]
|
24
|
+
attr_accessor :previous
|
25
|
+
|
26
|
+
##
|
27
|
+
# Impediments for this entry.
|
28
|
+
#
|
29
|
+
# @param [Array] impediments
|
30
|
+
#
|
31
|
+
# @return [Array]
|
32
|
+
attr_accessor :impediments
|
33
|
+
|
34
|
+
##
|
35
|
+
# Notes for this entry.
|
36
|
+
#
|
37
|
+
# @param [Array] notes
|
38
|
+
#
|
39
|
+
# @return [Array]
|
40
|
+
attr_accessor :notes
|
41
|
+
|
42
|
+
##
|
43
|
+
# Initializes the config with default values.
|
44
|
+
def initialize
|
45
|
+
reset_values
|
46
|
+
end
|
47
|
+
|
48
|
+
##
|
49
|
+
# Sets all config values back to their defaults.
|
50
|
+
#
|
51
|
+
# @return [Boolean] true if successful
|
52
|
+
def reset_values
|
53
|
+
@current = ["<!-- ADD TODAY'S WORK HERE -->"]
|
54
|
+
@previous = []
|
55
|
+
@impediments = ['None']
|
56
|
+
@notes = []
|
57
|
+
true
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module StandupMD
|
4
|
+
class Config
|
5
|
+
|
6
|
+
##
|
7
|
+
# The configuration class for StandupMD::EntryList
|
8
|
+
class EntryList
|
9
|
+
|
10
|
+
##
|
11
|
+
# Initializes the config with default values.
|
12
|
+
def initalize
|
13
|
+
reset_values
|
14
|
+
end
|
15
|
+
|
16
|
+
##
|
17
|
+
# Sets all config values back to their defaults.
|
18
|
+
#
|
19
|
+
# @return [Boolean] true if successful
|
20
|
+
def reset_values
|
21
|
+
# TODO add order ascending or decending.
|
22
|
+
true
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,199 @@
|
|
1
|
+
module StandupMD
|
2
|
+
class Config
|
3
|
+
|
4
|
+
##
|
5
|
+
# The configuration class for StandupMD::File
|
6
|
+
class File
|
7
|
+
##
|
8
|
+
# Number of octothorps that should preface entry headers.
|
9
|
+
#
|
10
|
+
# @return [Integer] between 1 and 5
|
11
|
+
#
|
12
|
+
# @default 1
|
13
|
+
attr_reader :header_depth
|
14
|
+
|
15
|
+
##
|
16
|
+
# Number of octothorps that should preface sub-headers.
|
17
|
+
#
|
18
|
+
# @return [Integer] between 2 and 6
|
19
|
+
#
|
20
|
+
# @default 2
|
21
|
+
attr_reader :sub_header_depth
|
22
|
+
|
23
|
+
##
|
24
|
+
# The directory in which the files are located.
|
25
|
+
#
|
26
|
+
# @return [String]
|
27
|
+
#
|
28
|
+
# @default "~/.cache/standup_md"
|
29
|
+
attr_reader :directory
|
30
|
+
|
31
|
+
##
|
32
|
+
# Character used as bullets for list entries.
|
33
|
+
#
|
34
|
+
# @return [String] either - (dash) or * (asterisk)
|
35
|
+
#
|
36
|
+
# @default "-" (dash)
|
37
|
+
attr_reader :bullet_character
|
38
|
+
|
39
|
+
##
|
40
|
+
# String to be used as "Current" header.
|
41
|
+
#
|
42
|
+
# @param [String] header
|
43
|
+
#
|
44
|
+
# @return [String]
|
45
|
+
#
|
46
|
+
# @default "Current"
|
47
|
+
attr_accessor :current_header
|
48
|
+
|
49
|
+
##
|
50
|
+
# String to be used as "Previous" header.
|
51
|
+
#
|
52
|
+
# @param [String] header
|
53
|
+
#
|
54
|
+
# @return [String]
|
55
|
+
#
|
56
|
+
# @default "Previous"
|
57
|
+
attr_accessor :previous_header
|
58
|
+
|
59
|
+
##
|
60
|
+
# String to be used as "Impediments" header.
|
61
|
+
#
|
62
|
+
# @param [String] header
|
63
|
+
#
|
64
|
+
# @return [String]
|
65
|
+
#
|
66
|
+
# @default "Impediments"
|
67
|
+
attr_accessor :impediments_header
|
68
|
+
|
69
|
+
##
|
70
|
+
# String to be used as "Notes" header.
|
71
|
+
#
|
72
|
+
# @param [String] header
|
73
|
+
#
|
74
|
+
# @return [String]
|
75
|
+
#
|
76
|
+
# @default "Notes"
|
77
|
+
attr_accessor :notes_header
|
78
|
+
|
79
|
+
##
|
80
|
+
# Preferred order for sub-headers.
|
81
|
+
#
|
82
|
+
# @param [Array] sub_header_order
|
83
|
+
#
|
84
|
+
# @return [Array]
|
85
|
+
#
|
86
|
+
# @default %w[previous current impediment notes]
|
87
|
+
attr_accessor :sub_header_order
|
88
|
+
|
89
|
+
##
|
90
|
+
# Format to be used for standup file names. Should be parse-able by
|
91
|
+
# strftime, and should be a monthly date.
|
92
|
+
#
|
93
|
+
# @param [String] name_format
|
94
|
+
#
|
95
|
+
# @return [String]
|
96
|
+
#
|
97
|
+
# @default "%Y_%m.md"
|
98
|
+
attr_accessor :name_format
|
99
|
+
|
100
|
+
##
|
101
|
+
# The date format for entry headers. Will be parsed by +strftime+.
|
102
|
+
#
|
103
|
+
# @param [String] format
|
104
|
+
#
|
105
|
+
# @return [String]
|
106
|
+
attr_accessor :header_date_format
|
107
|
+
|
108
|
+
##
|
109
|
+
# Should the file be created if it doesn't exist?
|
110
|
+
#
|
111
|
+
# @param [Boolean] create
|
112
|
+
#
|
113
|
+
# @return [boolean]
|
114
|
+
attr_accessor :create
|
115
|
+
|
116
|
+
##
|
117
|
+
# Initializes the config with default values.
|
118
|
+
def initialize
|
119
|
+
reset_values
|
120
|
+
end
|
121
|
+
|
122
|
+
##
|
123
|
+
# Sets all config values back to their defaults.
|
124
|
+
#
|
125
|
+
# @return [Boolean] true if successful
|
126
|
+
def reset_values
|
127
|
+
@header_date_format = '%Y-%m-%d'
|
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
|
140
|
+
end
|
141
|
+
|
142
|
+
##
|
143
|
+
# Number of octothorps (#) to use before the main header.
|
144
|
+
#
|
145
|
+
# @param [Integer] depth
|
146
|
+
#
|
147
|
+
# @return [Integer]
|
148
|
+
def header_depth=(depth)
|
149
|
+
if !depth.between?(1, 5)
|
150
|
+
raise 'Header depth out of bounds (1..5)'
|
151
|
+
elsif depth >= sub_header_depth
|
152
|
+
@sub_header_depth = depth + 1
|
153
|
+
end
|
154
|
+
@header_depth = depth
|
155
|
+
end
|
156
|
+
|
157
|
+
##
|
158
|
+
# Number of octothorps (#) to use before sub headers (Current, Previous,
|
159
|
+
# etc).
|
160
|
+
#
|
161
|
+
# @param [Integer] depth
|
162
|
+
#
|
163
|
+
# @return [Integer]
|
164
|
+
def sub_header_depth=(depth)
|
165
|
+
if !depth.between?(2, 6)
|
166
|
+
raise 'Sub-header depth out of bounds (2..6)'
|
167
|
+
elsif depth <= header_depth
|
168
|
+
@header_depth = depth - 1
|
169
|
+
end
|
170
|
+
@sub_header_depth = depth
|
171
|
+
end
|
172
|
+
|
173
|
+
##
|
174
|
+
# Setter for bullet_character. Must be * (asterisk) or - (dash).
|
175
|
+
#
|
176
|
+
# @param [String] character
|
177
|
+
#
|
178
|
+
# @return [String]
|
179
|
+
def bullet_character=(char)
|
180
|
+
raise 'Must be "-" or "*"' unless %w[- *].include?(char)
|
181
|
+
@bullet_character = char
|
182
|
+
end
|
183
|
+
|
184
|
+
##
|
185
|
+
# Setter for directory. Must be expanded in case the user uses `~` for home.
|
186
|
+
# If the directory doesn't exist, it will be created. To reset instance
|
187
|
+
# variables after changing the directory, you'll need to call load.
|
188
|
+
#
|
189
|
+
# @param [String] directory
|
190
|
+
#
|
191
|
+
# @return [String]
|
192
|
+
def directory=(directory)
|
193
|
+
directory = ::File.expand_path(directory)
|
194
|
+
FileUtils.mkdir_p(directory) unless ::File.directory?(directory)
|
195
|
+
@directory = directory
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module StandupMD
|
5
|
+
|
6
|
+
##
|
7
|
+
# Class for handling single entries. Includes the comparable module, and
|
8
|
+
# compares by date.
|
9
|
+
class Entry
|
10
|
+
include Comparable
|
11
|
+
|
12
|
+
##
|
13
|
+
# Access to the class's configuration.
|
14
|
+
#
|
15
|
+
# @return [StandupMD::Config::Entry]
|
16
|
+
def self.config
|
17
|
+
@config ||= StandupMD.config.entry
|
18
|
+
end
|
19
|
+
|
20
|
+
##
|
21
|
+
# The date of the entry.
|
22
|
+
#
|
23
|
+
# @param [Date] date
|
24
|
+
#
|
25
|
+
# @return [Date]
|
26
|
+
attr_accessor :date
|
27
|
+
|
28
|
+
##
|
29
|
+
# The tasks for today.
|
30
|
+
#
|
31
|
+
# @return [Array]
|
32
|
+
attr_accessor :current
|
33
|
+
|
34
|
+
##
|
35
|
+
# The tasks from the previous day.
|
36
|
+
#
|
37
|
+
# @return [Array]
|
38
|
+
attr_accessor :previous
|
39
|
+
|
40
|
+
##
|
41
|
+
# Iimpediments for this entry.
|
42
|
+
#
|
43
|
+
# @return [Array]
|
44
|
+
attr_accessor :impediments
|
45
|
+
|
46
|
+
##
|
47
|
+
# Nnotes to add to this entry.
|
48
|
+
#
|
49
|
+
# @return [Array]
|
50
|
+
attr_accessor :notes
|
51
|
+
|
52
|
+
##
|
53
|
+
# Creates a generic entry. Default values can be set via configuration.
|
54
|
+
# Yields the entry if a block is passed so you can change values.
|
55
|
+
#
|
56
|
+
# @return [StandupMD::Entry]
|
57
|
+
def self.create
|
58
|
+
entry = new(
|
59
|
+
Date.today,
|
60
|
+
config.current,
|
61
|
+
config.previous,
|
62
|
+
config.impediments,
|
63
|
+
config.notes
|
64
|
+
)
|
65
|
+
yield config if block_given?
|
66
|
+
entry
|
67
|
+
end
|
68
|
+
|
69
|
+
##
|
70
|
+
# Constructs instance of +StandupMD::Entry+.
|
71
|
+
#
|
72
|
+
# @param [Date] date
|
73
|
+
#
|
74
|
+
# @param [Array] current
|
75
|
+
#
|
76
|
+
# @param [Array] previous
|
77
|
+
#
|
78
|
+
# @param [Array] impediments
|
79
|
+
#
|
80
|
+
# @param [Array] notes
|
81
|
+
def initialize(date, current, previous, impediments, notes = [])
|
82
|
+
raise unless date.is_a?(Date)
|
83
|
+
@config = self.class.config
|
84
|
+
|
85
|
+
@date = date
|
86
|
+
@current = current
|
87
|
+
@previous = previous
|
88
|
+
@impediments = impediments
|
89
|
+
@notes = notes
|
90
|
+
end
|
91
|
+
|
92
|
+
##
|
93
|
+
# Sorting method for Comparable. Entries are compared by date.
|
94
|
+
def <=>(other)
|
95
|
+
date <=> other.date
|
96
|
+
end
|
97
|
+
|
98
|
+
##
|
99
|
+
# Entry as a hash .
|
100
|
+
#
|
101
|
+
# @return [Hash]
|
102
|
+
def to_h
|
103
|
+
{
|
104
|
+
date => {
|
105
|
+
'current' => current,
|
106
|
+
'previous' => previous,
|
107
|
+
'impediments' => impediments,
|
108
|
+
'notes' => notes
|
109
|
+
}
|
110
|
+
}
|
111
|
+
end
|
112
|
+
|
113
|
+
##
|
114
|
+
# Entry as a json object.
|
115
|
+
#
|
116
|
+
# @return [String]
|
117
|
+
def to_json
|
118
|
+
to_h.to_json
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|