Sha256: 4fcc67f30d0c90aee5e8e96fb07ef22bd6a07e80ab5234cae82c2a14c61946b1

Contents?: true

Size: 1.67 KB

Versions: 1

Compression:

Stored size: 1.67 KB

Contents

require "piccle/config"
require "piccle/database"
require "piccle/dstk_service"
require "piccle/extractor"
require "piccle/parser"
require "piccle/quilt_generator"
require "piccle/renderer"
require "piccle/js_renderer"
require "piccle/streams"
require "piccle/streams/base_stream"
require "piccle/streams/camera_stream"
require "piccle/streams/date_stream"
require "piccle/streams/event_stream"
require "piccle/streams/keyword_stream"
require "piccle/streams/location_stream"
require "piccle/template_helpers"
require "piccle/version"

module Piccle
  FULL_SIZE = 1737 # Longest edge
  THUMBNAIL_SIZE = 300 # Thumbnail, square

  @@config = Piccle::Config.new

  def config
    @@config
  end

  def config=(new_config)
    @@config = new_config
  end

  # We defer the loading of our model classes until their first access, so a user can configure their DB location.
  # When bin/piccle is run, we require 'piccle' immediately. But Sequel models must have a DB connection so they can
  # reflect from the schema to define their fields. We can't require 'piccle', load the models, and then swap out the
  # DB for a configured version later.
  # Instead, we use const_missing to load all our models when we first try to access one.
  def Piccle.const_missing(name)
    Sequel::Model.db = Piccle.config.db

    if %i[Photo Keyword Location].include?(name)
      Dir[Piccle.config.gem_root_join("lib", "piccle", "models", "*.rb")].each { |f| require f.delete_prefix("lib/").delete_suffix(".rb") }
      models = [Piccle::Photo, Piccle::Keyword, Piccle::Location]
      models.each(&:finalize_associations)
      models.each(&:freeze)
    end

    const_get(name)
  end

  module_function :config, :config=
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
piccle-0.1.0.rc1 lib/piccle.rb