work_guide 1.2.0 → 1.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3601b0cf778beaeb88809a78d26dd3e338550816
4
- data.tar.gz: 6febc2436d8db93a8d50e15fc24194941fedcc3f
3
+ metadata.gz: 67c88f7640b63487a85b8204722c633f3efb7074
4
+ data.tar.gz: 81c40b86796dd1b01da1d554a53171a643adf427
5
5
  SHA512:
6
- metadata.gz: e52c8c74631eed4eb219c3cbaf9b7cf57e1018b30eddc68d6b03d1a60256c2fb6f9287fed127e7a707d556c1ff05b538fa0c21a0705beb99de42a4b6836a9493
7
- data.tar.gz: 1939f4abf82766b61bcb5203af79e1c9517fce46f6b08a5263dda29bc11c008219cccbaed9010c8a95eef40cf6ca5f34997d20d88f2aa63500154770e015a530
6
+ metadata.gz: b397fed96ac1776230a170fd2e9182f2fc2d8cedd59c6471d2e85ec1e74df01e9866ba53809edc8c51b3af7c24420bbc61db57b8c8a8658f68f477713e47dc5e
7
+ data.tar.gz: f21ecee0754f824dbd6772c9f854d399edd7a7205897c5cb0bae9e3cde8f7a41500c280708d81c0a66dd36789d5f4706bb51a03c9cc33c74238cb7b074a7cd93
@@ -6,11 +6,13 @@ module WorkGuide
6
6
  desc "add [guide description]", "Add a new guide"
7
7
  option :cycle, default: 'daily', banner: '[hourly|daily|weekly|monthly]', aliases: :c
8
8
  option :priority, default: 'medium', banner: '[high|medium|low]'
9
+ option :week_start, default: 'monday', banner: '[sunday|monday|...]'
9
10
  def add(description)
10
11
  guide = Guide.create(
11
12
  description: description,
12
13
  priority: options[:priority],
13
- cycle: options[:cycle]
14
+ cycle: options[:cycle],
15
+ week_start: options[:week_start]
14
16
  )
15
17
  puts "Created [#{Guide.all.size - 1}]#{guide}"
16
18
  end
@@ -87,11 +89,11 @@ module WorkGuide
87
89
  }.sort_by { |index, guide|
88
90
  guide.priority_rate
89
91
  }.map { |index, guide|
90
- [index, guide.cycle, guide.priority, guide.description, guide.done_at]
92
+ [index, guide.cycle, guide.priority, guide.description, guide.done_at, guide.week_start_if_weekly]
91
93
  }
92
94
 
93
95
  table = Kosi::Table.new(
94
- header: %w(index cycle priorify description done_at)
96
+ header: %w(index cycle priorify description done_at week_start)
95
97
  )
96
98
  table.render(rows)
97
99
  end
@@ -3,7 +3,7 @@ require 'active_support/core_ext'
3
3
 
4
4
  module WorkGuide
5
5
  class Guide
6
- attr_accessor :description, :cycle, :done_at, :priority
6
+ attr_accessor :description, :cycle, :done_at, :priority, :week_start
7
7
 
8
8
  class << self
9
9
  def create(args)
@@ -32,7 +32,8 @@ module WorkGuide
32
32
  description: ,
33
33
  cycle: 'daily',
34
34
  done_at: nil,
35
- priority: 'medium'
35
+ priority: 'medium',
36
+ week_start: 'monday'
36
37
  )
37
38
  @description = description
38
39
  @cycle = cycle
@@ -40,6 +41,10 @@ module WorkGuide
40
41
  @done_at = Time.parse(done_at)
41
42
  end
42
43
  @priority = priority
44
+
45
+ if week_start
46
+ @week_start = week_start.to_sym
47
+ end
43
48
  end
44
49
 
45
50
  def should_do?
@@ -50,7 +55,7 @@ module WorkGuide
50
55
  when 'daily'
51
56
  1.day.since(done_at).beginning_of_day.past?
52
57
  when 'weekly'
53
- 1.week.since(done_at).beginning_of_day.past?
58
+ Time.now.beginning_of_week(week_start) >= done_at
54
59
  when 'monthly'
55
60
  1.month.since(done_at).beginning_of_month.past?
56
61
  else
@@ -61,6 +66,10 @@ module WorkGuide
61
66
  end
62
67
  end
63
68
 
69
+ def week_start_if_weekly
70
+ cycle == 'weekly' ? week_start : nil
71
+ end
72
+
64
73
  def priority_rate
65
74
  case priority
66
75
  when 'high' ; 1
@@ -76,6 +85,7 @@ module WorkGuide
76
85
  cycle: cycle,
77
86
  done_at: done_at,
78
87
  priority: priority,
88
+ week_start: week_start,
79
89
  }
80
90
  end
81
91
 
@@ -1,3 +1,3 @@
1
1
  module WorkGuide
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: work_guide
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - adorechic
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-13 00:00:00.000000000 Z
11
+ date: 2015-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor