docks_app 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.editorconfig +8 -0
- data/.gitignore +22 -0
- data/.rubocop.yml +20 -0
- data/.travis.yml +10 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +35 -0
- data/Rakefile +3 -0
- data/bin/docks +5 -0
- data/config/json/docks_config.json +71 -0
- data/config/ruby/docks_config.rb +127 -0
- data/config/yaml/docks_config.yml +70 -0
- data/docks.gemspec +38 -0
- data/lib/docks/build.rb +300 -0
- data/lib/docks/cache.rb +143 -0
- data/lib/docks/command_line.rb +65 -0
- data/lib/docks/configuration.rb +217 -0
- data/lib/docks/containers/base_container.rb +103 -0
- data/lib/docks/containers/class_container.rb +39 -0
- data/lib/docks/containers/component_container.rb +92 -0
- data/lib/docks/containers/demo_container.rb +105 -0
- data/lib/docks/containers/factory_container.rb +12 -0
- data/lib/docks/containers/function_container.rb +46 -0
- data/lib/docks/containers/mixin_container.rb +19 -0
- data/lib/docks/containers/pattern_container.rb +168 -0
- data/lib/docks/containers/pattern_library_container.rb +77 -0
- data/lib/docks/containers/state_container.rb +9 -0
- data/lib/docks/containers/symbol_container.rb +77 -0
- data/lib/docks/containers/variable_container.rb +47 -0
- data/lib/docks/containers/variant_container.rb +9 -0
- data/lib/docks/containers/variation_container.rb +38 -0
- data/lib/docks/containers.rb +25 -0
- data/lib/docks/descriptor.rb +60 -0
- data/lib/docks/errors.rb +5 -0
- data/lib/docks/group.rb +66 -0
- data/lib/docks/helpers/github_helper.rb +29 -0
- data/lib/docks/helpers/path_helper.rb +94 -0
- data/lib/docks/helpers/render_helper.rb +87 -0
- data/lib/docks/helpers.rb +19 -0
- data/lib/docks/languages/base_language.rb +17 -0
- data/lib/docks/languages/coffeescript_language.rb +30 -0
- data/lib/docks/languages/common_types/markup_language.rb +71 -0
- data/lib/docks/languages/css_language.rb +13 -0
- data/lib/docks/languages/erb_language.rb +21 -0
- data/lib/docks/languages/haml_language.rb +21 -0
- data/lib/docks/languages/html_language.rb +10 -0
- data/lib/docks/languages/javascript_language.rb +42 -0
- data/lib/docks/languages/json_language.rb +18 -0
- data/lib/docks/languages/less_language.rb +33 -0
- data/lib/docks/languages/markdown_language.rb +10 -0
- data/lib/docks/languages/sass_language.rb +36 -0
- data/lib/docks/languages/slim_language.rb +21 -0
- data/lib/docks/languages/stylus_language.rb +26 -0
- data/lib/docks/languages/yaml_language.rb +18 -0
- data/lib/docks/languages.rb +103 -0
- data/lib/docks/markdown.rb +18 -0
- data/lib/docks/messenger.rb +69 -0
- data/lib/docks/naming_conventions/base_naming_convention.rb +9 -0
- data/lib/docks/naming_conventions/bem_naming_convention.rb +45 -0
- data/lib/docks/naming_conventions/suit_naming_convention.rb +45 -0
- data/lib/docks/naming_conventions.rb +21 -0
- data/lib/docks/ostruct.rb +17 -0
- data/lib/docks/parser.rb +86 -0
- data/lib/docks/parsers/base_parser.rb +128 -0
- data/lib/docks/parsers/coffeescript_parser.rb +30 -0
- data/lib/docks/parsers/css_parser.rb +27 -0
- data/lib/docks/parsers/javascript_parser.rb +30 -0
- data/lib/docks/parsers/less_parser.rb +22 -0
- data/lib/docks/parsers/sass_parser.rb +31 -0
- data/lib/docks/parsers/stylus_parser.rb +28 -0
- data/lib/docks/process.rb +60 -0
- data/lib/docks/processors.rb +416 -0
- data/lib/docks/renderers/base_renderer.rb +64 -0
- data/lib/docks/renderers/common_features/capturable.rb +69 -0
- data/lib/docks/renderers/common_features/helperable.rb +23 -0
- data/lib/docks/renderers/erb_renderer.rb +68 -0
- data/lib/docks/renderers/haml_renderer.rb +37 -0
- data/lib/docks/renderers/slim_renderer.rb +33 -0
- data/lib/docks/symbol_sources/base_symbol_source.rb +12 -0
- data/lib/docks/symbol_sources/jquery_symbol_source.rb +17 -0
- data/lib/docks/symbol_sources/mdn_symbol_source.rb +35 -0
- data/lib/docks/symbol_sources/sass_symbol_source.rb +27 -0
- data/lib/docks/symbol_sources.rb +28 -0
- data/lib/docks/tags/access_tag.rb +27 -0
- data/lib/docks/tags/activate_with_tag.rb +17 -0
- data/lib/docks/tags/active_tag.rb +14 -0
- data/lib/docks/tags/alias_tag.rb +17 -0
- data/lib/docks/tags/author_tag.rb +19 -0
- data/lib/docks/tags/base_tag.rb +52 -0
- data/lib/docks/tags/beta_tag.rb +26 -0
- data/lib/docks/tags/class_tag.rb +16 -0
- data/lib/docks/tags/compatibility_tag.rb +19 -0
- data/lib/docks/tags/demo_type_tag.rb +14 -0
- data/lib/docks/tags/deprecated_tag.rb +26 -0
- data/lib/docks/tags/description_tag.rb +99 -0
- data/lib/docks/tags/example_tag.rb +20 -0
- data/lib/docks/tags/factory_tag.rb +16 -0
- data/lib/docks/tags/for_tag.rb +23 -0
- data/lib/docks/tags/group_tag.rb +10 -0
- data/lib/docks/tags/helper_tag.rb +13 -0
- data/lib/docks/tags/include_with_tag.rb +57 -0
- data/lib/docks/tags/javascript_action_tag.rb +10 -0
- data/lib/docks/tags/link_tag.rb +18 -0
- data/lib/docks/tags/markup_tag.rb +106 -0
- data/lib/docks/tags/member_tag.rb +37 -0
- data/lib/docks/tags/method_tag.rb +18 -0
- data/lib/docks/tags/name_tag.rb +10 -0
- data/lib/docks/tags/object_tag.rb +15 -0
- data/lib/docks/tags/param_tag.rb +94 -0
- data/lib/docks/tags/pattern_tag.rb +21 -0
- data/lib/docks/tags/preclude_tag.rb +17 -0
- data/lib/docks/tags/private_tag.rb +15 -0
- data/lib/docks/tags/property_tag.rb +18 -0
- data/lib/docks/tags/public_tag.rb +15 -0
- data/lib/docks/tags/require_tag.rb +47 -0
- data/lib/docks/tags/returns_tag.rb +31 -0
- data/lib/docks/tags/set_by_tag.rb +18 -0
- data/lib/docks/tags/signature_tag.rb +35 -0
- data/lib/docks/tags/since_tag.rb +26 -0
- data/lib/docks/tags/source_tag.rb +12 -0
- data/lib/docks/tags/state_tag.rb +21 -0
- data/lib/docks/tags/static_tag.rb +14 -0
- data/lib/docks/tags/subcomponent_tag.rb +68 -0
- data/lib/docks/tags/subtitle_tag.rb +11 -0
- data/lib/docks/tags/symbol_type_tag.rb +10 -0
- data/lib/docks/tags/throws_tag.rb +30 -0
- data/lib/docks/tags/title_tag.rb +10 -0
- data/lib/docks/tags/type_tag.rb +10 -0
- data/lib/docks/tags/value_tag.rb +10 -0
- data/lib/docks/tags/variant_tag.rb +21 -0
- data/lib/docks/tags/variation_tag.rb +136 -0
- data/lib/docks/tags.rb +103 -0
- data/lib/docks/templates.rb +122 -0
- data/lib/docks/themes.rb +19 -0
- data/lib/docks/types.rb +26 -0
- data/lib/docks/version.rb +3 -0
- data/lib/docks.rb +37 -0
- data/spec/fixtures/build/scripts/bar/bar_2.js +1 -0
- data/spec/fixtures/build/scripts/bar.js +1 -0
- data/spec/fixtures/build/styles/foo/foo-2.css +1 -0
- data/spec/fixtures/build/styles/foo.css +1 -0
- data/spec/fixtures/build/templates/baz/baz_2.erb +1 -0
- data/spec/fixtures/build/templates/baz.erb +1 -0
- data/spec/fixtures/grouper/components/button/button.coffee +0 -0
- data/spec/fixtures/grouper/components/button/button.haml +0 -0
- data/spec/fixtures/grouper/components/button/button.scss +0 -0
- data/spec/fixtures/grouper/components/checkbox/_checkbox.haml +0 -0
- data/spec/fixtures/grouper/components/checkbox/_checkbox.scss +0 -0
- data/spec/fixtures/grouper/components/checkbox/checkbox.coffee +0 -0
- data/spec/fixtures/grouper/components/form/form.coffee +0 -0
- data/spec/fixtures/grouper/components/form/form.m +0 -0
- data/spec/fixtures/grouper/components/form/form.scss +0 -0
- data/spec/fixtures/grouper/components/next-expanding-textarea/_next-expanding-textarea.scss +0 -0
- data/spec/fixtures/grouper/components/next-expanding-textarea/_next_expanding_textarea.coffee +0 -0
- data/spec/fixtures/grouper/components/next-expanding-textarea/next-expanding-textarea.haml +0 -0
- data/spec/fixtures/grouper/components/next-tab/next-tab.coffee +0 -0
- data/spec/fixtures/grouper/components/next-tab/next-tab.haml +0 -0
- data/spec/fixtures/grouper/components/next-tab/next-tab.scss +0 -0
- data/spec/fixtures/grouper/components/segmented control/segmented control.coffee +0 -0
- data/spec/fixtures/grouper/components/segmented control/segmented control.haml +0 -0
- data/spec/fixtures/grouper/components/segmented control/segmented control.min.html +0 -0
- data/spec/fixtures/grouper/components/segmented control/segmented control.scss +0 -0
- data/spec/fixtures/grouper/markup/list-view.haml +0 -0
- data/spec/fixtures/grouper/markup/resizable/resizable.haml +0 -0
- data/spec/fixtures/grouper/markup/toggle.haml +0 -0
- data/spec/fixtures/grouper/scripts/resizable/resizable.coffee +0 -0
- data/spec/fixtures/grouper/scripts/toggle.coffee +0 -0
- data/spec/fixtures/grouper/style/_list-view.scss +0 -0
- data/spec/fixtures/grouper/style/_toggle.scss +0 -0
- data/spec/fixtures/languages/stub.json +3 -0
- data/spec/fixtures/languages/stub.yml +2 -0
- data/spec/fixtures/parsers/coffeescript_parser_fixture_basic.coffee +20 -0
- data/spec/fixtures/parsers/coffeescript_parser_fixture_complex.coffee +80 -0
- data/spec/fixtures/parsers/css_parser_fixture_basic.css +44 -0
- data/spec/fixtures/parsers/css_parser_fixture_complex.css +120 -0
- data/spec/fixtures/parsers/javascript_parser_fixture_basic.js +27 -0
- data/spec/fixtures/parsers/javascript_parser_fixture_complex.js +85 -0
- data/spec/fixtures/parsers/sass_parser_fixture_basic.scss +39 -0
- data/spec/fixtures/parsers/sass_parser_fixture_complex.scss +149 -0
- data/spec/fixtures/parsers/stylus_parser_fixture_basic.styl +34 -0
- data/spec/fixtures/parsers/stylus_parser_fixture_complex.styl +113 -0
- data/spec/fixtures/processors/join_with_smart_line_breaks/code_blocks.txt +10 -0
- data/spec/fixtures/processors/join_with_smart_line_breaks/headings.txt +15 -0
- data/spec/fixtures/processors/join_with_smart_line_breaks/lists.txt +21 -0
- data/spec/fixtures/processors/join_with_smart_line_breaks/lists_with_nesting.txt +13 -0
- data/spec/fixtures/processors/join_with_smart_line_breaks/multiple_paragraphs.txt +11 -0
- data/spec/fixtures/renderers/helpers.rb +37 -0
- data/spec/fixtures/renderers/html_output.html +7 -0
- data/spec/fixtures/renderers/templates/layouts/application.html.erb +0 -0
- data/spec/fixtures/renderers/templates/layouts/more/subdirectory.html.erb +0 -0
- data/spec/fixtures/renderers/templates/partials/_leading_underscore.html.erb +1 -0
- data/spec/fixtures/renderers/templates/partials/more/_subdirectory.html.erb +1 -0
- data/spec/fixtures/renderers/templates/partials/partial.html.erb +0 -0
- data/spec/fixtures/renderers/templates/partials/template.html.erb +1 -0
- data/spec/fixtures/renderers/templates/template.html.erb +1 -0
- data/spec/fixtures/tags/description/button.md +24 -0
- data/spec/fixtures/tags/description/class.md +27 -0
- data/spec/fixtures/tags/description/component.md +23 -0
- data/spec/fixtures/tags/description/function.md +30 -0
- data/spec/lib/build_spec.rb +467 -0
- data/spec/lib/cache_spec.rb +175 -0
- data/spec/lib/command_line_spec.rb +77 -0
- data/spec/lib/configuration_spec.rb +180 -0
- data/spec/lib/containers/base_container_spec.rb +214 -0
- data/spec/lib/containers/class_container_spec.rb +209 -0
- data/spec/lib/containers/component_container_spec.rb +158 -0
- data/spec/lib/containers/demo_container_spec.rb +113 -0
- data/spec/lib/containers/function_container_spec.rb +116 -0
- data/spec/lib/containers/mixin_container_spec.rb +4 -0
- data/spec/lib/containers/pattern_container_spec.rb +291 -0
- data/spec/lib/containers/pattern_library_container_spec.rb +130 -0
- data/spec/lib/containers/symbol_container_spec.rb +216 -0
- data/spec/lib/containers/variable_container_spec.rb +116 -0
- data/spec/lib/containers/variation_container_spec.rb +52 -0
- data/spec/lib/containers_spec.rb +22 -0
- data/spec/lib/descriptor_spec.rb +73 -0
- data/spec/lib/group_spec.rb +151 -0
- data/spec/lib/helpers/path_helper_spec.rb +202 -0
- data/spec/lib/helpers/render_helper_spec.rb +159 -0
- data/spec/lib/helpers_spec.rb +35 -0
- data/spec/lib/languages/base_language_spec.rb +32 -0
- data/spec/lib/languages/coffeescript_language_spec.rb +52 -0
- data/spec/lib/languages/css_language_spec.rb +13 -0
- data/spec/lib/languages/erb_language_spec.rb +33 -0
- data/spec/lib/languages/haml_language_spec.rb +32 -0
- data/spec/lib/languages/javascript_language_spec.rb +54 -0
- data/spec/lib/languages/json_language_spec.rb +24 -0
- data/spec/lib/languages/less_language_spec.rb +39 -0
- data/spec/lib/languages/markup_language_spec.rb +95 -0
- data/spec/lib/languages/sass_language_spec.rb +53 -0
- data/spec/lib/languages/slim_language_spec.rb +32 -0
- data/spec/lib/languages/stylus_language_spec.rb +34 -0
- data/spec/lib/languages/yaml_language_spec.rb +24 -0
- data/spec/lib/languages_spec.rb +127 -0
- data/spec/lib/markdown_spec.rb +63 -0
- data/spec/lib/messenger_spec.rb +1 -0
- data/spec/lib/naming_conventions/bem_naming_convention_spec.rb +112 -0
- data/spec/lib/naming_conventions/suit_naming_convention_spec.rb +107 -0
- data/spec/lib/naming_conventions_spec.rb +28 -0
- data/spec/lib/ostruct_spec.rb +15 -0
- data/spec/lib/parser_spec.rb +93 -0
- data/spec/lib/parsers/base_parser_spec.rb +128 -0
- data/spec/lib/parsers/coffeescript_parser_spec.rb +184 -0
- data/spec/lib/parsers/css_parser_spec.rb +136 -0
- data/spec/lib/parsers/javascript_parser_spec.rb +216 -0
- data/spec/lib/parsers/less_parser_spec.rb +111 -0
- data/spec/lib/parsers/sass_parser_spec.rb +233 -0
- data/spec/lib/parsers/stylus_parser_spec.rb +212 -0
- data/spec/lib/process_spec.rb +96 -0
- data/spec/lib/processors_spec.rb +555 -0
- data/spec/lib/renderers/base_renderer_spec.rb +122 -0
- data/spec/lib/renderers/common_features/helperable_spec.rb +30 -0
- data/spec/lib/renderers/erb_renderer_spec.rb +119 -0
- data/spec/lib/renderers/haml_renderer_spec.rb +103 -0
- data/spec/lib/renderers/slim_renderer_spec.rb +103 -0
- data/spec/lib/symbol_sources/jquery_symbol_source_spec.rb +25 -0
- data/spec/lib/symbol_sources/mdn_symbol_source_spec.rb +40 -0
- data/spec/lib/symbol_sources/sass_symbol_source_spec.rb +39 -0
- data/spec/lib/symbol_sources_spec.rb +19 -0
- data/spec/lib/tags/access_tag_spec.rb +32 -0
- data/spec/lib/tags/activate_with_tag_spec.rb +31 -0
- data/spec/lib/tags/active_tag_spec.rb +24 -0
- data/spec/lib/tags/alias_tag_spec.rb +31 -0
- data/spec/lib/tags/author_tag_spec.rb +172 -0
- data/spec/lib/tags/base_tag_spec.rb +21 -0
- data/spec/lib/tags/beta_tag_spec.rb +52 -0
- data/spec/lib/tags/class_tag_spec.rb +29 -0
- data/spec/lib/tags/compatibility_tag_spec.rb +159 -0
- data/spec/lib/tags/demo_type_tag_spec.rb +24 -0
- data/spec/lib/tags/deprecated_tag_spec.rb +50 -0
- data/spec/lib/tags/description_tag_spec.rb +242 -0
- data/spec/lib/tags/example_tag_spec.rb +37 -0
- data/spec/lib/tags/factory_tag_spec.rb +29 -0
- data/spec/lib/tags/for_tag_spec.rb +45 -0
- data/spec/lib/tags/group_tag_spec.rb +20 -0
- data/spec/lib/tags/helper_tag_spec.rb +22 -0
- data/spec/lib/tags/include_with_tag_spec.rb +74 -0
- data/spec/lib/tags/javascript_action_tag_spec.rb +20 -0
- data/spec/lib/tags/link_tag_spec.rb +49 -0
- data/spec/lib/tags/markup_tag_spec.rb +255 -0
- data/spec/lib/tags/member_tag_spec.rb +167 -0
- data/spec/lib/tags/method_tag_spec.rb +27 -0
- data/spec/lib/tags/name_tag_spec.rb +20 -0
- data/spec/lib/tags/object_tag_spec.rb +24 -0
- data/spec/lib/tags/param_tag_spec.rb +261 -0
- data/spec/lib/tags/pattern_tag_spec.rb +49 -0
- data/spec/lib/tags/preclude_tag_spec.rb +31 -0
- data/spec/lib/tags/private_tag_spec.rb +31 -0
- data/spec/lib/tags/property_tag_spec.rb +27 -0
- data/spec/lib/tags/public_tag_spec.rb +29 -0
- data/spec/lib/tags/require_tag_spec.rb +133 -0
- data/spec/lib/tags/returns_tag_spec.rb +85 -0
- data/spec/lib/tags/set_by_tag_spec.rb +92 -0
- data/spec/lib/tags/signature_tag_spec.rb +125 -0
- data/spec/lib/tags/since_tag_spec.rb +48 -0
- data/spec/lib/tags/state_tag_spec.rb +199 -0
- data/spec/lib/tags/static_tag_spec.rb +27 -0
- data/spec/lib/tags/subcomponent_tag_spec.rb +78 -0
- data/spec/lib/tags/subtitle_tag_spec.rb +13 -0
- data/spec/lib/tags/symbol_type_tag_spec.rb +20 -0
- data/spec/lib/tags/throws_tag_spec.rb +49 -0
- data/spec/lib/tags/title_tag_spec.rb +20 -0
- data/spec/lib/tags/type_tag_spec.rb +20 -0
- data/spec/lib/tags/value_tag_spec.rb +20 -0
- data/spec/lib/tags/variant_tag_spec.rb +13 -0
- data/spec/lib/tags/variation_tag_spec.rb +154 -0
- data/spec/lib/tags_spec.rb +264 -0
- data/spec/lib/templates_spec.rb +185 -0
- data/spec/lib/themes_spec.rb +32 -0
- data/spec/spec_helper.rb +34 -0
- data/tasks/rspec.rake +7 -0
- data/tasks/rubocop.rake +8 -0
- metadata +740 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative "variation_tag.rb"
|
2
|
+
|
3
|
+
module Docks
|
4
|
+
module Tags
|
5
|
+
class State < Variation
|
6
|
+
def initialize
|
7
|
+
@name = :state
|
8
|
+
@parseable = true
|
9
|
+
@synonyms = [:states]
|
10
|
+
@multiple_allowed = true
|
11
|
+
end
|
12
|
+
|
13
|
+
def process(symbol)
|
14
|
+
symbol[@name].map! do |state|
|
15
|
+
state = break_apart_variation_details(state)
|
16
|
+
Containers::State.new(state)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module Docks
|
2
|
+
module Tags
|
3
|
+
class Subcomponent < Base
|
4
|
+
def initialize
|
5
|
+
@name = :subcomponent
|
6
|
+
@multiple_allowed = true
|
7
|
+
@parseable = false
|
8
|
+
end
|
9
|
+
|
10
|
+
def setup_post_processors
|
11
|
+
after_each_pattern(:middle) do |pattern|
|
12
|
+
join_subcomponents_to_parent(pattern)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def join_subcomponents_to_parent(pattern)
|
19
|
+
@components = pattern.components.dup
|
20
|
+
@new_components = []
|
21
|
+
|
22
|
+
@components.each do |component|
|
23
|
+
parent_component = find_parent_component(component)
|
24
|
+
next if parent_component.nil?
|
25
|
+
|
26
|
+
parent_component.subcomponents << component unless parent_component.subcomponents.include?(component)
|
27
|
+
pattern.remove(component)
|
28
|
+
end
|
29
|
+
|
30
|
+
pattern.add(:style, @new_components)
|
31
|
+
@components = @new_components = nil
|
32
|
+
pattern
|
33
|
+
end
|
34
|
+
|
35
|
+
def find_parent_component(component)
|
36
|
+
parent_component_name = Docks.config.naming_convention.parent_component(component.name)
|
37
|
+
return if parent_component_name == component.name
|
38
|
+
|
39
|
+
created_component = false
|
40
|
+
parent_component = nil
|
41
|
+
(@components + @new_components).each do |possible_parent|
|
42
|
+
parent_component = possible_parent.find(parent_component_name)
|
43
|
+
break if parent_component
|
44
|
+
end
|
45
|
+
|
46
|
+
unless parent_component
|
47
|
+
parent_component = Containers::Component.new(name: parent_component_name)
|
48
|
+
created_component = true
|
49
|
+
end
|
50
|
+
|
51
|
+
# Create all necessary ancestors
|
52
|
+
last_parent = parent_component
|
53
|
+
grandparent = find_parent_component(parent_component)
|
54
|
+
|
55
|
+
if created_component && grandparent.nil? && !@new_components.include?(parent_component)
|
56
|
+
@new_components << parent_component
|
57
|
+
end
|
58
|
+
|
59
|
+
loop do
|
60
|
+
break if grandparent.nil? || grandparent.subcomponents.include?(last_parent)
|
61
|
+
grandparent.subcomponents << last_parent
|
62
|
+
grandparent = find_parent_component(grandparent)
|
63
|
+
end
|
64
|
+
parent_component
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Docks
|
2
|
+
module Tags
|
3
|
+
class Throws < Base
|
4
|
+
def initialize
|
5
|
+
@name = :throws
|
6
|
+
@synonyms = [:throw, :exception]
|
7
|
+
@multiple_allowed = true
|
8
|
+
end
|
9
|
+
|
10
|
+
def process(symbol)
|
11
|
+
symbol.update(@name) do |throws|
|
12
|
+
Array(throws).map do |a_throw|
|
13
|
+
a_throw = multiline_description(a_throw) do |first_line|
|
14
|
+
if match = first_line.match(/\s*\{(?<type>[^\}]*)\}(?:\s*\-?\s*(?<description>.*))?/)
|
15
|
+
description = match[:description]
|
16
|
+
|
17
|
+
{
|
18
|
+
types: split_types(match[:type]),
|
19
|
+
description: description.nil? || description.length == 0 ? nil : match[:description]
|
20
|
+
}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
OpenStruct.new(a_throw)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative "variation_tag.rb"
|
2
|
+
|
3
|
+
module Docks
|
4
|
+
module Tags
|
5
|
+
class Variant < Variation
|
6
|
+
def initialize
|
7
|
+
@name = :variant
|
8
|
+
@synonyms = [:modifier]
|
9
|
+
@parseable = true
|
10
|
+
@multiple_allowed = true
|
11
|
+
end
|
12
|
+
|
13
|
+
def process(symbol)
|
14
|
+
symbol[@name].map! do |variant|
|
15
|
+
variant = break_apart_variation_details(variant)
|
16
|
+
Containers::Variant.new(variant)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
require_relative "base_tag.rb"
|
2
|
+
|
3
|
+
module Docks
|
4
|
+
module Tags
|
5
|
+
class Variation < Base
|
6
|
+
def initialize
|
7
|
+
@name = :variation
|
8
|
+
@parseable = false
|
9
|
+
@multiple_allowed = true
|
10
|
+
end
|
11
|
+
|
12
|
+
def setup_post_processors
|
13
|
+
after_each_pattern(:early) do |pattern|
|
14
|
+
join_variations_to_components(pattern)
|
15
|
+
clean_variation_names(pattern)
|
16
|
+
end
|
17
|
+
|
18
|
+
after_each_pattern(:late) do |pattern|
|
19
|
+
pattern.components.each { |component| mirror_preclusions(component) }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
protected
|
24
|
+
|
25
|
+
def mirror_preclusions(component)
|
26
|
+
variations = component.variations
|
27
|
+
variations.each do |variation|
|
28
|
+
precludes = variation.precludes
|
29
|
+
name = variation.name
|
30
|
+
|
31
|
+
variations.select { |other| precludes.include?(other.name) }.each do |other|
|
32
|
+
other.precludes << name unless other.precludes.include?(name)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
component.subcomponents.each { |subcomponent| mirror_preclusions(subcomponent) }
|
37
|
+
end
|
38
|
+
|
39
|
+
def clean_variation_names(pattern)
|
40
|
+
pattern.components.each do |component|
|
41
|
+
clean_component_variation_names(component)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def clean_component_variation_names(component)
|
46
|
+
component.variations.each do |variation|
|
47
|
+
component_name = component.name
|
48
|
+
variation.name = Docks.config.naming_convention.clean_variation_name(variation.name, component_name)
|
49
|
+
|
50
|
+
[:activate_with, :precludes].each do |need_name_fix|
|
51
|
+
variation[need_name_fix].map! { |item| Docks.config.naming_convention.clean_variation_name(item, component_name) }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
component.subcomponents.each { |subcomponent| clean_component_variation_names(subcomponent) }
|
56
|
+
end
|
57
|
+
|
58
|
+
def join_variations_to_components(pattern)
|
59
|
+
orphan_variations = pattern.symbols_of_type(Types::Symbol::STATE) + pattern.symbols_of_type(Types::Symbol::VARIANT)
|
60
|
+
@new_components = []
|
61
|
+
@components = pattern.components
|
62
|
+
|
63
|
+
orphan_variations.each do |variation|
|
64
|
+
component = component_for_variation(pattern, variation)
|
65
|
+
component[variation.symbol_type] << variation
|
66
|
+
pattern.remove(variation)
|
67
|
+
end
|
68
|
+
|
69
|
+
pattern.add(:style, @new_components)
|
70
|
+
@new_components = @components = nil
|
71
|
+
pattern
|
72
|
+
end
|
73
|
+
|
74
|
+
def component_for_variation(pattern, variation)
|
75
|
+
component_name = Docks.config.naming_convention.component(variation.name)
|
76
|
+
|
77
|
+
component = nil
|
78
|
+
(@components + @new_components).each do |check_component|
|
79
|
+
component = check_component.find(component_name)
|
80
|
+
break if component
|
81
|
+
end
|
82
|
+
|
83
|
+
if component.nil?
|
84
|
+
component = Containers::Component.new(name: component_name)
|
85
|
+
@new_components << component
|
86
|
+
end
|
87
|
+
|
88
|
+
component
|
89
|
+
end
|
90
|
+
|
91
|
+
def break_apart_variation_details(content)
|
92
|
+
content = Array(content) unless content.kind_of?(Array)
|
93
|
+
|
94
|
+
multiline_description(content) do |item|
|
95
|
+
match = item.match(/\s*\.?(?<class>[\$a-zA-Z\-\_]*)(?:\s*(?<details>\(.*\)))?(?:\s*\-?\s*(?<description>.*))?/m)
|
96
|
+
return nil if match.nil?
|
97
|
+
|
98
|
+
description = match[:description]
|
99
|
+
result = {
|
100
|
+
name: match[:class],
|
101
|
+
description: description.nil? || description.length == 0 ? nil : match[:description],
|
102
|
+
activate_with: [],
|
103
|
+
precludes: [],
|
104
|
+
set_by: [],
|
105
|
+
include_with: [],
|
106
|
+
demo_type: Docks::Types::Demo::DEFAULT,
|
107
|
+
javascript_action: nil,
|
108
|
+
active: false
|
109
|
+
}
|
110
|
+
|
111
|
+
unless match[:details].nil?
|
112
|
+
details = parenthetical_options(match[:details], :demo_type)
|
113
|
+
result.merge!(details)
|
114
|
+
|
115
|
+
result[:demo_type] = ensure_valid_demo_type(result[:demo_type])
|
116
|
+
result[:active] = stringy_boolean(result[:active])
|
117
|
+
|
118
|
+
[
|
119
|
+
:activate_with,
|
120
|
+
:precludes,
|
121
|
+
:include_with
|
122
|
+
].each do |array_param|
|
123
|
+
result[array_param] = split_on_characters(result[array_param], "\s\|")
|
124
|
+
end
|
125
|
+
|
126
|
+
result[:set_by] = split_on_top_level_parens_commas_and_pipes(result[:set_by]).map do |setter|
|
127
|
+
name_and_parenthetical(setter, :setter, :constant)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
result
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
data/lib/docks/tags.rb
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
module Docks
|
2
|
+
module Tags
|
3
|
+
def self.tag_for(tag)
|
4
|
+
@tags[base_tag_name(tag)]
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.base_tag_name(tag)
|
8
|
+
tag = tag.instance.name if tag.instance_of?(Class)
|
9
|
+
tag = tag.name if tag.kind_of?(Base)
|
10
|
+
tag = tag.to_sym
|
11
|
+
|
12
|
+
found = @synonyms[tag]
|
13
|
+
return found if found
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.register_bundled_tags
|
17
|
+
bundled_tags.each { |tag| register(tag) }
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.register(tag)
|
21
|
+
tag = tag.instance
|
22
|
+
tag.setup_post_processors
|
23
|
+
|
24
|
+
return false if tag.name.nil?
|
25
|
+
tag_name = tag.name.to_sym
|
26
|
+
@tags[tag_name] = tag
|
27
|
+
|
28
|
+
[tag_name, tag.synonyms].flatten.each do |synonym|
|
29
|
+
@synonyms[synonym.to_sym] = tag_name
|
30
|
+
@synonyms[synonym.to_s.pluralize.to_sym] = tag_name if tag.multiple_allowed?
|
31
|
+
end
|
32
|
+
|
33
|
+
true
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.<<(tag)
|
37
|
+
register(tag)
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.join_synonymous_tags(hash)
|
41
|
+
final_hash = {}
|
42
|
+
hash.each do |tag, value|
|
43
|
+
tag = tag.to_s.singularize.to_sym
|
44
|
+
base_tag = @synonyms[tag]
|
45
|
+
|
46
|
+
next if base_tag.nil?
|
47
|
+
|
48
|
+
if final_hash[base_tag].nil?
|
49
|
+
# No previous result for this tag or its synonyms. This effectively
|
50
|
+
# includes all non-multiple-allowed tags.
|
51
|
+
begin
|
52
|
+
final_hash[base_tag] = value.clone
|
53
|
+
rescue TypeError
|
54
|
+
final_hash[base_tag] = value
|
55
|
+
end
|
56
|
+
else
|
57
|
+
# All tags that could have previously-included synonym tags must be
|
58
|
+
# multiple-allowed tags. All multiple-allowed tags have new arrays
|
59
|
+
# for each declared tag.
|
60
|
+
final_hash[base_tag].concat(value)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
final_hash
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.has_tag?(tag)
|
68
|
+
!tag_for(tag).nil?
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.supported_tags
|
72
|
+
@synonyms.keys
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.supported_parseable_tags
|
76
|
+
supported_tags.select { |tag| tag_for(tag).parseable? }
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
def self.bundled_tags
|
83
|
+
if @bundled_tags.nil?
|
84
|
+
bundled = constants.select do |const|
|
85
|
+
klass = const_get(const)
|
86
|
+
Class === klass && !(klass.eql?(Base))
|
87
|
+
end
|
88
|
+
|
89
|
+
@bundled_tags = bundled.map { |const| const_get(const) }
|
90
|
+
end
|
91
|
+
|
92
|
+
@bundled_tags
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.clean
|
96
|
+
@tags = {}
|
97
|
+
@synonyms = {}
|
98
|
+
@bundled_tags = nil
|
99
|
+
end
|
100
|
+
|
101
|
+
clean
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
module Docks
|
2
|
+
module Templates
|
3
|
+
class Template
|
4
|
+
attr_reader :path, :layout
|
5
|
+
|
6
|
+
def self.new(name, options = {})
|
7
|
+
name.kind_of?(self) ? name : super
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(name, options = {})
|
11
|
+
@path = name
|
12
|
+
@matcher = options[:matches] || options[:for]
|
13
|
+
@layout = options[:layout]
|
14
|
+
end
|
15
|
+
|
16
|
+
def layout
|
17
|
+
@layout || Templates.default_layout
|
18
|
+
end
|
19
|
+
|
20
|
+
def matches?(id)
|
21
|
+
!(@matcher =~ id).nil?
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.demo; @demo_template end
|
26
|
+
def self.demo=(template); @demo_template = Template.new(template, layout: "demo") end
|
27
|
+
|
28
|
+
def self.default; @default_template end
|
29
|
+
def self.fallback; default end
|
30
|
+
def self.default=(template); @default_template = Template.new(template) end
|
31
|
+
def self.fallback=(template); self.default = template end
|
32
|
+
|
33
|
+
def self.default_layout; @default_layout end
|
34
|
+
def self.default_layout=(layout); @default_layout = layout end
|
35
|
+
|
36
|
+
def self.register(template, options = {})
|
37
|
+
if template.kind_of?(Hash)
|
38
|
+
register_from_hash(template)
|
39
|
+
else
|
40
|
+
@templates << Template.new(template, options)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.<<(template)
|
45
|
+
register(template)
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.template_for(id)
|
49
|
+
id = id.name if id.kind_of?(Containers::Pattern)
|
50
|
+
|
51
|
+
@templates.reverse_each do |template|
|
52
|
+
return template if template.matches?(id)
|
53
|
+
end
|
54
|
+
|
55
|
+
fallback
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.search_for_template(template, options = {})
|
59
|
+
return unless template.kind_of?(String) || template.kind_of?(Pathname)
|
60
|
+
return template if File.exists?(template)
|
61
|
+
|
62
|
+
if options[:must_be].nil?
|
63
|
+
in_root = loose_search_for(template)
|
64
|
+
return in_root unless in_root.nil?
|
65
|
+
end
|
66
|
+
|
67
|
+
in_specific = loose_search_for(File.join("#{(options[:must_be] || :partial).to_s.sub(/s$/, '')}{s,}", template))
|
68
|
+
return in_specific unless in_specific.nil?
|
69
|
+
|
70
|
+
raise Docks::NoTemplateError, "No #{options[:must_be] || "template"} matching '#{template}' was found. Make sure that you have a template by that name in the '#{options[:must_be].nil? ? Docks.config.asset_folders.templates : options[:must_be].to_s.pluralize}' folder of your pattern library's assets (or in a subdirectory of that folder), or provide a full path to the desired file."
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.last_template_update
|
74
|
+
@last_modified ||= begin
|
75
|
+
templates = Dir[Docks.config.templates + "**/*.*"]
|
76
|
+
templates.map { |template| File.mtime(template) }.sort.last
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
def self.register_from_hash(templates)
|
83
|
+
if fallback = templates.delete("default") || templates.delete("fallback")
|
84
|
+
self.fallback = fallback
|
85
|
+
end
|
86
|
+
|
87
|
+
if demo = templates.delete("demo")
|
88
|
+
self.demo = demo
|
89
|
+
end
|
90
|
+
|
91
|
+
templates.each do |match, template|
|
92
|
+
register(template, for: Regexp.new(match.to_s))
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.loose_search_for(path)
|
97
|
+
return if path.nil?
|
98
|
+
path = Docks.config.templates + path
|
99
|
+
path_pieces = path.to_s.sub(File.extname(path), "").split("/")
|
100
|
+
path_pieces[path_pieces.length - 1] = "{_,}#{path_pieces.last}"
|
101
|
+
Dir.glob("#{path_pieces.join("/")}.*").first
|
102
|
+
end
|
103
|
+
|
104
|
+
def self.clean
|
105
|
+
@demo_template = Template.new("demo", layout: (rails? ? "docks/demo" : "demo"))
|
106
|
+
@default_template = Template.new("pattern")
|
107
|
+
@default_layout = rails? ? "docks/pattern" : "pattern"
|
108
|
+
@templates = []
|
109
|
+
end
|
110
|
+
|
111
|
+
def self.rails?
|
112
|
+
defined?(Rails)
|
113
|
+
end
|
114
|
+
|
115
|
+
clean
|
116
|
+
end
|
117
|
+
|
118
|
+
def self.template_for(id); Templates.template_for(id) end
|
119
|
+
def self.current_render_destination; @current_render_destination end
|
120
|
+
def self.current_render_destination=(destination); @current_render_destination = destination end
|
121
|
+
def self.component_template_path; Pathname.new(File.expand_path("../../template/assets/templates/components", __FILE__)) end
|
122
|
+
end
|
data/lib/docks/themes.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Docks
|
2
|
+
module Themes
|
3
|
+
def self.for(theme)
|
4
|
+
if [String, ::Symbol].include?(theme.class)
|
5
|
+
begin
|
6
|
+
require "docks_theme_#{theme.to_s.downcase}"
|
7
|
+
theme = theme.to_sym
|
8
|
+
theme = const_get(theme).instance
|
9
|
+
rescue LoadError, NameError
|
10
|
+
theme = false
|
11
|
+
end
|
12
|
+
else
|
13
|
+
theme = theme.instance if theme.kind_of?(Class)
|
14
|
+
end
|
15
|
+
|
16
|
+
theme
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/docks/types.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Docks
|
2
|
+
module Types
|
3
|
+
module Symbol
|
4
|
+
COMPONENT = "component"
|
5
|
+
VARIANT = "variant"
|
6
|
+
STATE = "state"
|
7
|
+
MIXIN = "mixin"
|
8
|
+
PLACEHOLDER = "placeholder"
|
9
|
+
FUNCTION = "function"
|
10
|
+
VARIABLE = "variable"
|
11
|
+
CLASS = "class"
|
12
|
+
FACTORY = "factory"
|
13
|
+
PATTERN = "pattern"
|
14
|
+
DEMO = "demo"
|
15
|
+
end
|
16
|
+
|
17
|
+
module Demo
|
18
|
+
SELECT = "select"
|
19
|
+
JOINT = "joint"
|
20
|
+
OWN = "own"
|
21
|
+
NONE = "none"
|
22
|
+
HIDDEN = NONE
|
23
|
+
DEFAULT = SELECT
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/docks.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require "yaml"
|
2
|
+
require "json"
|
3
|
+
require "pathname"
|
4
|
+
require "fileutils"
|
5
|
+
require "ostruct"
|
6
|
+
require "singleton"
|
7
|
+
|
8
|
+
require "redcarpet"
|
9
|
+
require "active_support/inflector"
|
10
|
+
|
11
|
+
module Docks
|
12
|
+
ASSETS_DIR = "pattern_library_assets"
|
13
|
+
CONFIG_FILE = "docks_config.*"
|
14
|
+
end
|
15
|
+
|
16
|
+
require File.join(File.dirname(__FILE__), "docks", "types.rb")
|
17
|
+
require File.join(File.dirname(__FILE__), "docks", "configuration.rb")
|
18
|
+
Dir[File.join(File.dirname(__FILE__), "docks", "*.rb")].each { |file| require file }
|
19
|
+
|
20
|
+
require File.join(File.dirname(__FILE__), "docks", "parsers/base_parser.rb")
|
21
|
+
Dir[File.join(File.dirname(__FILE__), "docks", "parsers/*.rb")].each { |file| require file }
|
22
|
+
|
23
|
+
Dir[File.join(File.dirname(__FILE__), "docks", "renderers/*.rb")].each { |file| require file }
|
24
|
+
|
25
|
+
Dir[File.join(File.dirname(__FILE__), "docks", "themes/*.rb")].each { |file| require file }
|
26
|
+
|
27
|
+
require File.join(File.dirname(__FILE__), "docks", "languages/base_language.rb")
|
28
|
+
Dir[File.join(File.dirname(__FILE__), "docks", "languages/*.rb")].each { |file| require file }
|
29
|
+
|
30
|
+
require File.join(File.dirname(__FILE__), "docks", "tags/base_tag.rb")
|
31
|
+
Dir[File.join(File.dirname(__FILE__), "docks", "tags/*.rb")].each { |file| require file }
|
32
|
+
|
33
|
+
Dir[File.join(File.dirname(__FILE__), "docks", "containers/*.rb")].each { |file| require file }
|
34
|
+
|
35
|
+
require File.join(File.dirname(__FILE__), "docks", "descriptor.rb")
|
36
|
+
|
37
|
+
Dir[File.join(File.dirname(__FILE__), "docks", "helpers.rb")].each { |file| require file }
|
@@ -0,0 +1 @@
|
|
1
|
+
bar_2
|
@@ -0,0 +1 @@
|
|
1
|
+
baz
|
@@ -0,0 +1 @@
|
|
1
|
+
foo-2
|
@@ -0,0 +1 @@
|
|
1
|
+
foo
|
@@ -0,0 +1 @@
|
|
1
|
+
baz_2
|
@@ -0,0 +1 @@
|
|
1
|
+
baz
|
File without changes
|