jekyll-conrefifier 0.0.1 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7fd6a5071f7e5ace52c45ef3f8847acac7aae9db
4
- data.tar.gz: 64f0ce2548156487bfa205675ed0e54fbec2a387
3
+ metadata.gz: 326edf243db654eb22ef5f0cd49e5c6bcc756bb8
4
+ data.tar.gz: 099db511d1e1e3214cf9f88f86766cf77db5e57e
5
5
  SHA512:
6
- metadata.gz: a08a27b34f9ad08e591294f0eebb97ca1ac2f0b855925dfec43a1bfdb0cbaaa7e933b31e794c5b5ccbe35f85e4d6c5b1fc043a1e27ba59a2c99170134ee17869
7
- data.tar.gz: 79b585769a377eae919f873c0c48e71cd50a8f4141477cadc39de9a5397a3c00de531e6cbdeffef345a37e100302999fa6f961f90755bca6a9cc886d81979db7
6
+ metadata.gz: 44652e364eb5b19833c525612e9adc352fb8ffb53ab99bd2f7d6817377ee7cff2d6cbee674267ab3266c779fe9818e16b861d4fbd55d34bf14c3f1856a87f8a2
7
+ data.tar.gz: 4b318e9be13d3ecc9694a9f164a6e979b5dc8d2d4e747d0b08ae8e1814fcf4d3d07b6c22fc386696f4a5bd29ca67af93cb7f50fcfecb23adc8a4d2fc067ffb05
@@ -1,3 +1,16 @@
1
+ class Hash
2
+ def insert_before(key, kvpair)
3
+ arr = to_a
4
+ pos = arr.index(arr.assoc(key))
5
+ if pos
6
+ arr.insert(pos, kvpair)
7
+ else
8
+ arr << kvpair
9
+ end
10
+ replace Hash[arr]
11
+ end
12
+ end
13
+
1
14
  module Jekyll
2
15
  class Document
3
16
  alias_method :old_read, :read
@@ -23,10 +36,15 @@ module Jekyll
23
36
  # - '{{ site.data.conrefs.product_name[site.audience] }} Glossary'
24
37
  # renders as "GitHub Glossary" for dotcom, but "GitHub Enterprise Glossary" for Enterprise
25
38
  def read
39
+ keys_to_modify = {}
26
40
  old_read
27
41
  data.each_pair do |data_file, data_set|
28
42
  if data_set.is_a? Hash
29
43
  data_set.each_pair do |key, values|
44
+ if key =~ /\{\{.+?\}\}/
45
+ new_key = Liquid::Template.parse(key).render({ "site" => { "data" => data }.merge(config) })
46
+ keys_to_modify[key] = new_key
47
+ end
30
48
  if values.is_a? Array
31
49
  values.each_with_index do |value, i|
32
50
  if value =~ /\{\{.+?\}\}/
@@ -36,6 +54,10 @@ module Jekyll
36
54
  end
37
55
  end
38
56
  end
57
+ keys_to_modify.each_pair do |old_key, new_key|
58
+ data[data_file].insert_before(old_key, [new_key, data[data_file][old_key]])
59
+ data[data_file].delete(old_key)
60
+ end
39
61
  end
40
62
  end
41
63
  end
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module JekyllConrefifier
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -9,10 +9,18 @@ describe("Conrefifier") do
9
9
  expect(@dest.join("articles", "welcome-to-github", "index.html")).to exist
10
10
  end
11
11
 
12
- it "writes the proper content after fetching info from a data file" do
12
+ it "writes the proper content for values after fetching info from a data file" do
13
13
  index_file = @dest.join("index.html")
14
14
  expect(index_file).to exist
15
15
  index_contents = File.read(index_file)
16
16
  expect(index_contents).to include("GitHub Glossary")
17
17
  end
18
+
19
+
20
+ it "writes the proper content for keys after fetching info from a data file" do
21
+ index_file = @dest.join("index.html")
22
+ expect(index_file).to exist
23
+ index_contents = File.read(index_file)
24
+ expect(index_contents).to include("<a href=\"/categories/amazing\">Amazing</a>")
25
+ end
18
26
  end
@@ -5,3 +5,6 @@ Bootcamp:
5
5
  - Be Social
6
6
  - '{{ site.data.conrefs.product_name[site.audience] }} Glossary'
7
7
  - Good Resources for Learning Git and GitHub
8
+
9
+ '{{ site.data.conrefs.product_type }}':
10
+ - Something something
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-conrefifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen J. Torikian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-02 00:00:00.000000000 Z
11
+ date: 2014-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll