vizbuilder 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/vizbuilder.rb +16 -15
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4dc925f85d53e2dc765eca9ffae446e0197d471a5680a8b77c3f60aa9d48f6bb
4
- data.tar.gz: 7167536f3e903ac3c446f9be2773582065c22e126004f2330623bac87b2b6ce5
3
+ metadata.gz: 71af917f2f1a1a80a6bd1d2e56bac7574e7e2a3a7b076fcbf203d461eb1924cc
4
+ data.tar.gz: 6bef1bb5f64ec5565068b1627db81a5469dcc993c26be08329f294e808546a64
5
5
  SHA512:
6
- metadata.gz: 84a2a641318f6060ec8432e0aba51e4ca090b42651ca46fe74bbc57ec24338fc72495dcb88936be091e7f86c5dfa5e458cbdd1a2e2ed02a7f89ea1e7da9afc66
7
- data.tar.gz: 01c7df8fd30bce6dfa1d6cf67580f6698a889c7272ea00bff8775f4159ec0e9cce16c61e509712b96f15ea9841cfe3bfc08a99fdab0e615783ab74c9228d81aa
6
+ metadata.gz: 90e932c5a6184a02a6b9741d91bebca2dc79f7cdce4afdd4b283862ed8669b5d0ff72da055093c468401ca9578bc1d0fcf9105ed589c8d0f4865024eeedd7cd8
7
+ data.tar.gz: 44710ff243b226bb202c4c32bdd6391a34c3deec1f99dacfcf7b9b450526ba08492e60a949c23c831497fc3b1c1339d7a05ccabc5838141c03db5174db41bf80
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.1
1
+ 1.1.2
@@ -37,10 +37,10 @@ class VizBuilder
37
37
  index_prebuilt!
38
38
  # First we build prebuilt pages that need digests calculated by build_page
39
39
  digested = sitemap.select { |_path, page| page[:digest] == true }
40
- digested.each { |path, _page| build_page(path, TemplateContext.new(@config), silent: silent) }
40
+ digested.each { |path, _page| build_page(path, silent: silent) }
41
41
  # Then we build all other pages
42
42
  undigested = sitemap.reject { |_path, page| page[:digest] == true }
43
- undigested.each { |path, _page| build_page(path, TemplateContext.new(@config), silent: silent) }
43
+ undigested.each { |path, _page| build_page(path, silent: silent) }
44
44
  end
45
45
 
46
46
  # Run this builder as a server
@@ -112,8 +112,7 @@ class VizBuilder
112
112
  # Check our sitemap then our prebuilt folder for content to serve
113
113
  if sitemap[path].present?
114
114
  content_type = MimeMagic.by_path(path).to_s
115
- ctx = TemplateContext.new(@config)
116
- content = build_page(path, ctx)
115
+ content = build_page(path)
117
116
  status = 200
118
117
  elsif File.exist?(build_filename)
119
118
  content_type = MimeMagic.by_path(path).to_s
@@ -155,7 +154,7 @@ class VizBuilder
155
154
  # data was called.
156
155
  run_hook!(:after_load_data)
157
156
  # Add helpers to the TemplateContext class
158
- TemplateContext.include(*helper_modules) unless helper_modules.empty?
157
+ TemplateContext.include(*helper_modules.reverse) unless helper_modules.empty?
159
158
  # Mark app configured
160
159
  @_configured = true
161
160
  # Chainable
@@ -260,7 +259,7 @@ class VizBuilder
260
259
  if new_helpers.present?
261
260
  # extend the current Config instance with the helpers, making them available
262
261
  # to the rest of the configuration block
263
- extend(*new_helpers) if type.nil? || type.to_sym == :config
262
+ extend(*new_helpers.reverse) if type.nil? || type.to_sym == :config
264
263
  # add our new helpers to our array of all helpers
265
264
  @helper_modules += new_helpers if type.nil? || type.to_sym == :template
266
265
  end
@@ -406,13 +405,15 @@ class VizBuilder
406
405
  private
407
406
 
408
407
  # Generate one page from the sitemap and save to `build/`
409
- def build_page(path, ctx, silent: false)
410
- ctx.page = sitemap[path]
408
+ def build_page(path, silent: false)
409
+ page = sitemap[path]
411
410
  out_fname = File.join(BUILD_DIR, path)
412
411
  puts "Rendering #{out_fname}..." unless silent
413
412
 
414
413
  # Check page data for info on how to build this path
415
- if ctx.page['template'].present?
414
+ if page['template'].present?
415
+ ctx = TemplateContext.new(@config)
416
+ ctx.page = page
416
417
  # Check if we have a layout defined, use it
417
418
  layout = ctx.page.key?('layout') ? ctx.page['layout'] : config['layout']
418
419
 
@@ -424,10 +425,10 @@ class VizBuilder
424
425
  else
425
426
  ctx.render(ctx.page['template'])
426
427
  end
427
- elsif ctx.page['json'].present?
428
- content = ctx.page['json'].to_json
429
- elsif ctx.page['file'].present?
430
- content = File.read(ctx.page['file'])
428
+ elsif page['json'].present?
429
+ content = page['json'].to_json
430
+ elsif page['file'].present?
431
+ content = File.read(page['file'])
431
432
  else
432
433
  raise(
433
434
  ArgumentError,
@@ -436,13 +437,13 @@ class VizBuilder
436
437
  end
437
438
 
438
439
  # If page data includes a digest flag, add sha1 digest to output filename
439
- if ctx.page['digest'] == true
440
+ if page['digest'] == true
440
441
  ext = VizBuilder.fullextname(path)
441
442
  fname = File.basename(path, ext)
442
443
  dir = File.dirname(path)
443
444
  digest = Digest::SHA1.hexdigest(content)
444
445
  digest_fname = "#{fname}-#{digest}#{ext}"
445
- ctx.page['digest_path'] = "#{dir}/#{digest_fname}"
446
+ page['digest_path'] = "#{dir}/#{digest_fname}"
446
447
  out_fname = File.join(BUILD_DIR, dir, digest_fname)
447
448
  end
448
449
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vizbuilder
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Mark
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-14 00:00:00.000000000 Z
11
+ date: 2019-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport