Sha256: d9b40e380cb1e73c7b91da17437669e63feb6c1143f589346ae69eee7cb17fbf

Contents?: true

Size: 720 Bytes

Versions: 3

Compression:

Stored size: 720 Bytes

Contents

require 'toml'

module RevealCK
  class Config

    def initialize(args={})
      config_file = args[:config_file]
      @config = load_config config_file
    end

    def title
      @config["title"]
    end

    def author
      @config["author"]
    end

    def theme
      @config["presentation"]["theme"]
    end

    private

    DEFAULTS = {
      "title" => "Slides",
      "author" => "Hakim El Hattab",
      "presentation" => {
        "theme" => "default"
      }
    }

    def load_config(config_file)
      config = DEFAULTS.dup
      if config_file && File.exists?(config_file)
        file_config = TOML.load_file config_file
        config.merge! file_config
      end
      config
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
reveal-ck-0.1.5 lib/reveal-ck/config.rb
reveal-ck-0.1.4 lib/reveal-ck/config.rb
reveal-ck-0.1.3 lib/reveal-ck/config.rb