Sha256: 7b3ce8c3379afc4365d0129e80213d5069e1c14628256f3d447fd467df4adfc1

Contents?: true

Size: 1.4 KB

Versions: 1

Compression:

Stored size: 1.4 KB

Contents

require 'toml'

module RevealCK
  #
  # Public: The Config module supports the core metadata surrounding a
  # RevealCK Presentation: title, author, theme, and transition.
  #
  module Config

    def author
      @author || DEFAULTS['author']
    end

    def author=(author)
      @author = author
    end

    def title
      @title || DEFAULTS['title']
    end

    def title=(title)
      @title = title
    end

    def theme
      @theme || DEFAULTS['theme']
    end

    def theme=(theme)
      @theme = theme
    end

    def transition
      @transition || DEFAULTS['transition']
    end

    def transition=(transition)
      @transition = transition
    end

    DEFAULTS = {
      'title'      => 'Slides',
      'author'     => '',
      'theme'      => 'default',
      'transition' => 'default'
    }

    def merge_config(args)
      file = args[:file] || raise(':file is required')
      config = TOML.load_file file

      if config['author']
        @author = config['author'] unless @author
      end

      if config['title']
        @title = config['title'] unless @title
      end

      if config['presentation']
        presentation = config['presentation']
        if presentation['theme']
          @theme = presentation['theme'] unless @theme
        end

        if presentation['transition']
          @transition = presentation['transition'] unless @transition
        end
      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
reveal-ck-0.1.7 lib/reveal-ck/config.rb