docks_app 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (313) hide show
  1. data/.editorconfig +8 -0
  2. data/.gitignore +22 -0
  3. data/.rubocop.yml +20 -0
  4. data/.travis.yml +10 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +35 -0
  8. data/Rakefile +3 -0
  9. data/bin/docks +5 -0
  10. data/config/json/docks_config.json +71 -0
  11. data/config/ruby/docks_config.rb +127 -0
  12. data/config/yaml/docks_config.yml +70 -0
  13. data/docks.gemspec +38 -0
  14. data/lib/docks/build.rb +300 -0
  15. data/lib/docks/cache.rb +143 -0
  16. data/lib/docks/command_line.rb +65 -0
  17. data/lib/docks/configuration.rb +217 -0
  18. data/lib/docks/containers/base_container.rb +103 -0
  19. data/lib/docks/containers/class_container.rb +39 -0
  20. data/lib/docks/containers/component_container.rb +92 -0
  21. data/lib/docks/containers/demo_container.rb +105 -0
  22. data/lib/docks/containers/factory_container.rb +12 -0
  23. data/lib/docks/containers/function_container.rb +46 -0
  24. data/lib/docks/containers/mixin_container.rb +19 -0
  25. data/lib/docks/containers/pattern_container.rb +168 -0
  26. data/lib/docks/containers/pattern_library_container.rb +77 -0
  27. data/lib/docks/containers/state_container.rb +9 -0
  28. data/lib/docks/containers/symbol_container.rb +77 -0
  29. data/lib/docks/containers/variable_container.rb +47 -0
  30. data/lib/docks/containers/variant_container.rb +9 -0
  31. data/lib/docks/containers/variation_container.rb +38 -0
  32. data/lib/docks/containers.rb +25 -0
  33. data/lib/docks/descriptor.rb +60 -0
  34. data/lib/docks/errors.rb +5 -0
  35. data/lib/docks/group.rb +66 -0
  36. data/lib/docks/helpers/github_helper.rb +29 -0
  37. data/lib/docks/helpers/path_helper.rb +94 -0
  38. data/lib/docks/helpers/render_helper.rb +87 -0
  39. data/lib/docks/helpers.rb +19 -0
  40. data/lib/docks/languages/base_language.rb +17 -0
  41. data/lib/docks/languages/coffeescript_language.rb +30 -0
  42. data/lib/docks/languages/common_types/markup_language.rb +71 -0
  43. data/lib/docks/languages/css_language.rb +13 -0
  44. data/lib/docks/languages/erb_language.rb +21 -0
  45. data/lib/docks/languages/haml_language.rb +21 -0
  46. data/lib/docks/languages/html_language.rb +10 -0
  47. data/lib/docks/languages/javascript_language.rb +42 -0
  48. data/lib/docks/languages/json_language.rb +18 -0
  49. data/lib/docks/languages/less_language.rb +33 -0
  50. data/lib/docks/languages/markdown_language.rb +10 -0
  51. data/lib/docks/languages/sass_language.rb +36 -0
  52. data/lib/docks/languages/slim_language.rb +21 -0
  53. data/lib/docks/languages/stylus_language.rb +26 -0
  54. data/lib/docks/languages/yaml_language.rb +18 -0
  55. data/lib/docks/languages.rb +103 -0
  56. data/lib/docks/markdown.rb +18 -0
  57. data/lib/docks/messenger.rb +69 -0
  58. data/lib/docks/naming_conventions/base_naming_convention.rb +9 -0
  59. data/lib/docks/naming_conventions/bem_naming_convention.rb +45 -0
  60. data/lib/docks/naming_conventions/suit_naming_convention.rb +45 -0
  61. data/lib/docks/naming_conventions.rb +21 -0
  62. data/lib/docks/ostruct.rb +17 -0
  63. data/lib/docks/parser.rb +86 -0
  64. data/lib/docks/parsers/base_parser.rb +128 -0
  65. data/lib/docks/parsers/coffeescript_parser.rb +30 -0
  66. data/lib/docks/parsers/css_parser.rb +27 -0
  67. data/lib/docks/parsers/javascript_parser.rb +30 -0
  68. data/lib/docks/parsers/less_parser.rb +22 -0
  69. data/lib/docks/parsers/sass_parser.rb +31 -0
  70. data/lib/docks/parsers/stylus_parser.rb +28 -0
  71. data/lib/docks/process.rb +60 -0
  72. data/lib/docks/processors.rb +416 -0
  73. data/lib/docks/renderers/base_renderer.rb +64 -0
  74. data/lib/docks/renderers/common_features/capturable.rb +69 -0
  75. data/lib/docks/renderers/common_features/helperable.rb +23 -0
  76. data/lib/docks/renderers/erb_renderer.rb +68 -0
  77. data/lib/docks/renderers/haml_renderer.rb +37 -0
  78. data/lib/docks/renderers/slim_renderer.rb +33 -0
  79. data/lib/docks/symbol_sources/base_symbol_source.rb +12 -0
  80. data/lib/docks/symbol_sources/jquery_symbol_source.rb +17 -0
  81. data/lib/docks/symbol_sources/mdn_symbol_source.rb +35 -0
  82. data/lib/docks/symbol_sources/sass_symbol_source.rb +27 -0
  83. data/lib/docks/symbol_sources.rb +28 -0
  84. data/lib/docks/tags/access_tag.rb +27 -0
  85. data/lib/docks/tags/activate_with_tag.rb +17 -0
  86. data/lib/docks/tags/active_tag.rb +14 -0
  87. data/lib/docks/tags/alias_tag.rb +17 -0
  88. data/lib/docks/tags/author_tag.rb +19 -0
  89. data/lib/docks/tags/base_tag.rb +52 -0
  90. data/lib/docks/tags/beta_tag.rb +26 -0
  91. data/lib/docks/tags/class_tag.rb +16 -0
  92. data/lib/docks/tags/compatibility_tag.rb +19 -0
  93. data/lib/docks/tags/demo_type_tag.rb +14 -0
  94. data/lib/docks/tags/deprecated_tag.rb +26 -0
  95. data/lib/docks/tags/description_tag.rb +99 -0
  96. data/lib/docks/tags/example_tag.rb +20 -0
  97. data/lib/docks/tags/factory_tag.rb +16 -0
  98. data/lib/docks/tags/for_tag.rb +23 -0
  99. data/lib/docks/tags/group_tag.rb +10 -0
  100. data/lib/docks/tags/helper_tag.rb +13 -0
  101. data/lib/docks/tags/include_with_tag.rb +57 -0
  102. data/lib/docks/tags/javascript_action_tag.rb +10 -0
  103. data/lib/docks/tags/link_tag.rb +18 -0
  104. data/lib/docks/tags/markup_tag.rb +106 -0
  105. data/lib/docks/tags/member_tag.rb +37 -0
  106. data/lib/docks/tags/method_tag.rb +18 -0
  107. data/lib/docks/tags/name_tag.rb +10 -0
  108. data/lib/docks/tags/object_tag.rb +15 -0
  109. data/lib/docks/tags/param_tag.rb +94 -0
  110. data/lib/docks/tags/pattern_tag.rb +21 -0
  111. data/lib/docks/tags/preclude_tag.rb +17 -0
  112. data/lib/docks/tags/private_tag.rb +15 -0
  113. data/lib/docks/tags/property_tag.rb +18 -0
  114. data/lib/docks/tags/public_tag.rb +15 -0
  115. data/lib/docks/tags/require_tag.rb +47 -0
  116. data/lib/docks/tags/returns_tag.rb +31 -0
  117. data/lib/docks/tags/set_by_tag.rb +18 -0
  118. data/lib/docks/tags/signature_tag.rb +35 -0
  119. data/lib/docks/tags/since_tag.rb +26 -0
  120. data/lib/docks/tags/source_tag.rb +12 -0
  121. data/lib/docks/tags/state_tag.rb +21 -0
  122. data/lib/docks/tags/static_tag.rb +14 -0
  123. data/lib/docks/tags/subcomponent_tag.rb +68 -0
  124. data/lib/docks/tags/subtitle_tag.rb +11 -0
  125. data/lib/docks/tags/symbol_type_tag.rb +10 -0
  126. data/lib/docks/tags/throws_tag.rb +30 -0
  127. data/lib/docks/tags/title_tag.rb +10 -0
  128. data/lib/docks/tags/type_tag.rb +10 -0
  129. data/lib/docks/tags/value_tag.rb +10 -0
  130. data/lib/docks/tags/variant_tag.rb +21 -0
  131. data/lib/docks/tags/variation_tag.rb +136 -0
  132. data/lib/docks/tags.rb +103 -0
  133. data/lib/docks/templates.rb +122 -0
  134. data/lib/docks/themes.rb +19 -0
  135. data/lib/docks/types.rb +26 -0
  136. data/lib/docks/version.rb +3 -0
  137. data/lib/docks.rb +37 -0
  138. data/spec/fixtures/build/scripts/bar/bar_2.js +1 -0
  139. data/spec/fixtures/build/scripts/bar.js +1 -0
  140. data/spec/fixtures/build/styles/foo/foo-2.css +1 -0
  141. data/spec/fixtures/build/styles/foo.css +1 -0
  142. data/spec/fixtures/build/templates/baz/baz_2.erb +1 -0
  143. data/spec/fixtures/build/templates/baz.erb +1 -0
  144. data/spec/fixtures/grouper/components/button/button.coffee +0 -0
  145. data/spec/fixtures/grouper/components/button/button.haml +0 -0
  146. data/spec/fixtures/grouper/components/button/button.scss +0 -0
  147. data/spec/fixtures/grouper/components/checkbox/_checkbox.haml +0 -0
  148. data/spec/fixtures/grouper/components/checkbox/_checkbox.scss +0 -0
  149. data/spec/fixtures/grouper/components/checkbox/checkbox.coffee +0 -0
  150. data/spec/fixtures/grouper/components/form/form.coffee +0 -0
  151. data/spec/fixtures/grouper/components/form/form.m +0 -0
  152. data/spec/fixtures/grouper/components/form/form.scss +0 -0
  153. data/spec/fixtures/grouper/components/next-expanding-textarea/_next-expanding-textarea.scss +0 -0
  154. data/spec/fixtures/grouper/components/next-expanding-textarea/_next_expanding_textarea.coffee +0 -0
  155. data/spec/fixtures/grouper/components/next-expanding-textarea/next-expanding-textarea.haml +0 -0
  156. data/spec/fixtures/grouper/components/next-tab/next-tab.coffee +0 -0
  157. data/spec/fixtures/grouper/components/next-tab/next-tab.haml +0 -0
  158. data/spec/fixtures/grouper/components/next-tab/next-tab.scss +0 -0
  159. data/spec/fixtures/grouper/components/segmented control/segmented control.coffee +0 -0
  160. data/spec/fixtures/grouper/components/segmented control/segmented control.haml +0 -0
  161. data/spec/fixtures/grouper/components/segmented control/segmented control.min.html +0 -0
  162. data/spec/fixtures/grouper/components/segmented control/segmented control.scss +0 -0
  163. data/spec/fixtures/grouper/markup/list-view.haml +0 -0
  164. data/spec/fixtures/grouper/markup/resizable/resizable.haml +0 -0
  165. data/spec/fixtures/grouper/markup/toggle.haml +0 -0
  166. data/spec/fixtures/grouper/scripts/resizable/resizable.coffee +0 -0
  167. data/spec/fixtures/grouper/scripts/toggle.coffee +0 -0
  168. data/spec/fixtures/grouper/style/_list-view.scss +0 -0
  169. data/spec/fixtures/grouper/style/_toggle.scss +0 -0
  170. data/spec/fixtures/languages/stub.json +3 -0
  171. data/spec/fixtures/languages/stub.yml +2 -0
  172. data/spec/fixtures/parsers/coffeescript_parser_fixture_basic.coffee +20 -0
  173. data/spec/fixtures/parsers/coffeescript_parser_fixture_complex.coffee +80 -0
  174. data/spec/fixtures/parsers/css_parser_fixture_basic.css +44 -0
  175. data/spec/fixtures/parsers/css_parser_fixture_complex.css +120 -0
  176. data/spec/fixtures/parsers/javascript_parser_fixture_basic.js +27 -0
  177. data/spec/fixtures/parsers/javascript_parser_fixture_complex.js +85 -0
  178. data/spec/fixtures/parsers/sass_parser_fixture_basic.scss +39 -0
  179. data/spec/fixtures/parsers/sass_parser_fixture_complex.scss +149 -0
  180. data/spec/fixtures/parsers/stylus_parser_fixture_basic.styl +34 -0
  181. data/spec/fixtures/parsers/stylus_parser_fixture_complex.styl +113 -0
  182. data/spec/fixtures/processors/join_with_smart_line_breaks/code_blocks.txt +10 -0
  183. data/spec/fixtures/processors/join_with_smart_line_breaks/headings.txt +15 -0
  184. data/spec/fixtures/processors/join_with_smart_line_breaks/lists.txt +21 -0
  185. data/spec/fixtures/processors/join_with_smart_line_breaks/lists_with_nesting.txt +13 -0
  186. data/spec/fixtures/processors/join_with_smart_line_breaks/multiple_paragraphs.txt +11 -0
  187. data/spec/fixtures/renderers/helpers.rb +37 -0
  188. data/spec/fixtures/renderers/html_output.html +7 -0
  189. data/spec/fixtures/renderers/templates/layouts/application.html.erb +0 -0
  190. data/spec/fixtures/renderers/templates/layouts/more/subdirectory.html.erb +0 -0
  191. data/spec/fixtures/renderers/templates/partials/_leading_underscore.html.erb +1 -0
  192. data/spec/fixtures/renderers/templates/partials/more/_subdirectory.html.erb +1 -0
  193. data/spec/fixtures/renderers/templates/partials/partial.html.erb +0 -0
  194. data/spec/fixtures/renderers/templates/partials/template.html.erb +1 -0
  195. data/spec/fixtures/renderers/templates/template.html.erb +1 -0
  196. data/spec/fixtures/tags/description/button.md +24 -0
  197. data/spec/fixtures/tags/description/class.md +27 -0
  198. data/spec/fixtures/tags/description/component.md +23 -0
  199. data/spec/fixtures/tags/description/function.md +30 -0
  200. data/spec/lib/build_spec.rb +467 -0
  201. data/spec/lib/cache_spec.rb +175 -0
  202. data/spec/lib/command_line_spec.rb +77 -0
  203. data/spec/lib/configuration_spec.rb +180 -0
  204. data/spec/lib/containers/base_container_spec.rb +214 -0
  205. data/spec/lib/containers/class_container_spec.rb +209 -0
  206. data/spec/lib/containers/component_container_spec.rb +158 -0
  207. data/spec/lib/containers/demo_container_spec.rb +113 -0
  208. data/spec/lib/containers/function_container_spec.rb +116 -0
  209. data/spec/lib/containers/mixin_container_spec.rb +4 -0
  210. data/spec/lib/containers/pattern_container_spec.rb +291 -0
  211. data/spec/lib/containers/pattern_library_container_spec.rb +130 -0
  212. data/spec/lib/containers/symbol_container_spec.rb +216 -0
  213. data/spec/lib/containers/variable_container_spec.rb +116 -0
  214. data/spec/lib/containers/variation_container_spec.rb +52 -0
  215. data/spec/lib/containers_spec.rb +22 -0
  216. data/spec/lib/descriptor_spec.rb +73 -0
  217. data/spec/lib/group_spec.rb +151 -0
  218. data/spec/lib/helpers/path_helper_spec.rb +202 -0
  219. data/spec/lib/helpers/render_helper_spec.rb +159 -0
  220. data/spec/lib/helpers_spec.rb +35 -0
  221. data/spec/lib/languages/base_language_spec.rb +32 -0
  222. data/spec/lib/languages/coffeescript_language_spec.rb +52 -0
  223. data/spec/lib/languages/css_language_spec.rb +13 -0
  224. data/spec/lib/languages/erb_language_spec.rb +33 -0
  225. data/spec/lib/languages/haml_language_spec.rb +32 -0
  226. data/spec/lib/languages/javascript_language_spec.rb +54 -0
  227. data/spec/lib/languages/json_language_spec.rb +24 -0
  228. data/spec/lib/languages/less_language_spec.rb +39 -0
  229. data/spec/lib/languages/markup_language_spec.rb +95 -0
  230. data/spec/lib/languages/sass_language_spec.rb +53 -0
  231. data/spec/lib/languages/slim_language_spec.rb +32 -0
  232. data/spec/lib/languages/stylus_language_spec.rb +34 -0
  233. data/spec/lib/languages/yaml_language_spec.rb +24 -0
  234. data/spec/lib/languages_spec.rb +127 -0
  235. data/spec/lib/markdown_spec.rb +63 -0
  236. data/spec/lib/messenger_spec.rb +1 -0
  237. data/spec/lib/naming_conventions/bem_naming_convention_spec.rb +112 -0
  238. data/spec/lib/naming_conventions/suit_naming_convention_spec.rb +107 -0
  239. data/spec/lib/naming_conventions_spec.rb +28 -0
  240. data/spec/lib/ostruct_spec.rb +15 -0
  241. data/spec/lib/parser_spec.rb +93 -0
  242. data/spec/lib/parsers/base_parser_spec.rb +128 -0
  243. data/spec/lib/parsers/coffeescript_parser_spec.rb +184 -0
  244. data/spec/lib/parsers/css_parser_spec.rb +136 -0
  245. data/spec/lib/parsers/javascript_parser_spec.rb +216 -0
  246. data/spec/lib/parsers/less_parser_spec.rb +111 -0
  247. data/spec/lib/parsers/sass_parser_spec.rb +233 -0
  248. data/spec/lib/parsers/stylus_parser_spec.rb +212 -0
  249. data/spec/lib/process_spec.rb +96 -0
  250. data/spec/lib/processors_spec.rb +555 -0
  251. data/spec/lib/renderers/base_renderer_spec.rb +122 -0
  252. data/spec/lib/renderers/common_features/helperable_spec.rb +30 -0
  253. data/spec/lib/renderers/erb_renderer_spec.rb +119 -0
  254. data/spec/lib/renderers/haml_renderer_spec.rb +103 -0
  255. data/spec/lib/renderers/slim_renderer_spec.rb +103 -0
  256. data/spec/lib/symbol_sources/jquery_symbol_source_spec.rb +25 -0
  257. data/spec/lib/symbol_sources/mdn_symbol_source_spec.rb +40 -0
  258. data/spec/lib/symbol_sources/sass_symbol_source_spec.rb +39 -0
  259. data/spec/lib/symbol_sources_spec.rb +19 -0
  260. data/spec/lib/tags/access_tag_spec.rb +32 -0
  261. data/spec/lib/tags/activate_with_tag_spec.rb +31 -0
  262. data/spec/lib/tags/active_tag_spec.rb +24 -0
  263. data/spec/lib/tags/alias_tag_spec.rb +31 -0
  264. data/spec/lib/tags/author_tag_spec.rb +172 -0
  265. data/spec/lib/tags/base_tag_spec.rb +21 -0
  266. data/spec/lib/tags/beta_tag_spec.rb +52 -0
  267. data/spec/lib/tags/class_tag_spec.rb +29 -0
  268. data/spec/lib/tags/compatibility_tag_spec.rb +159 -0
  269. data/spec/lib/tags/demo_type_tag_spec.rb +24 -0
  270. data/spec/lib/tags/deprecated_tag_spec.rb +50 -0
  271. data/spec/lib/tags/description_tag_spec.rb +242 -0
  272. data/spec/lib/tags/example_tag_spec.rb +37 -0
  273. data/spec/lib/tags/factory_tag_spec.rb +29 -0
  274. data/spec/lib/tags/for_tag_spec.rb +45 -0
  275. data/spec/lib/tags/group_tag_spec.rb +20 -0
  276. data/spec/lib/tags/helper_tag_spec.rb +22 -0
  277. data/spec/lib/tags/include_with_tag_spec.rb +74 -0
  278. data/spec/lib/tags/javascript_action_tag_spec.rb +20 -0
  279. data/spec/lib/tags/link_tag_spec.rb +49 -0
  280. data/spec/lib/tags/markup_tag_spec.rb +255 -0
  281. data/spec/lib/tags/member_tag_spec.rb +167 -0
  282. data/spec/lib/tags/method_tag_spec.rb +27 -0
  283. data/spec/lib/tags/name_tag_spec.rb +20 -0
  284. data/spec/lib/tags/object_tag_spec.rb +24 -0
  285. data/spec/lib/tags/param_tag_spec.rb +261 -0
  286. data/spec/lib/tags/pattern_tag_spec.rb +49 -0
  287. data/spec/lib/tags/preclude_tag_spec.rb +31 -0
  288. data/spec/lib/tags/private_tag_spec.rb +31 -0
  289. data/spec/lib/tags/property_tag_spec.rb +27 -0
  290. data/spec/lib/tags/public_tag_spec.rb +29 -0
  291. data/spec/lib/tags/require_tag_spec.rb +133 -0
  292. data/spec/lib/tags/returns_tag_spec.rb +85 -0
  293. data/spec/lib/tags/set_by_tag_spec.rb +92 -0
  294. data/spec/lib/tags/signature_tag_spec.rb +125 -0
  295. data/spec/lib/tags/since_tag_spec.rb +48 -0
  296. data/spec/lib/tags/state_tag_spec.rb +199 -0
  297. data/spec/lib/tags/static_tag_spec.rb +27 -0
  298. data/spec/lib/tags/subcomponent_tag_spec.rb +78 -0
  299. data/spec/lib/tags/subtitle_tag_spec.rb +13 -0
  300. data/spec/lib/tags/symbol_type_tag_spec.rb +20 -0
  301. data/spec/lib/tags/throws_tag_spec.rb +49 -0
  302. data/spec/lib/tags/title_tag_spec.rb +20 -0
  303. data/spec/lib/tags/type_tag_spec.rb +20 -0
  304. data/spec/lib/tags/value_tag_spec.rb +20 -0
  305. data/spec/lib/tags/variant_tag_spec.rb +13 -0
  306. data/spec/lib/tags/variation_tag_spec.rb +154 -0
  307. data/spec/lib/tags_spec.rb +264 -0
  308. data/spec/lib/templates_spec.rb +185 -0
  309. data/spec/lib/themes_spec.rb +32 -0
  310. data/spec/spec_helper.rb +34 -0
  311. data/tasks/rspec.rake +7 -0
  312. data/tasks/rubocop.rake +8 -0
  313. metadata +740 -0
@@ -0,0 +1,77 @@
1
+ require "spec_helper"
2
+
3
+ dir = Dir.pwd
4
+
5
+ describe Docks::CommandLine do
6
+ subject { Docks::CommandLine }
7
+
8
+ describe "#run" do
9
+ it "runs #init when the first argument is init" do
10
+ args = %w(init)
11
+ cli = subject.new(args)
12
+ expect(cli).to receive(:init)
13
+ cli.run
14
+ end
15
+
16
+ it "runs the core parsing and building steps when the first argument isn't init" do
17
+ args = []
18
+ cli = subject.new(args)
19
+ expect(Docks).to receive(:configure_with)
20
+ expect(Docks).to receive(:parse)
21
+ expect(Docks).to receive(:build)
22
+ cli.run
23
+ end
24
+
25
+ it "passes the clear cache switch to Docks.parse" do
26
+ args = ["--clear-cache"]
27
+ cli = subject.new(args)
28
+ expect(Docks).to receive(:configure_with)
29
+ expect(Docks).to receive(:parse).with hash_including(clear_cache: true)
30
+ expect(Docks).to receive(:build)
31
+ cli.run
32
+ end
33
+ end
34
+
35
+ describe "#init" do
36
+ it "assigns reasonable defaults" do
37
+ args = %w(init)
38
+ expect(Docks::Builder).to receive(:setup).with hash_including(config_type: "yaml", template_language: "erb", style_language: "scss", script_language: "javascript")
39
+ subject.new(args).init
40
+ end
41
+
42
+ it "assigns a config type" do
43
+ type = "ruby"
44
+ args = ["init", "--config=#{type}"]
45
+ expect(Docks::Builder).to receive(:setup).with hash_including(config_type: type)
46
+ subject.new(args).init
47
+ end
48
+
49
+ it "assigns a template language" do
50
+ language = "haml"
51
+ args = ["init", "--template=#{language}"]
52
+ expect(Docks::Builder).to receive(:setup).with hash_including(template_language: language)
53
+ subject.new(args).init
54
+ end
55
+
56
+ it "assigns a style preprocessor" do
57
+ preprocessor = "less"
58
+ args = ["init", "--styles=#{preprocessor}"]
59
+ expect(Docks::Builder).to receive(:setup).with hash_including(style_language: preprocessor)
60
+ subject.new(args).init
61
+ end
62
+
63
+ it "assigns a scripting language" do
64
+ language = "coffeescript"
65
+ args = ["init", "--scripts=#{language}"]
66
+ expect(Docks::Builder).to receive(:setup).with hash_including(script_language: language)
67
+ subject.new(args).init
68
+ end
69
+
70
+ it "assigns a theme" do
71
+ theme = "basic"
72
+ args = ["init", "--theme=#{theme}"]
73
+ expect(Docks::Builder).to receive(:setup).with hash_including(theme: theme)
74
+ subject.new(args).init
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,180 @@
1
+ require "spec_helper"
2
+
3
+ describe Docks do
4
+ subject { Docks }
5
+
6
+ it "has a config property" do
7
+ expect(subject.config).to be Docks::Configuration.instance
8
+ end
9
+
10
+ describe ".configure" do
11
+ it "yields the configuration object" do
12
+ yielded = nil
13
+ subject.configure { |config| yielded = config }
14
+ expect(yielded).to be Docks::Configuration.instance
15
+ end
16
+
17
+ it "pre- and post-configures before configuration" do
18
+ expect(subject).to receive(:pre_configuration)
19
+ expect(subject).to receive(:post_configuration)
20
+ subject.configure {}
21
+ end
22
+
23
+ it "only runs the pre-configuration steps if it hasn't already been configured" do
24
+ expect(subject).to receive(:pre_configuration).once
25
+ subject.configure {}
26
+ subject.configure {}
27
+ end
28
+
29
+ it "configures itself with the default config file if no block is passed" do
30
+ expect(subject).to receive(:configure_with).with Docks::CONFIG_FILE
31
+ subject.configure
32
+ end
33
+ end
34
+ end
35
+
36
+ describe Docks::Configuration do
37
+ subject { Docks::Configuration.instance }
38
+
39
+ it "has the default configuration" do
40
+ expect(subject.sources).to eq [
41
+ subject.root + "styles/**/*.{css,scss,sass,less,styl}",
42
+ subject.root + "scripts/**/*.{js,coffee,coffeescript}"
43
+ ]
44
+ expect(subject.compiled_assets).to eq []
45
+ expect(subject.github_repo).to be nil
46
+ expect(subject.root).to eq Pathname.pwd
47
+ expect(subject.destination).to eq subject.root + "public"
48
+ expect(subject.cache_location).to eq subject.root + ".#{Docks::Cache::DIR}"
49
+ expect(subject.templates).to eq subject.root + "#{Docks::ASSETS_DIR}/templates"
50
+ expect(subject.asset_folders).to eq OpenStruct.new(styles: "styles", scripts: "scripts")
51
+ expect(subject.mount_at).to eq "pattern-library"
52
+ expect(subject.theme).to eq Docks::Themes::API.instance
53
+ expect(subject.use_theme_assets).to be true
54
+ end
55
+
56
+ describe "#root=" do
57
+ it "updates all root-dependent paths for a new root" do
58
+ test_dir_name = ".foo"
59
+ FileUtils.rm_rf(test_dir_name)
60
+ FileUtils.mkdir(test_dir_name)
61
+
62
+ subject.root = File.join(Dir.pwd, test_dir_name)
63
+ subject.sources = %w(styles/foo.css)
64
+
65
+ expect(subject.root).to eq Pathname.new(test_dir_name).realpath
66
+ expect(subject.destination).to eq subject.root + "public"
67
+ expect(subject.cache_location).to eq subject.root + ".#{Docks::Cache::DIR}"
68
+ expect(subject.templates).to eq subject.root + "#{Docks::ASSETS_DIR}/templates"
69
+ expect(subject.sources).to eq [subject.root + "styles/foo.css"]
70
+
71
+ FileUtils.rm_rf(test_dir_name)
72
+ end
73
+ end
74
+
75
+ describe "#destination=" do
76
+ it "allows setting root-relative paths" do
77
+ subject.destination = "out"
78
+ expect(subject.destination).to eq subject.root + "out"
79
+ end
80
+
81
+ it "allows setting non-root-relative paths" do
82
+ destination = Dir[File.join(Dir.pwd, "*")].first
83
+ subject.destination = destination
84
+ expect(subject.destination).to eq Pathname.new(destination).realpath
85
+ end
86
+ end
87
+
88
+ describe "#asset_folders=" do
89
+ it "merges the default asset folders" do
90
+ defaults = subject.asset_folders
91
+ expect { subject.asset_folders = { scripts: "javascripts" } }.not_to change { defaults.styles }
92
+ expect(subject.asset_folders.scripts).to eq "javascripts"
93
+ end
94
+ end
95
+
96
+ describe "#custom_languages" do
97
+ it "yields the language manager" do
98
+ expect { |block| subject.custom_languages(&block) }.to yield_with_args Docks::Languages
99
+ end
100
+ end
101
+
102
+ describe "#custom_templates" do
103
+ it "yields the template manager" do
104
+ expect { |block| subject.custom_templates(&block) }.to yield_with_args Docks::Templates
105
+ end
106
+ end
107
+
108
+ describe "#custom_templates=" do
109
+ it "passes the templates to Templates.register" do
110
+ templates = { foo: "bar", bar: "baz" }
111
+ expect(Docks::Templates).to receive(:register).with(templates)
112
+ subject.custom_templates = templates
113
+ end
114
+ end
115
+
116
+ describe "#custom_tags" do
117
+ it "yields the tag manager" do
118
+ expect { |block| subject.custom_tags(&block) }.to yield_with_args Docks::Tags
119
+ end
120
+ end
121
+
122
+ describe "#custom_symbol_sources" do
123
+ it "yields the symbol source manager" do
124
+ expect { |block| subject.custom_symbol_sources(&block) }.to yield_with_args Docks::SymbolSources
125
+ end
126
+ end
127
+
128
+ describe "#custom_parsers" do
129
+ it "yields the parser manager" do
130
+ expect { |block| subject.custom_parsers(&block) }.to yield_with_args Docks::Parser
131
+ end
132
+ end
133
+
134
+ describe "#github_repo" do
135
+ it "returns nil when there is no github repo" do
136
+ expect(subject.github_repo).to be nil
137
+ end
138
+
139
+ it "returns the URL for a github repo when provided" do
140
+ subject.github_repo = "https://github.com/lemonmade/docks"
141
+ expect(subject.github_repo).to eq "https://github.com/lemonmade/docks"
142
+ end
143
+
144
+ it "constructs the github URL when the repo was specified" do
145
+ subject.github_repo = "lemonmade/docks"
146
+ expect(subject.github_repo).to eq "https://github.com/lemonmade/docks"
147
+ end
148
+ end
149
+
150
+ describe "#naming_convention=" do
151
+ it "asks the naming convention manager for the new naming convention" do
152
+ expect(Docks::NamingConventions).to receive(:for).with(:foo).and_return(:bar)
153
+ subject.naming_convention = :foo
154
+ expect(subject.naming_convention).to eq :bar
155
+ end
156
+ end
157
+
158
+ describe "#theme=" do
159
+ it "asks the theme manager to set the new theme" do
160
+ expect(Docks::Themes).to receive(:for).with(:foo).and_return(:bar)
161
+ subject.theme = :foo
162
+ expect(subject.theme).to eq :bar
163
+ end
164
+ end
165
+
166
+ describe "#pattern_id=" do
167
+ it "passes the pattern ID block to the Docks class method" do
168
+ identifier = Docks.instance_variable_get(:@pattern_id)
169
+ expect(Docks).to receive(:pattern_id=).with(identifier)
170
+ subject.pattern_id = identifier
171
+ end
172
+ end
173
+
174
+ describe "#pattern_id" do
175
+ it "calls the core pattern ID method" do
176
+ expect(Docks).to receive(:pattern_id).with("foo").and_return "foo"
177
+ expect(subject.pattern_id("foo")).to eq "foo"
178
+ end
179
+ end
180
+ end
@@ -0,0 +1,214 @@
1
+ require "spec_helper"
2
+
3
+ describe Docks::Containers::Base do
4
+ before(:each) { Docks::Tags.register_bundled_tags }
5
+
6
+ let(:hash) do
7
+ { name: "baz", param: Hash.new, title: "bar" }
8
+ end
9
+
10
+ let(:container) { Docks::Containers::Base.new(hash) }
11
+
12
+ describe "#method_missing" do
13
+ context "when the method ends with `=`" do
14
+ it "normalizes the passed tag name" do
15
+ expect(Docks::Tags).to receive(:base_tag_name).with(:title).at_least(:once).and_call_original
16
+ container.title = :bar
17
+ end
18
+
19
+ it "sends the base tag of unrecognized symbols to the initialization hash" do
20
+ expect(container.instance_variable_get(:@details)).to receive(:[]=).with(:title, :bar)
21
+ container.title = :bar
22
+ end
23
+
24
+ it "does the default method missing when the method is not a recognized tag" do
25
+ expect { container.foo = :bar }.to raise_error(NoMethodError)
26
+ end
27
+ end
28
+
29
+ context "when the method is a plural of a recognized tag" do
30
+ it "normalizes the singular version of the hash name" do
31
+ expect(Docks::Tags).to receive(:base_tag_name).at_least(:once).with(:params).and_call_original
32
+ container.params
33
+ end
34
+
35
+ it "does the default method missing when the method is not a recognized tag" do
36
+ expect { container.foos }.to raise_error(NoMethodError)
37
+ end
38
+ end
39
+
40
+ context "when the method ends with anything other than `=` and it's a recognized tag" do
41
+ it "normalizes the passed tag name" do
42
+ expect(Docks::Tags).to receive(:base_tag_name).with(:title).at_least(:once).and_call_original
43
+ container.title
44
+ end
45
+
46
+ it "sends the base tag of unrecognized symbols to the initialization hash" do
47
+ expect(container.instance_variable_get(:@details)).to receive(:fetch).with(:title, nil)
48
+ container.title
49
+ end
50
+
51
+ it "does the default method missing when the method is not a recognized tag" do
52
+ expect { container.foo }.to raise_error(NoMethodError)
53
+ end
54
+ end
55
+ end
56
+
57
+ describe "#[]" do
58
+ it "normalizes the passed tag name" do
59
+ expect(Docks::Tags).to receive(:base_tag_name).with(:title).and_call_original
60
+ container[:title]
61
+ end
62
+
63
+ it "accesses the item in the contained hash" do
64
+ expect(container[:title]).to eq hash[:title]
65
+ end
66
+
67
+ it "returns nil when there is no such key" do
68
+ expect(container[:pattern]).to be nil
69
+ end
70
+ end
71
+
72
+ describe "#[]=" do
73
+ it "normalizes the passed tag name" do
74
+ expect(Docks::Tags).to receive(:base_tag_name).with(:title).and_call_original
75
+ container[:title] = :bar
76
+ end
77
+
78
+ it "sets the item in the contained hash" do
79
+ expect(container.instance_variable_get(:@details)).to receive(:[]=).with(:title, :bar).and_call_original
80
+ container[:title] = :bar
81
+ expect(container[:title]).to eq :bar
82
+ end
83
+
84
+ it "doesn't set the value for a non-registered tag" do
85
+ expect(container.instance_variable_get(:@details)).to_not receive(:[]=)
86
+ container[:foo] = :bar
87
+ end
88
+ end
89
+
90
+ describe "#update" do
91
+ it "normalizes the passed tag name" do
92
+ expect(Docks::Tags).to receive(:base_tag_name).at_least(:once).with(:title).and_call_original
93
+ container.update(:title) {}
94
+ end
95
+
96
+ it "yields the current value of the tag" do
97
+ value = nil
98
+ expected = container.title
99
+
100
+ container.update(:title) { |val| value = val }
101
+ expect(value).to eq expected
102
+ end
103
+
104
+ it "updates the tag with the value returned from the block" do
105
+ value = "qux"
106
+ container.update(:title) { value }
107
+ expect(container.title).to eq value
108
+ end
109
+ end
110
+
111
+ describe "#delete" do
112
+ it "normalizes the passed tag name" do
113
+ expect(Docks::Tags).to receive(:base_tag_name).with(:title).and_call_original
114
+ container.delete(:title)
115
+ end
116
+
117
+ it "deletes the item in the contained hash" do
118
+ original = hash[:title]
119
+ expect(container.instance_variable_get(:@details)).to receive(:delete).with(:title).and_call_original
120
+ expect(container.delete(:title)).to eq original
121
+ end
122
+ end
123
+
124
+ describe "#fetch" do
125
+ it "normalizes the passed tag name" do
126
+ expect(Docks::Tags).to receive(:base_tag_name).with(:title).and_call_original
127
+ container.fetch(:title, :bar)
128
+ end
129
+
130
+ it "passes the fetch method along to the contained hash" do
131
+ expect(container.instance_variable_get(:@details)).to receive(:fetch).with(:title, :bar).and_call_original
132
+ container.fetch(:title, :bar)
133
+ end
134
+ end
135
+
136
+ describe "#to_h" do
137
+ it "returns the backing hash" do
138
+ expect(container.to_h).to eq hash
139
+ end
140
+
141
+ it "is aliased to #to_hash" do
142
+ expect(container.to_hash).to eq container.to_h
143
+ end
144
+ end
145
+
146
+ describe "#find" do
147
+ it "returns itself when it matches the descriptor" do
148
+ expect(container.find(container.name)).to be container
149
+ end
150
+
151
+ it "returns false when it does not match" do
152
+ expect(container.find("#{container.name}#foo")).to be false
153
+ expect(container.find("foo")).to be false
154
+ end
155
+ end
156
+
157
+ describe "#tags" do
158
+ around do |example|
159
+ Docks::Tags.register_bundled_tags
160
+ example.run
161
+ Docks::Tags.send(:clean)
162
+ end
163
+
164
+ it "returns an array with all tags in the item" do
165
+ container = Docks::Containers::Base.new
166
+ expect(container.tags).to be_empty
167
+
168
+ container[Docks::Tags::Title] = "foo"
169
+ expect(container.tags).to be_an Array
170
+ expect(container.tags.length).to be 1
171
+ expect(container.tags.first).to be Docks::Tags::Title.instance
172
+
173
+ container.name = "bar"
174
+ expect(container.tags.length).to be 2
175
+ expect(container.tags).to include Docks::Tags::Title.instance
176
+ expect(container.tags).to include Docks::Tags::Name.instance
177
+
178
+ container.delete(:name)
179
+ expect(container.tags.length).to be 1
180
+ expect(container.tags.first).to be Docks::Tags::Title.instance
181
+ end
182
+ end
183
+
184
+ describe "#summarized?" do
185
+ it "is summarized only if generated by #summary" do
186
+ expect(container).to_not be_summarized
187
+ expect(container.summary).to be_summarized
188
+ end
189
+ end
190
+
191
+ describe "#summary" do
192
+ let(:summary) { container.summary }
193
+
194
+ it "preserves the name" do
195
+ expect(summary).to be_a described_class
196
+ expect(summary.name).to eq container.name
197
+ end
198
+
199
+ it "doesn't preserve anything else" do
200
+ container.description = "something long " * 100
201
+ expect(container.summary.description).to be nil
202
+ end
203
+ end
204
+
205
+ describe "forwarded to hash" do
206
+ %w(to_s inspect to_json each).each do |forwarded_method|
207
+ it "forwards #{forwarded_method} to the backing hash" do
208
+ forwarded_method = forwarded_method.to_sym
209
+ expect(container.instance_variable_get(:@details)).to receive(forwarded_method).at_least(:once)
210
+ container.send(forwarded_method)
211
+ end
212
+ end
213
+ end
214
+ end
@@ -0,0 +1,209 @@
1
+ require "spec_helper"
2
+
3
+ describe Docks::Containers::Klass do
4
+ subject { Docks::Containers::Klass.new(name: "foo") }
5
+
6
+ let(:method) do
7
+ Docks::Containers::Function.new(name: "bar")
8
+ end
9
+
10
+ let(:property) do
11
+ Docks::Containers::Variable.new(name: "bar")
12
+ end
13
+
14
+ let(:private_method) do
15
+ Docks::Containers::Function.new(name: "baz", access: Docks::Types::Access::PRIVATE)
16
+ end
17
+
18
+ let(:private_property) do
19
+ Docks::Containers::Variable.new(name: "baz", access: Docks::Types::Access::PRIVATE)
20
+ end
21
+
22
+ let(:static_method) do
23
+ Docks::Containers::Function.new(name: "baz", static: true, access: Docks::Types::Access::PRIVATE)
24
+ end
25
+
26
+ let(:static_property) do
27
+ Docks::Containers::Variable.new(name: "baz", static: true, access: Docks::Types::Access::PRIVATE)
28
+ end
29
+
30
+ describe "#find" do
31
+ it "returns false if the descriptor symbol doesn't match" do
32
+ expect(subject.find("baz")).to be false
33
+ end
34
+
35
+ it "returns the symbol when the symbol name matches and there are no other parts to the descriptor" do
36
+ expect(subject.find(subject.name)).to be subject
37
+ end
38
+
39
+ it "returns false when the symbol name matches but the member does not" do
40
+ expect(subject.find("#{subject.name}.bar")).to be false
41
+ expect(subject.find("#{subject.name}#bar")).to be false
42
+ expect(subject.find("#{subject.name}~bar")).to be false
43
+ end
44
+
45
+ it "returns an instance method" do
46
+ static_method.name = method.name
47
+ subject.add_members(static_method, method)
48
+ expect(subject.find("#{subject.name}##{method.name}")).to be method
49
+ end
50
+
51
+ it "returns a static method" do
52
+ static_method.name = method.name
53
+ subject.add_members(method, static_method)
54
+ expect(subject.find("#{subject.name}.#{static_method.name}")).to be static_method
55
+ end
56
+
57
+ it "returns an instance property" do
58
+ static_property.name = property.name
59
+ subject.add_members(static_property, property)
60
+ expect(subject.find("#{subject.name}##{property.name}")).to be property
61
+ end
62
+
63
+ it "returns a static property" do
64
+ static_property.name = property.name
65
+ subject.add_members(property, static_property)
66
+ expect(subject.find("#{subject.name}.#{static_property.name}")).to be static_property
67
+ end
68
+ end
69
+
70
+ describe "#public_methods" do
71
+ it "returns an empty array when there are no public methods" do
72
+ subject.add_member(private_method)
73
+ expect(subject.public_methods).to be_empty
74
+ end
75
+
76
+ it "returns all public methods of the class" do
77
+ subject.add_members(method, private_method)
78
+ public_methods = subject.public_methods
79
+ expect(public_methods.length).to be 1
80
+ expect(public_methods.first).to be method
81
+ end
82
+ end
83
+
84
+ describe "#private_methods" do
85
+ it "returns an empty array when there are no private methods" do
86
+ subject.add_member(method)
87
+ expect(subject.private_methods).to be_empty
88
+ end
89
+
90
+ it "returns all private methods of the class" do
91
+ subject.add_members(method, private_method)
92
+ public_methods = subject.private_methods
93
+ expect(public_methods.length).to be 1
94
+ expect(public_methods.first).to be private_method
95
+ end
96
+ end
97
+
98
+ describe "#static_methods" do
99
+ it "returns an empty array when there are no static methods" do
100
+ subject.add_members(method, private_method)
101
+ expect(subject.static_methods).to be_empty
102
+ end
103
+
104
+ it "returns all static methods of the class" do
105
+ subject.add_members(method, static_method, private_method)
106
+ static_methods = subject.static_methods
107
+ expect(static_methods.length).to be 1
108
+ expect(static_methods.first).to be static_method
109
+ end
110
+ end
111
+
112
+ describe "#instance_methods" do
113
+ it "returns an empty array when there are no instance methods" do
114
+ subject.add_member(static_method)
115
+ expect(subject.instance_methods).to be_empty
116
+ end
117
+
118
+ it "returns all instance methods of the class" do
119
+ subject.add_members(method, static_method, private_method)
120
+ instance_methods = subject.instance_methods
121
+ expect(instance_methods.length).to be 2
122
+ expect(instance_methods).to include method
123
+ expect(instance_methods).to include private_method
124
+ end
125
+ end
126
+
127
+ describe "#public_properties" do
128
+ it "returns an empty array when there are no public properties" do
129
+ subject.add_member(private_property)
130
+ expect(subject.public_properties).to be_empty
131
+ end
132
+
133
+ it "returns all public properties of the class" do
134
+ subject.add_members(property, private_property)
135
+ public_properties = subject.public_properties
136
+ expect(public_properties.length).to be 1
137
+ expect(public_properties.first).to be property
138
+ end
139
+ end
140
+
141
+ describe "#private_properties" do
142
+ it "returns an empty array when there are no private properties" do
143
+ subject.add_member(property)
144
+ expect(subject.private_properties).to be_empty
145
+ end
146
+
147
+ it "returns all private properties of the class" do
148
+ subject.add_members(property, private_property)
149
+ public_properties = subject.private_properties
150
+ expect(public_properties.length).to be 1
151
+ expect(public_properties.first).to be private_property
152
+ end
153
+ end
154
+
155
+ describe "#static_properties" do
156
+ it "returns an empty array when there are no static properties" do
157
+ subject.add_members(property, private_property)
158
+ expect(subject.static_properties).to be_empty
159
+ end
160
+
161
+ it "returns all static properties of the class" do
162
+ subject.add_members(property, static_property, private_property)
163
+ static_properties = subject.static_properties
164
+ expect(static_properties.length).to be 1
165
+ expect(static_properties.first).to be static_property
166
+ end
167
+ end
168
+
169
+ describe "#instance_properties" do
170
+ it "returns an empty array when there are no instance properties" do
171
+ subject.add_member(static_property)
172
+ expect(subject.instance_properties).to be_empty
173
+ end
174
+
175
+ it "returns all instance properties of the class" do
176
+ subject.add_members(property, static_property, private_property)
177
+ instance_properties = subject.instance_properties
178
+ expect(instance_properties.length).to be 2
179
+ expect(instance_properties).to include property
180
+ expect(instance_properties).to include private_property
181
+ end
182
+ end
183
+
184
+ describe "#instance_members" do
185
+ it "includes all instance methods and properties" do
186
+ subject.add_members(method, private_method, static_method)
187
+ subject.add_members(property, private_property, static_property)
188
+
189
+ members = subject.instance_members
190
+ expect(members.length).to be 4
191
+ expect(members).to include method
192
+ expect(members).to include property
193
+ expect(members).to include private_method
194
+ expect(members).to include private_property
195
+ end
196
+ end
197
+
198
+ describe "#static_members" do
199
+ it "includes all static methods and properties" do
200
+ subject.add_members(method, private_method, static_method)
201
+ subject.add_members(property, private_property, static_property)
202
+
203
+ members = subject.static_members
204
+ expect(members.length).to be 2
205
+ expect(members).to include static_method
206
+ expect(members).to include static_property
207
+ end
208
+ end
209
+ end