work_guide 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e2f9c94c583994b38f38023ea35eed5591ececbf
4
- data.tar.gz: faac44285c21db75f2c5bf379158fd9c523e47f0
3
+ metadata.gz: 3601b0cf778beaeb88809a78d26dd3e338550816
4
+ data.tar.gz: 6febc2436d8db93a8d50e15fc24194941fedcc3f
5
5
  SHA512:
6
- metadata.gz: 134056fe63fbfa09c92db65c375cf6b9bd96d6bae716aface57b43a034a1f6e526d48f8c7196c28265495aba7e83abe6cf0e7c5d77a3d5720aa3865c06f6bceb
7
- data.tar.gz: 7fcd895379904f268df6d2bdad82758496f1a5643a9943bcc61b1ae5d62b9d19756ca4178d2e59add968f0faf43873d220f00307ca848531b1b9f43f352cce13
6
+ metadata.gz: e52c8c74631eed4eb219c3cbaf9b7cf57e1018b30eddc68d6b03d1a60256c2fb6f9287fed127e7a707d556c1ff05b538fa0c21a0705beb99de42a4b6836a9493
7
+ data.tar.gz: 1939f4abf82766b61bcb5203af79e1c9517fce46f6b08a5263dda29bc11c008219cccbaed9010c8a95eef40cf6ca5f34997d20d88f2aa63500154770e015a530
@@ -17,7 +17,8 @@ module WorkGuide
17
17
 
18
18
  desc "update [index]", "Edit a guide"
19
19
  option :priority, default: 'medium', banner: '[high|medium|low]'
20
- def update(index)
20
+ def update(index = nil)
21
+ index = boot_peco(all: true) unless index.present?
21
22
  guide = Guide.all[index.to_i]
22
23
  guide.priority = options[:priority] if options[:priority]
23
24
  Guide.save
@@ -32,7 +33,8 @@ module WorkGuide
32
33
  default_task :list
33
34
 
34
35
  desc "delete [index]", "Delete a guide"
35
- def delete(index)
36
+ def delete(index = nil)
37
+ index = boot_peco(all: true) unless index.present?
36
38
  guide = Guide.all.delete_at(index.to_i)
37
39
  Guide.save
38
40
  puts "Deleted [#{index}]#{guide}"
@@ -42,18 +44,7 @@ module WorkGuide
42
44
  option :at, banner: "done_at"
43
45
  def done(*args)
44
46
  indexes = args.dup
45
- if indexes.empty?
46
- IO.popen("peco", "r+") do |io|
47
- io.puts guide_table
48
- io.close_write
49
- index = io.gets.split("|")[1]
50
- if index && index =~ /\d/
51
- indexes << index.strip
52
- else
53
- abort "[ERROR] Please select guide index !!"
54
- end
55
- end
56
- end
47
+ indexes << boot_peco if indexes.empty?
57
48
 
58
49
  guides = indexes.map { |index| Guide.all[index.to_i] }
59
50
  done_at =
@@ -75,6 +66,19 @@ module WorkGuide
75
66
 
76
67
  private
77
68
 
69
+ def boot_peco(all: false)
70
+ IO.popen("peco", "r+") do |io|
71
+ io.puts guide_table(all: all)
72
+ io.close_write
73
+ index = io.gets.split("|")[1]
74
+ if index && index =~ /\d/
75
+ index.strip
76
+ else
77
+ abort "[ERROR] Please select guide index !!"
78
+ end
79
+ end
80
+ end
81
+
78
82
  def guide_table(all: false)
79
83
  rows = Guide.all.map.with_index { |guide, index|
80
84
  [index, guide]
@@ -1,3 +1,3 @@
1
1
  module WorkGuide
2
- VERSION = "1.1.1"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: work_guide
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - adorechic