class Mako::Core
Attributes
constructor[R]
feeds[R]
renderers[R]
requester[R]
subscription_list[R]
writer[R]
Public Class Methods
new(args)
click to toggle source
# 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
Public Instance Methods
build()
click to toggle source
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.
# 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_binding()
click to toggle source
Private Instance Methods
log_configuration_information()
click to toggle source
Prints configuration file, source, and destination directory to STDOUT.
# File lib/mako/core.rb, line 53 def log_configuration_information Mako.logger.info "Configuration File: #{Mako.config.config_file}" Mako.logger.info "Theme: #{Mako.config.theme}" Mako.logger.info "Destination: #{Mako.config.destination}" end
log_time() { || ... }
click to toggle source
Provides build time logging information and writes it to STDOUT.
# File lib/mako/core.rb, line 60 def log_time Mako.logger.info 'Generating...' start_time = Time.now.to_f yield generation_time = Time.now.to_f - start_time Mako.logger.info "done in #{generation_time} seconds" end
request_and_build_feeds()
click to toggle source
# File lib/mako/core.rb, line 68 def request_and_build_feeds requesters = subscription_list.map { |feed_url| requester.new(feed_url: feed_url) } requesters.each do |feed_request| feed_response = feed_request.fetch next unless feed_request.ok? constructed_feed = constructor.new(feed_data: feed_response.body, feed_url: feed_response.feed_url) .parse_and_create feeds << constructed_feed if constructed_feed end end