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,168 @@
|
|
1
|
+
require_relative "base_container.rb"
|
2
|
+
|
3
|
+
module Docks
|
4
|
+
module Containers
|
5
|
+
class Pattern < Base
|
6
|
+
extend Forwardable
|
7
|
+
|
8
|
+
def self.type; Types::Symbol::PATTERN end
|
9
|
+
|
10
|
+
SYMBOL_SOURCES = [
|
11
|
+
Types::Languages::STYLE,
|
12
|
+
Types::Languages::SCRIPT
|
13
|
+
]
|
14
|
+
|
15
|
+
attr_accessor :modified, :files, :name
|
16
|
+
def_delegators :@symbols, :to_s, :inspect, :to_json
|
17
|
+
|
18
|
+
def initialize(pattern_details = {})
|
19
|
+
super
|
20
|
+
@name = @details.delete(:name)
|
21
|
+
@symbols = {}
|
22
|
+
@files = []
|
23
|
+
|
24
|
+
SYMBOL_SOURCES.each do |source|
|
25
|
+
@symbols[source] = []
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def add(source, symbols)
|
30
|
+
symbols = [symbols].flatten
|
31
|
+
symbols.each do |symbol|
|
32
|
+
symbol.belongs_to = self
|
33
|
+
end
|
34
|
+
|
35
|
+
pattern_symbol, regular_symbols = symbols.partition { |symbol| !symbol.pattern.nil? }
|
36
|
+
|
37
|
+
unless pattern_symbol.empty?
|
38
|
+
pattern_symbol = pattern_symbol.first
|
39
|
+
pattern_symbol[Tags::Title.instance.name] ||= pattern_symbol.delete(Tags::Pattern.instance.name)
|
40
|
+
@details.merge!(pattern_symbol.to_h)
|
41
|
+
end
|
42
|
+
|
43
|
+
@symbols[source].concat(regular_symbols)
|
44
|
+
end
|
45
|
+
|
46
|
+
def remove(remove_symbol)
|
47
|
+
SYMBOL_SOURCES.each do |symbol_source|
|
48
|
+
@symbols[symbol_source].delete_if { |symbol| symbol == remove_symbol }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def valid?
|
53
|
+
!@details.values.compact.empty? || SYMBOL_SOURCES.any? { |source| !@symbols[source].empty? }
|
54
|
+
end
|
55
|
+
|
56
|
+
def ==(other_pattern)
|
57
|
+
self.class == other_pattern.class && @symbols == other_pattern.instance_variable_get(:@symbols)
|
58
|
+
end
|
59
|
+
|
60
|
+
def title
|
61
|
+
fetch(Tags::Title.instance.name, name.capitalize)
|
62
|
+
end
|
63
|
+
|
64
|
+
def group
|
65
|
+
fetch(Tags::Group.instance.name, Types::Symbol::COMPONENT.capitalize)
|
66
|
+
end
|
67
|
+
|
68
|
+
def structure_symbols
|
69
|
+
@symbols[Types::Languages::STYLE]
|
70
|
+
end
|
71
|
+
|
72
|
+
alias_method :style_symbols, :structure_symbols
|
73
|
+
|
74
|
+
def has_structure?
|
75
|
+
structure_symbols.length > 0
|
76
|
+
end
|
77
|
+
|
78
|
+
def behavior_symbols
|
79
|
+
@symbols[Types::Languages::SCRIPT]
|
80
|
+
end
|
81
|
+
|
82
|
+
alias_method :script_symbols, :behavior_symbols
|
83
|
+
|
84
|
+
def has_behavior?
|
85
|
+
behavior_symbols.length > 0
|
86
|
+
end
|
87
|
+
|
88
|
+
Containers::TOP_LEVEL_SYMBOLS.each do |symbol|
|
89
|
+
define_method(symbol.pluralize.to_sym) do |options = {}|
|
90
|
+
symbols_of_type(symbol, options)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def symbols
|
95
|
+
@symbols.values.flatten
|
96
|
+
end
|
97
|
+
|
98
|
+
def find(descriptor)
|
99
|
+
super || find_in_symbols(descriptor)
|
100
|
+
end
|
101
|
+
|
102
|
+
def demos
|
103
|
+
return @demos unless @demos.nil?
|
104
|
+
|
105
|
+
@demos = []
|
106
|
+
components.each do |component|
|
107
|
+
@demos << Demo.new(component) if component.has_demo?
|
108
|
+
|
109
|
+
component.variations.each do |variation|
|
110
|
+
@demos << Demo.new(variation) if variation.demo_type == Types::Demo::OWN
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
@demos
|
115
|
+
end
|
116
|
+
|
117
|
+
alias_method :demo, :demos
|
118
|
+
|
119
|
+
def summary
|
120
|
+
return self if summarized?
|
121
|
+
|
122
|
+
summary = super
|
123
|
+
summary.group = group
|
124
|
+
summary.title = title
|
125
|
+
summary.instance_variable_set(:@symbols, Hash[@symbols.map { |type, symbols| [type, symbols.map(&:summary)] }])
|
126
|
+
summary
|
127
|
+
end
|
128
|
+
|
129
|
+
def symbols_of_type(type, options = {})
|
130
|
+
type = type.to_s
|
131
|
+
included = options[:include].nil? ? SYMBOL_SOURCES : [options[:include]].flatten
|
132
|
+
excluded = options[:exclude].nil? ? [] : Array(options[:exclude])
|
133
|
+
|
134
|
+
SYMBOL_SOURCES.inject([]) do |matches, source|
|
135
|
+
if included.include?(source) && !excluded.include?(source)
|
136
|
+
new_results = @symbols[source].select do |symbol|
|
137
|
+
symbol.symbol_type.to_s == type
|
138
|
+
end
|
139
|
+
|
140
|
+
matches.concat(new_results)
|
141
|
+
end
|
142
|
+
|
143
|
+
matches
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
protected
|
148
|
+
|
149
|
+
def matches_exactly?(descriptor)
|
150
|
+
descriptor.symbol.nil? && descriptor.pattern == name
|
151
|
+
end
|
152
|
+
|
153
|
+
def find_in_symbols(descriptor)
|
154
|
+
descriptor = Descriptor.new(descriptor)
|
155
|
+
find_result = false
|
156
|
+
|
157
|
+
SYMBOL_SOURCES.each do |source|
|
158
|
+
@symbols[source].each do |symbol|
|
159
|
+
find_result = symbol.find(descriptor)
|
160
|
+
break if find_result
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
find_result
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module Docks
|
2
|
+
module Containers
|
3
|
+
class PatternLibrary
|
4
|
+
attr_reader :patterns
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@patterns = {}
|
8
|
+
@summary = false
|
9
|
+
end
|
10
|
+
|
11
|
+
def <<(pattern)
|
12
|
+
@patterns[pattern.name.to_s] ||= pattern
|
13
|
+
end
|
14
|
+
|
15
|
+
def [](pattern_name)
|
16
|
+
@patterns[Docks.pattern_id(pattern_name)]
|
17
|
+
end
|
18
|
+
|
19
|
+
def has_pattern?(pattern_name)
|
20
|
+
!self[pattern_name].nil?
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_json; @patterns.to_json end
|
24
|
+
|
25
|
+
def group_by(grouper, &block)
|
26
|
+
grouped_patterns = {}
|
27
|
+
grouper = grouper.to_sym
|
28
|
+
|
29
|
+
@patterns.each do |name, pattern|
|
30
|
+
grouper_value = pattern.send(grouper)
|
31
|
+
next if grouper_value.nil?
|
32
|
+
grouped_patterns[grouper_value] ||= []
|
33
|
+
grouped_patterns[grouper_value] << pattern
|
34
|
+
end
|
35
|
+
|
36
|
+
if block_given?
|
37
|
+
grouped_patterns.each(&block)
|
38
|
+
else
|
39
|
+
grouped_patterns
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def groups(&block)
|
44
|
+
group_by(:group, &block)
|
45
|
+
end
|
46
|
+
|
47
|
+
def find(descriptor)
|
48
|
+
descriptor = Descriptor.new(descriptor, assume: :pattern)
|
49
|
+
pattern = @patterns[descriptor.pattern]
|
50
|
+
return false if pattern.nil?
|
51
|
+
|
52
|
+
symbol = pattern.find(descriptor)
|
53
|
+
symbol = nil if !symbol || symbol == pattern
|
54
|
+
::OpenStruct.new(pattern: pattern, symbol: symbol)
|
55
|
+
end
|
56
|
+
|
57
|
+
def summarized?; @summary end
|
58
|
+
alias_method :summary?, :summarized?
|
59
|
+
|
60
|
+
def summary
|
61
|
+
return self if summarized?
|
62
|
+
|
63
|
+
summary = self.class.new
|
64
|
+
summary.instance_variable_set(:@summary, true)
|
65
|
+
summary.instance_variable_set(:@patterns, Hash[@patterns.map { |name, pattern| [name, pattern.summary] }])
|
66
|
+
summary
|
67
|
+
end
|
68
|
+
alias_method :summarize, :summary
|
69
|
+
|
70
|
+
def summary!
|
71
|
+
@summary = true
|
72
|
+
@patterns = Hash[@patterns.map { |name, pattern| [name, pattern.summary] }]
|
73
|
+
end
|
74
|
+
alias_method :summarize!, :summary!
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require_relative "base_container.rb"
|
2
|
+
|
3
|
+
module Docks
|
4
|
+
module Containers
|
5
|
+
class Symbol < Base
|
6
|
+
attr_accessor :belongs_to, :properties, :methods
|
7
|
+
|
8
|
+
def self.type; "symbol" end
|
9
|
+
|
10
|
+
def self.from_symbol(symbol)
|
11
|
+
return if self == symbol.class
|
12
|
+
new(symbol.to_h)
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(symbol_hash = {})
|
16
|
+
super
|
17
|
+
self[:symbol_type] = self.class.type
|
18
|
+
@properties = []
|
19
|
+
@methods = []
|
20
|
+
end
|
21
|
+
|
22
|
+
def private?; fetch(:access, nil) == Docks::Types::Access::PRIVATE end
|
23
|
+
def public?; !private? end
|
24
|
+
|
25
|
+
def member?
|
26
|
+
self[:property] == true || self[:method] == true
|
27
|
+
end
|
28
|
+
|
29
|
+
def members; @methods + @properties end
|
30
|
+
|
31
|
+
def has_members?; !members.empty? end
|
32
|
+
|
33
|
+
def add_member(symbol)
|
34
|
+
symbol.for = fetch(:name)
|
35
|
+
symbol.belongs_to = self
|
36
|
+
symbol.static = true
|
37
|
+
|
38
|
+
if symbol.kind_of?(Variable)
|
39
|
+
symbol.property = true
|
40
|
+
@properties << symbol
|
41
|
+
else
|
42
|
+
symbol.method = true
|
43
|
+
@methods << symbol
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def add_members(*symbols)
|
48
|
+
symbols.each { |symbol| add_member(symbol) }
|
49
|
+
end
|
50
|
+
|
51
|
+
def find(descriptor)
|
52
|
+
descriptor = Descriptor.new(descriptor)
|
53
|
+
return self if matches_exactly?(descriptor)
|
54
|
+
|
55
|
+
members.find { |member| member.find(descriptor) } || false
|
56
|
+
end
|
57
|
+
|
58
|
+
def symbol_id
|
59
|
+
"#{fetch(:symbol_type)}-#{fetch(:name)}"
|
60
|
+
end
|
61
|
+
|
62
|
+
def to_descriptor
|
63
|
+
descriptor = ""
|
64
|
+
descriptor << "#{belongs_to.name}::" unless belongs_to.nil?
|
65
|
+
descriptor << fetch(:name)
|
66
|
+
descriptor
|
67
|
+
end
|
68
|
+
|
69
|
+
def summary
|
70
|
+
summary = super
|
71
|
+
summary.properties = @properties.map(&:summary)
|
72
|
+
summary.methods = @methods.map(&:summary)
|
73
|
+
summary
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require_relative "symbol_container.rb"
|
2
|
+
|
3
|
+
module Docks
|
4
|
+
module Containers
|
5
|
+
|
6
|
+
# Public: a container for Variable symbols.
|
7
|
+
|
8
|
+
class Variable < Symbol
|
9
|
+
def self.type; Docks::Types::Symbol::VARIABLE end
|
10
|
+
|
11
|
+
def static?; fetch(:static, false) end
|
12
|
+
def instance?; !static? end
|
13
|
+
def property?; fetch(:property, false) end
|
14
|
+
|
15
|
+
def symbol_id
|
16
|
+
return super unless property?
|
17
|
+
"property-#{"static-" if static?}#{fetch(:for)}-#{fetch(:name)}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_descriptor
|
21
|
+
return super unless property?
|
22
|
+
"#{belongs_to.to_descriptor}#{static? ? "." : "#"}#{fetch(:name)}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def summary
|
26
|
+
summary = super
|
27
|
+
summary.static = static?
|
28
|
+
summary.property = property?
|
29
|
+
summary.for = fetch(:for, nil)
|
30
|
+
summary
|
31
|
+
end
|
32
|
+
|
33
|
+
protected
|
34
|
+
|
35
|
+
def matches_exactly?(descriptor)
|
36
|
+
name = fetch(:name, nil)
|
37
|
+
|
38
|
+
return super unless property?
|
39
|
+
|
40
|
+
matches = (instance? && descriptor.instance_member == name) ||
|
41
|
+
(static? && descriptor.static_member == name)
|
42
|
+
|
43
|
+
matches && self
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require_relative "symbol_container.rb"
|
2
|
+
|
3
|
+
module Docks
|
4
|
+
module Containers
|
5
|
+
class Variation < Symbol
|
6
|
+
def self.type; "variation" end
|
7
|
+
|
8
|
+
def initialize(variation_hash = {})
|
9
|
+
super
|
10
|
+
set_defaults
|
11
|
+
end
|
12
|
+
|
13
|
+
def has_demo?
|
14
|
+
[Types::Demo::OWN, Types::Demo::JOINT].include?(demo_type)
|
15
|
+
end
|
16
|
+
|
17
|
+
protected
|
18
|
+
|
19
|
+
def matches_exactly?(descriptor)
|
20
|
+
super || (descriptor.member? && descriptor.member == fetch(:name) && descriptor.symbol == fetch(:for, nil))
|
21
|
+
end
|
22
|
+
|
23
|
+
def set_defaults
|
24
|
+
self[:active] = false if self[:active].nil?
|
25
|
+
self[:demo_type] ||= Types::Demo::SELECT
|
26
|
+
|
27
|
+
[:activate_with, :preclude, :set_by, :include_with].each do |defaults_to_array|
|
28
|
+
value = self[defaults_to_array]
|
29
|
+
self[defaults_to_array] = case value
|
30
|
+
when NilClass then []
|
31
|
+
when Array then value
|
32
|
+
else [value]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Docks
|
2
|
+
module Containers
|
3
|
+
TOP_LEVEL_SYMBOLS = [
|
4
|
+
Types::Symbol::COMPONENT,
|
5
|
+
Types::Symbol::CLASS,
|
6
|
+
Types::Symbol::FACTORY,
|
7
|
+
Types::Symbol::FUNCTION,
|
8
|
+
Types::Symbol::MIXIN,
|
9
|
+
Types::Symbol::VARIABLE
|
10
|
+
]
|
11
|
+
|
12
|
+
@@container_associations = Hash.new
|
13
|
+
|
14
|
+
def self.container_for(type = nil)
|
15
|
+
if @@container_associations.empty?
|
16
|
+
constants.each do |const|
|
17
|
+
klass = const_get(const)
|
18
|
+
@@container_associations[klass.type.to_sym] = klass if klass.respond_to?(:type)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
type.nil? ? Symbol : @@container_associations.fetch(type.to_sym, Symbol)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Docks
|
2
|
+
class Descriptor
|
3
|
+
PATTERN = /^([^:]*)::/
|
4
|
+
INSTANCE_MEMBER = /#(.*)/
|
5
|
+
STATIC_MEMBER = /\.(.*)/
|
6
|
+
LOCAL_MEMBER = /~(.*)/
|
7
|
+
MEMBERS = [:instance_member, :static_member, :local_member]
|
8
|
+
|
9
|
+
attr_reader :pattern, :symbol
|
10
|
+
attr_reader *MEMBERS
|
11
|
+
|
12
|
+
def self.new(descriptor_string, options = {})
|
13
|
+
descriptor_string.kind_of?(self) ? descriptor_string : super
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(descriptor_string, options)
|
17
|
+
parse(descriptor_string, options)
|
18
|
+
end
|
19
|
+
|
20
|
+
def member?
|
21
|
+
MEMBERS.any? { |member_type| !self.send(member_type).nil? }
|
22
|
+
end
|
23
|
+
|
24
|
+
def member
|
25
|
+
MEMBERS.each do |member_type|
|
26
|
+
member = self.send(member_type)
|
27
|
+
return member unless member.nil?
|
28
|
+
end
|
29
|
+
|
30
|
+
nil
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def parse(string, options)
|
36
|
+
string = string.sub(PATTERN) do
|
37
|
+
@pattern = Docks.pattern_id($1)
|
38
|
+
""
|
39
|
+
end
|
40
|
+
|
41
|
+
string = string.sub(INSTANCE_MEMBER) do
|
42
|
+
@instance_member = $1
|
43
|
+
""
|
44
|
+
end
|
45
|
+
|
46
|
+
string = string.sub(STATIC_MEMBER) do
|
47
|
+
@static_member = $1
|
48
|
+
""
|
49
|
+
end
|
50
|
+
|
51
|
+
string = string.sub(LOCAL_MEMBER) do
|
52
|
+
@local_member = $1
|
53
|
+
""
|
54
|
+
end
|
55
|
+
|
56
|
+
@symbol = string
|
57
|
+
@pattern, @symbol = @symbol, nil if options[:assume] == :pattern && @pattern.nil?
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/docks/errors.rb
ADDED
data/lib/docks/group.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
module Docks
|
2
|
+
@pattern_id = lambda do |filename|
|
3
|
+
File.basename(filename).split('.').first.split(/(\-\-|__)/).first.sub(/^_+/, '').gsub(/(\s|\-|_)+/, '_')
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.pattern_id(filename = nil, &block)
|
7
|
+
return nil unless filename.kind_of?(String)
|
8
|
+
@pattern_id.call(filename)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.pattern_id=(block)
|
12
|
+
return if block.call("foo").nil?
|
13
|
+
@pattern_id = block
|
14
|
+
end
|
15
|
+
|
16
|
+
class Grouper
|
17
|
+
def self.group(globs)
|
18
|
+
files = file_list_from_globs(globs)
|
19
|
+
groups = {}
|
20
|
+
return groups if files.empty?
|
21
|
+
|
22
|
+
# Cycle through all files identified by the glob, then assign them to
|
23
|
+
# the group matching their group ID.
|
24
|
+
files.each do |filename|
|
25
|
+
if should_include_file?(filename)
|
26
|
+
identifier = Docks.pattern_id(filename)
|
27
|
+
groups[identifier] ||= []
|
28
|
+
groups[identifier] << filename
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
groups
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.source_files_of_type(type)
|
36
|
+
return @source_files_by_type[type] unless @source_files_by_type.nil?
|
37
|
+
|
38
|
+
files = {}
|
39
|
+
files[Docks::Types::Languages::MARKUP] = []
|
40
|
+
files[Docks::Types::Languages::STYLE] = []
|
41
|
+
files[Docks::Types::Languages::SCRIPT] = []
|
42
|
+
files[Docks::Types::Languages::STUB] = []
|
43
|
+
files[Docks::Types::Languages::DESCRIPTION] = []
|
44
|
+
|
45
|
+
file_list_from_globs(Docks.config.sources).each do |filename|
|
46
|
+
files[Docks::Languages.file_type(filename)] << filename
|
47
|
+
end
|
48
|
+
|
49
|
+
@source_files_by_type = files
|
50
|
+
@source_files_by_type[type]
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def self.should_include_file?(filename)
|
58
|
+
Docks::Languages.extensions.include?(File.extname(filename)[1..-1]) &&
|
59
|
+
!filename.include?('.min.')
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.file_list_from_globs(globs)
|
63
|
+
Array(globs).map { |glob| Dir.glob(glob) }.flatten
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Docks
|
2
|
+
module Helpers
|
3
|
+
module Github
|
4
|
+
def has_github?
|
5
|
+
!(Docks.config.github_repo.nil? || Docks.config.github_repo.empty? || @pattern.files.empty?)
|
6
|
+
end
|
7
|
+
|
8
|
+
def github_url(file)
|
9
|
+
"#{github_root_url}/blob/master/#{url_encode(file).gsub("%2F", "/").sub(/^\//, "")}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def github_issue_message
|
13
|
+
root = Docks.config.root.to_s
|
14
|
+
files = @pattern.files.map { |file| file.sub(root, "") }
|
15
|
+
|
16
|
+
file_checklist = relative_pattern_files.map { |file| "- [#{@pattern.files.length == 1 ? "x" : " "}] [#{file}](#{github_url(file)})" }.join("\n")
|
17
|
+
"\n\n\n---\n\nThis issue is related to the following files:\n\n#{file_checklist}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def relative_pattern_files
|
21
|
+
@relative_pattern_files ||= @pattern.files.map { |file| file.sub(Docks.config.root.to_s, "") }
|
22
|
+
end
|
23
|
+
|
24
|
+
def github_root_url
|
25
|
+
@github_root_url ||= Docks.config.github_repo.sub(/(.)\/?$/, '\1')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|