jekyll-ramler 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.
- checksums.yaml +4 -4
- data/jekyll-ramler.gemspec +1 -1
- data/lib/raml-generate.rb +5 -5
- data/spec/config_spec.rb +14 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f230b6212247528fc03df0000009d3eb25c154e
|
4
|
+
data.tar.gz: bb207769c3478528d86c2ff22258955d39ad2f09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06140a5983654fc240b33d25e156585b5df0173ebf974ff2fec7f2e0cbed295768d2853cc49fe09da233ebd1dc4fa1d93340fc87edee4f6afbe4c9ea9de083eb
|
7
|
+
data.tar.gz: c26f71403202e493480dfe3f0256072c742805721aa930183ee5ac712997a456a3569fe989d6a4969194cc66cf72b2d538f44e48a6499d571f5df69607f13efc
|
data/jekyll-ramler.gemspec
CHANGED
data/lib/raml-generate.rb
CHANGED
@@ -24,7 +24,7 @@ module Jekyll
|
|
24
24
|
@dir = File.join(web_root, @dir)
|
25
25
|
@name = 'index.html'
|
26
26
|
|
27
|
-
layout = get_layout(dir) if layout.nil?
|
27
|
+
layout = get_layout("#{web_root}#{dir}") if layout.nil?
|
28
28
|
layout << '.html' if not layout.end_with?('.html')
|
29
29
|
|
30
30
|
self.process(@name)
|
@@ -46,13 +46,13 @@ module Jekyll
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def get_layout(dir, site=@site)
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
defaults = site.config.fetch('defaults', []).sort_by { |x| -(x.fetch('scope', {}).fetch('path', '').length) }
|
50
|
+
|
51
|
+
default = defaults.detect { |x| dir.include?(x['scope']['path'])}
|
52
52
|
|
53
53
|
default = {"values" => {}} if default.nil?
|
54
54
|
|
55
|
-
default['values'].fetch('layout', 'default')
|
55
|
+
layout = default['values'].fetch('layout', 'default')
|
56
56
|
end
|
57
57
|
|
58
58
|
end
|
data/spec/config_spec.rb
CHANGED
@@ -19,6 +19,7 @@ describe 'ReferencePageGenerator', fakefs:true do
|
|
19
19
|
|
20
20
|
FileUtils.mkdir_p('_layouts')
|
21
21
|
File.open('_layouts/default.html', 'w') { |f| f << "{{ content }}" }
|
22
|
+
File.open('_layouts/resource.html', 'w') { |f| f << "<h1>Resource</h1> <p>{{ content }}</p>" }
|
22
23
|
|
23
24
|
File.open('api.json', 'w') do |f|
|
24
25
|
f << JSON.pretty_generate(load_simple_raml)
|
@@ -141,5 +142,18 @@ describe 'ReferencePageGenerator', fakefs:true do
|
|
141
142
|
expect(File.file?('_site/productA/productA_api.json')).to be true
|
142
143
|
expect(File.file?('_site/productA/productA_api.raml')).to be true
|
143
144
|
end
|
145
|
+
|
146
|
+
it 'can use layouts configured for nested contexts' do
|
147
|
+
@site.config['defaults'] = [{
|
148
|
+
'scope' => {'path' => 'productA/resource'},
|
149
|
+
'values' => {'layout' => 'resource'}
|
150
|
+
}]
|
151
|
+
@site.config['ramler_api_paths'].delete('service.json')
|
152
|
+
|
153
|
+
@rpg.generate(@site)
|
154
|
+
@site.process
|
155
|
+
output = File.read('_site/productA/resource/test_resource/index.html')
|
156
|
+
expect(output).to include "<h1>Resource</h1>"
|
157
|
+
end
|
144
158
|
end
|
145
159
|
end
|