standup_md 0.3.4 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -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)
@@ -169,9 +185,10 @@ module StandupMD
169
185
  sorted_entries.filter(start_date, end_date).sort_reverse.each do |entry|
170
186
  f.puts header(entry.date)
171
187
  @config.sub_header_order.each do |attr|
172
- tasks = entry.send(attr)
188
+ tasks = entry.public_send(attr)
173
189
  next if !tasks || tasks.empty?
174
- f.puts sub_header(@config.send("#{attr}_header").capitalize)
190
+
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
177
194
  f.puts
@@ -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
@@ -2,8 +2,26 @@
2
2
 
3
3
  module StandupMD
4
4
  ##
5
- # The gem verision
6
- #
7
- # @return [String]
8
- VERSION = '0.3.4'
5
+ # Module that contains all gem version information. Follows semantic
6
+ # versioning. Read: https://semver.org/
7
+ module Version
8
+
9
+ ##
10
+ # Major version.
11
+ MAJOR = 0
12
+
13
+ ##
14
+ # Minor version.
15
+ MINOR = 3
16
+
17
+ ##
18
+ # Patch version.
19
+ PATCH = 9
20
+
21
+ ##
22
+ # Version as +MAJOR.MINOR.PATCH+
23
+ def self.to_s
24
+ "#{MAJOR}.#{MINOR}.#{PATCH}"
25
+ end
26
+ end
9
27
  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.4
4
+ version: 0.3.9
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-17 00:00:00.000000000 Z
11
+ date: 2021-05-08 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: []