jekyll-ramler 0.0.2 → 0.0.3

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: 0b51a16a272803f10915253d041eadd53213f8d4
4
- data.tar.gz: eb6626d0d68f77c7faa78041428214d419a2e664
3
+ metadata.gz: 2f230b6212247528fc03df0000009d3eb25c154e
4
+ data.tar.gz: bb207769c3478528d86c2ff22258955d39ad2f09
5
5
  SHA512:
6
- metadata.gz: d9c0d5900dc16eadbfe0119fca2a96b125835506d031fec593bcd8b1679be9b49f9f5dbd4771526d0571c7bd3a41febe782c43c04b32a5e4509cf96debd13048
7
- data.tar.gz: b445707349317d6923584813ff834a430ea55d48c17106bc489515a9dad8063aadec4970a33eb8679299d30fa589bcd255e489d217f6023087c932a9a24660f9
6
+ metadata.gz: 06140a5983654fc240b33d25e156585b5df0173ebf974ff2fec7f2e0cbed295768d2853cc49fe09da233ebd1dc4fa1d93340fc87edee4f6afbe4c9ea9de083eb
7
+ data.tar.gz: c26f71403202e493480dfe3f0256072c742805721aa930183ee5ac712997a456a3569fe989d6a4969194cc66cf72b2d538f44e48a6499d571f5df69607f13efc
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'jekyll-ramler'
3
- s.version = '0.0.2'
3
+ s.version = '0.0.3'
4
4
  s.date = '2015-02-09'
5
5
  s.authors = ['GovDelivery']
6
6
  s.email = 'support@govdelivery.com'
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
- default = site.config.fetch('defaults', {}).detect do |default|
50
- default['scope']['path'] == dir.split('/').first
51
- end
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-ramler
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
  - GovDelivery