class Photish::Render::Gallery

Attributes

config[R]
version_hash[R]

Public Class Methods

new(config, version_hash) click to toggle source
# File lib/photish/render/gallery.rb, line 4
def initialize(config, version_hash)
  @config = config
  @version_hash = version_hash
end

Public Instance Methods

all_for(collection) click to toggle source
# File lib/photish/render/gallery.rb, line 9
def all_for(collection)
  tasks(collection).shuffle.each(&:call)
end

Private Instance Methods

album_template() click to toggle source
# File lib/photish/render/gallery.rb, line 44
def album_template
  Template.new(layout_file,
               template_album_file,
               output_dir)
end
image_conversion() click to toggle source
# File lib/photish/render/gallery.rb, line 40
def image_conversion
  Image.new(config, version_hash)
end
layout_file() click to toggle source
# File lib/photish/render/gallery.rb, line 60
def layout_file
  File.join(site_dir, templates_dir, templates.layout)
end
page_template() click to toggle source
# File lib/photish/render/gallery.rb, line 50
def page_template
  GalleryPage.new(layout_file, output_dir)
end
photo_template() click to toggle source
# File lib/photish/render/gallery.rb, line 54
def photo_template
  Template.new(layout_file,
               template_photo_file,
               output_dir)
end
subset(items) click to toggle source
# File lib/photish/render/gallery.rb, line 34
def subset(items)
  worker_index_zeroed.step(items.count, workers)
                     .map { |i| items[i] }
                     .compact
end
tasks(collection) click to toggle source
# File lib/photish/render/gallery.rb, line 25
def tasks(collection)
  [
    ->{ album_template.render(subset(collection.all_albums))   },
    ->{ photo_template.render(subset(collection.all_photos))   },
    ->{ image_conversion.render(subset(collection.all_images)) },
    ->{ page_template.render(subset(collection.all_pages))     },
  ]
end
template_album_file() click to toggle source
# File lib/photish/render/gallery.rb, line 64
def template_album_file
  File.join(site_dir,  templates_dir, templates.album)
end
template_photo_file() click to toggle source
# File lib/photish/render/gallery.rb, line 68
def template_photo_file
  File.join(site_dir, templates_dir, templates.photo)
end
templates_dir() click to toggle source
# File lib/photish/render/gallery.rb, line 72
def templates_dir
  '_templates'
end
worker_index_zeroed() click to toggle source
# File lib/photish/render/gallery.rb, line 76
def worker_index_zeroed
  worker_index - 1
end