nanoc-conref-fs 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5ce3fca0efb82cce69239434123a5de9f135ad56
4
- data.tar.gz: 421b51a89886f2354f4357f5b741b97ae3554aa0
3
+ metadata.gz: 5f97b581aa4c8787bdf2b6ce84f1dcc3b210b035
4
+ data.tar.gz: 34ae3ad02c8bbf04ae4c10322e2356590e28e763
5
5
  SHA512:
6
- metadata.gz: 471d13dee8a6c72a1d3b2563f9c6e0205521c1c3ca324d906df534dde94f6af7d6275e6b15c718e21d22c8ad2ed8c7590ffe215755801e91b9fd1c05e9b56c0c
7
- data.tar.gz: 4195c8a0227022562027eaabce6ebd078244a5dda6844a3e4719656461905ec5563e61d8c35777c55ac38f3111dd9655db1d6a5994141de8a11b7b39a9a0285c
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 = obfuscate_liquid(content, data_vars)
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 "Could not convert \n#{content}"
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.obfuscate_liquid(content, data_vars)
61
- content.gsub(Conrefifier::BLOCK_SUB) do |match|
62
- # We must obfuscate Liquid variables while replacing conditionals
63
- match = match.gsub(/{{/, '~~#~~')
64
- match = Conrefifier.apply_liquid(match, data_vars)
65
- match.gsub('~~#~~', '{{')
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
@@ -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.3'
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.'
@@ -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
@@ -0,0 +1,9 @@
1
+ {% if page.version != 'cloud' %}
2
+ Gists:
3
+ - About gists
4
+ - Creating gists
5
+ - Forking and cloning gists
6
+ {% if page.version == 'dotcom' %}
7
+ - Deleting an anonymous gist
8
+ {% endif %}
9
+ {% endif %}
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.3
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-20 00:00:00.000000000 Z
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