lib/lookbook/config.rb in lookbook-1.0.0.beta.7 vs lib/lookbook/config.rb in lookbook-1.0.0.beta.8
- old
+ new
@@ -4,18 +4,18 @@
module Lookbook
class Config
def initialize
@options = Store.new
-
+
@options.set({
project_name: "Lookbook",
log_level: 2,
auto_refresh: true,
components_path: "app/components",
-
+
page_controller: "Lookbook::PageController",
page_route: "pages",
page_paths: ["test/components/docs"],
page_options: {},
markdown_options: Markdown::DEFAULT_OPTIONS,
@@ -42,11 +42,11 @@
ui_favicon: true,
hooks: {
after_initialize: [],
before_exit: [],
- after_change: [],
+ after_change: []
},
debug_menu: Rails.env.development?,
experimental_features: false,
@@ -98,11 +98,11 @@
hotkey: "p",
disabled: ->(data) { data.preview.params.none? },
padded: false,
system: true
}
- },
+ }
})
end
def project_name
@options.project_name == false ? nil : @options.project_name
@@ -145,22 +145,22 @@
absolute_path(@options.parser_registry_path)
end
def inspector_panels(&block)
panels = Store.new(@options.inspector_panels.select { |key, panel| panel != false })
- if block_given?
+ if block
yield panels
else
panels
end
end
def define_inspector_panel(name, opts = {})
pane = opts[:pane].presence || :drawer
siblings = inspector_panels.select { |key, panel| panel.pane == pane }
opts[:position] ||= siblings.size + 1
- @options.inspector_panels[name] = opts
+ @options.inspector_panels[name] = opts
siblings.each do |key, panel|
if panel.position >= opts[:position]
panel.position += 1
end
end
@@ -190,11 +190,10 @@
disabled: false,
show: true,
copy: nil,
panel_classes: nil,
locals: {},
- padded: true,
system: false
}
end
def ui_theme=(name)
@@ -205,11 +204,11 @@
Lookbook.logger.warn "'#{name}' is not a valid Lookbook theme. Theme setting not changed."
end
end
def ui_theme_overrides(&block)
- if block_given?
+ if block
yield @options.ui_theme_overrides
else
@options.ui_theme_overrides
end
end
@@ -236,11 +235,11 @@
end
def to_json(*a)
to_h.to_json(*a)
end
-
+
protected
def normalize_paths(paths)
paths.map! do |path|
full_path = absolute_path(path)
@@ -254,7 +253,11 @@
end
def method_missing(name, *args)
@options.send(name, *args)
end
+
+ def respond_to_missing?(name, *)
+ to_h.key? name
+ end
end
-end
\ No newline at end of file
+end