jekyll-drill 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/.editorconfig +16 -0
- data/.gitignore +4 -0
- data/LICENSE +21 -0
- data/README.md +3 -0
- data/jekyll-drill.gemspec +19 -0
- data/lib/jekyll-drill.rb +5 -0
- data/lib/jekyll-drill/filter.rb +42 -0
- data/lib/jekyll-drill/version.rb +3 -0
- metadata +108 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 75e86b3fb9ccdbb3120800a6917358f3befb15bbc93826e6b0ecd5b9d267d1c3
|
4
|
+
data.tar.gz: aa64fbc60a9d3e19432831e0de6798bf7b6477771ac90adaf20fc2879f3302ce
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a6f9000b02ed4febf364cc2e04f44ea0630b9f84d9bd8b65d978f864cab98c8c0013882118dd9e5466f35c674d6f7d22de6c74b8ec55c0f2a0f8f10a3f4b51a1
|
7
|
+
data.tar.gz: 3053783df1b13165751c1822446b6b4bf27c864fdfdba0329b01d77f702a010c04db3c118a662348845d83c218a25f957db6cc318d65a082a49ddb439b41423f
|
data/.editorconfig
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
root = true
|
2
|
+
|
3
|
+
[*]
|
4
|
+
indent_style = space
|
5
|
+
indent_size = 2
|
6
|
+
trim_trailing_whitespace = true
|
7
|
+
insert_final_newline = true
|
8
|
+
|
9
|
+
[*.{md,rb,gemspec},Makefile]
|
10
|
+
charset = utf-8
|
11
|
+
|
12
|
+
[Makefile]
|
13
|
+
indent_style = tab
|
14
|
+
|
15
|
+
[*.md]
|
16
|
+
trim_trailing_whitespace = false
|
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Brock Fanning <brockfanning@gmail.com> (https://github.com/brockfanning
|
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,19 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "jekyll-drill/version"
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = "jekyll-drill"
|
6
|
+
spec.summary = "Filter for drilling into an object with a dot-notated string"
|
7
|
+
spec.description = "Filter for drilling into an object with a dot-notated string"
|
8
|
+
spec.version = JekyllDrill::VERSION
|
9
|
+
spec.authors = ["Brock Fanning"]
|
10
|
+
spec.email = ["brockfanning@gmail.com"]
|
11
|
+
spec.homepage = "https://github.com/brockfanning/jekyll-drill"
|
12
|
+
spec.licenses = ["MIT"]
|
13
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|spec|features)/!) }
|
14
|
+
spec.require_paths = ["lib"]
|
15
|
+
spec.add_dependency "jekyll", "~> 3.0"
|
16
|
+
spec.add_development_dependency "rake", "~> 11.0"
|
17
|
+
spec.add_development_dependency "rspec", "~> 3.5"
|
18
|
+
spec.add_development_dependency "rubocop", "~> 0.52"
|
19
|
+
end
|
data/lib/jekyll-drill.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require "jekyll"
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module Drill
|
5
|
+
# Takes a dot-notated string and uses it to drill down into a hash.
|
6
|
+
# Returns the drilled value, or the original string if there are any
|
7
|
+
# errors.
|
8
|
+
def drill(str, obj)
|
9
|
+
# Keep track of the last thing we drilled to.
|
10
|
+
drilled = obj
|
11
|
+
|
12
|
+
# Keep track of how many levels we have drilled.
|
13
|
+
levels_drilled = 0
|
14
|
+
levels = str.split('.')
|
15
|
+
|
16
|
+
# Loop through each level.
|
17
|
+
levels.each do |level|
|
18
|
+
|
19
|
+
# If we have drilled down to a scalar value too soon, abort.
|
20
|
+
break if drilled.class != Hash
|
21
|
+
|
22
|
+
if drilled.has_key? level
|
23
|
+
# If we find something, continue drilling.
|
24
|
+
drilled = drilled[level]
|
25
|
+
levels_drilled += 1
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
# If we didn't drill the right number of levels, return the
|
31
|
+
# original string.
|
32
|
+
if levels.length != levels_drilled
|
33
|
+
return str
|
34
|
+
end
|
35
|
+
|
36
|
+
# Otherwise we must have drilled all they way.
|
37
|
+
return drilled
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
Liquid::Template.register_filter(Jekyll::Drill)
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-drill
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brock Fanning
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-02-22 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: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '11.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '11.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.52'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.52'
|
69
|
+
description: Filter for drilling into an object with a dot-notated string
|
70
|
+
email:
|
71
|
+
- brockfanning@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".editorconfig"
|
77
|
+
- ".gitignore"
|
78
|
+
- LICENSE
|
79
|
+
- README.md
|
80
|
+
- jekyll-drill.gemspec
|
81
|
+
- lib/jekyll-drill.rb
|
82
|
+
- lib/jekyll-drill/filter.rb
|
83
|
+
- lib/jekyll-drill/version.rb
|
84
|
+
homepage: https://github.com/brockfanning/jekyll-drill
|
85
|
+
licenses:
|
86
|
+
- MIT
|
87
|
+
metadata: {}
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 2.7.6
|
105
|
+
signing_key:
|
106
|
+
specification_version: 4
|
107
|
+
summary: Filter for drilling into an object with a dot-notated string
|
108
|
+
test_files: []
|