standup_md 0.3.5 → 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.
@@ -6,11 +6,9 @@ require_relative 'config/entry'
6
6
  require_relative 'config/entry_list'
7
7
 
8
8
  module StandupMD
9
-
10
9
  ##
11
10
  # This class provides a connector from StandupMD to the configuration classes.
12
11
  class Config
13
-
14
12
  ##
15
13
  # Reader for Cli config.
16
14
  #
@@ -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.
@@ -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.
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'forwardable'
3
4
 
4
5
  module StandupMD
5
-
6
6
  ##
7
7
  # Enumerable list of entries.
8
8
  class EntryList
@@ -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
- file = Dir.entries(config.directory).bsearch { |f| f == file_name }
38
- if file.nil? && !config.create
39
- raise "File #{file_name} not found." unless config.create
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
- raise ArgumentError, "Argument must be a Date object"
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
- if is_header?(line)
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(%r{^\#{#{@config.header_depth}}\s*}, '')
139
- section_type = @config.notes_header
140
- record[section_type] = []
141
- elsif is_sub_header?(line)
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
@@ -2,40 +2,38 @@
2
2
 
3
3
  module StandupMD
4
4
  class File
5
-
6
5
  ##
7
6
  # Module responsible for reading and writing standup files.
8
7
  module Helpers # :nodoc:
9
-
10
8
  private
11
9
 
12
- def is_header?(line) # :nodoc:
10
+ def header?(line) # :nodoc:
13
11
  line.match(header_regex)
14
12
  end
15
13
 
16
- def is_sub_header?(line) # :nodoc:
14
+ def sub_header?(line) # :nodoc:
17
15
  line.match(sub_header_regex)
18
16
  end
19
17
 
20
18
  def header_regex # :nodoc:
21
- %r{^#{'#' * StandupMD.config.file.header_depth}\s+}
19
+ /^#{'#' * StandupMD.config.file.header_depth}\s+/
22
20
  end
23
21
 
24
22
  def sub_header_regex # :nodoc:
25
- %r{^#{'#' * StandupMD.config.file.sub_header_depth}\s+}
23
+ /^#{'#' * StandupMD.config.file.sub_header_depth}\s+/
26
24
  end
27
25
 
28
26
  def bullet_character_regex # :nodoc:
29
- %r{\s*#{StandupMD.config.file.bullet_character}\s*}
27
+ /\s*#{StandupMD.config.file.bullet_character}\s*/
30
28
  end
31
29
 
32
30
  def determine_section_type(line) # :nodoc:
33
- line = line.sub(%r{^\#{#{StandupMD.config.file.sub_header_depth}}\s*}, '')
34
- [
35
- StandupMD.config.file.current_header,
36
- StandupMD.config.file.previous_header,
37
- StandupMD.config.file.impediments_header,
38
- StandupMD.config.file.notes_header
31
+ line = line.sub(/^\#{#{StandupMD.config.file.sub_header_depth}}\s*/, '')
32
+ [
33
+ StandupMD.config.file.current_header,
34
+ StandupMD.config.file.previous_header,
35
+ StandupMD.config.file.impediments_header,
36
+ StandupMD.config.file.notes_header
39
37
  ].each { |header| return header if line.include?(header) }
40
38
  raise "Unrecognized header [#{line}]"
41
39
  end
@@ -54,8 +52,8 @@ module StandupMD
54
52
  '#' * StandupMD.config.file.header_depth + ' ' + date.strftime(StandupMD.config.file.header_date_format)
55
53
  end
56
54
 
57
- def sub_header(sh)
58
- '#' * StandupMD.config.file.sub_header_depth + ' ' + sh
55
+ def sub_header(subhead)
56
+ '#' * StandupMD.config.file.sub_header_depth + ' ' + subhead
59
57
  end
60
58
  end
61
59
  end
@@ -1,9 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StandupMD
4
+
4
5
  ##
5
- # The gem verision
6
- #
7
- # @return [String]
8
- VERSION = '0.3.5'
6
+ # Module that contains all gem version information. Follows semantic
7
+ # versioning. Read: https://semver.org/
8
+ module Version
9
+
10
+ ##
11
+ # Major version.
12
+ MAJOR = 0
13
+
14
+ ##
15
+ # Minor version.
16
+ MINOR = 3
17
+
18
+ ##
19
+ # Patch version.
20
+ PATCH = 6
21
+
22
+ ##
23
+ # Version as +MAJOR.MINOR.PATCH+
24
+ def self.to_s
25
+ "#{MAJOR}.#{MINOR}.#{PATCH}"
26
+ end
27
+ end
9
28
  end
data/standup_md.gemspec CHANGED
@@ -2,7 +2,7 @@ require_relative 'lib/standup_md/version'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'standup_md'
5
- spec.version = StandupMD::VERSION
5
+ spec.version = StandupMD::Version.to_s
6
6
  spec.authors = ['Evan Gray']
7
7
  spec.email = 'evanthegrayt@vivaldi.net'
8
8
  spec.license = 'MIT'
@@ -12,25 +12,21 @@ Gem::Specification.new do |spec|
12
12
  spec.description = %q{Generate and edit standups in markdown format}
13
13
  spec.homepage = 'https://evanthegrayt.github.io/standup_md/'
14
14
 
15
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
16
- # to allow pushing to a single host or delete this section to allow pushing to any host.
17
- if spec.respond_to?(:metadata)
18
- spec.metadata['allowed_push_host'] = 'https://rubygems.org'
19
-
20
- spec.metadata['homepage_uri'] = spec.homepage
21
- spec.metadata['source_code_uri'] = 'https://github.com/evanthegrayt/standup_md'
22
- spec.metadata['documentation_uri'] = 'https://evanthegrayt.github.io/standup_md/doc/index.html'
23
- else
15
+ unless spec.respond_to?(:metadata)
24
16
  raise 'RubyGems 2.0 or newer is required to protect against ' \
25
17
  'public gem pushes.'
26
18
  end
27
19
 
28
- # Specify which files should be added to the gem when it is released.
29
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
30
- # spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
31
- # `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
32
- # end
33
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
21
+ spec.metadata['homepage_uri'] = spec.homepage
22
+ spec.metadata['source_code_uri'] =
23
+ 'https://github.com/evanthegrayt/standup_md'
24
+ spec.metadata['documentation_uri'] =
25
+ 'https://evanthegrayt.github.io/standup_md/doc/index.html'
26
+
27
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
28
+ f.match(%r{^(test|spec|features)/})
29
+ end
34
30
  spec.bindir = 'bin'
35
31
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
36
32
  spec.require_paths = ['lib']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: standup_md
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Gray
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-23 00:00:00.000000000 Z
11
+ date: 2021-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -92,6 +92,7 @@ files:
92
92
  - doc/StandupMD/Entry.html
93
93
  - doc/StandupMD/EntryList.html
94
94
  - doc/StandupMD/File.html
95
+ - doc/StandupMD/Version.html
95
96
  - doc/created.rid
96
97
  - doc/css/fonts.css
97
98
  - doc/css/rdoc.css
@@ -158,7 +159,7 @@ metadata:
158
159
  homepage_uri: https://evanthegrayt.github.io/standup_md/
159
160
  source_code_uri: https://github.com/evanthegrayt/standup_md
160
161
  documentation_uri: https://evanthegrayt.github.io/standup_md/doc/index.html
161
- post_install_message:
162
+ post_install_message:
162
163
  rdoc_options: []
163
164
  require_paths:
164
165
  - lib
@@ -173,8 +174,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
174
  - !ruby/object:Gem::Version
174
175
  version: '0'
175
176
  requirements: []
176
- rubygems_version: 3.1.2
177
- signing_key:
177
+ rubygems_version: 3.2.3
178
+ signing_key:
178
179
  specification_version: 4
179
180
  summary: The cure for all your standup woes
180
181
  test_files: []