never_do 0.2.3 → 0.2.4

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/x +31 -27
  3. data/lib/never_do/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a30e8b26b9245568ea043177ec36aec51f2cb35
4
- data.tar.gz: 5fdd11edc96f286f65c3ce0491088c6b9ce3c484
3
+ metadata.gz: 3377d4b7ce8383a4cf4b306d3669b37f291d3154
4
+ data.tar.gz: 4ed79834221f73868671845c36a4ce68ad6f0e81
5
5
  SHA512:
6
- metadata.gz: ce9837357d35e4e3f5e293b4d397ddf3634ced3c8e7d24bc4b6c385a151f8e7153261dd1b59f33d131e7b9bc0f88e439c002514068df25d488cf40ba909b6c29
7
- data.tar.gz: 5353bae6cf7f4a988fe4a9de7295be2084a41795d13602a254df275eedc23aaae8ac550d7883075133a4513aa4205e8c40e5eff1cbd15bc43a68af78e0c25e36
6
+ metadata.gz: b1c047ae583b1d1947d6754ac7bac5aa86a333a7e19da054e98befd7c8c154aa9d2f474c92ea86e22ce11dbd40c73497a8cf8857810e6f7dee6c3afe4b8a278d
7
+ data.tar.gz: 4756b4f4a200d059b445d0e0ad3b4c771d1845f94c93741e6703d4442f52da7ecd6339f2baa22c64d61a58b0055a5e512d81e39bc24009f7dc25737b83f9135c
data/bin/x CHANGED
@@ -88,41 +88,45 @@ class X
88
88
 
89
89
  def generate(output)
90
90
  output ||= "./task_log.md"
91
- # group by year, then group by month
92
- File.open(output, "w") do |f|
93
- [*@ys, *@zs].group_by { |t| Time.at(t.start).year }.each do |year, y_tasks|
94
- y_tot = y_tasks.size
95
- y_done = 0
96
-
97
- f.puts "## #{year}"
98
- f.puts "\n------"
99
- f.puts
100
-
101
- y_tasks.group_by { |t| Time.at(t.start).month }.each do |month, m_tasks|
102
- cur_month = Date::MONTHNAMES[month]
103
- m_tot = m_tasks.size
104
- m_done = 0
105
-
106
- f.puts "### #{cur_month}"
91
+ begin
92
+ # group by year, then group by month
93
+ File.open(output, "w") do |f|
94
+ [*@ys, *@zs].group_by { |t| Time.at(t.start).year }.each do |year, y_tasks|
95
+ y_tot = y_tasks.size
96
+ y_done = 0
97
+
98
+ f.puts "## #{year}"
107
99
  f.puts "\n------"
108
100
  f.puts
109
101
 
110
- m_tasks.sort_by(&:start).each do |task|
111
- mark = task.finish? ? "x" : " "
112
- m_done += 1 if task.finish?
113
- f.puts "- [#{mark}] #{task.desc}"
114
- end
102
+ y_tasks.group_by { |t| Time.at(t.start).month }.each do |month, m_tasks|
103
+ cur_month = Date::MONTHNAMES[month]
104
+ m_tot = m_tasks.size
105
+ m_done = 0
115
106
 
116
- f.puts "\nIn #{cur_month}, you have #{m_tot} tasks, finished #{m_done} tasks, complete #{(100.0*m_done/m_tot).round(2)}% of them.\n"
107
+ f.puts "### #{cur_month}"
108
+ f.puts "\n------"
109
+ f.puts
117
110
 
118
- y_done += m_done
119
- end
111
+ m_tasks.sort_by(&:start).each do |task|
112
+ mark = task.finish? ? "x" : " "
113
+ m_done += 1 if task.finish?
114
+ f.puts "- [#{mark}] #{task.desc}"
115
+ end
116
+
117
+ f.puts "\nIn #{cur_month}, you have #{m_tot} tasks, finished #{m_done} tasks, complete #{(100.0*m_done/m_tot).round(2)}% of them.\n"
118
+
119
+ y_done += m_done
120
+ end
120
121
 
121
- f.puts "\nIn year #{year}, you have #{y_tot} tasks, finished #{y_done} tasks, complete #{(100.0*y_done/y_tot).round(2)}% of them.\n"
122
+ f.puts "\nIn year #{year}, you have #{y_tot} tasks, finished #{y_done} tasks, complete #{(100.0*y_done/y_tot).round(2)}% of them.\n"
123
+ end
122
124
  end
123
- end
124
125
 
125
- puts "task list is generated to #{output}"
126
+ puts "task list is generated to #{output}"
127
+ rescue
128
+ puts "File open error, make sure #{output} is a file"
129
+ end
126
130
  end
127
131
 
128
132
  private
@@ -1,3 +1,3 @@
1
1
  module NeverDo
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: never_do
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - delta