dev_flow 0.1.6 → 0.2.0

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.
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+ module DateName
3
+
4
+ # return the name of `from_date` on the view point of `to_date`
5
+ def self.zh from_date, to_date = DateTime.now
6
+ from_date = DateTime.parse(from_date) if from_date.is_a?(String)
7
+ to_date = DateTime.parse(to_date) if to_date.is_a?(String)
8
+ days = (from_date - to_date).to_i
9
+
10
+ case days
11
+ when -3 then "大前天"
12
+ when -2 then "前天"
13
+ when -1 then "昨天"
14
+ when 0 then "今天"
15
+ when 1 then "明天"
16
+ when 2 then "后天"
17
+ when 3 then "大后天"
18
+ when -9 .. -4 then "#{(0-days).to_s}天前"
19
+ when 4 .. 9 then "#{days.to_s}天后"
20
+ else
21
+ from_date.year == to_date.year ? from_date.strftime("%m月%d日")
22
+ : from_date.strftime("%Y年%m月%d日")
23
+ end
24
+ end
25
+
26
+ end
@@ -1,6 +1,6 @@
1
1
  module DevFlow
2
- class Task
3
2
 
3
+ class Task
4
4
  def as_title header = ' '
5
5
  name = self.display_name
6
6
  name = self.display_name.bold if self.is_workable?
@@ -13,7 +13,7 @@ module DevFlow
13
13
  on_branch = sprintf "(=> %s, %02d%%)", self.branch_name.bold, self.progress
14
14
  end
15
15
 
16
- title = sprintf("%s[%s]%s%s", ' '*(self.level-1), header, name, on_branch)
16
+ title = sprintf("%s[%s]%s (%s-%s) %s", ' '*(self.level-1), header, name, DateName.zh(self.start_date).bold, DateName.zh(self.end_date).bold, on_branch)
17
17
  end
18
18
 
19
19
  ## a task is completable if all children complated
@@ -1,3 +1,3 @@
1
1
  module DevFlow
2
- VERSION = '0.1.6'
2
+ VERSION = '0.2.0'
3
3
  end
data/lib/dev_flow.rb CHANGED
@@ -13,6 +13,7 @@ require 'dev_flow/task_console'
13
13
  # application and commands
14
14
  require 'dev_flow/app'
15
15
  require 'dev_flow/version'
16
+ require 'dev_flow/date_name'
16
17
 
17
18
  # other helper and libraries
18
19
  require 'dev_flow/girc'
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+ require "dev_flow/date_name"
4
+
5
+ describe DateName do
6
+ describe ".zh" do
7
+ it "can handle yesterday" do
8
+ DateName.zh(DateTime.now-1).should eq('昨天')
9
+ end
10
+
11
+ it "can handle next two days" do
12
+ DateName.zh(DateTime.now+2).should eq('后天')
13
+ end
14
+
15
+ it "can handle next two days" do
16
+ DateName.zh(DateTime.now+6, DateTime.now+4).should eq('后天')
17
+ end
18
+
19
+ it "can handle next 6 days" do
20
+ DateName.zh(DateTime.now+6).should eq('6天后')
21
+ end
22
+
23
+ it "can handle 8 days before" do
24
+ DateName.zh(DateTime.now-6).should eq('6天前')
25
+ end
26
+
27
+ it "can handle next 14 days" do
28
+ DateName.zh(DateTime.parse("2012-1-14"), DateTime.parse("2012-1-1")).should eq('01月14日')
29
+ end
30
+
31
+ it "can handle before 11 days on last year" do
32
+ DateName.zh(DateTime.parse("2011-12-20"), DateTime.parse("2012-1-1")).should eq('2011年12月20日')
33
+ end
34
+ end
35
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dev_flow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-02 00:00:00.000000000 Z
12
+ date: 2013-04-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: term-ansicolor
@@ -67,6 +67,7 @@ files:
67
67
  - lib/dev_flow/commands/init.rb
68
68
  - lib/dev_flow/commands/progress.rb
69
69
  - lib/dev_flow/commands/ur.rb
70
+ - lib/dev_flow/date_name.rb
70
71
  - lib/dev_flow/girc.rb
71
72
  - lib/dev_flow/member.rb
72
73
  - lib/dev_flow/roadmap.rb
@@ -74,6 +75,7 @@ files:
74
75
  - lib/dev_flow/task_console.rb
75
76
  - lib/dev_flow/version.rb
76
77
  - spec/app_spec.rb
78
+ - spec/date_name_spec.rb
77
79
  - spec/roadmap_spec.rb
78
80
  - spec/spec_helper.rb
79
81
  - spec/task_spec.rb
@@ -112,6 +114,7 @@ specification_version: 3
112
114
  summary: a bundle of tools for ROADMAP/git based development flow control.
113
115
  test_files:
114
116
  - spec/app_spec.rb
117
+ - spec/date_name_spec.rb
115
118
  - spec/roadmap_spec.rb
116
119
  - spec/spec_helper.rb
117
120
  - spec/task_spec.rb