jekyll-get-json 0.0.2 → 1.0.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/.editorconfig +16 -16
- data/.gitignore +4 -4
- data/README.md +42 -42
- data/jekyll-get-json.gemspec +17 -17
- data/lib/jekyll-get-json.rb +5 -5
- data/lib/jekyll-get-json/converter.rb +39 -39
- data/lib/jekyll-get-json/version.rb +3 -3
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f4b6ce90f71962510cf2ea075c618b7df8c937799a97f0c1a8def9328dd9a8d
|
4
|
+
data.tar.gz: 50106bcebfa74af0a998f450401b3ba9fe15f9d9b3addd896a67139a67377ede
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 526026c03a52d753130573507d05f6d0ab4eeb6a5a540452d4131ffb627e42e2c0d0714224632f781657c4220e2f0c2d571588cda6f8143a9c9c5f5aeab67a05
|
7
|
+
data.tar.gz: 44494a2056c443dd668401bcfbf915edea26c557b92e8014023b7378fd6235d6db3ec6490565916fe4a45f93736661e63c0e3e9fe4e357db628e8ca0f4c1fdaa
|
data/.editorconfig
CHANGED
@@ -1,16 +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
|
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
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
_site
|
2
|
-
.sass-cache
|
3
|
-
.jekyll-metadata
|
4
|
-
*.gem
|
1
|
+
_site
|
2
|
+
.sass-cache
|
3
|
+
.jekyll-metadata
|
4
|
+
*.gem
|
data/README.md
CHANGED
@@ -1,43 +1,43 @@
|
|
1
|
-
# jekyll-get-json
|
2
|
-
|
3
|
-
> 💎 Import remote JSON data into the data for a Jekyll site
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
1. Use `bundle add jekyll-get-json` to add this to your site's Gemfile.
|
8
|
-
2. Add this plugin to the `plugins` listed in your `_config.yml` file. For example:
|
9
|
-
```
|
10
|
-
plugins:
|
11
|
-
- jekyll-get-json
|
12
|
-
```
|
13
|
-
|
14
|
-
## Usage
|
15
|
-
|
16
|
-
Add a `jekyll_get_json` section to your `_config.yml` file. This section should be an array of objects containing `data` and `json` properties:
|
17
|
-
* The `data` property specifies where in the `site.data` you would like to put this data.
|
18
|
-
* The `json` property is the remote URL of the JSON file.
|
19
|
-
|
20
|
-
To illustrate an example, assuming that you have a remote JSON file at `https://example.com/data.json` containing this:
|
21
|
-
```
|
22
|
-
{
|
23
|
-
"bar": "Success!"
|
24
|
-
}
|
25
|
-
```
|
26
|
-
And you put the following into your `_config.yml` file:
|
27
|
-
```
|
28
|
-
jekyll_get_json:
|
29
|
-
- data: foo
|
30
|
-
json: 'https://example.com/data.json'
|
31
|
-
```
|
32
|
-
Then in your Jekyll site you will be able to use:
|
33
|
-
```
|
34
|
-
{{ site.data.foo.bar }}
|
35
|
-
```
|
36
|
-
And you will see:
|
37
|
-
```
|
38
|
-
Success!
|
39
|
-
```
|
40
|
-
|
41
|
-
## Credit
|
42
|
-
|
1
|
+
# jekyll-get-json
|
2
|
+
|
3
|
+
> 💎 Import remote JSON data into the data for a Jekyll site
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
1. Use `bundle add jekyll-get-json` to add this to your site's Gemfile.
|
8
|
+
2. Add this plugin to the `plugins` listed in your `_config.yml` file. For example:
|
9
|
+
```
|
10
|
+
plugins:
|
11
|
+
- jekyll-get-json
|
12
|
+
```
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
Add a `jekyll_get_json` section to your `_config.yml` file. This section should be an array of objects containing `data` and `json` properties:
|
17
|
+
* The `data` property specifies where in the `site.data` you would like to put this data.
|
18
|
+
* The `json` property is the remote URL of the JSON file.
|
19
|
+
|
20
|
+
To illustrate an example, assuming that you have a remote JSON file at `https://example.com/data.json` containing this:
|
21
|
+
```
|
22
|
+
{
|
23
|
+
"bar": "Success!"
|
24
|
+
}
|
25
|
+
```
|
26
|
+
And you put the following into your `_config.yml` file:
|
27
|
+
```
|
28
|
+
jekyll_get_json:
|
29
|
+
- data: foo
|
30
|
+
json: 'https://example.com/data.json'
|
31
|
+
```
|
32
|
+
Then in your Jekyll site you will be able to use:
|
33
|
+
```
|
34
|
+
{{ site.data.foo.bar }}
|
35
|
+
```
|
36
|
+
And you will see:
|
37
|
+
```
|
38
|
+
Success!
|
39
|
+
```
|
40
|
+
|
41
|
+
## Credit
|
42
|
+
|
43
43
|
This plugin is basically a more limited version of [jekyll-get](https://github.com/18F/jekyll-get), duplicated here purely for the purposes of making it a Ruby gem.
|
data/jekyll-get-json.gemspec
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
lib = File.expand_path("../lib", __FILE__)
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require "jekyll-get-json/version"
|
4
|
-
Gem::Specification.new do |spec|
|
5
|
-
spec.name = "jekyll-get-json"
|
6
|
-
spec.summary = "Import remote JSON data into the data for a Jekyll site"
|
7
|
-
spec.description = "Import remote JSON data into the data for a Jekyll site"
|
8
|
-
spec.version = JekyllGetJson::VERSION
|
9
|
-
spec.authors = ["Brock Fanning"]
|
10
|
-
spec.email = ["brockfanning@gmail.com"]
|
11
|
-
spec.homepage = "https://github.com/brockfanning/jekyll-get-json"
|
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_dependency "deep_merge", "~> 1.2"
|
17
|
-
end
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "jekyll-get-json/version"
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = "jekyll-get-json"
|
6
|
+
spec.summary = "Import remote JSON data into the data for a Jekyll site"
|
7
|
+
spec.description = "Import remote JSON data into the data for a Jekyll site"
|
8
|
+
spec.version = JekyllGetJson::VERSION
|
9
|
+
spec.authors = ["Brock Fanning"]
|
10
|
+
spec.email = ["brockfanning@gmail.com"]
|
11
|
+
spec.homepage = "https://github.com/brockfanning/jekyll-get-json"
|
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_dependency "deep_merge", "~> 1.2"
|
17
|
+
end
|
data/lib/jekyll-get-json.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require_relative "jekyll-get-json/version"
|
2
|
-
require_relative "jekyll-get-json/converter"
|
3
|
-
|
4
|
-
module JekyllGetJson
|
5
|
-
end
|
1
|
+
require_relative "jekyll-get-json/version"
|
2
|
+
require_relative "jekyll-get-json/converter"
|
3
|
+
|
4
|
+
module JekyllGetJson
|
5
|
+
end
|
@@ -1,39 +1,39 @@
|
|
1
|
-
require "jekyll"
|
2
|
-
require 'json'
|
3
|
-
require 'deep_merge'
|
4
|
-
require 'open-uri'
|
5
|
-
|
6
|
-
module JekyllGetJson
|
7
|
-
class GetJsonGenerator < Jekyll::Generator
|
8
|
-
safe true
|
9
|
-
priority :highest
|
10
|
-
|
11
|
-
def generate(site)
|
12
|
-
|
13
|
-
config = site.config['jekyll_get_json']
|
14
|
-
if !config
|
15
|
-
warn "No config".yellow
|
16
|
-
return
|
17
|
-
end
|
18
|
-
if !config.kind_of?(Array)
|
19
|
-
config = [config]
|
20
|
-
end
|
21
|
-
|
22
|
-
config.each do |d|
|
23
|
-
begin
|
24
|
-
target = site.data[d['data']]
|
25
|
-
source = JSON.load(open(d['json']))
|
26
|
-
|
27
|
-
if target
|
28
|
-
target.deep_merge(source)
|
29
|
-
else
|
30
|
-
site.data[d['data']] = source
|
31
|
-
end
|
32
|
-
rescue
|
33
|
-
next
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
1
|
+
require "jekyll"
|
2
|
+
require 'json'
|
3
|
+
require 'deep_merge'
|
4
|
+
require 'open-uri'
|
5
|
+
|
6
|
+
module JekyllGetJson
|
7
|
+
class GetJsonGenerator < Jekyll::Generator
|
8
|
+
safe true
|
9
|
+
priority :highest
|
10
|
+
|
11
|
+
def generate(site)
|
12
|
+
|
13
|
+
config = site.config['jekyll_get_json']
|
14
|
+
if !config
|
15
|
+
warn "No config".yellow
|
16
|
+
return
|
17
|
+
end
|
18
|
+
if !config.kind_of?(Array)
|
19
|
+
config = [config]
|
20
|
+
end
|
21
|
+
|
22
|
+
config.each do |d|
|
23
|
+
begin
|
24
|
+
target = site.data[d['data']]
|
25
|
+
source = JSON.load(URI.open(d['json']))
|
26
|
+
|
27
|
+
if target
|
28
|
+
target.deep_merge(source)
|
29
|
+
else
|
30
|
+
site.data[d['data']] = source
|
31
|
+
end
|
32
|
+
rescue
|
33
|
+
next
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
@@ -1,3 +1,3 @@
|
|
1
|
-
module JekyllGetJson
|
2
|
-
VERSION = "0.0
|
3
|
-
end
|
1
|
+
module JekyllGetJson
|
2
|
+
VERSION = "1.0.0".freeze
|
3
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-get-json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brock Fanning
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -72,8 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
72
|
- !ruby/object:Gem::Version
|
73
73
|
version: '0'
|
74
74
|
requirements: []
|
75
|
-
|
76
|
-
rubygems_version: 2.7.1
|
75
|
+
rubygems_version: 3.1.4
|
77
76
|
signing_key:
|
78
77
|
specification_version: 4
|
79
78
|
summary: Import remote JSON data into the data for a Jekyll site
|