jekyll_config_to_JSON 0.0.2 → 0.0.3

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 +4 -4
  2. data/lib/jekyll_config_to_JSON.rb +27 -23
  3. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc043ee133ba1b40f7943a555d2ba8805d3abbdb
4
- data.tar.gz: f6f6285bdc96c7c40f2476efaab64b93c37324b6
3
+ metadata.gz: 254ac74e0b2dfdff05877dc6c8686b1512f1485e
4
+ data.tar.gz: 0c825c8c5d43c3ac45ad908f5c6af832dd114258
5
5
  SHA512:
6
- metadata.gz: 117dc92f15672222fccf5518c2d30f101d0029dc99003d3a3270a4acfb23f684abef58d613de5808f412bb00bf1f0d02f8689cdf2afd05a7b6a579993ebc8867
7
- data.tar.gz: d967b3e9ef720cabc027c0b26da2f28201612b1c84e2da6556a59491193fd50d848d27140c7e4fad91c07bf826e99bb84540cda8ccf4914404e16489304071f1
6
+ metadata.gz: 35cd22eade87afc0a28f481eaf5e5ec37509ff4cd11142a3d95b8a361acbf4546cb1bb95ef9118fbd2350d7b87b992b9353755c17f629f8d6255337812d79c0d
7
+ data.tar.gz: 70a2dfa8bc3688d95483b2fb73ee6f9ae317cafb4f849343395d62cb1264aa7fd0c895915bdb5a859da2e0287c1fd1934fc33ec8ef820c33fce93ffadf17cc0a
@@ -6,8 +6,8 @@ module Jekyll
6
6
  safe true
7
7
  priority :low
8
8
  @@globals = {
9
- "json_file" => "config.json",
10
- "output_directory" => "/api/config",
9
+ "json_file_path" => "",
10
+ "output_directory" => "/.api/v1/",
11
11
  "output_file" => "config.json",
12
12
  "src_dir" => "",
13
13
  "dst_dir" => ""
@@ -16,27 +16,30 @@ module Jekyll
16
16
  @@globals["output_directory"]
17
17
  end
18
18
  def self.json_file
19
- @@globals["json_file"]
19
+ @@globals["json_file_path"]
20
20
  end
21
-
21
+
22
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
23
  config = site.config['react']
29
24
  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'])
25
+
26
+ if @@globals["src_dir"].to_s.empty? && @@globals["dst_dir"].to_s.empty?
27
+ @@globals["src_dir"] = File.join(site.source, @@globals["output_directory"])
28
+ @@globals["dst_dir"] = File.join(site.dest, @@globals["output_directory"])
29
+ FileUtils.mkdir_p(@@globals["src_dir"]) unless File.exists?(@@globals["src_dir"])
30
+ @@globals["json_file_path"] = File.join(@@globals["src_dir"], @@globals["output_file"])
31
+ f = File.new(@@globals["json_file_path"], "w+")
32
+ f.puts config_json
33
+ f.close
34
+ if File.exists?@@globals["json_file_path"]
35
+ site.static_files << Jekyll::StaticFile.new(site, site.source, @@globals['output_directory'], @@globals['output_file'])
36
+ end
37
+ end
38
+
37
39
 
38
40
  end
39
41
  end
42
+
40
43
  #static override of the Jekyll Class
41
44
  class Site
42
45
  alias :super_write :write
@@ -44,16 +47,17 @@ module Jekyll
44
47
  # call the super method to generate our site
45
48
  # Must call otherwise our site will be gone :'(
46
49
  super_write
47
-
50
+
48
51
  # cleanup source folder
49
52
  src_folder = File.join(source, GenerateJSON::json_output_directory)
50
53
  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
-
54
+ if File.exists?(src_folder)
55
+ FileUtils.rm_rf(src_folder)
56
+ src_arr = src_folder.split("/")
57
+ src_arr.pop
58
+ src_folder = src_arr.join("/")
59
+ FileUtils.rm_rf(src_folder)
60
+ end
57
61
  end
58
62
  end
59
63
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll_config_to_JSON
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Plaza (InsidiousMind)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-03 00:00:00.000000000 Z
11
+ date: 2017-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -63,3 +63,4 @@ signing_key:
63
63
  specification_version: 4
64
64
  summary: A Jekyll Plugin that generates a JSON file of configuration variables
65
65
  test_files: []
66
+ has_rdoc: