jekyll-xml-source 0.1.1
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 +7 -0
- data/jekyll_xml_source.rb +66 -0
- metadata +73 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d2efa99342c76eaabc43258c65a24e59b91438b0e0c180571feb34178d76e68a
|
4
|
+
data.tar.gz: 7f2077eb777a3c68ef337464232555407d5a97827b16c5066529e8804b8891cc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d8adc125e86a2f29bc340e60c9f9ae4aa00253b76c0b694126647fa099a23bc7aa2896742c221ab657e7fee9cd5321afafe0c2b6ffba7d7d0803f5bf25e61095
|
7
|
+
data.tar.gz: 575f46b3d178eff3f3f53ad906696c314f6e1ba1f1cf01a4d2135d0d571c0c58f950c51abdcc6c364b7ddfb5513919d1308c2137198c8cd204228717115f6173
|
@@ -0,0 +1,66 @@
|
|
1
|
+
##
|
2
|
+
# Download XML data from external sources
|
3
|
+
# Convert data to JSON and optionally save it to cache
|
4
|
+
#
|
5
|
+
# @author Derek Smart<derek@grindaga.com>
|
6
|
+
# @copyright 2018
|
7
|
+
# @license MIT
|
8
|
+
|
9
|
+
require 'json'
|
10
|
+
require 'net/http'
|
11
|
+
require 'active_support/core_ext/hash'
|
12
|
+
|
13
|
+
module Jekyll_Xml_Source
|
14
|
+
class Generator < Jekyll::Generator
|
15
|
+
safe true
|
16
|
+
priority :highest
|
17
|
+
|
18
|
+
def saveToCache(data_source, name, content)
|
19
|
+
path = "#{data_source}/#{name}.json"
|
20
|
+
File.open(path,"w") do |file|
|
21
|
+
file.write(content)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def loadFromCache(data_source, name)
|
26
|
+
path = "#{data_source}/#{name}.json"
|
27
|
+
if not File.exist?(path)
|
28
|
+
return
|
29
|
+
end
|
30
|
+
File.open(path,"r") do |file|
|
31
|
+
return JSON.load(file.read())
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def generate(site)
|
36
|
+
config = site.config['jekyll_xml']
|
37
|
+
data_source = (site.config['data_source'] || '_data')
|
38
|
+
|
39
|
+
if !config
|
40
|
+
return
|
41
|
+
end
|
42
|
+
|
43
|
+
config.each do |data|
|
44
|
+
if data['cache']
|
45
|
+
site.data[data['data']] = loadFromCache(data_source, data['data'])
|
46
|
+
end
|
47
|
+
|
48
|
+
if site.data[data['data']].nil?
|
49
|
+
begin
|
50
|
+
result = Net::HTTP.get_response(URI.parse(data['source'])).body
|
51
|
+
site.data[data['data']] = JSON.load(Hash.from_xml(result).to_json)
|
52
|
+
rescue
|
53
|
+
next
|
54
|
+
end
|
55
|
+
|
56
|
+
if data['cache']
|
57
|
+
saveToCache(data_source, data['data'], Hash.from_xml(result).to_json)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-xml-source
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Derek Smart
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-07-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: json
|
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: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Jekyll XML Source is a plugin that will download XML from external sites
|
42
|
+
and makes the data available when generating a site. It also works for RSS feeds.
|
43
|
+
Once downloaded it is converted to JSON.
|
44
|
+
email: derek@grindaga.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- jekyll_xml_source.rb
|
50
|
+
homepage: https://github.com/mcred/jekyll-xml-source/
|
51
|
+
licenses:
|
52
|
+
- MIT
|
53
|
+
metadata: {}
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
requirements: []
|
69
|
+
rubygems_version: 3.1.2
|
70
|
+
signing_key:
|
71
|
+
specification_version: 4
|
72
|
+
summary: A plugin that will download XML from external sites.
|
73
|
+
test_files: []
|