lookbook 1.2.1 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +47 -14
- data/app/components/lookbook/code/component.html.erb +1 -1
- data/app/components/lookbook/inspector_panel/component.rb +3 -5
- data/app/components/lookbook/nav/item/component.html.erb +1 -1
- data/app/components/lookbook/params/editor/component.rb +3 -10
- data/app/components/lookbook/params/field/component.html.erb +8 -8
- data/app/components/lookbook/params/field/component.rb +21 -72
- data/app/controllers/concerns/lookbook/targetable_concern.rb +156 -0
- data/app/controllers/concerns/lookbook/with_preview_controller_concern.rb +13 -0
- data/app/controllers/lookbook/application_controller.rb +13 -3
- data/app/controllers/lookbook/inspector_controller.rb +45 -0
- data/app/controllers/lookbook/page_controller.rb +11 -7
- data/app/controllers/lookbook/previews_controller.rb +4 -210
- data/app/helpers/lookbook/output_helper.rb +5 -5
- data/app/views/layouts/lookbook/skeleton.html.erb +3 -3
- data/app/views/lookbook/index.html.erb +12 -1
- data/app/views/lookbook/{previews → inspector}/inputs/_color.html.erb +0 -0
- data/app/views/lookbook/{previews → inspector}/inputs/_range.html.erb +0 -0
- data/app/views/lookbook/{previews → inspector}/inputs/_select.html.erb +0 -0
- data/app/views/lookbook/{previews → inspector}/inputs/_text.html.erb +0 -0
- data/app/views/lookbook/{previews → inspector}/inputs/_textarea.html.erb +0 -0
- data/app/views/lookbook/{previews → inspector}/inputs/_toggle.html.erb +3 -3
- data/app/views/lookbook/{previews → inspector}/panels/_content.html.erb +0 -0
- data/app/views/lookbook/{previews → inspector}/panels/_notes.html.erb +0 -0
- data/app/views/lookbook/{previews → inspector}/panels/_output.html.erb +0 -0
- data/app/views/lookbook/{previews → inspector}/panels/_params.html.erb +4 -4
- data/app/views/lookbook/{previews → inspector}/panels/_preview.html.erb +0 -0
- data/app/views/lookbook/{previews → inspector}/panels/_source.html.erb +0 -0
- data/app/views/lookbook/{previews → inspector}/show.html.erb +4 -1
- data/config/app.yml +8 -1
- data/config/inputs.yml +12 -12
- data/config/panels.yml +5 -5
- data/config/routes.rb +5 -5
- data/config/tags.yml +4 -1
- data/lib/lookbook/engine.rb +101 -150
- data/lib/lookbook/file_watcher.rb +47 -0
- data/lib/lookbook/page.rb +15 -16
- data/lib/lookbook/param.rb +99 -0
- data/lib/lookbook/preview.rb +8 -1
- data/lib/lookbook/{preview_controller.rb → preview_actions.rb} +14 -3
- data/lib/lookbook/preview_example.rb +1 -1
- data/lib/lookbook/preview_group.rb +0 -4
- data/lib/lookbook/preview_parser.rb +53 -0
- data/lib/lookbook/process.rb +21 -0
- data/lib/lookbook/services/code/code_beautifier.rb +21 -0
- data/lib/lookbook/services/code/code_highlighter.rb +69 -0
- data/lib/lookbook/services/data/parsers/data_parser.rb +22 -0
- data/lib/lookbook/services/data/parsers/json_parser.rb +7 -0
- data/lib/lookbook/services/data/parsers/yaml_parser.rb +7 -0
- data/lib/lookbook/services/data/resolvers/data_resolver.rb +70 -0
- data/lib/lookbook/services/data/resolvers/eval_resolver.rb +10 -0
- data/lib/lookbook/services/data/resolvers/file_resolver.rb +28 -0
- data/lib/lookbook/services/data/resolvers/method_resolver.rb +10 -0
- data/lib/lookbook/services/data/resolvers/yaml_resolver.rb +18 -0
- data/lib/lookbook/services/markdown_renderer.rb +29 -0
- data/lib/lookbook/services/string_value_caster.rb +60 -0
- data/lib/lookbook/services/tags/tag_options_parser.rb +62 -0
- data/lib/lookbook/services/templates/action_view_annotations_handler.rb +21 -0
- data/lib/lookbook/services/templates/action_view_annotations_stripper.rb +15 -0
- data/lib/lookbook/services/templates/frontmatter_extractor.rb +28 -0
- data/lib/lookbook/services/templates/styles_extractor.rb +38 -0
- data/lib/lookbook/services/{search_param_builder.rb → urls/search_param_builder.rb} +1 -1
- data/lib/lookbook/services/{search_param_parser.rb → urls/search_param_parser.rb} +1 -1
- data/lib/lookbook/source_inspector.rb +26 -45
- data/lib/lookbook/stores/config_store.rb +7 -8
- data/lib/lookbook/stores/input_store.rb +7 -3
- data/lib/lookbook/stores/tag_store.rb +3 -5
- data/lib/lookbook/support/null_object.rb +10 -0
- data/lib/lookbook/support/service.rb +2 -2
- data/lib/lookbook/support/store.rb +1 -1
- data/lib/lookbook/support/utils/attribute_utils.rb +6 -1
- data/lib/lookbook/support/utils/path_utils.rb +6 -3
- data/lib/lookbook/tags/component_tag.rb +7 -0
- data/lib/lookbook/tags/custom_tag.rb +59 -0
- data/lib/lookbook/tags/display_tag.rb +15 -0
- data/lib/lookbook/tags/hidden_tag.rb +13 -0
- data/lib/lookbook/tags/id_tag.rb +7 -0
- data/lib/lookbook/tags/label_tag.rb +4 -0
- data/lib/lookbook/tags/logical_path_tag.rb +4 -0
- data/lib/lookbook/tags/param_tag.rb +61 -0
- data/lib/lookbook/tags/position_tag.rb +16 -0
- data/lib/lookbook/tags/tag_provider.rb +18 -0
- data/lib/lookbook/tags/yard_tag.rb +62 -0
- data/lib/lookbook/utils.rb +0 -40
- data/lib/lookbook/version.rb +1 -1
- data/lib/lookbook/websocket.rb +60 -0
- data/lib/lookbook.rb +2 -1
- data/public/lookbook-assets/css/lookbook.css +30 -77
- data/public/lookbook-assets/css/lookbook.css.map +1 -1
- data/public/lookbook-assets/js/lookbook.js +7 -2
- data/public/lookbook-assets/js/lookbook.js.map +1 -1
- metadata +55 -26
- data/lib/lookbook/code_formatter.rb +0 -68
- data/lib/lookbook/markdown.rb +0 -22
- data/lib/lookbook/params.rb +0 -157
- data/lib/lookbook/parser.rb +0 -42
- data/lib/lookbook/tag.rb +0 -122
- data/lib/lookbook/tag_options.rb +0 -111
- data/lib/lookbook/tags.rb +0 -17
- data/lib/lookbook/template_parser.rb +0 -72
@@ -14,13 +14,15 @@ module Lookbook
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def page_paths=(paths = nil)
|
17
|
-
store[:page_paths]
|
18
|
-
|
17
|
+
store[:page_paths].push(*paths.to_a)
|
18
|
+
end
|
19
|
+
|
20
|
+
def page_extensions=(extensions = nil)
|
21
|
+
store[:page_extensions].push(*extensions.to_a).uniq!
|
19
22
|
end
|
20
23
|
|
21
24
|
def preview_paths=(paths = nil)
|
22
|
-
store[:preview_paths]
|
23
|
-
store[:preview_paths] += paths.to_a
|
25
|
+
store[:preview_paths].push(*paths.to_a)
|
24
26
|
end
|
25
27
|
|
26
28
|
def preview_display_params
|
@@ -34,13 +36,10 @@ module Lookbook
|
|
34
36
|
end
|
35
37
|
|
36
38
|
def listen_extensions=(extensions = nil)
|
37
|
-
store[:listen_extensions]
|
38
|
-
store[:listen_extensions] += extensions.to_a
|
39
|
-
store[:listen_extensions].uniq!
|
39
|
+
store[:listen_extensions].push(*extensions.to_a).uniq!
|
40
40
|
end
|
41
41
|
|
42
42
|
def markdown_options=(options = nil)
|
43
|
-
store[:markdown_options] ||= {}
|
44
43
|
store[:markdown_options].merge!(options.to_h)
|
45
44
|
end
|
46
45
|
|
@@ -18,11 +18,11 @@ module Lookbook
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def add_input(input, *args)
|
21
|
-
store[input
|
21
|
+
store[normalize_name(input)] = build_config(input, *args)
|
22
22
|
end
|
23
23
|
|
24
24
|
def get_input(input)
|
25
|
-
store[input
|
25
|
+
store[normalize_name(input)]
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.init_from_config
|
@@ -35,6 +35,10 @@ module Lookbook
|
|
35
35
|
|
36
36
|
protected
|
37
37
|
|
38
|
+
def normalize_name(name)
|
39
|
+
name.to_s.tr("-", "_").to_sym
|
40
|
+
end
|
41
|
+
|
38
42
|
def build_config(name, *args)
|
39
43
|
partial = nil
|
40
44
|
opts = nil
|
@@ -48,7 +52,7 @@ module Lookbook
|
|
48
52
|
Store.new({
|
49
53
|
name: name.to_sym,
|
50
54
|
partial: partial,
|
51
|
-
|
55
|
+
options: DEFAULTS.merge(opts.to_h)
|
52
56
|
})
|
53
57
|
else
|
54
58
|
raise ConfigError.new("inputs must define a partial path", scope: "inputs.config")
|
@@ -7,7 +7,7 @@ module Lookbook
|
|
7
7
|
|
8
8
|
def initialize(config = nil)
|
9
9
|
@store = {}
|
10
|
-
config.to_h.each { add_tag(
|
10
|
+
config.to_h.each { |k, v| add_tag(k, v) }
|
11
11
|
end
|
12
12
|
|
13
13
|
def add_tag(name, opts = nil)
|
@@ -34,12 +34,10 @@ module Lookbook
|
|
34
34
|
protected
|
35
35
|
|
36
36
|
def build_config(name, opts = nil)
|
37
|
-
opts = opts.to_h
|
38
37
|
Store.new({
|
39
38
|
name: name.to_sym,
|
40
|
-
label:
|
41
|
-
|
42
|
-
opts: opts[:opts].to_h
|
39
|
+
label: name.to_s.titleize,
|
40
|
+
options: opts.to_h
|
43
41
|
})
|
44
42
|
end
|
45
43
|
end
|
@@ -2,7 +2,12 @@ module Lookbook
|
|
2
2
|
module AttributeUtils
|
3
3
|
class << self
|
4
4
|
def dom_id(*args)
|
5
|
-
["lookbook", *args]
|
5
|
+
entity_id(["lookbook", *args])
|
6
|
+
end
|
7
|
+
|
8
|
+
def entity_id(*args)
|
9
|
+
parts = args.map { |arg| arg.to_s.force_encoding("UTF-8").parameterize.dasherize }
|
10
|
+
parts.join("-").tr("/_", "-").delete_prefix("-").delete_suffix("-").gsub("--", "-")
|
6
11
|
end
|
7
12
|
end
|
8
13
|
end
|
@@ -6,14 +6,17 @@ module Lookbook
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def normalize_all(paths, allow_root: false)
|
9
|
-
|
10
|
-
paths.map do |path|
|
9
|
+
Array(paths).map do |path|
|
11
10
|
full_path = to_absolute(path)
|
12
11
|
if Dir.exist?(full_path)
|
13
|
-
full_path if allow_root || full_path
|
12
|
+
full_path if allow_root || !root_path?(full_path)
|
14
13
|
end
|
15
14
|
end.compact.uniq
|
16
15
|
end
|
16
|
+
|
17
|
+
def root_path?(path)
|
18
|
+
Rails.application.root.to_s == path.to_s
|
19
|
+
end
|
17
20
|
end
|
18
21
|
end
|
19
22
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Lookbook
|
2
|
+
class CustomTag < YardTag
|
3
|
+
attr_reader :arg_names, :tag_args
|
4
|
+
|
5
|
+
def initialize(tag_name, text = nil, *args)
|
6
|
+
tag_definition = Engine.tags.get_tag(tag_name)
|
7
|
+
unless tag_definition
|
8
|
+
raise ParserError.new "Unknown custom tag type '#{tag_name}'"
|
9
|
+
end
|
10
|
+
|
11
|
+
super(tag_name, text.to_s, *args)
|
12
|
+
|
13
|
+
@custom_attributes = Store.new
|
14
|
+
@arg_names = tag_definition.options.fetch(:named_args, [])
|
15
|
+
@after_parse = tag_definition.options.fetch(:after_parse, nil)
|
16
|
+
|
17
|
+
validate_arg_names
|
18
|
+
|
19
|
+
@tag_args = parse_tag
|
20
|
+
@after_parse.call(self) if @after_parse.respond_to?(:call)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Method aliases to keep compatability with
|
24
|
+
# the original custom tag implementation
|
25
|
+
alias_method :tag_body, :text
|
26
|
+
alias_method :opts, :options
|
27
|
+
|
28
|
+
protected
|
29
|
+
|
30
|
+
def parse_tag
|
31
|
+
text_tokens = Shellwords.split(text)
|
32
|
+
values = text_tokens.slice(0, arg_names.size)
|
33
|
+
|
34
|
+
arg_names.map.with_index do |name, i|
|
35
|
+
[name.to_sym, values[i]]
|
36
|
+
end.to_h
|
37
|
+
end
|
38
|
+
|
39
|
+
def validate_arg_names
|
40
|
+
arg_names.each do |name|
|
41
|
+
if methods.include? name.to_sym
|
42
|
+
raise ParserError.new "'#{name}' is a reserved word and cannot be used as an argument name."
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def method_missing(name, *args)
|
48
|
+
if name.end_with? "="
|
49
|
+
@custom_attributes[name.to_s.chomp("=")] = args.first
|
50
|
+
else
|
51
|
+
@custom_attributes.public_send(name, *args) || tag_args[name]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def respond_to_missing?(name, include_private)
|
56
|
+
@custom_attributes.key?(name) || tag_args.key?(name) || super
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Lookbook
|
2
|
+
class ParamTag < YardTag
|
3
|
+
VALUE_TYPE_MATCHER = /^(\[\s?([A-Z]{1}\w+)\s?\])/
|
4
|
+
DESCRIPTION_MATCHER = /"(.*[^\\])"$/
|
5
|
+
|
6
|
+
attr_reader :tag_args
|
7
|
+
|
8
|
+
def initialize(text)
|
9
|
+
@name, text_without_name = extract_name(text)
|
10
|
+
@tag_args = parse_tag_body(text_without_name)
|
11
|
+
super("param", tag_args[:rest], nil, @name)
|
12
|
+
end
|
13
|
+
|
14
|
+
def input
|
15
|
+
tag_args[:input]&.downcase&.tr("_", "-")
|
16
|
+
end
|
17
|
+
|
18
|
+
def description
|
19
|
+
tag_args[:description]
|
20
|
+
end
|
21
|
+
|
22
|
+
def value_type
|
23
|
+
tag_args[:value_type]&.downcase
|
24
|
+
end
|
25
|
+
|
26
|
+
def value_default
|
27
|
+
default_value_parts = object.parameters.find { |parts| parts[0].chomp(":") == name }
|
28
|
+
if default_value_parts
|
29
|
+
object.instance_eval(default_value_parts[1])
|
30
|
+
else
|
31
|
+
raise ParserError.new "Unknown method parameter '#{name}'"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
protected
|
36
|
+
|
37
|
+
def extract_name(text)
|
38
|
+
parts = text.to_s.split(" ")
|
39
|
+
[parts.shift, parts.join(" ")]
|
40
|
+
end
|
41
|
+
|
42
|
+
def parse_tag_body(text)
|
43
|
+
value_type = nil
|
44
|
+
description = nil
|
45
|
+
|
46
|
+
text.match(VALUE_TYPE_MATCHER) do |match_data|
|
47
|
+
value_type = match_data[2]
|
48
|
+
text.gsub!(VALUE_TYPE_MATCHER, "").strip!
|
49
|
+
end
|
50
|
+
|
51
|
+
text.match(DESCRIPTION_MATCHER) do |match_data|
|
52
|
+
description = match_data[1]
|
53
|
+
text.gsub!(DESCRIPTION_MATCHER, "").strip!
|
54
|
+
end
|
55
|
+
|
56
|
+
input, rest = text.split(" ", 2)
|
57
|
+
|
58
|
+
{input: input, value_type: value_type, description: description, rest: rest}
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Lookbook
|
2
|
+
class TagProvider < ::YARD::Tags::Tag
|
3
|
+
def self.new(tag_name, text, types = nil, name = nil)
|
4
|
+
tag_name = tag_name.to_s
|
5
|
+
|
6
|
+
if tag_name == "custom"
|
7
|
+
raise NameError.new "'custom' is a reserved tag name and cannot be used"
|
8
|
+
end
|
9
|
+
|
10
|
+
begin
|
11
|
+
tag_class = "Lookbook::#{tag_name.camelize}Tag".constantize
|
12
|
+
tag_class.new(text)
|
13
|
+
rescue NameError
|
14
|
+
CustomTag.new(tag_name, text)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Lookbook
|
2
|
+
class YardTag < ::YARD::Tags::Tag
|
3
|
+
def initialize(*args)
|
4
|
+
if args.size < 2
|
5
|
+
tag_name = self.class.name.demodulize.underscore.chomp("_tag")
|
6
|
+
super(tag_name, args.first, nil, @name)
|
7
|
+
else
|
8
|
+
super(*args)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def text
|
13
|
+
tag_parts[:text]
|
14
|
+
end
|
15
|
+
|
16
|
+
def options
|
17
|
+
tag_parts[:options]
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_s
|
21
|
+
value.to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
# The `value` attribute should be overriden in child classes
|
25
|
+
# to return the resolved value of the tag, where appropriate.
|
26
|
+
# i.e. for the @hidden tag this would return boolean true/false.
|
27
|
+
alias_method :value, :text
|
28
|
+
|
29
|
+
protected
|
30
|
+
|
31
|
+
def tag_parts
|
32
|
+
if @tag_parts.nil?
|
33
|
+
options, text = TagOptionsParser.call(@text, {
|
34
|
+
file: host_file,
|
35
|
+
base_dir: (File.dirname(host_file) if host_file),
|
36
|
+
eval_context: host_class_instance,
|
37
|
+
permit_eval: Lookbook.config.preview_params_options_eval
|
38
|
+
})
|
39
|
+
end
|
40
|
+
@tag_parts ||= {options: options, text: text}
|
41
|
+
end
|
42
|
+
|
43
|
+
def host_file
|
44
|
+
location = object&.files&.first # [file, line_number]
|
45
|
+
location&.first
|
46
|
+
end
|
47
|
+
|
48
|
+
def host_class_instance
|
49
|
+
host_class = lookup_host_class
|
50
|
+
host_class&.new
|
51
|
+
end
|
52
|
+
|
53
|
+
def lookup_host_class
|
54
|
+
host_code_object = if object.is_a?(YARD::CodeObjects::MethodObject)
|
55
|
+
object.parent
|
56
|
+
elsif object.is_a?(YARD::CodeObjects::ClassObject)
|
57
|
+
object
|
58
|
+
end
|
59
|
+
host_code_object&.path&.constantize
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/lookbook/utils.rb
CHANGED
@@ -4,29 +4,6 @@ module Lookbook
|
|
4
4
|
|
5
5
|
POSITION_PREFIX_REGEX = /^(\d+?)[-_]/
|
6
6
|
FRONTMATTER_REGEX = /\A---(.|\n)*?---/
|
7
|
-
ACTION_VIEW_ANNOTATIONS_REGEX = /<!-- (BEGIN|END) (.*) -->/
|
8
|
-
|
9
|
-
def self.strip_action_view_annotations!(text)
|
10
|
-
text&.gsub!(ACTION_VIEW_ANNOTATIONS_REGEX, "")
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.without_action_view_annotations
|
14
|
-
original_value = ActionView::Base.annotate_rendered_view_with_filenames
|
15
|
-
ActionView::Base.annotate_rendered_view_with_filenames = false
|
16
|
-
res = yield
|
17
|
-
ActionView::Base.annotate_rendered_view_with_filenames = original_value
|
18
|
-
res
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.with_optional_action_view_annotations
|
22
|
-
if ActionView::Base.respond_to?(:annotate_rendered_view_with_filenames) && Lookbook.config.preview_disable_action_view_annotations
|
23
|
-
without_action_view_annotations do
|
24
|
-
yield
|
25
|
-
end
|
26
|
-
else
|
27
|
-
yield
|
28
|
-
end
|
29
|
-
end
|
30
7
|
|
31
8
|
protected
|
32
9
|
|
@@ -59,14 +36,6 @@ module Lookbook
|
|
59
36
|
parse_position_prefix(str).last
|
60
37
|
end
|
61
38
|
|
62
|
-
def get_frontmatter(str)
|
63
|
-
parse_frontmatter(str).first
|
64
|
-
end
|
65
|
-
|
66
|
-
def strip_frontmatter(str)
|
67
|
-
parse_frontmatter(str).last
|
68
|
-
end
|
69
|
-
|
70
39
|
def to_lookup_path(path)
|
71
40
|
path.split("/").map { |segment| remove_position_prefix(segment) }.join("/")
|
72
41
|
end
|
@@ -83,15 +52,6 @@ module Lookbook
|
|
83
52
|
|
84
53
|
private
|
85
54
|
|
86
|
-
def parse_frontmatter(content)
|
87
|
-
frontmatter = content.match(FRONTMATTER_REGEX)
|
88
|
-
if frontmatter.nil?
|
89
|
-
[{}, content]
|
90
|
-
else
|
91
|
-
[YAML.safe_load(frontmatter[0]), content.gsub(FRONTMATTER_REGEX, "")]
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
55
|
def parse_position_prefix(str)
|
96
56
|
pos = str.match(POSITION_PREFIX_REGEX)
|
97
57
|
if pos.nil?
|
data/lib/lookbook/version.rb
CHANGED
@@ -0,0 +1,60 @@
|
|
1
|
+
module Lookbook
|
2
|
+
class Websocket
|
3
|
+
attr_reader :engine_mount_path, :server, :logger
|
4
|
+
|
5
|
+
def initialize(engine_mount_path, logger: Lookbook.logger)
|
6
|
+
@engine_mount_path = engine_mount_path
|
7
|
+
@logger = logger
|
8
|
+
|
9
|
+
logger.info "Initializing websocket"
|
10
|
+
|
11
|
+
if Gem::Version.new(Rails.version) >= Gem::Version.new(6.0)
|
12
|
+
@server = ActionCable::Server::Base.new config: cable_config
|
13
|
+
else
|
14
|
+
@server = ActionCable::Server::Base.new
|
15
|
+
@server.config = cable_config
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def broadcast(message, payload = nil)
|
20
|
+
logger.debug message.to_s
|
21
|
+
server.broadcast(message.to_s, payload.to_h)
|
22
|
+
end
|
23
|
+
|
24
|
+
def mount_path
|
25
|
+
"/cable"
|
26
|
+
end
|
27
|
+
|
28
|
+
def full_mount_path
|
29
|
+
"#{engine_mount_path}/#{mount_path}".gsub("//", "/")
|
30
|
+
end
|
31
|
+
|
32
|
+
def mountable?
|
33
|
+
true
|
34
|
+
end
|
35
|
+
|
36
|
+
alias_method :mounted?, :mountable?
|
37
|
+
|
38
|
+
def self.noop
|
39
|
+
NullWebsocket.new
|
40
|
+
end
|
41
|
+
|
42
|
+
protected
|
43
|
+
|
44
|
+
def cable_config
|
45
|
+
cable = ActionCable::Server::Configuration.new
|
46
|
+
cable.cable = {adapter: "async"}.with_indifferent_access
|
47
|
+
cable.mount_path = nil
|
48
|
+
cable.connection_class = -> { Lookbook::Connection }
|
49
|
+
cable.logger = logger
|
50
|
+
cable
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class NullWebsocket < NullObject
|
55
|
+
def mountable?
|
56
|
+
false
|
57
|
+
end
|
58
|
+
alias_method :mounted?, :mountable?
|
59
|
+
end
|
60
|
+
end
|
data/lib/lookbook.rb
CHANGED
@@ -6,6 +6,7 @@ loader.ignore("#{__dir__}/lookbook.rb")
|
|
6
6
|
loader.push_dir("#{__dir__}/lookbook", namespace: Lookbook)
|
7
7
|
loader.collapse("#{__dir__}/lookbook/*")
|
8
8
|
loader.collapse("#{__dir__}/lookbook/*/*")
|
9
|
+
loader.collapse("#{__dir__}/lookbook/*/*/*")
|
9
10
|
loader.setup
|
10
11
|
|
11
12
|
module Lookbook
|
@@ -88,7 +89,7 @@ module Lookbook
|
|
88
89
|
def define_tag(name, args = nil, &block)
|
89
90
|
Engine.tags.add_tag(name, {
|
90
91
|
named_args: args.to_a,
|
91
|
-
|
92
|
+
after_parse: block
|
92
93
|
})
|
93
94
|
end
|
94
95
|
|