Class: Confinement::Site

Inherits:
Object
  • Object
show all
Defined in:
lib/confinement.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) {|_self| ... } ⇒ Site

Returns a new instance of Site.

Yields:

  • (_self)

Yield Parameters:



231
232
233
234
235
236
237
238
239
240
241
242
243
# File 'lib/confinement.rb', line 231

def initialize(config)
  @root = config.root

  yield(self)

  @view_context_helpers ||= []
  @guesses ||= Rendering.guesses

  @route_identifiers = RouteIdentifiers.new
  @asset_blobs = Blobs.new(scoped_root: config.source.assets_path, file_abstraction_class: Asset)
  @content_blobs = Blobs.new(scoped_root: config.source.contents_path, file_abstraction_class: Content)
  @layout_blobs = Blobs.new(scoped_root: config.source.layouts_path, file_abstraction_class: Layout)
end

Instance Attribute Details

#asset_blobsObject (readonly)

Returns the value of attribute asset_blobs.



248
249
250
# File 'lib/confinement.rb', line 248

def asset_blobs
  @asset_blobs
end

#content_blobsObject (readonly)

Returns the value of attribute content_blobs.



249
250
251
# File 'lib/confinement.rb', line 249

def content_blobs
  @content_blobs
end

#guessesObject

Returns the value of attribute guesses.



253
254
255
# File 'lib/confinement.rb', line 253

def guesses
  @guesses
end

#layout_blobsObject (readonly)

Returns the value of attribute layout_blobs.



250
251
252
# File 'lib/confinement.rb', line 250

def layout_blobs
  @layout_blobs
end

#rootObject (readonly)

Returns the value of attribute root.



245
246
247
# File 'lib/confinement.rb', line 245

def root
  @root
end

#route_identifiersObject (readonly)

Returns the value of attribute route_identifiers.



247
248
249
# File 'lib/confinement.rb', line 247

def route_identifiers
  @route_identifiers
end

#view_context_helpersObject

Returns the value of attribute view_context_helpers.



252
253
254
# File 'lib/confinement.rb', line 252

def view_context_helpers
  @view_context_helpers
end

Instance Method Details

#partial_compilationObject



275
276
277
# File 'lib/confinement.rb', line 275

def partial_compilation
  { asset_blobs: @asset_blobs }
end

#partial_compilation=(previous_partial_compilation) ⇒ Object



279
280
281
282
283
284
285
# File 'lib/confinement.rb', line 279

def partial_compilation=(previous_partial_compilation)
  return if previous_partial_compilation.nil?

  @asset_blobs = previous_partial_compilation.fetch(:asset_blobs)

  nil
end

#rules {|assets: @asset_blobs, layouts: @layout_blobs, contents: @content_blobs, routes: @route_identifiers| ... } ⇒ Object

Yields:



255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
# File 'lib/confinement.rb', line 255

def rules
  yield(
    assets: @asset_blobs,
    layouts: @layout_blobs,
    contents: @content_blobs,
    routes: @route_identifiers
  )

  guesser = Rendering::Guesser.new(guesses)
  guess_renderers(guesser, @layout_blobs)
  guess_renderers(guesser, @content_blobs)

  @asset_blobs.done!
  @layout_blobs.done!
  @content_blobs.done!
  @route_identifiers.done!

  nil
end