himekaminize 0.0.10 → 0.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 +4 -4
- data/lib/himekaminize/filters/task_filter.rb +25 -1
- data/lib/himekaminize/nodes/task.rb +15 -3
- data/lib/himekaminize/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f7a61ec8474872ea935b07540d7b5087e35110d
|
4
|
+
data.tar.gz: 204673fa1f5f35adb3f1008ca24a147d79fde642
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd2fb0c686e70c5236de2dcb7c5ccbfce3855bcee608d0993398d55fe2f06c1442d8b57e7415a69c14634fc0c341eecdaf09144b865dd7cb3c6263e1633acb73
|
7
|
+
data.tar.gz: 13694698f87224147f1ed4a0c905808d0d13dcdb794f2863be6a79c521c8f38b8960e2c2a705f9cec9f486eac292710e6e5f672fece40c08fb886f1634dc441d
|
@@ -14,6 +14,13 @@ module Himekaminize
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
+
# Attach depth, and parent_seq
|
18
|
+
output.map.with_index do |line, index|
|
19
|
+
next line if !line.is_a?(Himekaminize::Nodes::Task) || index == 0 || line.none_parent?
|
20
|
+
prev_i = index - 1
|
21
|
+
next attach_parent_task(output, line, prev_i)
|
22
|
+
end
|
23
|
+
|
17
24
|
if only_task_list?
|
18
25
|
output = output.select { |line| line.is_a?(Himekaminize::Nodes::Task) }
|
19
26
|
end
|
@@ -22,7 +29,7 @@ module Himekaminize
|
|
22
29
|
seq = 1
|
23
30
|
update_task_status_list.each do |v|
|
24
31
|
output = output.map do |line|
|
25
|
-
if line.is_a?(Himekaminize::Nodes::Task) && line.
|
32
|
+
if line.is_a?(Himekaminize::Nodes::Task) && line.seq == v[:seq]
|
26
33
|
line.update_status(v[:status].to_sym)
|
27
34
|
line
|
28
35
|
else
|
@@ -48,6 +55,23 @@ module Himekaminize
|
|
48
55
|
def update_task_status_list
|
49
56
|
@context[:update_task_status_list].presence || {}
|
50
57
|
end
|
58
|
+
|
59
|
+
def attach_parent_task(output, task, prev_i)
|
60
|
+
prev_i.downto(0) do |pi|
|
61
|
+
unless output[pi].is_a?(Himekaminize::Nodes::Task)
|
62
|
+
task.depth ||= 0
|
63
|
+
return task
|
64
|
+
end
|
65
|
+
if task.parent?(output[pi])
|
66
|
+
task.depth = output[pi].depth + 1
|
67
|
+
task.parent_seq = output[pi].seq
|
68
|
+
return task
|
69
|
+
else
|
70
|
+
task.depth ||= 0
|
71
|
+
end
|
72
|
+
end
|
73
|
+
task
|
74
|
+
end
|
51
75
|
end
|
52
76
|
end
|
53
77
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require "active_support/core_ext/module"
|
1
2
|
module Himekaminize
|
2
3
|
module Nodes
|
3
4
|
class Task < BaseNode
|
@@ -6,15 +7,17 @@ module Himekaminize
|
|
6
7
|
|
7
8
|
INCOMPLETE_MD = '- [ ]'.freeze
|
8
9
|
COMPLETE_MD = '- [x]'.freeze
|
9
|
-
attr_accessor :name, :status, :
|
10
|
+
attr_accessor :name, :status, :seq, :space, :depth, :parent_seq
|
11
|
+
alias_attribute :sequence, :seq
|
10
12
|
|
11
13
|
COMPLETE_STATUSE = :complete
|
12
14
|
INCOMPLETE_STATUSE = :incomplete
|
13
15
|
STATUSES = %I(#{COMPLETE_STATUSE} #{INCOMPLETE_STATUSE})
|
14
16
|
|
15
|
-
def initialize(line,
|
16
|
-
@
|
17
|
+
def initialize(line, seq)
|
18
|
+
@seq = seq
|
17
19
|
@status, @name, @space = split_name_and_status(line)
|
20
|
+
@depth, @parent_seq = 0, nil if @space.length == 0
|
18
21
|
end
|
19
22
|
|
20
23
|
def to_s
|
@@ -27,6 +30,15 @@ module Himekaminize
|
|
27
30
|
@status = status
|
28
31
|
end
|
29
32
|
|
33
|
+
def parent?(a)
|
34
|
+
return false unless a.is_a?(self.class)
|
35
|
+
@space.length - 4 <= a.space.length && a.space.length <= @space.length - 1
|
36
|
+
end
|
37
|
+
|
38
|
+
def none_parent?
|
39
|
+
@depth == 0 || @seq == 1
|
40
|
+
end
|
41
|
+
|
30
42
|
private
|
31
43
|
def split_name_and_status(line)
|
32
44
|
/\A(\s*)(#{INCOMPLETE_PATTERN}|#{COMPLETE_PATTERN})(.*)/.match(line) do |m|
|
data/lib/himekaminize/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: himekaminize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- otukutun
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|