vizbuilder 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/VERSION +1 -1
  4. data/lib/vizbuilder.rb +18 -5
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 51f92c1fd3944056565422dd247601a8b15ba9e5e173edd596689b1511469e39
4
- data.tar.gz: '029ed027b6ca7620051c6a3003f6d4dcb646faf9cb7699af5dda3bddf56be122'
3
+ metadata.gz: 6496f3b17728ad1b6fc1a1b7684bf5f1a479ad66ef1b20b9677ad5c4ad871abf
4
+ data.tar.gz: 56ee82f7d98ae592749c764b6eb6608b2f8094d17ed6d8bbc27d3bf9a232fe73
5
5
  SHA512:
6
- metadata.gz: 4f46a7be4d80cf2f2cc1b4b77d667ace49f540896397b0509aaca1149df7a0ef711b56b7d51dc26f9d390d33f69138d215759f860417c3671c261024383f4aeb
7
- data.tar.gz: a9af4e089431d541b393a2b881d7a446d03a6597b858f0cf2c59d3d9b380a80d85b1c968c8c23006801fe74c08a25f6a7eda7372ec3dd7d8208763a7c5ac876e
6
+ metadata.gz: 6750afeea6e5e1172d93211b9f2935e2976f93699e319046b21b3f6cf4ef82f273119bb4dbebbe894b747536ddb83509f5385571d571964a38cb3b8f1daba6aa
7
+ data.tar.gz: c2ba4cf930aa4730c8891a09c094569113f2b1bae84af92d8daff722be472d184109d13dfb9e32a8b303fc1690399b899064fc2c741316d3424e2fdf9573aad0
data/README.md CHANGED
@@ -2,7 +2,7 @@ A fast, simple static site builder, inspired by [Middleman](https://middlemanapp
2
2
 
3
3
  ## Why another static site generator?
4
4
 
5
- We've been using Middleman in Vox Media newsrooms for many years to build static articles and embeddable interactives. But as we've built larger projects and projects that require frequent updates, we've found that Middleman's extensive dependencies and complexity can cause high resource use and long build times. This is not a criticism of Middleman, Middleman is great and you should use it if it does what you need.
5
+ We've been using Middleman in Vox Media newsrooms for many years to build static articles and embeddable interactives. But as we've built larger projects and projects that require frequent updates, we've found that Middleman's extensive dependencies and complexity can cause high resource use and long build times. However Middleman is great for a lot of use-cases and you should use it if it does what you need.
6
6
 
7
7
  We need something simple and fast. Something that provides only the functionality we need and uses a few simple dependencies.
8
8
 
@@ -32,9 +32,9 @@ end
32
32
 
33
33
  # if run with the argument `runserver` run as a development server
34
34
  if ARGV[0] == 'runserver'
35
- app.runserver
35
+ app.runserver!
36
36
  else
37
- app.build
37
+ app.build!
38
38
  end
39
39
  ```
40
40
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
data/lib/vizbuilder.rb CHANGED
@@ -135,6 +135,20 @@ class VizBuilder
135
135
  ".#{parts[1..-1].join('.')}"
136
136
  end
137
137
 
138
+ # Plaster over API changes in ERB
139
+ def self.erb_new(template_path)
140
+ # The parameters of ERB.new are changed in ruby 2.6
141
+ erb_changed_ruby_version = Gem::Version.new('2.6.0')
142
+ current_ruby_version = Gem::Version.new(RUBY_VERSION)
143
+ erb = if current_ruby_version >= erb_changed_ruby_version
144
+ ERB.new(File.read(template_path), trim_mode: '-')
145
+ else
146
+ ERB.new(File.read(template_path), nil, '-')
147
+ end
148
+ erb.filename = File.expand_path(template_path)
149
+ erb
150
+ end
151
+
138
152
  # Convenience methods for configuring the site
139
153
  class Config
140
154
  attr_accessor :data, :config, :sitemap, :hooks, :helper_modules
@@ -254,8 +268,7 @@ class VizBuilder
254
268
  def render(template_path, locals = {})
255
269
  old_locals = @locals
256
270
  @locals = locals.with_indifferent_access
257
- erb = ERB.new(File.read(template_path), trim_mode: '-')
258
- erb.filename = File.expand_path(template_path)
271
+ erb = VizBuilder.erb_new(template_path)
259
272
  ret = erb.result(binding)
260
273
  @locals = old_locals
261
274
  ret
@@ -347,6 +360,7 @@ class VizBuilder
347
360
  def build_page(path, ctx, silent: false)
348
361
  ctx.page = sitemap[path]
349
362
  out_fname = File.join(BUILD_DIR, path)
363
+ puts "Rendering #{out_fname}..." unless silent
350
364
 
351
365
  # Check page data for info on how to build this path
352
366
  if ctx.page['template'].present?
@@ -370,7 +384,7 @@ class VizBuilder
370
384
 
371
385
  # If page data includes a digest flag, add sha1 digest to output filename
372
386
  if ctx.page['digest'] == true
373
- ext = Builder.fullextname(path)
387
+ ext = VizBuilder.fullextname(path)
374
388
  fname = File.basename(path, ext)
375
389
  dir = File.dirname(path)
376
390
  digest = Digest::SHA1.hexdigest(content)
@@ -379,7 +393,6 @@ class VizBuilder
379
393
  out_fname = File.join(BUILD_DIR, dir, digest_fname)
380
394
  end
381
395
 
382
- puts "Writing #{out_fname}..." unless silent
383
396
  FileUtils.mkdir_p(File.dirname(out_fname))
384
397
  File.write(out_fname, content)
385
398
  content
@@ -414,7 +427,7 @@ class VizBuilder
414
427
  # Find prebuilt assets and add them to the sitemap
415
428
  def index_prebuilt!
416
429
  Dir.glob("#{PREBUILT_DIR}/**/[^_]*.*") do |filename|
417
- sitemap[filename.sub("#{PREBUILT_DIR}/", '')] = { file: filename, digest: true }
430
+ config.add_page(filename.sub("#{PREBUILT_DIR}/", ''), file: filename, digest: true)
418
431
  end
419
432
  end
420
433
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vizbuilder
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Mark