nanoc-conref-fs 0.6.3 → 0.6.4
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/lib/nanoc-conref-fs/datafiles.rb +10 -9
- data/nanoc-conref-fs.gemspec +1 -1
- data/test/datafiles_test.rb +9 -1
- data/test/fixtures/data/categories/nested.yml +9 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f97b581aa4c8787bdf2b6ce84f1dcc3b210b035
|
4
|
+
data.tar.gz: 34ae3ad02c8bbf04ae4c10322e2356590e28e763
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf54ac5ff6c190200b73a587e0b67e01d5a13936853355ad86b6f2c0c1e833fd4a2b04ebdb9572070212d7acecdaa5e19f7cc5198dc3d2fc27c810f1af382261
|
7
|
+
data.tar.gz: 92dad5ef9e7bb28bc07b7b5d5bb788a84d831f26ce4fa42105a4f0cff714d2826cef1f23f081ed8f6c56106b701ad461fbac6f08511b9b93d6fa165587387b79
|
@@ -5,15 +5,17 @@ require_relative 'conrefifier'
|
|
5
5
|
|
6
6
|
module NanocConrefFS
|
7
7
|
module Datafiles
|
8
|
+
OBFUSCATION = '~~#~~'
|
9
|
+
|
8
10
|
def self.apply_conditionals(config, path:, content:, rep:)
|
9
11
|
vars = Conrefifier.file_variables(config[:data_variables], path, rep)
|
10
12
|
data_vars = { :page => vars, :site => { :config => config } }
|
11
13
|
|
12
|
-
content =
|
14
|
+
content = obfuscate_and_liquify(content, data_vars)
|
13
15
|
begin
|
14
16
|
doc = YAML.load(content)
|
15
17
|
rescue Psych::SyntaxError => e
|
16
|
-
STDERR.puts "
|
18
|
+
STDERR.puts "\nCould not convert following file:\n#{content}"
|
17
19
|
raise "#{e.message}: #{e.inspect}"
|
18
20
|
end
|
19
21
|
|
@@ -57,13 +59,12 @@ module NanocConrefFS
|
|
57
59
|
data
|
58
60
|
end
|
59
61
|
|
60
|
-
def self.
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
end
|
62
|
+
def self.obfuscate_and_liquify(content, data_vars)
|
63
|
+
# We must obfuscate Liquid variables while replacing conditionals,
|
64
|
+
# else they get wiped out
|
65
|
+
content.gsub!(/\{\{/, OBFUSCATION)
|
66
|
+
content = Conrefifier.apply_liquid(content, data_vars)
|
67
|
+
content.gsub(OBFUSCATION, '{{')
|
67
68
|
end
|
68
69
|
end
|
69
70
|
end
|
data/nanoc-conref-fs.gemspec
CHANGED
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = 'nanoc-conref-fs'
|
6
|
-
spec.version = '0.6.
|
6
|
+
spec.version = '0.6.4'
|
7
7
|
spec.authors = ['Garen Torikian']
|
8
8
|
spec.email = ['gjtorikian@gmail.com']
|
9
9
|
spec.summary = 'A Nanoc filesystem to permit using conrefs/reusables in your content.'
|
data/test/datafiles_test.rb
CHANGED
@@ -3,7 +3,7 @@ require 'test_helper'
|
|
3
3
|
class DatafilesTest < MiniTest::Test
|
4
4
|
def test_it_collects_the_files
|
5
5
|
files = NanocConrefFS::Datafiles.collect_data(File.join(FIXTURES_DIR, 'data')).keys.sort
|
6
|
-
names = %w(categories/category categories/simple reusables/intro reusables/names variables/asterisks variables/empty variables/product)
|
6
|
+
names = %w(categories/category categories/nested categories/simple reusables/intro reusables/names variables/asterisks variables/empty variables/product)
|
7
7
|
names.map! { |name| File.join(FIXTURES_DIR, 'data', "#{name}.yml") }
|
8
8
|
assert_equal files, names
|
9
9
|
end
|
@@ -34,4 +34,12 @@ class DatafilesTest < MiniTest::Test
|
|
34
34
|
assert_includes result.to_s, 'We use {{ site.data.reusables.names.new_name }}'
|
35
35
|
assert_includes result.to_s, '{{ site.data.variables.product.product_name }} is great'
|
36
36
|
end
|
37
|
+
|
38
|
+
def test_it_converts_nested_blocks
|
39
|
+
file = File.join(FIXTURES_DIR, 'data', 'categories', 'nested.yml')
|
40
|
+
content = File.read(file)
|
41
|
+
result = NanocConrefFS::Datafiles.apply_conditionals(CONFIG, path: file, content: content, rep: :default)
|
42
|
+
assert_includes result.to_s, 'About gists'
|
43
|
+
refute_includes result.to_s, 'Deleting an anonymous gist'
|
44
|
+
end
|
37
45
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nanoc-conref-fs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen Torikian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nanoc
|
@@ -164,6 +164,7 @@ files:
|
|
164
164
|
- test/fixtures/content/parents/two_parents.html
|
165
165
|
- test/fixtures/content/parents/two_parents.md
|
166
166
|
- test/fixtures/data/categories/category.yml
|
167
|
+
- test/fixtures/data/categories/nested.yml
|
167
168
|
- test/fixtures/data/categories/simple.yml
|
168
169
|
- test/fixtures/data/reusables/intro.yml
|
169
170
|
- test/fixtures/data/reusables/names.yml
|
@@ -250,6 +251,7 @@ test_files:
|
|
250
251
|
- test/fixtures/content/parents/two_parents.html
|
251
252
|
- test/fixtures/content/parents/two_parents.md
|
252
253
|
- test/fixtures/data/categories/category.yml
|
254
|
+
- test/fixtures/data/categories/nested.yml
|
253
255
|
- test/fixtures/data/categories/simple.yml
|
254
256
|
- test/fixtures/data/reusables/intro.yml
|
255
257
|
- test/fixtures/data/reusables/names.yml
|