Sha256: d86eef4c984de4108db91065956eecaa4c46470cbb0f1072e725ca2a385ca7c1
Contents?: true
Size: 1.76 KB
Versions: 11
Compression:
Stored size: 1.76 KB
Contents
module RevealCK # # Public: A PresentationDSL defines the DSL behind a # presentation. It also knows how to load file containing the DSL. # class PresentationDSL include Retrieve attr_reader :author, :title, :theme, :transition attr_reader :config def initialize(args) @slides = [] @config = retrieve(:config, args) end # Rubocop doesn't like trivial accessors, but docile breaks if # trivial accessors are used. # rubocop:disable TrivialAccessors def theme(theme) config.theme = theme end def transition(transition) config.transition = transition end def title(title) config.title = title end def author(author) config.author = author end # rubocop:enable TrivialAccessors def revealjs_config(key, value) config.revealjs_config[key] = value end def slide(template, variables = {}) variables[:template] = template variables[:config] = @config @slides << RevealCK::Slide.new(variables) end def contents_of(path) File.open(path).read end def build presentation = RevealCK::Presentation.new config: config presentation.theme = @theme if @theme presentation.transition = @transition if @transition presentation.author = @author if @author presentation.title = @title if @title @slides.each { |slide| presentation.add slide } presentation end require 'docile' def presentation(&block) Docile.dsl_eval(self, &block).build end def self.load(args) file, config = retrieve(:file, args), retrieve(:config, args) builder = PresentationDSL.new config: config contents = File.open(file).read builder.instance_eval(contents) end end end
Version data entries
11 entries across 11 versions & 1 rubygems