tudu 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -140,6 +140,16 @@ one
140
140
  two
141
141
  ~~~
142
142
 
143
+ ### done. from doing to done and from first todos to doing with progress option.
144
+ * done -p
145
+
146
+ ~~~
147
+ $ tudu add one two three
148
+ $ tudu choose one
149
+ $ tudu done -p
150
+ 1/3|===> |33%
151
+ ~~~
152
+
143
153
  ### tasks show all tasks from [todos, doings, dones].
144
154
  * tudu tasks
145
155
 
@@ -225,13 +235,25 @@ hoge
225
235
  ### dones 'search word' show specific dones tasks.
226
236
  same as 'tasks search_word' case
227
237
 
238
+ ### progress show tasks progress.
239
+ * tudu progress
240
+
241
+ ~~~
242
+ $ tudu add a b c
243
+ $ tudu choose a
244
+ $ tudu done
245
+ $ tudu progress
246
+ 1/3|===> |33%
247
+ ~~~
248
+
228
249
  ### Notes
229
250
  if you want to do other operation, edit [todos, doings, dones] directly.
230
251
 
231
252
  it's only plain text, so you can edit freely.
232
253
 
233
254
  ## History
234
- * version 0.0.3 : add categorized option to tasks.
255
+ * version 0.0.4 : add 'progress'. add progress option to 'done'.
256
+ * version 0.0.3 : add categorized option to 'tasks'.
235
257
  * version 0.0.2 : after execute 'done', if there is no todos and doings, display celebration message.
236
258
  * version 0.0.2 : if 'choose' no args. choose first tudu.
237
259
  * version 0.0.1 : first release.
data/bin/tudu CHANGED
@@ -33,36 +33,43 @@ module Tudu
33
33
  end
34
34
 
35
35
  desc "done", "done tasks from doings to dones file. and choose task from todos's top task to doings"
36
+ option :progress, :type => :boolean, :aliases => '-p', :desc => "display tasks progress"
36
37
  def done
37
38
  Tudu::Core.new.done
39
+ progress if options[:progress]
38
40
  end
39
41
 
40
- desc "tasks", "tasks search tasks from todos,doings,dones file. no args => get all tasks. set search word args, you get hit tasks"
41
- option :category, :type => :boolean, :aliases => '-c', :desc => "show categorized tasks"
42
+ desc "tasks", "search tasks from todos,doings,dones file. no args => get all tasks. set search word args, you get hit tasks"
43
+ option :category, :type => :boolean, :aliases => '-c', :desc => "display categorized tasks"
42
44
  def tasks(*args)
43
45
  puts Tudu::Core.new.tasks args.first, options
44
46
  end
45
47
 
46
- desc "todos", "todos search tasks from todos file. no args => get all tasks. set search word args, you get hit tasks"
48
+ desc "todos", "search tasks from todos file. no args => get all tasks. set search word args, you get hit tasks"
47
49
  def todos(*args)
48
50
  puts Tudu::Core.new.todos args.first
49
51
  end
50
52
 
51
- desc "doings", "doings search tasks from doings file. no args => get all tasks. set search word args, you get hit tasks"
53
+ desc "doings", "search tasks from doings file. no args => get all tasks. set search word args, you get hit tasks"
52
54
  def doings(*args)
53
55
  puts Tudu::Core.new.doings args.first
54
56
  end
55
57
 
56
- desc "now", "now search tasks from doings file. no args => get all tasks. set search word args, you get hit tasks"
58
+ desc "now", "search tasks from doings file. no args => get all tasks. set search word args, you get hit tasks"
57
59
  def now(*args)
58
60
  puts Tudu::Core.new.now args.first
59
61
  end
60
62
 
61
- desc "dones", "dones search tasks from dones file. no args => get all tasks. set search word args, you get hit tasks"
63
+ desc "dones", "search tasks from dones file. no args => get all tasks. set search word args, you get hit tasks"
62
64
  def dones(*args)
63
65
  puts Tudu::Core.new.dones args.first
64
66
  end
65
67
 
68
+ desc "progress", "display tasks progress"
69
+ def progress
70
+ puts Tudu::Core.new.progress
71
+ end
72
+
66
73
  desc "version", "version"
67
74
  def version
68
75
  p Tudu::VERSION
data/lib/tasks.rb CHANGED
@@ -207,6 +207,21 @@ module Tudu
207
207
  tasks.select {|task|task.name == task_name}.first
208
208
  end
209
209
 
210
+ #== display tasks progress
211
+ #=== Returns
212
+ # return progress
213
+ def progress
214
+ total_count = get_tasks.size
215
+ dones_count = get_dones.size
216
+ percent = total_count == 0 ? 0 : (dones_count.to_f / total_count.to_f * 100).round
217
+ prefix = "#{dones_count}/#{total_count}|"
218
+ done_bar = "="*(percent/10)
219
+ rest_bar = " "*(10-(percent/10))
220
+ progress_bar = "#{done_bar}>#{rest_bar}"
221
+ sufix = "|#{percent}%"
222
+ "#{prefix}#{progress_bar}#{sufix}"
223
+ end
224
+
210
225
  private
211
226
  def get_first_todo_name_if_nil_or_empty(task_name)
212
227
  (task_name.nil? || task_name.empty?) ? get_todos.first.name : task_name
data/lib/tudu/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tudu
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/tudu_core.rb CHANGED
@@ -71,6 +71,13 @@ module Tudu
71
71
  Tudu::Tasks.filter_tasks(Tudu::Tasks.get_dones, search_word).map(&:name)
72
72
  end
73
73
 
74
+ #== display tasks progress
75
+ #=== Returns
76
+ # return progress
77
+ def progress
78
+ Tudu::Tasks.progress
79
+ end
80
+
74
81
  def categorized_tasks(tasks, search_word)
75
82
  ret = []
76
83
  tasks = Tudu::Tasks.filter_tasks(Tudu::Tasks.get_tasks, search_word)
data/spec/tasks_spec.rb CHANGED
@@ -796,4 +796,66 @@ describe Tudu::Tasks do
796
796
  end
797
797
  end
798
798
  end
799
+
800
+ context :progress do
801
+ cases = [
802
+ {
803
+ case_no: 1,
804
+ case_title: "display progress",
805
+ todos: ["task5", "task6"],
806
+ doings: ["task3", "task4"],
807
+ dones: ["task1", "task2"],
808
+ expected: "2/6|===> |33%",
809
+ },
810
+ {
811
+ case_no: 2,
812
+ case_title: "display none progress",
813
+ todos: ["task3", "task4"],
814
+ doings: ["task1", "task2"],
815
+ dones: [],
816
+ expected: "0/4|> |0%",
817
+ },
818
+ {
819
+ case_no: 3,
820
+ case_title: "display complete progress",
821
+ todos: [],
822
+ doings: [],
823
+ dones: ["task1", "task2"],
824
+ expected: "2/2|==========>|100%",
825
+ },
826
+ ]
827
+
828
+ cases.each do |c|
829
+ it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
830
+ begin
831
+ case_before c
832
+
833
+ # -- given --
834
+ # nothing
835
+
836
+ # -- when --
837
+ actual = Tudu::Tasks.progress
838
+
839
+ # -- then --
840
+ ret = expect(actual).to eq(c[:expected])
841
+ ensure
842
+ case_after c
843
+ end
844
+ end
845
+
846
+ def case_before(c)
847
+ # implement each case before
848
+ Tudu::Core.new.init
849
+ File.open("./#{Tudu::Tasks::TUDU_DIR}/todos", "w") {|f|f.puts c[:todos].join("\n")}
850
+ File.open("./#{Tudu::Tasks::TUDU_DIR}/doings", "w") {|f|f.puts c[:doings].join("\n")}
851
+ File.open("./#{Tudu::Tasks::TUDU_DIR}/dones", "w") {|f|f.puts c[:dones].join("\n")}
852
+ end
853
+
854
+ def case_after(c)
855
+ # implement each case after
856
+ return unless File.exists? Tudu::Tasks::TUDU_DIR
857
+ FileUtils.rm_rf(Tudu::Tasks::TUDU_DIR)
858
+ end
859
+ end
860
+ end
799
861
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tudu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-15 00:00:00.000000000 Z
12
+ date: 2013-12-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
16
- requirement: &25932060 !ruby/object:Gem::Requirement
16
+ requirement: &21802584 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.18.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *25932060
24
+ version_requirements: *21802584
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &25931292 !ruby/object:Gem::Requirement
27
+ requirement: &21802272 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.14.1
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *25931292
35
+ version_requirements: *21802272
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: simplecov
38
- requirement: &25930836 !ruby/object:Gem::Requirement
38
+ requirement: &21801960 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.8.2
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *25930836
46
+ version_requirements: *21801960
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
- requirement: &25929816 !ruby/object:Gem::Requirement
49
+ requirement: &21801684 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '1.3'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *25929816
57
+ version_requirements: *21801684
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rake
60
- requirement: &25929192 !ruby/object:Gem::Requirement
60
+ requirement: &21801456 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *25929192
68
+ version_requirements: *21801456
69
69
  description: Single person's minimum unit of task manager
70
70
  email:
71
71
  - tbpgr@tbpgr.jp