work-md 0.4.4 → 0.4.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7dba8433c9dbfaa9a989aeb3fd986a1917aa54d43da9bb4af2e7389a46979938
4
- data.tar.gz: 2d1540ff631bf222f970efe6a53504704f7f6425247732d1a83340938e9e305e
3
+ metadata.gz: 5e11b12242f29e25b4cd175693b475d548e37c422f966cca7c4ecdd7ae7bbf23
4
+ data.tar.gz: 7707b5b4ddbcf93fcfa22209eafcfd214de35cf56faec7739ed2b3239af33cd1
5
5
  SHA512:
6
- metadata.gz: 585e1dece08f50f1b323e751f0bf3d711c69f453773996b2281aef334e11ed564fef356425cd55ea17c79dda36d38724de2759fd717777e8aec8f16a0e1d3609
7
- data.tar.gz: 137a09fd7e7bdffa9fa64eacc26213f148509dd68461196d9d63aec359d65ac07534ae1b24f1e4dd51af10f8d2b992c33c349a165c9c0874cf5cdb971bcf8764
6
+ metadata.gz: 49da10202bf64a92baff477f92ad3cb510e8445ef4792b64298f0449680862b0b241ed8a710f047dd846ee5cf9d53930b9bc1594ca1a4e9fcaa29b6adef8ad0e
7
+ data.tar.gz: 932cc585bf763de7d26eade30b48a903885ba23a17a5a6594e3d088f598a7b99fbb99414bb98b0042b2b351f7a32e740c8c0bd74f82851afd2960235ec5aa06d
@@ -37,6 +37,8 @@ module Work
37
37
  end
38
38
 
39
39
  Work::Md::File.create_and_open_parsed(parser)
40
+ rescue Work::Md::Parser::Error => e
41
+ Work::Md::Cli.help(e.message)
40
42
  rescue StandardError
41
43
  Work::Md::Cli.help(
42
44
  ::TTY::Box.frame(
@@ -42,7 +42,9 @@ module Work
42
42
  end
43
43
 
44
44
  Work::Md::File.create_and_open_parsed(parser)
45
- rescue StandardError
45
+ rescue Work::Md::Parser::Error => e
46
+ Work::Md::Cli.help(e.message)
47
+ rescue StandardError => e
46
48
  Work::Md::Cli.help(
47
49
  ::TTY::Box.frame(
48
50
  "message: Some of verified markdown files may be with an incorrect format",
data/lib/work/md/file.rb CHANGED
@@ -72,9 +72,9 @@ module Work
72
72
  end
73
73
 
74
74
  f.puts("\n\n")
75
-
76
- Work::Md::File.open_in_editor([parsed_file_path])
77
75
  end
76
+
77
+ Work::Md::File.open_in_editor([parsed_file_path])
78
78
  end
79
79
  end
80
80
  end
@@ -1,8 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'date'
4
+
3
5
  module Work
4
6
  module Md
5
7
  module Parser
8
+ class Error < StandardError; end
9
+
6
10
  # rubocop:disable Metrics/ClassLength
7
11
  class Engine
8
12
  IS_FROZEN_ERROR_MESSAGE = 'Work::Md::Parser::Engine is frozen'
@@ -108,12 +112,12 @@ module Work
108
112
 
109
113
  @days_bars ||=
110
114
  @parsed_files.map do |f|
111
- pom = (1..f.pomodoros).map { '⬛' }.join
112
- mee = f.meetings.map { '📅' }.join
113
- int = f.interruptions.map { '⚠️' }.join
114
- dif = f.difficulties.map { '😓' }.join
115
- obs = f.observations.map { '📝' }.join
116
- tas = f.tasks.map { '✔️' }.join
115
+ pom = (1..f.pomodoros).map { '⬛' }.join if f.pomodoros
116
+ mee = f.meetings.map { '📅' }.join if f.meetings
117
+ int = f.interruptions.map { '⚠️' }.join if f.interruptions
118
+ dif = f.difficulties.map { '😓' }.join if f.difficulties
119
+ obs = f.observations.map { '📝' }.join if f.observations
120
+ tas = f.tasks.map { '✔️' }.join if f.tasks
117
121
 
118
122
  "(#{f.date}) #{pom}#{mee}#{int}#{dif}#{obs}#{tas}"
119
123
  end
@@ -170,6 +174,19 @@ module Work
170
174
  parsed_file.pomodoros =
171
175
  parse_pomodoro(content, start_with: @t[:pomodoros])
172
176
  end
177
+ rescue StandardError
178
+ # TODO: Write tests for this scenario
179
+ file_name = Date.strptime(parsed_file.date, '%d/%m/%Y').strftime('%Y/%m/%d.md')
180
+ message = ::TTY::Box.frame(
181
+ "message: Cannot parse file '#{file_name}' maybe it's in an incorrect format.",
182
+ '',
183
+ 'Usage example:',
184
+ '',
185
+ 'work-md pl 7 # parse the last 7 days',
186
+ **Work::Md::Cli.error_frame_style
187
+ )
188
+
189
+ raise Error, message
173
190
  end
174
191
  # rubocop:enable Metrics/CyclomaticComplexity
175
192
  # rubocop:enable Metrics/PerceivedComplexity
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Work
4
4
  module Md
5
- VERSION = '0.4.4'
5
+ VERSION = '0.4.5'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: work-md
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrique Fernandez Teixeira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-25 00:00:00.000000000 Z
11
+ date: 2021-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-box