Class: Mako::Core

Inherits:
Object
  • Object
show all
Includes:
ERB::Util, ViewHelpers
Defined in:
lib/mako/core.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ViewHelpers

#last_updated, #quick_nav, #today

Constructor Details

#initialize(args) ⇒ Core

Returns a new instance of Core.



11
12
13
14
15
16
17
18
# File 'lib/mako/core.rb', line 11

def initialize(args)
  @feeds = []
  @requester = args.fetch(:requester)
  @constructor = args.fetch(:constructor)
  @renderers = args.fetch(:renderers)
  @writer = args.fetch(:writer)
  @subscription_list = args.fetch(:subscription_list)
end

Instance Attribute Details

#constructorObject (readonly)

Returns the value of attribute constructor.



8
9
10
# File 'lib/mako/core.rb', line 8

def constructor
  @constructor
end

#feedsObject (readonly)

Returns the value of attribute feeds.



8
9
10
# File 'lib/mako/core.rb', line 8

def feeds
  @feeds
end

#renderersObject (readonly)

Returns the value of attribute renderers.



8
9
10
# File 'lib/mako/core.rb', line 8

def renderers
  @renderers
end

#requesterObject (readonly)

Returns the value of attribute requester.



8
9
10
# File 'lib/mako/core.rb', line 8

def requester
  @requester
end

#subscription_listObject (readonly)

Returns the value of attribute subscription_list.



8
9
10
# File 'lib/mako/core.rb', line 8

def subscription_list
  @subscription_list
end

#writerObject (readonly)

Returns the value of attribute writer.



8
9
10
# File 'lib/mako/core.rb', line 8

def writer
  @writer
end

Instance Method Details

#buildObject

Gets list of feed_urls, requests each of them and uses the constructor to make Feed and Article objects, then calls to the renderers to render the page and stylesheets.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/mako/core.rb', line 23

def build
  log_configuration_information

  if subscription_list.empty?
    Mako.logger.warn 'No feeds were found in your subscriptions file. Please add feeds and try again.'
    return
  end

  log_time do
    request_and_build_feeds
    renderers.each do |renderer|
      renderer_instance = renderer.new(bound: self)
      writer.new(renderer: renderer_instance,
                 destination: File.expand_path(renderer_instance.file_path, Mako.config.destination)).write
    end
  end
end

#get_bindingBinding

Returns the Binding of Core for the ERB renderer. Binding encapsulates the execution context for the Core class, and makes all of the variables and methods of Core available to the renderer.

Returns:

  • (Binding)


46
47
48
# File 'lib/mako/core.rb', line 46

def get_binding
  binding
end