work_guide 1.0.2 → 1.1.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: 8b14a2c345a23a49262f5b17e729c59cff93a23c
4
- data.tar.gz: 85697eb2b4c31a72fd587488406b53d882d77ab7
3
+ metadata.gz: bc17254fea790062a5d548392151b0e7217099e6
4
+ data.tar.gz: 0d6a5b03b5c2e843443ded65b14874f50c94d87f
5
5
  SHA512:
6
- metadata.gz: cbf238f4768c021d52c99ca0d716cb162f21fcf651a9835f806daf9079827db22199da38646a185e545a60f2c03028a54350932490cb18818e1706448ecf9831
7
- data.tar.gz: 90e1bee94254057cea6703f397ceae6f34c0ff4403b5024eb27b7f8d3dad8cd9fc9e9a2de737cc78d8fcbb9177c0aee0518c0379ba04301d26212828adef1a79
6
+ metadata.gz: e8f5cd226cbd2fbe188ad5545c57aaf07ad7f00f3f23f1894862492a92af7abcb7280e47f02657993644a63f6b7cc2efabed932ac0baf16b87c2638d7c3fc85c
7
+ data.tar.gz: 21c7ee9d10185b4b414052eeb6b6e33a9fa1a8ac3d2d242a2858a4fae844168dbf16343bab6bad399f5098f47139629636f4d3c270a776c0666dfd2dee273d01
@@ -25,21 +25,7 @@ module WorkGuide
25
25
  desc "list", "List guides"
26
26
  option :all, type: :boolean, default: false, aliases: :a
27
27
  def list
28
- table = Kosi::Table.new(
29
- header: %w(index cycle priorify description done_at)
30
- )
31
-
32
- rows = Guide.all.map.with_index { |guide, index|
33
- [index, guide]
34
- }.select { |index, guide|
35
- options[:all] || guide.should_do?
36
- }.sort_by { |index, guide|
37
- guide.priority_rate
38
- }.map { |index, guide|
39
- [index, guide.cycle, guide.priority, guide.description, guide.done_at]
40
- }
41
-
42
- puts table.render(rows)
28
+ puts guide_table(all: options[:all])
43
29
  end
44
30
  default_task :list
45
31
 
@@ -52,7 +38,21 @@ module WorkGuide
52
38
 
53
39
  desc "done [index]", "Mark as done"
54
40
  option :at, banner: "done_at"
55
- def done(*indexes)
41
+ def done(*args)
42
+ indexes = args.dup
43
+ if indexes.empty?
44
+ IO.popen("peco", "r+") do |io|
45
+ io.puts guide_table
46
+ io.close_write
47
+ index = io.gets.split("|")[1]
48
+ if index && index =~ /\d/
49
+ indexes << index.strip
50
+ else
51
+ abort "[ERROR] Please select guide index !!"
52
+ end
53
+ end
54
+ end
55
+
56
56
  guides = indexes.map { |index| Guide.all[index.to_i] }
57
57
  done_at =
58
58
  if options[:at]
@@ -70,5 +70,24 @@ module WorkGuide
70
70
  puts "Done [#{index}]#{Guide.all[index.to_i]}"
71
71
  end
72
72
  end
73
+
74
+ private
75
+
76
+ def guide_table(all: false)
77
+ rows = Guide.all.map.with_index { |guide, index|
78
+ [index, guide]
79
+ }.select { |index, guide|
80
+ all || guide.should_do?
81
+ }.sort_by { |index, guide|
82
+ guide.priority_rate
83
+ }.map { |index, guide|
84
+ [index, guide.cycle, guide.priority, guide.description, guide.done_at]
85
+ }
86
+
87
+ table = Kosi::Table.new(
88
+ header: %w(index cycle priorify description done_at)
89
+ )
90
+ table.render(rows)
91
+ end
73
92
  end
74
93
  end
@@ -1,3 +1,3 @@
1
1
  module WorkGuide
2
- VERSION = "1.0.2"
2
+ VERSION = "1.1.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.0.2
4
+ version: 1.1.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-10 00:00:00.000000000 Z
11
+ date: 2015-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor