jekyll_config_to_JSON 0.0.2

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/jekyll_config_to_JSON.rb +59 -0
  3. metadata +65 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cc043ee133ba1b40f7943a555d2ba8805d3abbdb
4
+ data.tar.gz: f6f6285bdc96c7c40f2476efaab64b93c37324b6
5
+ SHA512:
6
+ metadata.gz: 117dc92f15672222fccf5518c2d30f101d0029dc99003d3a3270a4acfb23f684abef58d613de5808f412bb00bf1f0d02f8689cdf2afd05a7b6a579993ebc8867
7
+ data.tar.gz: d967b3e9ef720cabc027c0b26da2f28201612b1c84e2da6556a59491193fd50d848d27140c7e4fad91c07bf826e99bb84540cda8ccf4914404e16489304071f1
@@ -0,0 +1,59 @@
1
+ module Jekyll
2
+ require 'json'
3
+ require 'fileutils'
4
+
5
+ class GenerateJSON < Jekyll::Generator
6
+ safe true
7
+ priority :low
8
+ @@globals = {
9
+ "json_file" => "config.json",
10
+ "output_directory" => "/api/config",
11
+ "output_file" => "config.json",
12
+ "src_dir" => "",
13
+ "dst_dir" => ""
14
+ }
15
+ def self.json_output_directory
16
+ @@globals["output_directory"]
17
+ end
18
+ def self.json_file
19
+ @@globals["json_file"]
20
+ end
21
+
22
+ def generate(site)
23
+
24
+ @@globals["src_dir"] = File.join(site.source, @@globals["output_directory"])
25
+ @@globals["dst_dir"] = File.join(site.dest, @@globals["output_directory"])
26
+ FileUtils.mkdir_p(@@globals["src_dir"]) unless File.exists?(@@globals["src_dir"])
27
+
28
+ config = site.config['react']
29
+ config_json = config.to_json
30
+
31
+ @@globals["json_file"] = File.join(@@globals["src_dir"], @@globals["json_file"])
32
+ f = File.new(@@globals["json_file"], "w+")
33
+ f.puts config_json
34
+ f.close
35
+
36
+ site.static_files << Jekyll::StaticFile.new(site, site.source, @@globals['output_directory'], @@globals['output_file'])
37
+
38
+ end
39
+ end
40
+ #static override of the Jekyll Class
41
+ class Site
42
+ alias :super_write :write
43
+ def write
44
+ # call the super method to generate our site
45
+ # Must call otherwise our site will be gone :'(
46
+ super_write
47
+
48
+ # cleanup source folder
49
+ src_folder = File.join(source, GenerateJSON::json_output_directory)
50
+ File.unlink GenerateJSON::json_file if File.exists?(GenerateJSON::json_file)
51
+ FileUtils.rm_rf(src_folder)
52
+ src_arr = src_folder.split("/")
53
+ src_arr.pop
54
+ src_folder = src_arr.join("/")
55
+ FileUtils.rm_rf(src_folder)
56
+
57
+ end
58
+ end
59
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll_config_to_JSON
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Andrew Plaza (InsidiousMind)
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-01-03 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.3.1
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '4.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 3.3.1
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '4.0'
33
+ description:
34
+ email:
35
+ - aplaza@liquidthink.net
36
+ executables: []
37
+ extensions: []
38
+ extra_rdoc_files: []
39
+ files:
40
+ - lib/jekyll_config_to_JSON.rb
41
+ homepage: https://github.com/InsidiousMind/Config-to-JSON-Jekyll-Plugin
42
+ licenses:
43
+ - GPL-3.0
44
+ metadata: {}
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubyforge_project:
61
+ rubygems_version: 2.5.2
62
+ signing_key:
63
+ specification_version: 4
64
+ summary: A Jekyll Plugin that generates a JSON file of configuration variables
65
+ test_files: []