middleman-presentation-core 0.16.0.alpha

Sign up to get free protection for your applications and to get access to all the features.
Files changed (223) hide show
  1. checksums.yaml +7 -0
  2. data/.rdebugrc +7 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +52 -0
  5. data/.simplecov +25 -0
  6. data/.yardopts +5 -0
  7. data/Guardfile +13 -0
  8. data/LICENSE.software +21 -0
  9. data/Rakefile +200 -0
  10. data/config/license_finder.yml +13 -0
  11. data/cucumber.yml +2 -0
  12. data/doc/licenses/dependencies.csv +55 -0
  13. data/doc/licenses/dependencies.db +0 -0
  14. data/doc/licenses/dependencies.html +1415 -0
  15. data/doc/licenses/dependencies.md +603 -0
  16. data/doc/licenses/dependencies_detailed.csv +190 -0
  17. data/doc/yard/.keep +0 -0
  18. data/features/build_presentation.feature +62 -0
  19. data/features/code_highlighting.feature +43 -0
  20. data/features/components.feature +29 -0
  21. data/features/create_plugin-cli.feature +11 -0
  22. data/features/create_presentation-cli.feature +349 -0
  23. data/features/create_slide-cli.feature +188 -0
  24. data/features/create_slides-templates-cli.feature +114 -0
  25. data/features/create_theme-cli.feature +58 -0
  26. data/features/default_slides.feature +58 -0
  27. data/features/edit_slide-cli.feature +121 -0
  28. data/features/export_presentation-cli.feature +23 -0
  29. data/features/grouping_slides.feature +150 -0
  30. data/features/ignore_slides.feature +103 -0
  31. data/features/init_application-cli.feature +59 -0
  32. data/features/init_predefined_slides.feature +9 -0
  33. data/features/language_detection.feature +0 -0
  34. data/features/list_assets-cli.feature +13 -0
  35. data/features/list_components-cli.feature +13 -0
  36. data/features/list_helpers-cli.feature +13 -0
  37. data/features/list_plugins-cli.feature +13 -0
  38. data/features/list_styles-cli.feature +17 -0
  39. data/features/plugins.feature +63 -0
  40. data/features/presentation.feature +57 -0
  41. data/features/rename_slide-cli.feature +176 -0
  42. data/features/render_slides.feature +76 -0
  43. data/features/show_config-cli.feature +25 -0
  44. data/features/show_footer.feature +14 -0
  45. data/features/show_slide_number.feature +31 -0
  46. data/features/show_support_information-cli.feature +12 -0
  47. data/features/support/aruba.rb +18 -0
  48. data/features/support/ci.rb +3 -0
  49. data/features/support/env.rb +25 -0
  50. data/features/support/fixtures.rb +21 -0
  51. data/features/support/hash.rb +2 -0
  52. data/features/support/reporting.rb +2 -0
  53. data/features/version_number.feature +15 -0
  54. data/fixtures/middleman-presentation-simple_plugin/Rakefile +1 -0
  55. data/fixtures/middleman-presentation-simple_plugin/lib/middleman-presentation-plugin.rb +0 -0
  56. data/fixtures/middleman-presentation-simple_plugin/lib/middleman-presentation-simple_plugin/helpers.rb +13 -0
  57. data/fixtures/middleman-presentation-simple_plugin/lib/middleman-presentation-simple_plugin/plugin.rb +34 -0
  58. data/fixtures/middleman-presentation-simple_plugin/lib/middleman-presentation-simple_plugin/version.rb +8 -0
  59. data/fixtures/middleman-presentation-simple_plugin/lib/middleman-presentation-simple_plugin.rb +11 -0
  60. data/fixtures/middleman-presentation-simple_plugin/middleman-presentation-simple_plugin.gemspec +22 -0
  61. data/fixtures/middleman-presentation-simple_plugin/vendor/assets/stylesheets/test_simple.scss +3 -0
  62. data/lib/middleman-presentation-core/application_config.rb +198 -0
  63. data/lib/middleman-presentation-core/asset.rb +103 -0
  64. data/lib/middleman-presentation-core/asset_component.rb +34 -0
  65. data/lib/middleman-presentation-core/asset_list.rb +84 -0
  66. data/lib/middleman-presentation-core/asset_store.rb +73 -0
  67. data/lib/middleman-presentation-core/assets_loader.rb +95 -0
  68. data/lib/middleman-presentation-core/assets_manager.rb +73 -0
  69. data/lib/middleman-presentation-core/cache.rb +49 -0
  70. data/lib/middleman-presentation-core/cli/base.rb +30 -0
  71. data/lib/middleman-presentation-core/cli/base_group.rb +11 -0
  72. data/lib/middleman-presentation-core/cli/build.rb +13 -0
  73. data/lib/middleman-presentation-core/cli/build_presentation.rb +57 -0
  74. data/lib/middleman-presentation-core/cli/change.rb +13 -0
  75. data/lib/middleman-presentation-core/cli/change_slide.rb +82 -0
  76. data/lib/middleman-presentation-core/cli/create.rb +16 -0
  77. data/lib/middleman-presentation-core/cli/create_plugin.rb +62 -0
  78. data/lib/middleman-presentation-core/cli/create_presentation.rb +300 -0
  79. data/lib/middleman-presentation-core/cli/create_slide.rb +52 -0
  80. data/lib/middleman-presentation-core/cli/create_theme.rb +81 -0
  81. data/lib/middleman-presentation-core/cli/edit.rb +13 -0
  82. data/lib/middleman-presentation-core/cli/edit_slide.rb +49 -0
  83. data/lib/middleman-presentation-core/cli/export.rb +11 -0
  84. data/lib/middleman-presentation-core/cli/export_presentation.rb +55 -0
  85. data/lib/middleman-presentation-core/cli/init.rb +12 -0
  86. data/lib/middleman-presentation-core/cli/init_application.rb +48 -0
  87. data/lib/middleman-presentation-core/cli/init_predefined_slides.rb +31 -0
  88. data/lib/middleman-presentation-core/cli/list.rb +66 -0
  89. data/lib/middleman-presentation-core/cli/reset_thor.rb +18 -0
  90. data/lib/middleman-presentation-core/cli/runner.rb +47 -0
  91. data/lib/middleman-presentation-core/cli/serve.rb +13 -0
  92. data/lib/middleman-presentation-core/cli/serve_presentation.rb +30 -0
  93. data/lib/middleman-presentation-core/cli/shared.rb +51 -0
  94. data/lib/middleman-presentation-core/cli/show.rb +70 -0
  95. data/lib/middleman-presentation-core/comparable_slide.rb +69 -0
  96. data/lib/middleman-presentation-core/component.rb +86 -0
  97. data/lib/middleman-presentation-core/components_manager.rb +96 -0
  98. data/lib/middleman-presentation-core/configuration_file.rb +15 -0
  99. data/lib/middleman-presentation-core/css_class_extracter.rb +41 -0
  100. data/lib/middleman-presentation-core/custom_template.rb +15 -0
  101. data/lib/middleman-presentation-core/erb_template.rb +15 -0
  102. data/lib/middleman-presentation-core/errors.rb +10 -0
  103. data/lib/middleman-presentation-core/existing_slide.rb +92 -0
  104. data/lib/middleman-presentation-core/frontend_component.rb +75 -0
  105. data/lib/middleman-presentation-core/group_template.rb +15 -0
  106. data/lib/middleman-presentation-core/helpers_manager.rb +37 -0
  107. data/lib/middleman-presentation-core/ignore_file.rb +52 -0
  108. data/lib/middleman-presentation-core/liquid_template.rb +15 -0
  109. data/lib/middleman-presentation-core/list.rb +7 -0
  110. data/lib/middleman-presentation-core/locale_configurator.rb +84 -0
  111. data/lib/middleman-presentation-core/logger.rb +8 -0
  112. data/lib/middleman-presentation-core/main.rb +55 -0
  113. data/lib/middleman-presentation-core/markdown_template.rb +15 -0
  114. data/lib/middleman-presentation-core/middleman_environment.rb +108 -0
  115. data/lib/middleman-presentation-core/middleman_extension.rb +12 -0
  116. data/lib/middleman-presentation-core/middleman_step_definitions.rb +131 -0
  117. data/lib/middleman-presentation-core/new_slide.rb +140 -0
  118. data/lib/middleman-presentation-core/overwrite_sass.rb +22 -0
  119. data/lib/middleman-presentation-core/plugin.rb +8 -0
  120. data/lib/middleman-presentation-core/plugin_api.rb +65 -0
  121. data/lib/middleman-presentation-core/plugins_manager.rb +7 -0
  122. data/lib/middleman-presentation-core/predefined_slide_templates_directory.rb +15 -0
  123. data/lib/middleman-presentation-core/presentation_helper.rb +69 -0
  124. data/lib/middleman-presentation-core/register_extension.rb +4 -0
  125. data/lib/middleman-presentation-core/roles/comparable_by_name.rb +24 -0
  126. data/lib/middleman-presentation-core/slide_group.rb +33 -0
  127. data/lib/middleman-presentation-core/slide_list.rb +52 -0
  128. data/lib/middleman-presentation-core/slide_name.rb +61 -0
  129. data/lib/middleman-presentation-core/start.rb +68 -0
  130. data/lib/middleman-presentation-core/step_definitions.rb +238 -0
  131. data/lib/middleman-presentation-core/syntax_highlighter.rb +42 -0
  132. data/lib/middleman-presentation-core/test_helpers.rb +22 -0
  133. data/lib/middleman-presentation-core/transformers/file_keeper.rb +13 -0
  134. data/lib/middleman-presentation-core/transformers/group_slides.rb +34 -0
  135. data/lib/middleman-presentation-core/transformers/ignore_slides.rb +28 -0
  136. data/lib/middleman-presentation-core/transformers/remove_duplicate_slides.rb +32 -0
  137. data/lib/middleman-presentation-core/transformers/sort_slides.rb +13 -0
  138. data/lib/middleman-presentation-core/utils.rb +40 -0
  139. data/lib/middleman-presentation-core/version.rb +8 -0
  140. data/lib/middleman-presentation-core.rb +127 -0
  141. data/locales/de.yml +233 -0
  142. data/locales/en.yml +236 -0
  143. data/middleman-presentation-core.gemspec +40 -0
  144. data/source/slides/01.html.liquid +0 -0
  145. data/spec/asset_component_spec.rb +13 -0
  146. data/spec/asset_list_spec.rb +50 -0
  147. data/spec/asset_spec.rb +45 -0
  148. data/spec/asset_store_spec.rb +61 -0
  149. data/spec/assets_manager_spec.rb +111 -0
  150. data/spec/components_manager_spec.rb +142 -0
  151. data/spec/css_class_extracter_spec.rb +28 -0
  152. data/spec/existing_slide_spec.rb +177 -0
  153. data/spec/frontend_component_spec.rb +94 -0
  154. data/spec/helpers_manager_spec.rb +90 -0
  155. data/spec/ignore_file_spec.rb +75 -0
  156. data/spec/new_slide_spec.rb +155 -0
  157. data/spec/presentation_helper_spec.rb +137 -0
  158. data/spec/shared_examples/.keep +0 -0
  159. data/spec/slide_group_spec.rb +54 -0
  160. data/spec/slide_list_spec.rb +125 -0
  161. data/spec/slide_name_spec.rb +53 -0
  162. data/spec/spec_helper.rb +19 -0
  163. data/spec/support/aruba.rb +53 -0
  164. data/spec/support/ci.rb +20 -0
  165. data/spec/support/environment.rb +18 -0
  166. data/spec/support/filesystem.rb +22 -0
  167. data/spec/support/locale.rb +2 -0
  168. data/spec/support/reporting.rb +2 -0
  169. data/spec/support/rspec.rb +9 -0
  170. data/spec/support/string.rb +2 -0
  171. data/spec/transformers/file_keeper_spec.rb +24 -0
  172. data/spec/transformers/group_slides_spec.rb +44 -0
  173. data/spec/transformers/ignore_slides_spec.rb +64 -0
  174. data/spec/transformers/remove_duplicate_slides_spec.rb +120 -0
  175. data/spec/transformers/sort_slides_spec.rb +17 -0
  176. data/spec/utils_spec.rb +14 -0
  177. data/templates/.bowerrc.tt +4 -0
  178. data/templates/.gitignore +5 -0
  179. data/templates/Gemfile.tt +32 -0
  180. data/templates/LICENSE.presentation +1 -0
  181. data/templates/Rakefile +59 -0
  182. data/templates/bower.json.tt +8 -0
  183. data/templates/bundler_config.tt +6 -0
  184. data/templates/config.rb.tt +2 -0
  185. data/templates/config.yaml.tt +17 -0
  186. data/templates/gitignore.tt +14 -0
  187. data/templates/plugin/%plugin_name%.gemspec.tt +24 -0
  188. data/templates/plugin/.gitignore +13 -0
  189. data/templates/plugin/Gemfile.tt +4 -0
  190. data/templates/plugin/LICENSE.txt.tt +22 -0
  191. data/templates/plugin/README.md.tt +31 -0
  192. data/templates/plugin/Rakefile +1 -0
  193. data/templates/plugin/lib/%plugin_name%/version.rb.tt +8 -0
  194. data/templates/plugin/lib/%plugin_name%.rb.tt +10 -0
  195. data/templates/predefined_slides.d/00_00.html.erb.tt +26 -0
  196. data/templates/predefined_slides.d/00_01.html.md.tt +6 -0
  197. data/templates/predefined_slides.d/999980.html.erb.tt +4 -0
  198. data/templates/predefined_slides.d/999981.html.erb.tt +27 -0
  199. data/templates/predefined_slides.d/999982.html.erb.tt +4 -0
  200. data/templates/presentation_theme/bower.json.tt +20 -0
  201. data/templates/presentation_theme/images/.keep +0 -0
  202. data/templates/presentation_theme/javascripts/%theme_name%.js.tt +0 -0
  203. data/templates/presentation_theme/stylesheets/%theme_name%.scss.tt +9 -0
  204. data/templates/presentation_theme/stylesheets/_fonts.scss.tt +0 -0
  205. data/templates/presentation_theme/stylesheets/_images.scss.tt +5 -0
  206. data/templates/presentation_theme/stylesheets/_theme.scss.tt +251 -0
  207. data/templates/rackup.config.erb +16 -0
  208. data/templates/script/bootstrap +5 -0
  209. data/templates/script/build +3 -0
  210. data/templates/script/export +3 -0
  211. data/templates/script/presentation +3 -0
  212. data/templates/script/slide +3 -0
  213. data/templates/script/start +43 -0
  214. data/templates/slides/custom.md.tt +3 -0
  215. data/templates/slides/erb.tt +5 -0
  216. data/templates/slides/group.tt +3 -0
  217. data/templates/slides/liquid.tt +5 -0
  218. data/templates/slides/markdown.tt +3 -0
  219. data/templates/source/index.html.erb +1 -0
  220. data/templates/source/javascripts/application.js.tt +3 -0
  221. data/templates/source/layout.erb +133 -0
  222. data/templates/source/stylesheets/application.scss.tt +3 -0
  223. metadata +574 -0
@@ -0,0 +1,125 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ RSpec.describe SlideList do
5
+
6
+ context '#initialize' do
7
+ it 'requires a list of patterns' do
8
+ slide = double('Middleman::Presentation::NewSlide')
9
+ allow(slide).to receive(:name).and_return '01'
10
+
11
+ slide_builder = double('Middleman::Presentation::NewSlide')
12
+ allow(slide_builder).to receive(:new).and_return slide
13
+
14
+ expect do
15
+ SlideList.new('01', slide_builder: slide_builder)
16
+ end.not_to raise_error
17
+ end
18
+
19
+ it 'accepts a block' do
20
+ slide = double('Middleman::Presentation::NewSlide')
21
+ allow(slide).to receive(:name).and_return '01'
22
+
23
+ slide_builder = double('Middleman::Presentation::NewSlide')
24
+ allow(slide_builder).to receive(:new).and_return slide
25
+
26
+ expect do
27
+ SlideList.new('01', slide_builder: slide_builder) do |_l|
28
+ end
29
+ end.not_to raise_error
30
+ end
31
+ end
32
+
33
+ context '#all' do
34
+ it 'holds all slides: existing and not existing' do
35
+ touch_file '01'
36
+ touch_file '02'
37
+
38
+ slide_builder = double('Middleman::Presentation::NewSlide')
39
+
40
+ %w(01 02 03).each do |name|
41
+ expect(slide_builder).to receive(:new).with(name, {}).and_return(OpenStruct.new(name: name))
42
+ end
43
+
44
+ list = SlideList.new(%w(01 02 03), slide_builder: slide_builder)
45
+ expect(list.all.size).to eq 3
46
+ end
47
+ end
48
+
49
+ context '#transform_with' do
50
+ it 'takes a transformer to modify each entry' do
51
+ slide = double('Middleman::Presentation::NewSlide')
52
+ allow(slide).to receive(:name).and_return '01'
53
+
54
+ slide_builder = double('Middleman::Presentation::NewSlide')
55
+ allow(slide_builder).to receive(:new).and_return slide
56
+
57
+ transformer = double('Transformer')
58
+ expect(transformer).to receive(:transform)
59
+
60
+ SlideList.new(%w(01), slide_builder: slide_builder) do |l|
61
+ l.transform_with transformer
62
+ end
63
+ end
64
+ end
65
+
66
+ context '#each_new' do
67
+ it 'iterates over all non existing slides because they are assumed to be new' do
68
+ slide1 = double('Slide')
69
+ expect(slide1).to receive(:exist?).and_return false
70
+
71
+ slide2 = double('Slide')
72
+ expect(slide2).to receive(:exist?).and_return true
73
+
74
+ slide_builder = double('Middleman::Presentation::NewSlide')
75
+ allow(slide_builder).to receive(:new).and_return(slide1, slide2)
76
+
77
+ result = SlideList.new(%w(01 02), slide_builder: slide_builder).each_new
78
+ expect(result).to include slide1
79
+ expect(result).not_to include slide2
80
+ end
81
+ end
82
+
83
+ context '#each_existing' do
84
+ it 'iterates over all existing slides' do
85
+ slide1 = double('Slide')
86
+ expect(slide1).to receive(:exist?).and_return false
87
+
88
+ slide2 = double('Slide')
89
+ expect(slide2).to receive(:exist?).and_return true
90
+
91
+ slide_builder = double('Middleman::Presentation::NewSlide')
92
+ allow(slide_builder).to receive(:new).and_return(slide1, slide2)
93
+
94
+ result = SlideList.new(%w(01 02), slide_builder: slide_builder).each_existing
95
+ expect(result).not_to include slide1
96
+ expect(result).to include slide2
97
+ end
98
+ end
99
+
100
+ context '#existing_slides' do
101
+ it 'returns all existing slides' do
102
+ slide = double('Slide')
103
+ expect(slide).to receive(:exist?).and_return true
104
+
105
+ slide_builder = double('Middleman::Presentation::NewSlide')
106
+ allow(slide_builder).to receive(:new).and_return slide
107
+
108
+ existing_slides = SlideList.new(%w(01), slide_builder: slide_builder).existing_slides
109
+ expect(existing_slides).to include slide
110
+ end
111
+ end
112
+
113
+ context '#to_a' do
114
+ it 'converts list to array' do
115
+ slide1 = double('Slide')
116
+ slide2 = double('Slide')
117
+
118
+ slide_builder = double('Middleman::Presentation::NewSlide')
119
+ allow(slide_builder).to receive(:new).and_return(slide1, slide2)
120
+
121
+ result = SlideList.new(%w(01 02), slide_builder: slide_builder).to_a
122
+ expect(result).to eq [slide1, slide2]
123
+ end
124
+ end
125
+ end
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ RSpec.describe SlideName do
5
+ context '#to_s' do
6
+ let(:old_slide) { instance_double('Middleman::Presentation::ExistingSlide') }
7
+
8
+ it 'switches type from erb to md if no basename/type is given' do
9
+ expect(old_slide).to receive(:base_name).and_return('01')
10
+ expect(old_slide).to receive(:ext_name).and_return('.html.erb')
11
+
12
+ name = SlideName.new(old_slide, base_name: nil, type: nil)
13
+ expect(name.to_s).to eq '01.md'
14
+ end
15
+
16
+ it 'switches type from erb to md if no basename/type is given' do
17
+ expect(old_slide).to receive(:base_name).and_return('01')
18
+ expect(old_slide).to receive(:ext_name).and_return('.html.md')
19
+
20
+ name = SlideName.new(old_slide, base_name: nil, type: nil)
21
+ expect(name.to_s).to eq '01.erb'
22
+ end
23
+
24
+ it 'switches type from other types than erb/md to md only if no basename/type is given' do
25
+ expect(old_slide).to receive(:base_name).and_return('01')
26
+ expect(old_slide).to receive(:ext_name).and_return('.html.liquid')
27
+
28
+ name = SlideName.new(old_slide, base_name: nil, type: nil)
29
+ expect(name.to_s).to eq '01.md'
30
+ end
31
+
32
+ it 'switches to given type and uses base name from old slide' do
33
+ expect(old_slide).to receive(:base_name).and_return('01')
34
+
35
+ name = SlideName.new(old_slide, base_name: nil, type: 'erb')
36
+ expect(name.to_s).to eq '01.erb'
37
+ end
38
+
39
+ it 'switches to given type (with dot) and uses base name from old slide' do
40
+ expect(old_slide).to receive(:base_name).and_return('01')
41
+
42
+ name = SlideName.new(old_slide, base_name: nil, type: '.erb')
43
+ expect(name.to_s).to eq '01.erb'
44
+ end
45
+
46
+ it 'switches to given basename and uses type from old slide' do
47
+ expect(old_slide).to receive(:ext_name).and_return('.html.erb')
48
+
49
+ name = SlideName.new(old_slide, base_name: '02', type: nil)
50
+ expect(name.to_s).to eq '02.erb'
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,19 @@
1
+ # encoding: utf-8
2
+ $LOAD_PATH << File.expand_path('../../lib', __FILE__)
3
+
4
+ require 'simplecov'
5
+ SimpleCov.command_name 'rspec'
6
+ SimpleCov.start
7
+
8
+ # Pull in all of the gems including those in the `test` group
9
+ require 'bundler'
10
+ Bundler.require :default, :test, :development
11
+
12
+ require 'middleman-presentation'
13
+
14
+ # Loading support files
15
+ Dir.glob(::File.expand_path('../support/*.rb', __FILE__)).each { |f| require_relative f }
16
+ Dir.glob(::File.expand_path('../shared_examples/*.rb', __FILE__)).each { |f| require_relative f }
17
+
18
+ # Avoid writing "describe MyModule::MyClass do [..]" but "describe MyClass do [..]"
19
+ include Middleman::Presentation
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+ require 'aruba/api'
3
+ require 'aruba/reporting'
4
+
5
+ module Middleman
6
+ module Presentation
7
+ # Spec Helpers
8
+ module SpecHelper
9
+ # Helpers for aruba
10
+ module Aruba
11
+ include ::Aruba::Api
12
+
13
+ def dirs
14
+ @dirs ||= %w(tmp rspec)
15
+ end
16
+
17
+ def absolute_path(*args)
18
+ in_current_dir { File.expand_path File.join(*args) }
19
+ end
20
+
21
+ def _create_file(*args)
22
+ super
23
+
24
+ args.first
25
+ end
26
+
27
+ def create_dir(*args)
28
+ super
29
+
30
+ args.first
31
+ end
32
+
33
+ def touch_file(file_name)
34
+ in_current_dir do
35
+ file_name = File.expand_path(file_name)
36
+ _mkdir(File.dirname(file_name))
37
+ FileUtils.touch file_name
38
+ end
39
+
40
+ file_name
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ RSpec.configure do |c|
48
+ c.include Middleman::Presentation::SpecHelper::Aruba
49
+ c.before :each do
50
+ clean_current_dir
51
+ restore_env
52
+ end
53
+ end
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+
3
+ # Test helpers
4
+ require 'middleman-presentation-core/test_helpers'
5
+
6
+ module Middleman
7
+ module Presentation
8
+ # Spec Helpers
9
+ module SpecHelper
10
+ # Helpers for ci
11
+ module Ci
12
+ include Middleman::Presentation::TestHelpers
13
+ end
14
+ end
15
+ end
16
+ end
17
+
18
+ RSpec.configure do |c|
19
+ c.include Middleman::Presentation::SpecHelper::Ci
20
+ end
@@ -0,0 +1,18 @@
1
+ # encoding: utf-8
2
+ # require 'fedux_org_stdlib/environment'
3
+ #
4
+ # module Middleman
5
+ # module Presentation
6
+ # # Spec Helpers
7
+ # module SpecHelper
8
+ # # Helpers for environment
9
+ # module Environment
10
+ # include FeduxOrgStdlib::Environment
11
+ # end
12
+ # end
13
+ # end
14
+ # end
15
+ #
16
+ # RSpec.configure do |c|
17
+ # c.include Middleman::Presentation::SpecHelper::Environment
18
+ # end
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+ # require 'fedux_org_stdlib/filesystem'
3
+ #
4
+ # module Middleman
5
+ # module Presentation
6
+ # module SpecHelper
7
+ # # Helpers for filesystem
8
+ # module Filesystem
9
+ # include FeduxOrgStdlib::Filesystem
10
+ #
11
+ # def root_directory
12
+ # ::File.expand_path('../../../', __FILE__)
13
+ # end
14
+ # end
15
+ # end
16
+ # end
17
+ # end
18
+ #
19
+ # RSpec.configure do |c|
20
+ # c.include Middleman::Presentation::SpecHelper::Filesystem
21
+ # c.before(:each) { cleanup_working_directory }
22
+ # end
@@ -0,0 +1,2 @@
1
+ # encoding: utf-8
2
+ Middleman::Presentation.locale_configurator.use_locale :en
@@ -0,0 +1,2 @@
1
+ # encoding: utf-8
2
+ require 'active_support/core_ext/kernel/reporting'
@@ -0,0 +1,9 @@
1
+ # encoding: utf-8
2
+ RSpec.configure do |config|
3
+ config.filter_run_including focus: true
4
+ config.run_all_when_everything_filtered = true
5
+
6
+ config.mock_with :rspec do |mocks|
7
+ mocks.verify_doubled_constant_names = true
8
+ end
9
+ end
@@ -0,0 +1,2 @@
1
+ # encoding: utf-8
2
+ require 'active_support/core_ext/string/strip'
@@ -0,0 +1,24 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ RSpec.describe Transformers::FileKeeper do
5
+ context '#transform' do
6
+ it 'removes directories from array and keep files' do
7
+ slide1 = instance_double('Middleman::Presentation::NewSlide')
8
+ file = touch_file('01.html.erb')
9
+ allow(slide1).to receive(:path).and_return absolute_path(file)
10
+
11
+ slide2 = instance_double('Middleman::Presentation::NewSlide')
12
+ directory = create_dir('01_dir')
13
+ allow(slide2).to receive(:path).and_return absolute_path(directory)
14
+
15
+ slides = []
16
+ slides << slide2
17
+ slides << slide1
18
+
19
+ slides = Transformers::FileKeeper.new.transform(slides)
20
+ expect(slides).to include slide1
21
+ expect(slides).not_to include slide2
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,44 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ RSpec.describe Transformers::GroupSlides do
5
+ context '#initialize' do
6
+ it 'requires a base directory' do
7
+ template = double('Template')
8
+ allow(template).to receive(:result)
9
+
10
+ expect do
11
+ Transformers::GroupSlides.new(template: template)
12
+ end.not_to raise_error
13
+ end
14
+ end
15
+
16
+ context '#transforms' do
17
+ it 'groups slides with same group' do
18
+ slide1 = instance_double('Middleman::Presentation::ExistingSlide')
19
+ allow(slide1).to receive(:group).and_return 'group'
20
+ allow(slide1).to receive(:group?).and_return true
21
+ allow(slide1).to receive(:render).and_return '01'
22
+
23
+ slide2 = instance_double('Middleman::Presentation::ExistingSlide')
24
+ allow(slide2).to receive(:group).and_return 'group'
25
+ allow(slide2).to receive(:group?).and_return true
26
+ allow(slide2).to receive(:render).and_return '02'
27
+
28
+ slide3 = instance_double('Middleman::Presentation::ExistingSlide')
29
+ allow(slide3).to receive(:group).and_return nil
30
+ allow(slide3).to receive(:group?).and_return false
31
+ allow(slide3).to receive(:render).and_return '03'
32
+
33
+ transformer = Transformers::GroupSlides.new(template: Erubis::Eruby.new('<%= slides %>'))
34
+ result = transformer.transform [slide1, slide2, slide3]
35
+
36
+ expect(result).not_to include slide1
37
+ expect(result).not_to include slide2
38
+ expect(result).to include slide3
39
+
40
+ group = result.first
41
+ expect(group.render { |s| s }).to include "01\n02"
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,64 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ RSpec.describe Transformers::IgnoreSlides do
5
+ context '#transform' do
6
+ it 'ignores slides based on file name' do
7
+ ignore_file = write_file '.slidesignore', <<-EOS.strip_heredoc
8
+ 02.html.md
9
+ EOS
10
+
11
+ slide1 = instance_double('Middleman::Presentation::ExistingSlide')
12
+ allow(slide1).to receive(:match?).and_return(false)
13
+
14
+ slide2 = instance_double('Middleman::Presentation::ExistingSlide')
15
+ allow(slide2).to receive(:match?).and_return(false)
16
+ allow(slide2).to receive(:match?).with(/(?-mix:^!$)|(?-mix:02.html.md)/).and_return(true)
17
+
18
+ transformer = Transformers::IgnoreSlides.new ignore_file: absolute_path(ignore_file)
19
+ result = transformer.transform([slide1, slide2])
20
+
21
+ expect(result).to include slide1
22
+ expect(result).not_to include slide2
23
+ end
24
+
25
+ it 'unignores slides based on file name' do
26
+ ignore_file = write_file '.slidesignore', <<-EOS.strip_heredoc
27
+ .md$
28
+ !02.html.md
29
+ EOS
30
+
31
+ slide1 = instance_double('Middleman::Presentation::ExistingSlide')
32
+ allow(slide1).to receive(:match?).with(/(?-mix:^!$)|(?-mix:.md$)/).and_return(false)
33
+ allow(slide1).to receive(:match?).with(/(?-mix:^!$)|(?-mix:02.html.md)/).and_return(true)
34
+
35
+ slide2 = instance_double('Middleman::Presentation::ExistingSlide')
36
+ allow(slide2).to receive(:match?).with(/(?-mix:^!$)|(?-mix:.md$)/).and_return(true)
37
+ allow(slide2).to receive(:match?).with(/(?-mix:^!$)|(?-mix:02.html.md)/).and_return(true)
38
+
39
+ slide3 = instance_double('Middleman::Presentation::ExistingSlide')
40
+ allow(slide3).to receive(:match?).with(/(?-mix:^!$)|(?-mix:.md$)/).and_return(true)
41
+ allow(slide3).to receive(:match?).with(/(?-mix:^!$)|(?-mix:02.html.md)/).and_return(false)
42
+
43
+ transformer = Transformers::IgnoreSlides.new ignore_file: absolute_path(ignore_file)
44
+ result = transformer.transform([slide1, slide2, slide3])
45
+
46
+ expect(result).to include slide1
47
+ expect(result).to include slide2
48
+ expect(result).not_to include slide3
49
+ end
50
+
51
+ it 'handles non existing ignore file' do
52
+ slide1 = instance_double('Middleman::Presentation::ExistingSlide')
53
+ slide2 = instance_double('Middleman::Presentation::ExistingSlide')
54
+ slide3 = instance_double('Middleman::Presentation::ExistingSlide')
55
+
56
+ transformer = Transformers::IgnoreSlides.new ignore_file: SecureRandom.hex
57
+ result = transformer.transform([slide1, slide2, slide3])
58
+
59
+ expect(result).to include slide1
60
+ expect(result).to include slide2
61
+ expect(result).to include slide3
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,120 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ RSpec.describe Transformers::RemoveDuplicateSlides do
5
+ context '#transform' do
6
+ it 'removes similar slides: same basename but different file name' do
7
+ slide1 = instance_double('Middleman::Presentation::ExistingSlide')
8
+ slide2 = instance_double('Middleman::Presentation::ExistingSlide')
9
+ slide3 = instance_double('Middleman::Presentation::ExistingSlide')
10
+
11
+ allow(slide1).to receive(:eql?).with(slide1).and_return(true)
12
+ allow(slide1).to receive(:eql?).with(slide2).and_return(false)
13
+ allow(slide1).to receive(:eql?).with(slide3).and_return(false)
14
+ allow(slide1).to receive(:similar?).with(slide1).and_return(false)
15
+ allow(slide1).to receive(:similar?).with(slide2).and_return(true)
16
+ allow(slide1).to receive(:similar?).with(slide3).and_return(false)
17
+
18
+ allow(slide2).to receive(:eql?).with(slide1).and_return(false)
19
+ allow(slide2).to receive(:eql?).with(slide2).and_return(true)
20
+ allow(slide2).to receive(:eql?).with(slide3).and_return(false)
21
+ allow(slide2).to receive(:similar?).with(slide1).and_return(true)
22
+ allow(slide2).to receive(:similar?).with(slide2).and_return(false)
23
+ allow(slide2).to receive(:similar?).with(slide3).and_return(false)
24
+
25
+ allow(slide3).to receive(:eql?).with(slide1).and_return(false)
26
+ allow(slide3).to receive(:eql?).with(slide2).and_return(false)
27
+ allow(slide3).to receive(:eql?).with(slide3).and_return(true)
28
+ allow(slide3).to receive(:similar?).with(slide1).and_return(false)
29
+ allow(slide3).to receive(:similar?).with(slide2).and_return(false)
30
+ allow(slide3).to receive(:similar?).with(slide3).and_return(false)
31
+
32
+ transformer = Transformers::RemoveDuplicateSlides.new
33
+ result = transformer.transform([slide1, slide2, slide3])
34
+
35
+ expect(result).not_to include slide1
36
+ expect(result).not_to include slide2
37
+ expect(result).to include slide3
38
+ end
39
+
40
+ it 'raises an error on similar slides' do
41
+ slide1 = instance_double('Middleman::Presentation::ExistingSlide')
42
+ slide2 = instance_double('Middleman::Presentation::ExistingSlide')
43
+
44
+ allow(slide1).to receive(:eql?).with(slide1).and_return(false)
45
+ allow(slide1).to receive(:eql?).with(slide2).and_return(false)
46
+ allow(slide1).to receive(:file_name).and_return('01.html.erb')
47
+ allow(slide1).to receive(:similar?).with(slide1).and_return(true)
48
+ allow(slide1).to receive(:similar?).with(slide2).and_return(true)
49
+
50
+ allow(slide2).to receive(:eql?).with(slide1).and_return(false)
51
+ allow(slide2).to receive(:eql?).with(slide2).and_return(false)
52
+ allow(slide2).to receive(:file_name).and_return('01.html.md')
53
+ allow(slide2).to receive(:similar?).with(slide1).and_return(true)
54
+ allow(slide2).to receive(:similar?).with(slide2).and_return(true)
55
+
56
+ transformer = Transformers::RemoveDuplicateSlides.new raise_error: true
57
+
58
+ expect do
59
+ transformer.transform([slide1, slide2])
60
+ end.to raise_error ArgumentError
61
+ end
62
+
63
+ it 'considers additional slides which will be not part of the output' do
64
+ slide1 = instance_double('Middleman::Presentation::ExistingSlide')
65
+ slide2 = instance_double('Middleman::Presentation::ExistingSlide')
66
+ slide3 = instance_double('Middleman::Presentation::ExistingSlide')
67
+ slide4 = instance_double('Middleman::Presentation::ExistingSlide')
68
+
69
+ allow(slide1).to receive(:file_name).and_return '01.html.erb'
70
+ allow(slide1).to receive(:eql?).with(slide1).and_return(true)
71
+ allow(slide1).to receive(:eql?).with(slide2).and_return(true)
72
+ allow(slide1).to receive(:eql?).with(slide3).and_return(false)
73
+ allow(slide1).to receive(:eql?).with(slide4).and_return(false)
74
+ allow(slide1).to receive(:similar?).with(slide1).and_return(false)
75
+ allow(slide1).to receive(:similar?).with(slide2).and_return(true)
76
+ allow(slide1).to receive(:similar?).with(slide3).and_return(false)
77
+ allow(slide1).to receive(:similar?).with(slide4).and_return(false)
78
+
79
+ allow(slide2).to receive(:file_name).and_return '01.html.md'
80
+ allow(slide2).to receive(:eql?).with(slide1).and_return(false)
81
+ allow(slide2).to receive(:eql?).with(slide2).and_return(true)
82
+ allow(slide2).to receive(:eql?).with(slide3).and_return(false)
83
+ allow(slide2).to receive(:eql?).with(slide4).and_return(false)
84
+ allow(slide2).to receive(:similar?).with(slide1).and_return(true)
85
+ allow(slide2).to receive(:similar?).with(slide2).and_return(false)
86
+ allow(slide2).to receive(:similar?).with(slide3).and_return(false)
87
+ allow(slide2).to receive(:similar?).with(slide4).and_return(false)
88
+
89
+ allow(slide2).to receive(:file_name).and_return '02.html.md'
90
+ allow(slide3).to receive(:eql?).with(slide1).and_return(false)
91
+ allow(slide3).to receive(:eql?).with(slide2).and_return(false)
92
+ allow(slide3).to receive(:eql?).with(slide3).and_return(true)
93
+ allow(slide3).to receive(:eql?).with(slide4).and_return(false)
94
+ allow(slide3).to receive(:similar?).with(slide1).and_return(false)
95
+ allow(slide3).to receive(:similar?).with(slide2).and_return(false)
96
+ allow(slide3).to receive(:similar?).with(slide3).and_return(false)
97
+ allow(slide3).to receive(:similar?).with(slide4).and_return(false)
98
+
99
+ allow(slide2).to receive(:file_name).and_return '03.html.md'
100
+ allow(slide4).to receive(:eql?).with(slide1).and_return(false)
101
+ allow(slide4).to receive(:eql?).with(slide2).and_return(false)
102
+ allow(slide4).to receive(:eql?).with(slide3).and_return(false)
103
+ allow(slide4).to receive(:eql?).with(slide4).and_return(true)
104
+ allow(slide4).to receive(:similar?).with(slide1).and_return(false)
105
+ allow(slide4).to receive(:similar?).with(slide2).and_return(false)
106
+ allow(slide4).to receive(:similar?).with(slide3).and_return(false)
107
+ allow(slide4).to receive(:similar?).with(slide4).and_return(false)
108
+
109
+ transformer = Transformers::RemoveDuplicateSlides.new additional_slides: [slide2, slide4]
110
+ result = transformer.transform([slide1, slide3])
111
+
112
+ # slide1 cannot be part of output
113
+ # because a similar slide already exists
114
+ expect(result).not_to include slide1
115
+ expect(result).not_to include slide2
116
+ expect(result).not_to include slide4
117
+ expect(result).to include slide3
118
+ end
119
+ end
120
+ end
@@ -0,0 +1,17 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ RSpec.describe Transformers::SortSlides do
5
+ context '#transform' do
6
+ it 'sorts slides' do
7
+ slides = []
8
+ slides << 1
9
+ slides << 3
10
+ slides << 2
11
+
12
+ slides = Transformers::SortSlides.new.transform(slides)
13
+ expect(slides.first).to eq 1
14
+ expect(slides.last).to eq 3
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,14 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ RSpec.describe Utils do
5
+ context '#zip' do
6
+ it 'creates a zip archive from directory' do
7
+ touch_file 'test.txt'
8
+
9
+ Middleman::Presentation::Utils.zip absolute_path('.'), absolute_path('test.zip')
10
+
11
+ check_file_presence(['test.zip'], true)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,4 @@
1
+ {
2
+ "directory": "<%= @bower_directory %>",
3
+ "json": "bower.json"
4
+ }
@@ -0,0 +1,5 @@
1
+ /.bundle
2
+ /build
3
+ /.sass-cache
4
+ /.cache
5
+ .DS_Store
@@ -0,0 +1,32 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'middleman'
4
+
5
+ # For faster file watcher updates on Windows:
6
+ # gem 'wdm', :platforms => [:mswin, :mingw]
7
+
8
+ <% if Middleman::Presentation.config.runtime_environment == :test -%>
9
+ # Make sure the paths are correct, otherwise you get
10
+ # Bundler-errors a la `Path does not exist`
11
+ gem 'middleman-presentation', path: '<%= File.join(@rubygem_path, 'middleman-presentation') %>'
12
+ gem 'middleman-presentation-core', path: '<%= File.join(@rubygem_path, 'middleman-presentation-core') %>'
13
+ gem 'middleman-presentation-helpers', path: '<%= File.join(@rubygem_path, 'middleman-presentation-helpers') %>'
14
+ gem 'middleman-presentation-simple_plugin', path: '<%= File.join(@rubygem_path, 'middleman-presentation-core/fixtures/middleman-presentation-simple_plugin') %>'
15
+ <% else -%>
16
+ gem 'middleman-presentation'
17
+ <% end -%>
18
+
19
+ # Choose one to make `execjs` happy
20
+ # gem 'therubyracer'
21
+ # gem 'therubyrhino'
22
+
23
+ gem 'kramdown'
24
+ gem 'github-markup'
25
+ gem 'liquid'
26
+ gem 'rake'
27
+
28
+ group :debug do
29
+ gem 'pry'
30
+ gem 'byebug'
31
+ gem 'pry-byebug'
32
+ end
@@ -0,0 +1 @@
1
+ This is a stub. Please place the license or a link to the license for your presentation here.