himekaminize 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/README.md +39 -0
- data/Rakefile +6 -0
- data/bin/console +10 -0
- data/bin/setup +8 -0
- data/himekaminize.gemspec +27 -0
- data/lib/himekaminize.rb +5 -0
- data/lib/himekaminize/filters/base_filter.rb +11 -0
- data/lib/himekaminize/filters/task_filter.rb +15 -0
- data/lib/himekaminize/task.rb +28 -0
- data/lib/himekaminize/task_list.rb +32 -0
- data/lib/himekaminize/version.rb +3 -0
- metadata +128 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cc49f509e0f670ac3fcb69bcdc3afabfc3fdfe7f
|
4
|
+
data.tar.gz: 77a2d8f192a27e43caa05499ab8e29011cb3a261
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 952d607821e879de0d9ad6716ca886f3ea0c36dc677f1e3fc2a403b8fb73054ecd6a9ad31ff305f36d80c15d90bf6dbffe9d8bbb6a05bce4d876b04660cd9193
|
7
|
+
data.tar.gz: 41d08096c5613851bc1494331454383faf4f717455b16663131dd3b50b055722fa048359b46d258ddde5c1ee2baf83f4c5b63dcebace8640a9fda18aaaf2bba6
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Himekaminize [![Build Status](https://travis-ci.org/otukutun/himekaminize.svg?branch=master)](https://travis-ci.org/otukutun/himekaminize)
|
2
|
+
|
3
|
+
Utilities to extract markdown some parts.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'himekaminize'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
```sh
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
```sh
|
22
|
+
$ gem install himekaminize
|
23
|
+
```
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
```
|
28
|
+
Himekaminize::TaskList.new("- [ ] TODO\n - [ ] ねる\n - [ ] おきる").to_a
|
29
|
+
```
|
30
|
+
|
31
|
+
## Development
|
32
|
+
|
33
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
34
|
+
|
35
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
36
|
+
|
37
|
+
## Contributing
|
38
|
+
|
39
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/himekaminize.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "himekaminize"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
require "pry"
|
10
|
+
Pry.start
|
data/bin/setup
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "himekaminize/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "himekaminize"
|
8
|
+
spec.version = Himekaminize::VERSION
|
9
|
+
spec.authors = ["otukutun"]
|
10
|
+
spec.email = ["orehaorz@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "Utilities to extract markdown."
|
13
|
+
spec.homepage = "https://github.com/otukutun/himekaminize"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
16
|
+
f.match(%r{^(test|spec|features)/})
|
17
|
+
end
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "activesupport", "~> 5.1"
|
23
|
+
spec.add_development_dependency "bundler"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
26
|
+
spec.add_development_dependency 'pry', '~> 0'
|
27
|
+
end
|
data/lib/himekaminize.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module Himekaminize
|
2
|
+
module Filters
|
3
|
+
class TaskFilter < BaseFilter
|
4
|
+
# @note Override
|
5
|
+
# @param array [Array]
|
6
|
+
# @return [Array]
|
7
|
+
def call(array)
|
8
|
+
array
|
9
|
+
.select { |line| line.is_a?(String) && line =~ /\A\s*(#{Himekaminize::Task::INCOMPLETE_PATTERN}|#{Himekaminize::Task::COMPLETE_PATTERN})/ }
|
10
|
+
.map.with_index {|n, idx| Himekaminize::Task.new(n, idx + 1)}
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Himekaminize
|
2
|
+
class Task
|
3
|
+
INCOMPLETE_PATTERN = /[-+*]\s\[\s\]\s/
|
4
|
+
COMPLETE_PATTERN = /[-+*]\s\[[xX]\]\s/
|
5
|
+
|
6
|
+
attr_accessor :name, :status, :sequence
|
7
|
+
|
8
|
+
COMPLETE_STATUSE = :complete
|
9
|
+
INCOMPLETE_STATUSE = :incomplete
|
10
|
+
|
11
|
+
def initialize(line, sequence)
|
12
|
+
@sequence = sequence
|
13
|
+
@status, @name = split_name_and_status(line)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
def split_name_and_status(line)
|
18
|
+
/\A\s*(#{INCOMPLETE_PATTERN}|#{COMPLETE_PATTERN})(.*)/.match(line) do |m|
|
19
|
+
if m[1] =~ /#{INCOMPLETE_PATTERN}/
|
20
|
+
return [INCOMPLETE_STATUSE, m[2]]
|
21
|
+
else
|
22
|
+
return [COMPLETE_STATUSE, m[2]]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Himekaminize
|
2
|
+
class TaskList
|
3
|
+
class << self
|
4
|
+
# @return [Array<Himekaminize::Filters::BaseFilter>]
|
5
|
+
def filters
|
6
|
+
@filters ||= [
|
7
|
+
::Himekaminize::Filters::TaskFilter.new
|
8
|
+
]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# @param markdown [String]
|
13
|
+
def initialize(markdown)
|
14
|
+
@markdown = markdown
|
15
|
+
to_lines
|
16
|
+
end
|
17
|
+
|
18
|
+
# @todo
|
19
|
+
# @param markdown [Array]
|
20
|
+
def to_a
|
21
|
+
self.class.filters.inject(@lines) do |result, filter|
|
22
|
+
filter.call(result)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def to_lines
|
29
|
+
@lines = @markdown.lines
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: himekaminize
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- otukutun
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-08-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- orehaorz@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".travis.yml"
|
93
|
+
- Gemfile
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- bin/console
|
97
|
+
- bin/setup
|
98
|
+
- himekaminize.gemspec
|
99
|
+
- lib/himekaminize.rb
|
100
|
+
- lib/himekaminize/filters/base_filter.rb
|
101
|
+
- lib/himekaminize/filters/task_filter.rb
|
102
|
+
- lib/himekaminize/task.rb
|
103
|
+
- lib/himekaminize/task_list.rb
|
104
|
+
- lib/himekaminize/version.rb
|
105
|
+
homepage: https://github.com/otukutun/himekaminize
|
106
|
+
licenses: []
|
107
|
+
metadata: {}
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
requirements: []
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 2.6.11
|
125
|
+
signing_key:
|
126
|
+
specification_version: 4
|
127
|
+
summary: Utilities to extract markdown.
|
128
|
+
test_files: []
|