himekaminize 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +21 -0
- data/README.md +1 -1
- data/lib/himekaminize/filterable.rb +42 -0
- data/lib/himekaminize/filters/task_filter.rb +9 -4
- data/lib/himekaminize/task_list.rb +17 -18
- data/lib/himekaminize/version.rb +1 -1
- data/lib/himekaminize.rb +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6861ce77d1b6849a5e62d90850f9c1112cb2ce78
|
4
|
+
data.tar.gz: d31f5223a6a3d4c9015bf062f47be8c78a682c80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78b7c30f47eb493215b54cf33951afa970d2041379e336354943729e1537766e81a05fbe8f09c78eff93e3cdc7cc1a467449683838433d88967fe81b8d13041a
|
7
|
+
data.tar.gz: adef4562190b45107faf0a12f171b3cd6ac09666d4df1e99499342ad8f8a812904ee91b399bd10e55693e13af74850da20ba409f26df3de9cbf05401a20ad2e8
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 otukutun
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Himekaminize [![Build Status](https://travis-ci.org/otukutun/himekaminize.svg?branch=master)](https://travis-ci.org/otukutun/himekaminize)
|
1
|
+
# Himekaminize [![Build Status](https://travis-ci.org/otukutun/himekaminize.svg?branch=master)](https://travis-ci.org/otukutun/himekaminize) [![Gem Version](https://badge.fury.io/rb/himekaminize.svg)](https://badge.fury.io/rb/himekaminize)
|
2
2
|
|
3
3
|
Utilities to extract markdown some parts.
|
4
4
|
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require "active_support/concern"
|
2
|
+
|
3
|
+
module Himekaminize
|
4
|
+
module Filterable
|
5
|
+
extend ::ActiveSupport::Concern
|
6
|
+
|
7
|
+
def initialize(markdown)
|
8
|
+
@markdown = markdown
|
9
|
+
to_lines
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_a
|
13
|
+
filters.inject(lines) do |result, filter|
|
14
|
+
filter.call(result)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def filters
|
21
|
+
@filters ||= self.class.filter_classes.map(&:new)
|
22
|
+
end
|
23
|
+
|
24
|
+
def markdown
|
25
|
+
@markdown
|
26
|
+
end
|
27
|
+
|
28
|
+
def lines
|
29
|
+
@lines
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_lines
|
33
|
+
@lines = markdown.lines
|
34
|
+
end
|
35
|
+
|
36
|
+
module ClassMethods
|
37
|
+
def filter_classes
|
38
|
+
raise ::NotImplementedError
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -5,11 +5,16 @@ module Himekaminize
|
|
5
5
|
# @param array [Array]
|
6
6
|
# @return [Array]
|
7
7
|
def call(array)
|
8
|
-
|
9
|
-
|
10
|
-
.
|
8
|
+
seq = 0
|
9
|
+
array.map do |line|
|
10
|
+
if line.is_a?(String) && line =~ /\A\s*(#{Himekaminize::Task::INCOMPLETE_PATTERN}|#{Himekaminize::Task::COMPLETE_PATTERN})/
|
11
|
+
seq += 1
|
12
|
+
Himekaminize::Task.new(line, seq)
|
13
|
+
else
|
14
|
+
line
|
15
|
+
end
|
16
|
+
end
|
11
17
|
end
|
12
|
-
|
13
18
|
end
|
14
19
|
end
|
15
20
|
end
|
@@ -1,32 +1,31 @@
|
|
1
1
|
module Himekaminize
|
2
2
|
class TaskList
|
3
|
+
include ::Himekaminize::Filterable
|
3
4
|
class << self
|
4
5
|
# @return [Array<Himekaminize::Filters::BaseFilter>]
|
5
|
-
def
|
6
|
-
@
|
7
|
-
::Himekaminize::Filters::TaskFilter
|
6
|
+
def filter_classes
|
7
|
+
@filter_classes ||= [
|
8
|
+
::Himekaminize::Filters::TaskFilter
|
8
9
|
]
|
9
10
|
end
|
10
11
|
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
to_lines
|
13
|
+
def to_task_list
|
14
|
+
array = to_a
|
15
|
+
array.select { |line| line.is_a?(Himekaminize::Task) }
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
def to_s
|
19
|
+
array = to_a
|
20
|
+
seq = 0
|
21
|
+
array.map do |line|
|
22
|
+
if line.is_a?(Himekaminize::Task)
|
23
|
+
Himekaminize::Task.new(line, seq)
|
24
|
+
else
|
25
|
+
line
|
26
|
+
end
|
23
27
|
end
|
24
|
-
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def to_lines
|
29
|
-
@lines = @markdown.lines
|
28
|
+
.join("\n\r")
|
30
29
|
end
|
31
30
|
end
|
32
31
|
end
|
data/lib/himekaminize/version.rb
CHANGED
data/lib/himekaminize.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.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- otukutun
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -91,12 +91,14 @@ files:
|
|
91
91
|
- ".rspec"
|
92
92
|
- ".travis.yml"
|
93
93
|
- Gemfile
|
94
|
+
- LICENSE.txt
|
94
95
|
- README.md
|
95
96
|
- Rakefile
|
96
97
|
- bin/console
|
97
98
|
- bin/setup
|
98
99
|
- himekaminize.gemspec
|
99
100
|
- lib/himekaminize.rb
|
101
|
+
- lib/himekaminize/filterable.rb
|
100
102
|
- lib/himekaminize/filters/base_filter.rb
|
101
103
|
- lib/himekaminize/filters/task_filter.rb
|
102
104
|
- lib/himekaminize/task.rb
|