standup_md 0.3.6 → 0.3.11

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.
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 ||= StandupMD::Config.new
20
+ @config || reset_config
21
21
  end
22
22
 
23
23
  ##
@@ -49,11 +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
- file = ::File.expand_path(file)
54
- raise "File #{file} does not exist." unless ::File.file?(file)
55
+ ::File.expand_path(file).tap do |file|
56
+ raise "File #{file} does not exist." unless ::File.file?(file)
55
57
 
56
- @config_file_loaded = true
57
- load file
58
+ @config_file_loaded = true
59
+ load file
60
+ end
58
61
  end
59
62
  end
@@ -28,13 +28,13 @@ module StandupMD
28
28
  ##
29
29
  # Creates an instance of +StandupMD+ and runs what the user requested.
30
30
  def self.execute(options = [])
31
- exe = new(options)
32
-
33
- exe.write_file if config.write
34
- if config.print
35
- exe.print(exe.entry)
36
- elsif config.edit
37
- exe.edit
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
38
38
  end
39
39
  end
40
40
 
@@ -125,25 +125,22 @@ module StandupMD
125
125
  # @return [StandupMD::Entry]
126
126
  def new_entry(file)
127
127
  entry = file.entries.find(config.cli.date)
128
- if entry.nil? && config.cli.date == Date.today
129
- previous_entry = set_previous_entry(file)
130
- entry = StandupMD::Entry.new(
131
- config.cli.date,
132
- config.entry.current,
133
- previous_entry,
134
- config.entry.impediments,
135
- config.entry.notes
136
- )
137
- file.entries << entry
138
- end
139
- entry
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 }
140
137
  end
141
138
 
142
139
  ##
143
140
  # The "previous" entries.
144
141
  #
145
142
  # @return [Array]
146
- def set_previous_entry(file)
143
+ def previous_entry(file)
147
144
  return config.entry.previous_entry unless config.cli.auto_fill_previous
148
145
 
149
146
  return prev_entry(prev_file.load.entries) if file.new? && prev_file
@@ -200,9 +200,9 @@ module StandupMD
200
200
  #
201
201
  # @return [String]
202
202
  def directory=(directory)
203
- directory = ::File.expand_path(directory)
204
- FileUtils.mkdir_p(directory) unless ::File.directory?(directory)
205
- @directory = directory
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
@@ -55,15 +55,13 @@ module StandupMD
55
55
  #
56
56
  # @return [StandupMD::Entry]
57
57
  def self.create
58
- entry = new(
58
+ new(
59
59
  Date.today,
60
60
  config.current,
61
61
  config.previous,
62
62
  config.impediments,
63
63
  config.notes
64
- )
65
- yield config if block_given?
66
- entry
64
+ ).tap { |entry| yield entry if block_given? }
67
65
  end
68
66
 
69
67
  ##
@@ -82,11 +80,11 @@ module StandupMD
82
80
  raise unless date.is_a?(Date)
83
81
  @config = self.class.config
84
82
 
85
- @date = date
86
- @current = current
87
- @previous = previous
88
- @impediments = impediments
89
- @notes = notes
83
+ @date = date
84
+ @current = current
85
+ @previous = previous
86
+ @impediments = impediments
87
+ @notes = notes
90
88
  end
91
89
 
92
90
  ##
@@ -26,7 +26,7 @@ module StandupMD
26
26
  def initialize(*entries)
27
27
  @config = self.class.config
28
28
  unless entries.all? { |e| e.is_a?(StandupMD::Entry) }
29
- raise ArgumentError, 'Entry must instance of StandupMD::Entry'
29
+ raise ArgumentError, 'Entry must be an instance of StandupMD::Entry'
30
30
  end
31
31
  @entries = entries
32
32
  end
@@ -39,7 +39,7 @@ module StandupMD
39
39
  # @return [Array]
40
40
  def <<(entry)
41
41
  unless entry.is_a?(StandupMD::Entry)
42
- raise ArgumentError, 'Entry must instance of StandupMD::Entry'
42
+ raise ArgumentError, 'Entry must be an instance of StandupMD::Entry'
43
43
  end
44
44
  @entries << entry
45
45
  end
@@ -1,28 +1,50 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StandupMD
4
-
5
4
  ##
6
5
  # Module that contains all gem version information. Follows semantic
7
6
  # versioning. Read: https://semver.org/
8
7
  module Version
9
-
10
8
  ##
11
9
  # Major version.
10
+ #
11
+ # @return [Integer]
12
12
  MAJOR = 0
13
13
 
14
14
  ##
15
15
  # Minor version.
16
+ #
17
+ # @return [Integer]
16
18
  MINOR = 3
17
19
 
18
20
  ##
19
21
  # Patch version.
20
- PATCH = 6
22
+ #
23
+ # @return [Integer]
24
+ PATCH = 11
25
+
26
+ ##
27
+ # Version as +[MAJOR, MINOR, PATCH]+
28
+ #
29
+ # @return [Array]
30
+ def self.to_a
31
+ [MAJOR, MINOR, PATCH]
32
+ end
21
33
 
22
34
  ##
23
35
  # Version as +MAJOR.MINOR.PATCH+
36
+ #
37
+ # @return [String]
24
38
  def self.to_s
25
- "#{MAJOR}.#{MINOR}.#{PATCH}"
39
+ to_a.join('.')
40
+ end
41
+
42
+ ##
43
+ # Version as +{major: MAJOR, minor: MINOR, patch: PATCH}+
44
+ #
45
+ # @return [Hash]
46
+ def self.to_h
47
+ Hash[%i[major minor patch].zip(to_a)]
26
48
  end
27
49
  end
28
50
  end
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.6
4
+ version: 0.3.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Gray
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-26 00:00:00.000000000 Z
11
+ date: 2021-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake