work_md 0.2.6 → 0.2.7

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: 566027a143beb9e55274abe76ef2f0d0c7a44078d4773c595e9cdce2175a2c32
4
- data.tar.gz: d4094062e154849f8514d26c20d52d37e931d3f844f2b162cb26eab2b7a70d5d
3
+ metadata.gz: 240715cce22ce57249e206aaccb86151732c059fa4af0f00b1b3d2c8f47389bb
4
+ data.tar.gz: 436b17f29758239fe959abdf6d8ffaf24f629ba3fb41315bf92e8c42eaaac4cb
5
5
  SHA512:
6
- metadata.gz: 41053f4429dfd6a4a3af74e52da1d6f131aac58c79c9034a201814a89dc67fd7a2e3feae74c25afa8c0ffc0b610cf9d8332392ee69cb66f43011779033a4af21
7
- data.tar.gz: 4daed1478dedc190e1d3eef1719c54f16af4040519b276ab08820453e08371112fd92cd70b9aef8c3e32480cee65257daa884f3580b0748cb8d32c34c6fabd3f
6
+ metadata.gz: 595cc7e93141034918c3076dcf1416fe46ba9c0194fd06026e117269c73482a595d8d6cfdf7b23cc73e67a60880971d3ba2c76453a567ea6581d273c529414d7
7
+ data.tar.gz: e9599c13e70ade59262afb89dca054c8dc54821906e9eca4a113efc579716f3df2e1e2f91819d1a0b0edb77a632b8d227233aa3912b70fd87dcb509b984cd0ed
data/lib/work_md.rb CHANGED
@@ -5,6 +5,7 @@ require_relative 'work_md/config'
5
5
  require_relative 'work_md/file'
6
6
  require_relative 'work_md/commands/today'
7
7
  require_relative 'work_md/commands/yesterday'
8
+ require_relative 'work_md/commands/tyesterday'
8
9
  require_relative 'work_md/parser/engine'
9
10
  require_relative 'work_md/commands/parse'
10
11
  require_relative 'work_md/cli'
data/lib/work_md/cli.rb CHANGED
@@ -7,6 +7,7 @@ module WorkMd
7
7
  ALIAS_COMMANDS =
8
8
  {
9
9
  't' => 'today',
10
+ 'ty' => 'tyesterday',
10
11
  'y' => 'yesterday',
11
12
  'p' => 'parse'
12
13
  }.freeze
@@ -46,6 +47,7 @@ module WorkMd
46
47
  '- work_md',
47
48
  '- work_md today',
48
49
  '- work_md yesterday',
50
+ '- work_md tyesterday',
49
51
  '- work_md parse',
50
52
  '',
51
53
  'read more in github.com/henriquefernandez/work_md',
@@ -17,7 +17,7 @@ module WorkMd
17
17
 
18
18
  month = "0#{month.to_i}" if month.to_i < 10
19
19
 
20
- args['d'].split(',').each do |day|
20
+ add_file_to_parser = ->(day) do
21
21
  day = "0#{day.to_i}" if day.to_i < 10
22
22
 
23
23
  file_name = WorkMd::Config.work_dir + "/#{year}/#{month}/#{day}.md"
@@ -25,6 +25,14 @@ module WorkMd
25
25
  parser.add_file(file_name)
26
26
  end
27
27
 
28
+ if args['d'].include?('..')
29
+ range = args['d'].split('..')
30
+
31
+ (range[0].to_i..range[1].to_i).each { |day| add_file_to_parser.(day) }
32
+ else
33
+ args['d'].split(',').each { |day| add_file_to_parser.(day) }
34
+ end
35
+
28
36
  parser.freeze
29
37
 
30
38
  ::File.delete(PARSED_FILE_PATH) if ::File.exist? PARSED_FILE_PATH
@@ -51,6 +59,11 @@ module WorkMd
51
59
  f.puts("- #{difficulty}\n\n")
52
60
  end
53
61
  f.puts("---\n\n")
62
+ f.puts("### #{t[:observations]} (#{parser.observations.size}):\n\n")
63
+ parser.observations.each do |observation|
64
+ f.puts("- #{observation}\n\n")
65
+ end
66
+ f.puts("---\n\n")
54
67
  f.puts("### #{t[:pomodoros]} (#{parser.average_pomodoros} #{t[:per_day]}):\n\n")
55
68
  f.puts(parser.pomodoros)
56
69
  end
@@ -72,6 +85,7 @@ module WorkMd
72
85
  "work_md parse -d=1 -m=5 -y=2000 | get day 1 from month 5 and year 2000",
73
86
  "work_md parse -d=1,2,3 | get day 1, 2 and 3 from the current month and year",
74
87
  "work_md parse -d=1,2 -m=4 | get day 1 and 2 from month 4 and current year",
88
+ "work_md parse -d=1..10 -m=4 | get day 1 to 10 from month 4 and current year",
75
89
  **WorkMd::Cli.error_frame_style
76
90
  )
77
91
  )
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WorkMd
4
+ module Commands
5
+ class Tyesterday
6
+ class << self
7
+ def execute(_argv = [])
8
+ WorkMd::File.open_or_create(DateTime.now)
9
+ WorkMd::File.open_or_create(Date.today.prev_day)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -12,6 +12,7 @@ module WorkMd
12
12
  meetings: 'Reuniões',
13
13
  interruptions: 'Interrupções',
14
14
  difficulties: 'Dificuldades',
15
+ observations: 'Observações',
15
16
  pomodoros: 'Pomodoros / Ciclos',
16
17
  per_day: 'por dia'
17
18
  },
@@ -21,6 +22,7 @@ module WorkMd
21
22
  meetings: 'Meetings',
22
23
  interruptions: 'Interruptions',
23
24
  difficulties: 'Difficulties',
25
+ observations: 'Observations',
24
26
  pomodoros: 'Pomodoros / Cycles',
25
27
  per_day: 'per day'
26
28
  }
data/lib/work_md/file.rb CHANGED
@@ -26,6 +26,8 @@ module WorkMd
26
26
  f.puts("---\n\n")
27
27
  f.puts("### #{t[:difficulties]}:\n\n")
28
28
  f.puts("---\n\n")
29
+ f.puts("### #{t[:observations]}:\n\n")
30
+ f.puts("---\n\n")
29
31
  f.puts("### #{t[:pomodoros]}:\n\n")
30
32
  f.puts("0\n\n")
31
33
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  module WorkMd
4
4
  module Parser
5
+ # rubocop:disable Metrics/ClassLength
5
6
  class Engine
6
7
  IS_FROZEN_ERROR_MESSAGE = 'WorkMd::Parser::Engine is frozen'
7
8
  IS_NOT_FROZEN_ERROR_MESSAGE = 'WorkMd::Parser::Engine is not frozen'
@@ -11,6 +12,7 @@ module WorkMd
11
12
  :meetings,
12
13
  :interruptions,
13
14
  :difficulties,
15
+ :observations,
14
16
  :date,
15
17
  :pomodoros
16
18
  end
@@ -66,9 +68,15 @@ module WorkMd
66
68
  @difficulties ||= @parsed_files.map(&:difficulties).flatten
67
69
  end
68
70
 
71
+ def observations
72
+ raise IS_NOT_FROZEN_ERROR_MESSAGE unless @frozen
73
+
74
+ @observations ||= @parsed_files.map(&:observations).flatten
75
+ end
76
+
69
77
  def average_pomodoros
70
78
  if @parsed_files.size.positive? && pomodoros.positive?
71
- return (pomodoros / @parsed_files.size)
79
+ return (pomodoros.to_f / @parsed_files.size).round(1)
72
80
  end
73
81
 
74
82
  0
@@ -115,7 +123,10 @@ module WorkMd
115
123
  parsed_file.difficulties = parse_list(content).map do |difficulty|
116
124
  "(#{parsed_file.date}) #{difficulty}"
117
125
  end
118
-
126
+ elsif content.start_with?(@t[:observations])
127
+ parsed_file.observations = parse_list(content).map do |observations|
128
+ "(#{parsed_file.date}) #{observations}"
129
+ end
119
130
  elsif content.start_with?(@t[:pomodoros])
120
131
  parsed_file.pomodoros = parse_pomodoro(content)
121
132
  end
@@ -148,5 +159,6 @@ module WorkMd
148
159
  .map(&:strip)
149
160
  end
150
161
  end
162
+ # rubocop:enable Metrics/ClassLength
151
163
  end
152
164
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WorkMd
4
- VERSION = '0.2.6'
4
+ VERSION = '0.2.7'
5
5
  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.2.6
4
+ version: 0.2.7
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-08-01 00:00:00.000000000 Z
11
+ date: 2021-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-box
@@ -53,6 +53,7 @@ files:
53
53
  - lib/work_md/cli.rb
54
54
  - lib/work_md/commands/parse.rb
55
55
  - lib/work_md/commands/today.rb
56
+ - lib/work_md/commands/tyesterday.rb
56
57
  - lib/work_md/commands/yesterday.rb
57
58
  - lib/work_md/config.rb
58
59
  - lib/work_md/file.rb