jekyll_from_to_until 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +2 -0
- data/.rubocop.yml +34 -0
- data/.ruby-version +1 -0
- data/.vscode/launch.json +35 -0
- data/.vscode/settings.json +4 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +134 -0
- data/LICENSE.txt +21 -0
- data/README.md +264 -0
- data/Rakefile +4 -0
- data/jekyll_from_to_until.gemspec +49 -0
- data/lib/jekyll_from_to_until/version.rb +5 -0
- data/lib/jekyll_from_to_until.rb +87 -0
- data/sig/jekyll_from_to_until.rbs +4 -0
- metadata +219 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9517266ec097c2c09c61fff55305331cbb8bdc7948f83c9aebf65ba389f92c98
|
4
|
+
data.tar.gz: aba3d59ca29e51fe632f48963bf9a1bbc28a2d794e8c4c1de244ac1857f67432
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 430b2dce1ce0819671b3fd0b424bbd697ccde1edeac0e80ae78e2c531c9b852c3f9b6ac00b8d6cb4c9ecbeff2f2aaed0b10ace4e5e56e394b236e6e6e5ef5dec
|
7
|
+
data.tar.gz: 10e2dff6a413bd310af07e719b6a654ced0cf6572f46720eb248ec30a26380f11b5f8780edb557c4b3b701f820998f46a52e5546f647f7cdfb06029d4af514a3
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require: rubocop-jekyll
|
2
|
+
inherit_gem:
|
3
|
+
rubocop-jekyll: .rubocop.yml
|
4
|
+
|
5
|
+
AllCops:
|
6
|
+
Exclude:
|
7
|
+
- vendor/**/*
|
8
|
+
- Gemfile*
|
9
|
+
NewCops: enable
|
10
|
+
TargetRubyVersion: 2.6
|
11
|
+
|
12
|
+
Layout/LineLength:
|
13
|
+
Max: 150
|
14
|
+
|
15
|
+
Layout/MultilineMethodCallIndentation:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
Layout/MultilineOperationIndentation:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
Metrics/BlockLength:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
Style/PercentLiteralDelimiters:
|
25
|
+
Enabled: false
|
26
|
+
|
27
|
+
Style/RegexpLiteral:
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
Style/StringLiterals:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
Style/StringLiteralsInInterpolation:
|
34
|
+
Enabled: false
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.0.0
|
data/.vscode/launch.json
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
{
|
2
|
+
// Use IntelliSense to learn about possible attributes.
|
3
|
+
// Hover to view descriptions of existing attributes.
|
4
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
5
|
+
"version": "0.2.0",
|
6
|
+
"configurations": [
|
7
|
+
{
|
8
|
+
"args": [
|
9
|
+
"-I",
|
10
|
+
"${workspaceRoot}"
|
11
|
+
],
|
12
|
+
"cwd": "${workspaceRoot}",
|
13
|
+
"name": "RSpec - all",
|
14
|
+
"program": "${env:HOME}/.gems/bin/rspec",
|
15
|
+
"request": "launch",
|
16
|
+
"showDebuggerOutput": false,
|
17
|
+
"type": "Ruby",
|
18
|
+
"useBundler": true,
|
19
|
+
},
|
20
|
+
{
|
21
|
+
"args": [
|
22
|
+
"-I",
|
23
|
+
"${workspaceRoot}",
|
24
|
+
"${file}"
|
25
|
+
],
|
26
|
+
"cwd": "${workspaceRoot}",
|
27
|
+
"name": "RSpec - active spec file only",
|
28
|
+
"program": "${env:HOME}/.gems/bin/rspec",
|
29
|
+
"showDebuggerOutput": false,
|
30
|
+
"request": "launch",
|
31
|
+
"type": "Ruby",
|
32
|
+
"useBundler": true,
|
33
|
+
},
|
34
|
+
]
|
35
|
+
}
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
## 1.0.0 / 2022-03-14
|
2
|
+
* Made into a Ruby gem and published on RubyGems.org as [jekyll_from_to_until](https://rubygems.org/gems/jekyll_from_to_until).
|
3
|
+
* `bin/attach` script added for debugging
|
4
|
+
* Rubocop standards added
|
5
|
+
* Proper versioning and CHANGELOG.md added
|
6
|
+
|
7
|
+
## 0.1.0 / 2020-12-29
|
8
|
+
* Initial version published
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
jekyll_from_to_until (1.0.0)
|
5
|
+
jekyll
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.8.0)
|
11
|
+
public_suffix (>= 2.0.2, < 5.0)
|
12
|
+
ast (2.4.2)
|
13
|
+
coderay (1.1.3)
|
14
|
+
colorator (1.1.0)
|
15
|
+
concurrent-ruby (1.1.9)
|
16
|
+
debase (0.2.4.1)
|
17
|
+
debase-ruby_core_source (>= 0.10.2)
|
18
|
+
debase-ruby_core_source (0.10.14)
|
19
|
+
diff-lcs (1.5.0)
|
20
|
+
em-websocket (0.5.3)
|
21
|
+
eventmachine (>= 0.12.9)
|
22
|
+
http_parser.rb (~> 0)
|
23
|
+
eventmachine (1.2.7)
|
24
|
+
ffi (1.15.5)
|
25
|
+
forwardable-extended (2.6.0)
|
26
|
+
http_parser.rb (0.8.0)
|
27
|
+
i18n (1.10.0)
|
28
|
+
concurrent-ruby (~> 1.0)
|
29
|
+
jekyll (4.2.2)
|
30
|
+
addressable (~> 2.4)
|
31
|
+
colorator (~> 1.0)
|
32
|
+
em-websocket (~> 0.5)
|
33
|
+
i18n (~> 1.0)
|
34
|
+
jekyll-sass-converter (~> 2.0)
|
35
|
+
jekyll-watch (~> 2.0)
|
36
|
+
kramdown (~> 2.3)
|
37
|
+
kramdown-parser-gfm (~> 1.0)
|
38
|
+
liquid (~> 4.0)
|
39
|
+
mercenary (~> 0.4.0)
|
40
|
+
pathutil (~> 0.9)
|
41
|
+
rouge (~> 3.0)
|
42
|
+
safe_yaml (~> 1.0)
|
43
|
+
terminal-table (~> 2.0)
|
44
|
+
jekyll-sass-converter (2.2.0)
|
45
|
+
sassc (> 2.0.1, < 3.0)
|
46
|
+
jekyll-watch (2.2.1)
|
47
|
+
listen (~> 3.0)
|
48
|
+
kramdown (2.3.1)
|
49
|
+
rexml
|
50
|
+
kramdown-parser-gfm (1.1.0)
|
51
|
+
kramdown (~> 2.0)
|
52
|
+
liquid (4.0.3)
|
53
|
+
listen (3.7.1)
|
54
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
55
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
56
|
+
mercenary (0.4.0)
|
57
|
+
method_source (1.0.0)
|
58
|
+
parallel (1.21.0)
|
59
|
+
parser (3.1.1.0)
|
60
|
+
ast (~> 2.4.1)
|
61
|
+
pathutil (0.16.2)
|
62
|
+
forwardable-extended (~> 2.6)
|
63
|
+
pry (0.14.1)
|
64
|
+
coderay (~> 1.1)
|
65
|
+
method_source (~> 1.0)
|
66
|
+
public_suffix (4.0.6)
|
67
|
+
rainbow (3.1.1)
|
68
|
+
rake (13.0.6)
|
69
|
+
rb-fsevent (0.11.1)
|
70
|
+
rb-inotify (0.10.1)
|
71
|
+
ffi (~> 1.0)
|
72
|
+
regexp_parser (2.2.1)
|
73
|
+
rexml (3.2.5)
|
74
|
+
rouge (3.28.0)
|
75
|
+
rspec (3.11.0)
|
76
|
+
rspec-core (~> 3.11.0)
|
77
|
+
rspec-expectations (~> 3.11.0)
|
78
|
+
rspec-mocks (~> 3.11.0)
|
79
|
+
rspec-core (3.11.0)
|
80
|
+
rspec-support (~> 3.11.0)
|
81
|
+
rspec-expectations (3.11.0)
|
82
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
83
|
+
rspec-support (~> 3.11.0)
|
84
|
+
rspec-mocks (3.11.0)
|
85
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
86
|
+
rspec-support (~> 3.11.0)
|
87
|
+
rspec-support (3.11.0)
|
88
|
+
rubocop (1.18.4)
|
89
|
+
parallel (~> 1.10)
|
90
|
+
parser (>= 3.0.0.0)
|
91
|
+
rainbow (>= 2.2.2, < 4.0)
|
92
|
+
regexp_parser (>= 1.8, < 3.0)
|
93
|
+
rexml
|
94
|
+
rubocop-ast (>= 1.8.0, < 2.0)
|
95
|
+
ruby-progressbar (~> 1.7)
|
96
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
97
|
+
rubocop-ast (1.16.0)
|
98
|
+
parser (>= 3.1.1.0)
|
99
|
+
rubocop-jekyll (0.12.0)
|
100
|
+
rubocop (~> 1.18.0)
|
101
|
+
rubocop-performance (~> 1.2)
|
102
|
+
rubocop-performance (1.13.3)
|
103
|
+
rubocop (>= 1.7.0, < 2.0)
|
104
|
+
rubocop-ast (>= 0.4.0)
|
105
|
+
rubocop-rake (0.6.0)
|
106
|
+
rubocop (~> 1.0)
|
107
|
+
ruby-debug-ide (0.7.3)
|
108
|
+
rake (>= 0.8.1)
|
109
|
+
ruby-progressbar (1.11.0)
|
110
|
+
safe_yaml (1.0.5)
|
111
|
+
sassc (2.4.0)
|
112
|
+
ffi (~> 1.9)
|
113
|
+
terminal-table (2.0.0)
|
114
|
+
unicode-display_width (~> 1.1, >= 1.1.1)
|
115
|
+
unicode-display_width (1.8.0)
|
116
|
+
|
117
|
+
PLATFORMS
|
118
|
+
x86_64-linux
|
119
|
+
|
120
|
+
DEPENDENCIES
|
121
|
+
bundler
|
122
|
+
debase
|
123
|
+
jekyll
|
124
|
+
jekyll_from_to_until!
|
125
|
+
pry
|
126
|
+
rake (~> 13.0)
|
127
|
+
rspec
|
128
|
+
rubocop
|
129
|
+
rubocop-jekyll
|
130
|
+
rubocop-rake
|
131
|
+
ruby-debug-ide
|
132
|
+
|
133
|
+
BUNDLED WITH
|
134
|
+
2.3.7
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Mike Slinn
|
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
ADDED
@@ -0,0 +1,264 @@
|
|
1
|
+
`jekyll_from_to_until`
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/jekyll_from_to_until.svg)](https://badge.fury.io/rb/jekyll_from_to_until)
|
3
|
+
===========
|
4
|
+
|
5
|
+
This Jekyll plugin provides 3 filters that return portions of a multiline string.
|
6
|
+
Regular expression is used to specify matches; the simplest regular expression is a string.
|
7
|
+
* `from` — returns the portion beginning with the line that satisfies a regular expression to the end of the multiline string.
|
8
|
+
* `to` — returns the portion from the first line to the line that satisfies a regular expression, including the matched line.
|
9
|
+
* `until` — returns the portion from the first line to the line that satisfies a regular expression, excluding the matched line.
|
10
|
+
|
11
|
+
[Rubular](https://rubular.com/) is a handy online tool to try out regular expressions.
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'jekyll_from_to_until'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle install
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
$ gem install jekyll_from_to_until
|
28
|
+
|
29
|
+
|
30
|
+
## Syntax
|
31
|
+
The regular expression may be enclosed in single quotes, double quotes, or nothing.
|
32
|
+
|
33
|
+
### `from`
|
34
|
+
All of these examples perform identically.
|
35
|
+
```
|
36
|
+
{{ sourceOfLines | from: 'regex' }}
|
37
|
+
{{ sourceOfLines | from: "regex" }}
|
38
|
+
{{ sourceOfLines | from: regex }}
|
39
|
+
```
|
40
|
+
|
41
|
+
### `to`
|
42
|
+
All of these examples perform identically.
|
43
|
+
```
|
44
|
+
{{ sourceOfLines | to: 'regex' }}
|
45
|
+
{{ sourceOfLines | to: "regex" }}
|
46
|
+
{{ sourceOfLines | to: regex }}
|
47
|
+
```
|
48
|
+
|
49
|
+
### `until`
|
50
|
+
All of these examples perform identically.
|
51
|
+
```
|
52
|
+
{{ sourceOfLines | until: 'regex' }}
|
53
|
+
{{ sourceOfLines | until: "regex" }}
|
54
|
+
{{ sourceOfLines | until: regex }}
|
55
|
+
```
|
56
|
+
:warning: Important: the name of the filter must be followed by a colon (:). If you fail to do that an error will be generated and the Jekyll site building process will halt. The error message looks something like this: `Liquid Warning: Liquid syntax error (line 285): Expected end_of_string but found string in "{{ lines | from '2' | until: '4' | xml_escape }}" in /some_directory/some_files.html Liquid Exception: Liquid error (line 285): wrong number of arguments (given 1, expected 2) in /some_directory/some_file.html Error: Liquid error (line 285): wrong number of arguments (given 1, expected 2)`
|
57
|
+
## Usage
|
58
|
+
|
59
|
+
Some of the following examples use a multiline string containing 5 lines, called lines, which was created this way:
|
60
|
+
|
61
|
+
```
|
62
|
+
{% capture lines %}line 1
|
63
|
+
line 2
|
64
|
+
line 3
|
65
|
+
line 4
|
66
|
+
line 5
|
67
|
+
{% endcapture %}
|
68
|
+
```
|
69
|
+
|
70
|
+
Other examples use a multiline string containing the contents of .gitignore, which looks like this:
|
71
|
+
```
|
72
|
+
.bsp/
|
73
|
+
project/
|
74
|
+
target/
|
75
|
+
*.gz
|
76
|
+
*.sublime*
|
77
|
+
*.swp
|
78
|
+
*.out
|
79
|
+
*.Identifier
|
80
|
+
*.log
|
81
|
+
.idea*
|
82
|
+
*.iml
|
83
|
+
*.tmp
|
84
|
+
*~
|
85
|
+
~*
|
86
|
+
.DS_Store
|
87
|
+
.idea
|
88
|
+
.jekyll-cache/
|
89
|
+
.jekyll-metadata
|
90
|
+
.makeAwsBucketAndDistribution.log
|
91
|
+
.sass-cache/
|
92
|
+
.yardoc/
|
93
|
+
__pycache__/
|
94
|
+
__MACOSX
|
95
|
+
_build/
|
96
|
+
_package/
|
97
|
+
_site/
|
98
|
+
bin/*.class
|
99
|
+
doc/
|
100
|
+
jekyll/doc/
|
101
|
+
node_modules/
|
102
|
+
Notepad++/
|
103
|
+
out/
|
104
|
+
package/
|
105
|
+
instances.json
|
106
|
+
rescue_ubuntu2010
|
107
|
+
rescue_ubuntu2010.b64
|
108
|
+
landingPageShortName.md
|
109
|
+
test.html
|
110
|
+
RUNNING_PID
|
111
|
+
mslinn_jekyll_plugins.zip
|
112
|
+
cloud9.tar
|
113
|
+
cloud9.zip
|
114
|
+
mslinn_aws.tar
|
115
|
+
```
|
116
|
+
|
117
|
+
### From the third line of string
|
118
|
+
These examples return the lines of the file from the beginning of the until a line with the string "3" is found, including the matched line. The only difference between the examples is the delimiter around the regular expression.
|
119
|
+
```
|
120
|
+
{{ lines | from: '3' }}
|
121
|
+
{{ lines | from: "3" }}
|
122
|
+
{{ lines | from: 3 }}
|
123
|
+
```
|
124
|
+
The above all generate:
|
125
|
+
```
|
126
|
+
line 3
|
127
|
+
line 4
|
128
|
+
line 5
|
129
|
+
```
|
130
|
+
|
131
|
+
### From Line In a File Containing 'PID'
|
132
|
+
```
|
133
|
+
{% capture gitignore %}{% flexible_include '.gitignore' %}{% endcapture %}
|
134
|
+
{{ gitignore | from: 'PID' | xml_escape }}
|
135
|
+
```
|
136
|
+
The above generates:
|
137
|
+
```
|
138
|
+
RUNNING_PID
|
139
|
+
mslinn_jekyll_plugins.zip
|
140
|
+
cloud9.tar
|
141
|
+
cloud9.zip
|
142
|
+
mslinn_aws.tar
|
143
|
+
```
|
144
|
+
|
145
|
+
### To the third line of string
|
146
|
+
These examples return the lines of the file from the first line until a line with the string "3" is found, including the matched line. The only difference between the examples is the delimiter around the regular expression.
|
147
|
+
```
|
148
|
+
{{ lines | to: '3' }}
|
149
|
+
{{ lines | to: "3" }}
|
150
|
+
{{ lines | to: 3 }}
|
151
|
+
```
|
152
|
+
The above all generate:
|
153
|
+
```
|
154
|
+
line 1
|
155
|
+
line 2
|
156
|
+
line 3
|
157
|
+
```
|
158
|
+
|
159
|
+
### To Line In a File Containing 'idea'
|
160
|
+
```
|
161
|
+
{{ gitignore | to: 'idea' }}
|
162
|
+
```
|
163
|
+
The above generates:
|
164
|
+
```
|
165
|
+
.bsp/
|
166
|
+
project/
|
167
|
+
target/
|
168
|
+
*.gz
|
169
|
+
*.sublime*
|
170
|
+
*.swp
|
171
|
+
*.out
|
172
|
+
*.Identifier
|
173
|
+
*.log
|
174
|
+
.idea*
|
175
|
+
```
|
176
|
+
|
177
|
+
### Until the third line of string
|
178
|
+
These examples return the lines of the file until a line with the string "3" is found, excluding the matched line. The only difference between the examples is the delimiter around the regular expression.
|
179
|
+
```
|
180
|
+
{{ lines | until: '3' }}
|
181
|
+
{{ lines | until: "3" }}
|
182
|
+
{{ lines | until: 3 }}
|
183
|
+
```
|
184
|
+
The above all generate:
|
185
|
+
```
|
186
|
+
line 1
|
187
|
+
line 2
|
188
|
+
```
|
189
|
+
|
190
|
+
### Until Line In a File Containing 'idea'
|
191
|
+
```
|
192
|
+
{{ gitignore | until: 'idea' }}
|
193
|
+
```
|
194
|
+
The above generates:
|
195
|
+
```
|
196
|
+
.bsp/
|
197
|
+
project/
|
198
|
+
target/
|
199
|
+
*.gz
|
200
|
+
*.sublime*
|
201
|
+
*.swp
|
202
|
+
*.out
|
203
|
+
*.Identifier
|
204
|
+
*.log
|
205
|
+
```
|
206
|
+
|
207
|
+
### From the string "2" until the string "4"
|
208
|
+
These examples return the lines of the file until a line with the string "3" is found, excluding the matched line. The only difference between the examples is the delimiter around the regular expression.
|
209
|
+
```
|
210
|
+
{{ lines | from: '2' | until: '4' }}
|
211
|
+
{{ lines | from: "2" | until: "4" }}
|
212
|
+
{{ lines | from: 2 | until: 4 }}
|
213
|
+
```
|
214
|
+
The above all generate:
|
215
|
+
```
|
216
|
+
line 2
|
217
|
+
line 3
|
218
|
+
```
|
219
|
+
|
220
|
+
### From Line In a File Containing 'idea' Until no match
|
221
|
+
The `.gitignore` file does not contain the string `xx`. If we attempt to match against that string the remainder of the file is returned for the to and until filter, and the empty string is returned for the from filter.
|
222
|
+
```
|
223
|
+
{{ gitignore | from: 'PID' | until: 'xx' }}
|
224
|
+
```
|
225
|
+
The above generates:
|
226
|
+
```
|
227
|
+
RUNNING_PID
|
228
|
+
mslinn_jekyll_plugins.zip
|
229
|
+
cloud9.tar
|
230
|
+
cloud9.zip
|
231
|
+
mslinn_aws.tar
|
232
|
+
```
|
233
|
+
|
234
|
+
### More Complex Regular Expressions
|
235
|
+
The from, to and until filters can all accept more complex regular expressions. This regular expression matches lines that have either the string sun or cloud at the beginning of the line.
|
236
|
+
```
|
237
|
+
{{ gitignore | from: '^(cloud|sun)' }}
|
238
|
+
```
|
239
|
+
The above generates:
|
240
|
+
```
|
241
|
+
cloud9.tar
|
242
|
+
cloud9.zip
|
243
|
+
mslinn_aws.tar
|
244
|
+
```
|
245
|
+
|
246
|
+
|
247
|
+
## Development
|
248
|
+
|
249
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
250
|
+
|
251
|
+
Install development dependencies like this:
|
252
|
+
```
|
253
|
+
$ BUNDLE_WITH="development" bundle install
|
254
|
+
```
|
255
|
+
|
256
|
+
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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
257
|
+
|
258
|
+
## Contributing
|
259
|
+
|
260
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/mslinn/jekyll_from_to_until.
|
261
|
+
|
262
|
+
## License
|
263
|
+
|
264
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/jekyll_from_to_until/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "jekyll_from_to_until"
|
7
|
+
spec.version = JekyllFromToUntil::VERSION
|
8
|
+
spec.authors = ["Mike Slinn"]
|
9
|
+
spec.email = ["mslinn@mslinn.com"]
|
10
|
+
|
11
|
+
spec.summary = "This Jekyll plugin provides 3 filters that return portions of a multiline string: from, to and until."
|
12
|
+
spec.description = <<~END_DESC
|
13
|
+
This Jekyll plugin provides 3 filters that return portions of a multiline string: from, to and until.
|
14
|
+
Regular expression is used to specify matches; the simplest regular expression is a string.
|
15
|
+
END_DESC
|
16
|
+
spec.homepage = 'https://github.com/mslinn/jekyll_from_to_until'
|
17
|
+
spec.license = "MIT"
|
18
|
+
spec.required_ruby_version = ">= 2.6.0"
|
19
|
+
|
20
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org/"
|
21
|
+
|
22
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
23
|
+
spec.metadata["source_code_uri"] = 'https://github.com/mslinn/jekyll_from_to_until'
|
24
|
+
spec.metadata["changelog_uri"] = 'https://github.com/mslinn/jekyll_from_to_until/CHANGELOG.md'
|
25
|
+
|
26
|
+
# Specify which files should be added to the gem when it is released.
|
27
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
28
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
29
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
30
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
31
|
+
end
|
32
|
+
end
|
33
|
+
spec.bindir = "exe"
|
34
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
35
|
+
spec.require_paths = ["lib"]
|
36
|
+
|
37
|
+
spec.add_dependency 'jekyll'
|
38
|
+
|
39
|
+
spec.add_development_dependency 'bundler'
|
40
|
+
spec.add_development_dependency 'debase'
|
41
|
+
spec.add_development_dependency 'jekyll'
|
42
|
+
spec.add_development_dependency 'pry'
|
43
|
+
spec.add_development_dependency 'rake'
|
44
|
+
spec.add_development_dependency 'rspec'
|
45
|
+
spec.add_development_dependency 'rubocop'
|
46
|
+
spec.add_development_dependency 'rubocop-jekyll'
|
47
|
+
spec.add_development_dependency 'rubocop-rake'
|
48
|
+
spec.add_development_dependency 'ruby-debug-ide'
|
49
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# @author Copyright 2020 Michael Slinn
|
4
|
+
# Jekyll filters for working with multiline strings.
|
5
|
+
|
6
|
+
require_relative "jekyll_from_to_until/version"
|
7
|
+
|
8
|
+
module JekyllFromToUntil
|
9
|
+
class Error < StandardError; end
|
10
|
+
|
11
|
+
# Filters a multiline string, returning the portion beginning with the line that satisfies a regex.
|
12
|
+
# The regex could be enclosed in single quotes, double quotes, or nothing.
|
13
|
+
# @param input_strings [String] The multi-line string to scan
|
14
|
+
# @param regex [String] The regular expression to match against each line of `input_strings` until found
|
15
|
+
# @return [String] The remaining multi-line string
|
16
|
+
# @example Returns remaining lines starting with the line containing the word `module`.
|
17
|
+
# {{ flexible_include '/blog/2020/10/03/jekyll-plugins.html' | from 'module' }}
|
18
|
+
def from(input_strings, regex)
|
19
|
+
return '' unless check_parameters(input_strings, regex)
|
20
|
+
|
21
|
+
regex = remove_quotations(regex.to_s.strip)
|
22
|
+
matched = false
|
23
|
+
result = ''
|
24
|
+
input_strings.each_line do |line|
|
25
|
+
matched = true if !matched && line =~ /#{regex}/
|
26
|
+
result += line if matched
|
27
|
+
end
|
28
|
+
result
|
29
|
+
end
|
30
|
+
|
31
|
+
# Filters a multiline string, returning the portion from the beginning until and including the line that satisfies a regex.
|
32
|
+
# The regex could be enclosed in single quotes, double quotes, or nothing.
|
33
|
+
# @example Returns lines up to and including the line containing the word `module`.
|
34
|
+
# {{ flexible_include '/blog/2020/10/03/jekyll-plugins.html' | to 'module' }}
|
35
|
+
def to(input_strings, regex)
|
36
|
+
return '' unless check_parameters(input_strings, regex)
|
37
|
+
|
38
|
+
regex = remove_quotations(regex.to_s.strip)
|
39
|
+
result = ''
|
40
|
+
input_strings.each_line do |line|
|
41
|
+
result += line
|
42
|
+
return result if line.match?(/#{regex}/)
|
43
|
+
end
|
44
|
+
result
|
45
|
+
end
|
46
|
+
|
47
|
+
# Filters a multiline string, returning the portion from the beginning until but not including the line that satisfies a regex.
|
48
|
+
# The regex could be enclosed in single quotes, double quotes, or nothing.
|
49
|
+
# @example Returns lines up to but not including the line containing the word `module`.
|
50
|
+
# {{ flexible_include '/blog/2020/10/03/jekyll-plugins.html' | until 'module' }}
|
51
|
+
def until(input_strings, regex)
|
52
|
+
return '' unless check_parameters(input_strings, regex)
|
53
|
+
|
54
|
+
regex = remove_quotations(regex.to_s.strip)
|
55
|
+
result = ''
|
56
|
+
input_strings.each_line do |line|
|
57
|
+
return result if line.match?(/#{regex}/)
|
58
|
+
|
59
|
+
result += line
|
60
|
+
end
|
61
|
+
result
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def check_parameters(input_strings, regex)
|
67
|
+
if input_strings.nil? || input_strings.empty?
|
68
|
+
Jekyll.logger.warn "Warning: Plugin 'from' received no input for regex #{regex}."
|
69
|
+
return false
|
70
|
+
end
|
71
|
+
|
72
|
+
regex = regex.to_s
|
73
|
+
if regex.nil? || regex.empty?
|
74
|
+
Jekyll.logger.warn "Warning: Plugin 'from' received no regex for input #{input_strings}."
|
75
|
+
return false
|
76
|
+
end
|
77
|
+
true
|
78
|
+
end
|
79
|
+
|
80
|
+
def remove_quotations(str)
|
81
|
+
str = str.slice(1..-2) if (str.start_with?('"') && str.end_with?('"')) ||
|
82
|
+
(str.start_with?("'") && str.end_with?("'"))
|
83
|
+
str
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
Liquid::Template.register_filter(JekyllFromToUntil)
|
metadata
ADDED
@@ -0,0 +1,219 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll_from_to_until
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mike Slinn
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-03-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jekyll
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
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: debase
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: jekyll
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '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
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rubocop-jekyll
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rubocop-rake
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: ruby-debug-ide
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
description: |
|
168
|
+
This Jekyll plugin provides 3 filters that return portions of a multiline string: from, to and until.
|
169
|
+
Regular expression is used to specify matches; the simplest regular expression is a string.
|
170
|
+
email:
|
171
|
+
- mslinn@mslinn.com
|
172
|
+
executables: []
|
173
|
+
extensions: []
|
174
|
+
extra_rdoc_files: []
|
175
|
+
files:
|
176
|
+
- ".rspec"
|
177
|
+
- ".rubocop.yml"
|
178
|
+
- ".ruby-version"
|
179
|
+
- ".vscode/launch.json"
|
180
|
+
- ".vscode/settings.json"
|
181
|
+
- CHANGELOG.md
|
182
|
+
- Gemfile
|
183
|
+
- Gemfile.lock
|
184
|
+
- LICENSE.txt
|
185
|
+
- README.md
|
186
|
+
- Rakefile
|
187
|
+
- jekyll_from_to_until.gemspec
|
188
|
+
- lib/jekyll_from_to_until.rb
|
189
|
+
- lib/jekyll_from_to_until/version.rb
|
190
|
+
- sig/jekyll_from_to_until.rbs
|
191
|
+
homepage: https://github.com/mslinn/jekyll_from_to_until
|
192
|
+
licenses:
|
193
|
+
- MIT
|
194
|
+
metadata:
|
195
|
+
allowed_push_host: https://rubygems.org/
|
196
|
+
homepage_uri: https://github.com/mslinn/jekyll_from_to_until
|
197
|
+
source_code_uri: https://github.com/mslinn/jekyll_from_to_until
|
198
|
+
changelog_uri: https://github.com/mslinn/jekyll_from_to_until/CHANGELOG.md
|
199
|
+
post_install_message:
|
200
|
+
rdoc_options: []
|
201
|
+
require_paths:
|
202
|
+
- lib
|
203
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
204
|
+
requirements:
|
205
|
+
- - ">="
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
version: 2.6.0
|
208
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
209
|
+
requirements:
|
210
|
+
- - ">="
|
211
|
+
- !ruby/object:Gem::Version
|
212
|
+
version: '0'
|
213
|
+
requirements: []
|
214
|
+
rubygems_version: 3.2.5
|
215
|
+
signing_key:
|
216
|
+
specification_version: 4
|
217
|
+
summary: 'This Jekyll plugin provides 3 filters that return portions of a multiline
|
218
|
+
string: from, to and until.'
|
219
|
+
test_files: []
|