Class: Wingtips::Configuration
- Inherits:
-
Object
- Object
- Wingtips::Configuration
- Includes:
- DSL
- Defined in:
- lib/wingtips/configuration.rb
Class Attribute Summary collapse
-
.current ⇒ Object
Returns the value of attribute current.
Instance Attribute Summary collapse
-
#slide_classes ⇒ Object
readonly
Returns the value of attribute slide_classes.
Instance Method Summary collapse
- #app_options ⇒ Object
-
#initialize(path) ⇒ Configuration
constructor
A new instance of Configuration.
- #load_options(full_path) ⇒ Object
- #slides(*slide_classes) ⇒ Object
- #template_options ⇒ Object
- #unnamed_slides_allowed? ⇒ Boolean
- #wingtips_options(opts = {}) ⇒ Object
Methods included from DSL
Constructor Details
#initialize(path) ⇒ Configuration
Returns a new instance of Configuration.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/wingtips/configuration.rb', line 7 def initialize(path) self.class.current = self = { app: { title: 'Presentation', fullscreen: true }, templates: {} } full_path = File.(path) (full_path) load_templates full_path full_path # the empty slide at the start is needed as otherwise the dimensions # of the first slide are most likely messed up = [Wingtips::Slide] self.instance_eval(File.read(full_path)) end |
Class Attribute Details
.current ⇒ Object
Returns the value of attribute current.
72 73 74 |
# File 'lib/wingtips/configuration.rb', line 72 def current @current end |
Instance Attribute Details
#slide_classes ⇒ Object (readonly)
Returns the value of attribute slide_classes.
5 6 7 |
# File 'lib/wingtips/configuration.rb', line 5 def end |
Instance Method Details
#app_options ⇒ Object
51 52 53 |
# File 'lib/wingtips/configuration.rb', line 51 def [:app] end |
#load_options(full_path) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/wingtips/configuration.rb', line 30 def (full_path) begin = true self.instance_eval(File.read(full_path)) rescue NameError = false # expected to hit the first slide class and then abort evaling # the config file. This is necessary so we can have the options at the # beginning of the config file while they are needed in the tamplates # for instance. So what happens is: # 1. read config (options should be on top) # 2. error upon encountering the first class, continue in initialize # 3. Load slides and templates (while options are already loaded) # 4. eval the config file again (options are read again, shouldn't be # a problem). This time no error as slide and template classes are # loaded # Yes there could be a separate options file, but it didn't feel right # to have a config and an options file end end |
#slides(*slide_classes) ⇒ Object
63 64 65 |
# File 'lib/wingtips/configuration.rb', line 63 def (*) .concat() end |
#template_options ⇒ Object
55 56 57 |
# File 'lib/wingtips/configuration.rb', line 55 def [:templates] end |
#unnamed_slides_allowed? ⇒ Boolean
67 68 69 |
# File 'lib/wingtips/configuration.rb', line 67 def end |
#wingtips_options(opts = {}) ⇒ Object
59 60 61 |
# File 'lib/wingtips/configuration.rb', line 59 def (opts={}) HashUtils.deep_merge! , opts end |