middleman-presentation-core 0.16.0.alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rdebugrc +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +52 -0
- data/.simplecov +25 -0
- data/.yardopts +5 -0
- data/Guardfile +13 -0
- data/LICENSE.software +21 -0
- data/Rakefile +200 -0
- data/config/license_finder.yml +13 -0
- data/cucumber.yml +2 -0
- data/doc/licenses/dependencies.csv +55 -0
- data/doc/licenses/dependencies.db +0 -0
- data/doc/licenses/dependencies.html +1415 -0
- data/doc/licenses/dependencies.md +603 -0
- data/doc/licenses/dependencies_detailed.csv +190 -0
- data/doc/yard/.keep +0 -0
- data/features/build_presentation.feature +62 -0
- data/features/code_highlighting.feature +43 -0
- data/features/components.feature +29 -0
- data/features/create_plugin-cli.feature +11 -0
- data/features/create_presentation-cli.feature +349 -0
- data/features/create_slide-cli.feature +188 -0
- data/features/create_slides-templates-cli.feature +114 -0
- data/features/create_theme-cli.feature +58 -0
- data/features/default_slides.feature +58 -0
- data/features/edit_slide-cli.feature +121 -0
- data/features/export_presentation-cli.feature +23 -0
- data/features/grouping_slides.feature +150 -0
- data/features/ignore_slides.feature +103 -0
- data/features/init_application-cli.feature +59 -0
- data/features/init_predefined_slides.feature +9 -0
- data/features/language_detection.feature +0 -0
- data/features/list_assets-cli.feature +13 -0
- data/features/list_components-cli.feature +13 -0
- data/features/list_helpers-cli.feature +13 -0
- data/features/list_plugins-cli.feature +13 -0
- data/features/list_styles-cli.feature +17 -0
- data/features/plugins.feature +63 -0
- data/features/presentation.feature +57 -0
- data/features/rename_slide-cli.feature +176 -0
- data/features/render_slides.feature +76 -0
- data/features/show_config-cli.feature +25 -0
- data/features/show_footer.feature +14 -0
- data/features/show_slide_number.feature +31 -0
- data/features/show_support_information-cli.feature +12 -0
- data/features/support/aruba.rb +18 -0
- data/features/support/ci.rb +3 -0
- data/features/support/env.rb +25 -0
- data/features/support/fixtures.rb +21 -0
- data/features/support/hash.rb +2 -0
- data/features/support/reporting.rb +2 -0
- data/features/version_number.feature +15 -0
- data/fixtures/middleman-presentation-simple_plugin/Rakefile +1 -0
- data/fixtures/middleman-presentation-simple_plugin/lib/middleman-presentation-plugin.rb +0 -0
- data/fixtures/middleman-presentation-simple_plugin/lib/middleman-presentation-simple_plugin/helpers.rb +13 -0
- data/fixtures/middleman-presentation-simple_plugin/lib/middleman-presentation-simple_plugin/plugin.rb +34 -0
- data/fixtures/middleman-presentation-simple_plugin/lib/middleman-presentation-simple_plugin/version.rb +8 -0
- data/fixtures/middleman-presentation-simple_plugin/lib/middleman-presentation-simple_plugin.rb +11 -0
- data/fixtures/middleman-presentation-simple_plugin/middleman-presentation-simple_plugin.gemspec +22 -0
- data/fixtures/middleman-presentation-simple_plugin/vendor/assets/stylesheets/test_simple.scss +3 -0
- data/lib/middleman-presentation-core/application_config.rb +198 -0
- data/lib/middleman-presentation-core/asset.rb +103 -0
- data/lib/middleman-presentation-core/asset_component.rb +34 -0
- data/lib/middleman-presentation-core/asset_list.rb +84 -0
- data/lib/middleman-presentation-core/asset_store.rb +73 -0
- data/lib/middleman-presentation-core/assets_loader.rb +95 -0
- data/lib/middleman-presentation-core/assets_manager.rb +73 -0
- data/lib/middleman-presentation-core/cache.rb +49 -0
- data/lib/middleman-presentation-core/cli/base.rb +30 -0
- data/lib/middleman-presentation-core/cli/base_group.rb +11 -0
- data/lib/middleman-presentation-core/cli/build.rb +13 -0
- data/lib/middleman-presentation-core/cli/build_presentation.rb +57 -0
- data/lib/middleman-presentation-core/cli/change.rb +13 -0
- data/lib/middleman-presentation-core/cli/change_slide.rb +82 -0
- data/lib/middleman-presentation-core/cli/create.rb +16 -0
- data/lib/middleman-presentation-core/cli/create_plugin.rb +62 -0
- data/lib/middleman-presentation-core/cli/create_presentation.rb +300 -0
- data/lib/middleman-presentation-core/cli/create_slide.rb +52 -0
- data/lib/middleman-presentation-core/cli/create_theme.rb +81 -0
- data/lib/middleman-presentation-core/cli/edit.rb +13 -0
- data/lib/middleman-presentation-core/cli/edit_slide.rb +49 -0
- data/lib/middleman-presentation-core/cli/export.rb +11 -0
- data/lib/middleman-presentation-core/cli/export_presentation.rb +55 -0
- data/lib/middleman-presentation-core/cli/init.rb +12 -0
- data/lib/middleman-presentation-core/cli/init_application.rb +48 -0
- data/lib/middleman-presentation-core/cli/init_predefined_slides.rb +31 -0
- data/lib/middleman-presentation-core/cli/list.rb +66 -0
- data/lib/middleman-presentation-core/cli/reset_thor.rb +18 -0
- data/lib/middleman-presentation-core/cli/runner.rb +47 -0
- data/lib/middleman-presentation-core/cli/serve.rb +13 -0
- data/lib/middleman-presentation-core/cli/serve_presentation.rb +30 -0
- data/lib/middleman-presentation-core/cli/shared.rb +51 -0
- data/lib/middleman-presentation-core/cli/show.rb +70 -0
- data/lib/middleman-presentation-core/comparable_slide.rb +69 -0
- data/lib/middleman-presentation-core/component.rb +86 -0
- data/lib/middleman-presentation-core/components_manager.rb +96 -0
- data/lib/middleman-presentation-core/configuration_file.rb +15 -0
- data/lib/middleman-presentation-core/css_class_extracter.rb +41 -0
- data/lib/middleman-presentation-core/custom_template.rb +15 -0
- data/lib/middleman-presentation-core/erb_template.rb +15 -0
- data/lib/middleman-presentation-core/errors.rb +10 -0
- data/lib/middleman-presentation-core/existing_slide.rb +92 -0
- data/lib/middleman-presentation-core/frontend_component.rb +75 -0
- data/lib/middleman-presentation-core/group_template.rb +15 -0
- data/lib/middleman-presentation-core/helpers_manager.rb +37 -0
- data/lib/middleman-presentation-core/ignore_file.rb +52 -0
- data/lib/middleman-presentation-core/liquid_template.rb +15 -0
- data/lib/middleman-presentation-core/list.rb +7 -0
- data/lib/middleman-presentation-core/locale_configurator.rb +84 -0
- data/lib/middleman-presentation-core/logger.rb +8 -0
- data/lib/middleman-presentation-core/main.rb +55 -0
- data/lib/middleman-presentation-core/markdown_template.rb +15 -0
- data/lib/middleman-presentation-core/middleman_environment.rb +108 -0
- data/lib/middleman-presentation-core/middleman_extension.rb +12 -0
- data/lib/middleman-presentation-core/middleman_step_definitions.rb +131 -0
- data/lib/middleman-presentation-core/new_slide.rb +140 -0
- data/lib/middleman-presentation-core/overwrite_sass.rb +22 -0
- data/lib/middleman-presentation-core/plugin.rb +8 -0
- data/lib/middleman-presentation-core/plugin_api.rb +65 -0
- data/lib/middleman-presentation-core/plugins_manager.rb +7 -0
- data/lib/middleman-presentation-core/predefined_slide_templates_directory.rb +15 -0
- data/lib/middleman-presentation-core/presentation_helper.rb +69 -0
- data/lib/middleman-presentation-core/register_extension.rb +4 -0
- data/lib/middleman-presentation-core/roles/comparable_by_name.rb +24 -0
- data/lib/middleman-presentation-core/slide_group.rb +33 -0
- data/lib/middleman-presentation-core/slide_list.rb +52 -0
- data/lib/middleman-presentation-core/slide_name.rb +61 -0
- data/lib/middleman-presentation-core/start.rb +68 -0
- data/lib/middleman-presentation-core/step_definitions.rb +238 -0
- data/lib/middleman-presentation-core/syntax_highlighter.rb +42 -0
- data/lib/middleman-presentation-core/test_helpers.rb +22 -0
- data/lib/middleman-presentation-core/transformers/file_keeper.rb +13 -0
- data/lib/middleman-presentation-core/transformers/group_slides.rb +34 -0
- data/lib/middleman-presentation-core/transformers/ignore_slides.rb +28 -0
- data/lib/middleman-presentation-core/transformers/remove_duplicate_slides.rb +32 -0
- data/lib/middleman-presentation-core/transformers/sort_slides.rb +13 -0
- data/lib/middleman-presentation-core/utils.rb +40 -0
- data/lib/middleman-presentation-core/version.rb +8 -0
- data/lib/middleman-presentation-core.rb +127 -0
- data/locales/de.yml +233 -0
- data/locales/en.yml +236 -0
- data/middleman-presentation-core.gemspec +40 -0
- data/source/slides/01.html.liquid +0 -0
- data/spec/asset_component_spec.rb +13 -0
- data/spec/asset_list_spec.rb +50 -0
- data/spec/asset_spec.rb +45 -0
- data/spec/asset_store_spec.rb +61 -0
- data/spec/assets_manager_spec.rb +111 -0
- data/spec/components_manager_spec.rb +142 -0
- data/spec/css_class_extracter_spec.rb +28 -0
- data/spec/existing_slide_spec.rb +177 -0
- data/spec/frontend_component_spec.rb +94 -0
- data/spec/helpers_manager_spec.rb +90 -0
- data/spec/ignore_file_spec.rb +75 -0
- data/spec/new_slide_spec.rb +155 -0
- data/spec/presentation_helper_spec.rb +137 -0
- data/spec/shared_examples/.keep +0 -0
- data/spec/slide_group_spec.rb +54 -0
- data/spec/slide_list_spec.rb +125 -0
- data/spec/slide_name_spec.rb +53 -0
- data/spec/spec_helper.rb +19 -0
- data/spec/support/aruba.rb +53 -0
- data/spec/support/ci.rb +20 -0
- data/spec/support/environment.rb +18 -0
- data/spec/support/filesystem.rb +22 -0
- data/spec/support/locale.rb +2 -0
- data/spec/support/reporting.rb +2 -0
- data/spec/support/rspec.rb +9 -0
- data/spec/support/string.rb +2 -0
- data/spec/transformers/file_keeper_spec.rb +24 -0
- data/spec/transformers/group_slides_spec.rb +44 -0
- data/spec/transformers/ignore_slides_spec.rb +64 -0
- data/spec/transformers/remove_duplicate_slides_spec.rb +120 -0
- data/spec/transformers/sort_slides_spec.rb +17 -0
- data/spec/utils_spec.rb +14 -0
- data/templates/.bowerrc.tt +4 -0
- data/templates/.gitignore +5 -0
- data/templates/Gemfile.tt +32 -0
- data/templates/LICENSE.presentation +1 -0
- data/templates/Rakefile +59 -0
- data/templates/bower.json.tt +8 -0
- data/templates/bundler_config.tt +6 -0
- data/templates/config.rb.tt +2 -0
- data/templates/config.yaml.tt +17 -0
- data/templates/gitignore.tt +14 -0
- data/templates/plugin/%plugin_name%.gemspec.tt +24 -0
- data/templates/plugin/.gitignore +13 -0
- data/templates/plugin/Gemfile.tt +4 -0
- data/templates/plugin/LICENSE.txt.tt +22 -0
- data/templates/plugin/README.md.tt +31 -0
- data/templates/plugin/Rakefile +1 -0
- data/templates/plugin/lib/%plugin_name%/version.rb.tt +8 -0
- data/templates/plugin/lib/%plugin_name%.rb.tt +10 -0
- data/templates/predefined_slides.d/00_00.html.erb.tt +26 -0
- data/templates/predefined_slides.d/00_01.html.md.tt +6 -0
- data/templates/predefined_slides.d/999980.html.erb.tt +4 -0
- data/templates/predefined_slides.d/999981.html.erb.tt +27 -0
- data/templates/predefined_slides.d/999982.html.erb.tt +4 -0
- data/templates/presentation_theme/bower.json.tt +20 -0
- data/templates/presentation_theme/images/.keep +0 -0
- data/templates/presentation_theme/javascripts/%theme_name%.js.tt +0 -0
- data/templates/presentation_theme/stylesheets/%theme_name%.scss.tt +9 -0
- data/templates/presentation_theme/stylesheets/_fonts.scss.tt +0 -0
- data/templates/presentation_theme/stylesheets/_images.scss.tt +5 -0
- data/templates/presentation_theme/stylesheets/_theme.scss.tt +251 -0
- data/templates/rackup.config.erb +16 -0
- data/templates/script/bootstrap +5 -0
- data/templates/script/build +3 -0
- data/templates/script/export +3 -0
- data/templates/script/presentation +3 -0
- data/templates/script/slide +3 -0
- data/templates/script/start +43 -0
- data/templates/slides/custom.md.tt +3 -0
- data/templates/slides/erb.tt +5 -0
- data/templates/slides/group.tt +3 -0
- data/templates/slides/liquid.tt +5 -0
- data/templates/slides/markdown.tt +3 -0
- data/templates/source/index.html.erb +1 -0
- data/templates/source/javascripts/application.js.tt +3 -0
- data/templates/source/layout.erb +133 -0
- data/templates/source/stylesheets/application.scss.tt +3 -0
- metadata +574 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
RSpec.describe AssetList do
|
|
5
|
+
let(:creator_stub) { Class.new }
|
|
6
|
+
let(:creator) { stub_const('Middleman::Presentation::Asset', creator_stub) }
|
|
7
|
+
let(:asset) { instance_double('Middleman::Presentation::Asset') }
|
|
8
|
+
|
|
9
|
+
context '#initialize' do
|
|
10
|
+
it 'creates asset instances' do
|
|
11
|
+
touch_file 'stylesheets/blub.scss'
|
|
12
|
+
|
|
13
|
+
expect(creator).to receive(:new).with(source_path: absolute_path('stylesheets/blub.scss'), relative_source_path: 'stylesheets/blub.scss', destination_path: nil).and_return(asset)
|
|
14
|
+
|
|
15
|
+
component1 = instance_double('Middleman::Presentation::Component')
|
|
16
|
+
allow(component1).to receive(:path).and_return(absolute_path('.'))
|
|
17
|
+
allow(component1).to receive(:base_path).and_return(absolute_path('.'))
|
|
18
|
+
allow(component1).to receive(:output_paths).and_return([])
|
|
19
|
+
allow(component1).to receive(:loadable_files).and_return([])
|
|
20
|
+
allow(component1).to receive(:ignorable_files).and_return([])
|
|
21
|
+
allow(component1).to receive(:importable_files).and_return([])
|
|
22
|
+
|
|
23
|
+
components = []
|
|
24
|
+
components << component1
|
|
25
|
+
|
|
26
|
+
result = []
|
|
27
|
+
AssetList.new(components).each { |a| result << a }
|
|
28
|
+
|
|
29
|
+
expect(result).to include asset
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# context '#each' do
|
|
34
|
+
# it 'iterates of assets' do
|
|
35
|
+
# expect(creator).to receive(:new).with(source_path: absolute_path('images/image1.png'), relative_source_path: 'images/image1.png', destination_path: nil).and_return(asset)
|
|
36
|
+
|
|
37
|
+
# component1 = instance_double('Middleman::Presentation::Component')
|
|
38
|
+
# allow(component1).to receive(:path).and_return(absolute_path('images/image1.png'))
|
|
39
|
+
# allow(component1).to receive(:output_paths).and_return(absolute_path('images/image1.png'))
|
|
40
|
+
|
|
41
|
+
# components = []
|
|
42
|
+
# components << component1
|
|
43
|
+
|
|
44
|
+
# result = []
|
|
45
|
+
# result = AssetList.new(components).each { |a| result << a }
|
|
46
|
+
|
|
47
|
+
# expect(result).to include asset
|
|
48
|
+
# end
|
|
49
|
+
# end
|
|
50
|
+
end
|
data/spec/asset_spec.rb
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
RSpec.describe Asset do
|
|
5
|
+
context '#merge!' do
|
|
6
|
+
it 'keeps information about importable' do
|
|
7
|
+
asset1 = Asset.new(source_path: absolute_path('asset/path'), importable: false, relative_source_path: 'asset/path', destination_path: nil)
|
|
8
|
+
asset2 = Asset.new(source_path: absolute_path('asset/path'), importable: true, relative_source_path: 'asset/path', destination_path: nil)
|
|
9
|
+
asset1.merge! asset2
|
|
10
|
+
|
|
11
|
+
expect(asset1).to be_importable
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'keeps information about loadable' do
|
|
15
|
+
asset1 = Asset.new(source_path: absolute_path('asset/path'), loadable: false, relative_source_path: 'asset/path', destination_path: nil)
|
|
16
|
+
asset2 = Asset.new(source_path: absolute_path('asset/path'), loadable: true, relative_source_path: 'asset/path', destination_path: nil)
|
|
17
|
+
asset1.merge! asset2
|
|
18
|
+
|
|
19
|
+
expect(asset1).to be_loadable
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'keeps information about destination path' do
|
|
23
|
+
asset1 = Asset.new(source_path: absolute_path('asset/path'), relative_source_path: 'asset/path', destination_path: 'dir')
|
|
24
|
+
asset2 = Asset.new(source_path: absolute_path('asset/path'), relative_source_path: 'asset/path', destination_path: 'dir2')
|
|
25
|
+
|
|
26
|
+
asset1.merge! asset2
|
|
27
|
+
|
|
28
|
+
expect(asset1.destination_path).to eq Pathname.new('dir')
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'adds information about destination path if does not exist' do
|
|
32
|
+
asset1 = Asset.new(source_path: absolute_path('asset/path'), relative_source_path: 'asset/path', destination_path: nil)
|
|
33
|
+
asset2 = Asset.new(source_path: absolute_path('asset/path'), relative_source_path: 'asset/path', destination_path: 'dir2')
|
|
34
|
+
|
|
35
|
+
asset1.merge! asset2
|
|
36
|
+
|
|
37
|
+
expect(asset1.destination_path).to eq Pathname.new('dir2')
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it 'has an import path' do
|
|
41
|
+
asset = Asset.new(source_path: absolute_path('asset/path/image.png'), relative_source_path: 'asset/path/image.png', destination_path: nil)
|
|
42
|
+
expect(asset.import_path).to eq Pathname.new('asset/path/image')
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
RSpec.describe AssetStore do
|
|
5
|
+
context '#add' do
|
|
6
|
+
it 'adds asset to store' do
|
|
7
|
+
asset = instance_double('Middleman::Presentation::Asset')
|
|
8
|
+
|
|
9
|
+
store = AssetStore.new
|
|
10
|
+
expect { store.add asset }.not_to raise_error
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'merges existing assets' do
|
|
14
|
+
asset2 = instance_double('Middleman::Presentation::Asset')
|
|
15
|
+
allow(asset2).to receive(:source_path).and_return('source/path')
|
|
16
|
+
|
|
17
|
+
asset1 = instance_double('Middleman::Presentation::Asset')
|
|
18
|
+
allow(asset1).to receive(:source_path).and_return('source/path')
|
|
19
|
+
expect(asset1).to receive(:merge!).with(asset2)
|
|
20
|
+
|
|
21
|
+
store = AssetStore.new
|
|
22
|
+
store.add asset1
|
|
23
|
+
store.add asset2
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
context '#find' do
|
|
28
|
+
it 'finds existing assets' do
|
|
29
|
+
asset = OpenStruct.new(source_path: 'asset/path', loadable: false)
|
|
30
|
+
|
|
31
|
+
store = AssetStore.new
|
|
32
|
+
store.add asset
|
|
33
|
+
|
|
34
|
+
asset = store.find source_path: asset.source_path
|
|
35
|
+
|
|
36
|
+
expect(asset).to be asset
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it 'uses a block as well' do
|
|
40
|
+
asset = OpenStruct.new(source_path: 'asset/path', loadable: false)
|
|
41
|
+
|
|
42
|
+
store = AssetStore.new
|
|
43
|
+
store.add asset
|
|
44
|
+
|
|
45
|
+
asset = store.find { |a| a.source_path == asset.source_path }
|
|
46
|
+
|
|
47
|
+
expect(asset).to be asset
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
context '#assets' do
|
|
52
|
+
it 'returns assets stored in asset store' do
|
|
53
|
+
asset = instance_double('Middleman::Presentation::Asset')
|
|
54
|
+
|
|
55
|
+
store = AssetStore.new
|
|
56
|
+
store.add asset
|
|
57
|
+
|
|
58
|
+
expect(store.assets).to include asset
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
RSpec.describe AssetsManager do
|
|
5
|
+
let(:manager) { AssetsManager.new }
|
|
6
|
+
let(:asset) { instance_double('Middleman::Presentation::Asset') }
|
|
7
|
+
let(:list) { instance_double('Middleman::Presentation::AssetList') }
|
|
8
|
+
|
|
9
|
+
context '#load_from_list' do
|
|
10
|
+
it 'loads assets from list' do
|
|
11
|
+
allow(list).to receive(:each) { |&block| [asset].each(&block) }
|
|
12
|
+
|
|
13
|
+
manager.load_from_list list
|
|
14
|
+
expect(manager).to be_know asset
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
context '#each_loadable_asset' do
|
|
19
|
+
it 'iterates over all assets' do
|
|
20
|
+
allow(asset).to receive(:valid?).and_return(true)
|
|
21
|
+
allow(asset).to receive(:loadable?).and_return(true)
|
|
22
|
+
allow(asset).to receive(:source_path).and_return('image1.png')
|
|
23
|
+
|
|
24
|
+
allow(list).to receive(:each) { |&block| [asset].each(&block) }
|
|
25
|
+
|
|
26
|
+
manager.load_from_list list
|
|
27
|
+
|
|
28
|
+
output = capture :stdout do
|
|
29
|
+
manager.each_loadable_asset { |a| puts a.source_path }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
expect(output).to include 'image1.png'
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
context '#each_importable_stylesheet' do
|
|
37
|
+
it 'iterates over all assets' do
|
|
38
|
+
asset1 = instance_double('Middleman::Presentation::Asset')
|
|
39
|
+
allow(asset1).to receive(:valid?).and_return(true)
|
|
40
|
+
allow(asset1).to receive(:importable?).and_return(true)
|
|
41
|
+
allow(asset1).to receive(:stylesheet?).and_return(false)
|
|
42
|
+
allow(asset1).to receive(:source_path).and_return('image1.png')
|
|
43
|
+
|
|
44
|
+
asset2 = instance_double('Middleman::Presentation::Asset')
|
|
45
|
+
allow(asset2).to receive(:valid?).and_return(true)
|
|
46
|
+
allow(asset2).to receive(:importable?).and_return(true)
|
|
47
|
+
allow(asset2).to receive(:stylesheet?).and_return(true)
|
|
48
|
+
allow(asset2).to receive(:source_path).and_return('stylesheet.css')
|
|
49
|
+
|
|
50
|
+
allow(list).to receive(:each) { |&block| [asset1, asset2].each(&block) }
|
|
51
|
+
|
|
52
|
+
manager.load_from_list list
|
|
53
|
+
|
|
54
|
+
output = capture :stdout do
|
|
55
|
+
manager.each_importable_stylesheet { |a| puts a.source_path }
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
expect(output).to include 'stylesheet.css'
|
|
59
|
+
expect(output).not_to include 'image1.png'
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
context '#each_importable_javascript' do
|
|
64
|
+
it 'iterates over all assets' do
|
|
65
|
+
asset1 = instance_double('Middleman::Presentation::Asset')
|
|
66
|
+
allow(asset1).to receive(:valid?).and_return(true)
|
|
67
|
+
allow(asset1).to receive(:importable?).and_return(true)
|
|
68
|
+
allow(asset1).to receive(:script?).and_return(false)
|
|
69
|
+
allow(asset1).to receive(:source_path).and_return('image1.png')
|
|
70
|
+
|
|
71
|
+
asset2 = instance_double('Middleman::Presentation::Asset')
|
|
72
|
+
allow(asset2).to receive(:valid?).and_return(true)
|
|
73
|
+
allow(asset2).to receive(:importable?).and_return(true)
|
|
74
|
+
allow(asset2).to receive(:script?).and_return(true)
|
|
75
|
+
allow(asset2).to receive(:source_path).and_return('script.js')
|
|
76
|
+
|
|
77
|
+
allow(list).to receive(:each) { |&block| [asset1, asset2].each(&block) }
|
|
78
|
+
|
|
79
|
+
manager.load_from_list list
|
|
80
|
+
|
|
81
|
+
output = capture :stdout do
|
|
82
|
+
manager.each_importable_javascript { |a| puts a.source_path }
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
expect(output).to include 'script.js'
|
|
86
|
+
expect(output).not_to include 'image1.png'
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
context '#to_s' do
|
|
91
|
+
it 'returns a string representation of self' do
|
|
92
|
+
allow(asset).to receive(:relative_source_path).and_return('image1.png')
|
|
93
|
+
allow(asset).to receive(:destination_path).and_return('output.d')
|
|
94
|
+
allow(asset).to receive(:loadable?).and_return(true)
|
|
95
|
+
allow(asset).to receive(:importable?).and_return(true)
|
|
96
|
+
|
|
97
|
+
allow(list).to receive(:each) { |&block| [asset].each(&block) }
|
|
98
|
+
|
|
99
|
+
manager.load_from_list list
|
|
100
|
+
|
|
101
|
+
expect(manager.to_s).to eq <<-EOS.strip_heredoc.chomp
|
|
102
|
+
+-------------+------------------+----------+------------+
|
|
103
|
+
| Source path | Destination path | Loadable | Importable |
|
|
104
|
+
+-------------+------------------+----------+------------+
|
|
105
|
+
| image1.png | output.d | true | true |
|
|
106
|
+
+-------------+------------------+----------+------------+
|
|
107
|
+
1 row in set
|
|
108
|
+
EOS
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
RSpec.describe ComponentsManager do
|
|
5
|
+
let(:component) { instance_double('Middleman::Presentation::Component') }
|
|
6
|
+
|
|
7
|
+
before(:each) do
|
|
8
|
+
allow(component).to receive(:root_directory=)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
context '#add' do
|
|
12
|
+
it 'passes the bower directory to component' do
|
|
13
|
+
expect(component).to receive(:root_directory=).with('dir')
|
|
14
|
+
|
|
15
|
+
manager = ComponentsManager.new
|
|
16
|
+
manager.bower_directory = 'dir'
|
|
17
|
+
manager.add(component)
|
|
18
|
+
manager.available_components
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'outputs warning on unknown type' do
|
|
22
|
+
manager = ComponentsManager.new
|
|
23
|
+
|
|
24
|
+
result = capture :stderr do
|
|
25
|
+
manager.add('garbage')
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
expect(result).to include 'Sorry, but argument "garbage" needs to respond to "#root_directory="'
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
context '#available_components' do
|
|
33
|
+
it 'returns available fronted components' do
|
|
34
|
+
allow(component).to receive(:name).and_return('test1')
|
|
35
|
+
|
|
36
|
+
manager = ComponentsManager.new
|
|
37
|
+
manager.add(component)
|
|
38
|
+
|
|
39
|
+
expect(manager.available_components.first.name).to eq 'test1'
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'returns the frontend components in the order they were added' do
|
|
43
|
+
components = []
|
|
44
|
+
|
|
45
|
+
5.times do |i|
|
|
46
|
+
component = instance_double('Middleman::Presentation::Component')
|
|
47
|
+
allow(component).to receive(:name).and_return("test#{i - 1}")
|
|
48
|
+
allow(component).to receive(:root_directory=)
|
|
49
|
+
|
|
50
|
+
components << component
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
manager = ComponentsManager.new
|
|
54
|
+
manager.add(components[0])
|
|
55
|
+
manager.add(components[2])
|
|
56
|
+
manager.add(components[4])
|
|
57
|
+
manager.add(components[1])
|
|
58
|
+
manager.add(components[3])
|
|
59
|
+
manager.add(components[3])
|
|
60
|
+
manager.add(components[4])
|
|
61
|
+
manager.add(components[4])
|
|
62
|
+
|
|
63
|
+
expect(manager.available_components[0].name).to be components[0].name
|
|
64
|
+
expect(manager.available_components[1].name).to be components[2].name
|
|
65
|
+
expect(manager.available_components[2].name).to be components[4].name
|
|
66
|
+
expect(manager.available_components[3].name).to be components[1].name
|
|
67
|
+
expect(manager.available_components[4].name).to be components[3].name
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
context '#each_fetchable_component' do
|
|
72
|
+
it 'iterates over each fetchable component' do
|
|
73
|
+
expect(component).to receive(:fetchable?).and_return(true)
|
|
74
|
+
|
|
75
|
+
manager = ComponentsManager.new
|
|
76
|
+
manager.add(component)
|
|
77
|
+
|
|
78
|
+
result = []
|
|
79
|
+
manager.each_fetchable_component { |c| result << c }
|
|
80
|
+
|
|
81
|
+
expect(result.count).to eq 1
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
context '#each_nonfetchable_component' do
|
|
86
|
+
it 'iterates over each non fetchable component' do
|
|
87
|
+
expect(component).to receive(:fetchable?).and_return(false)
|
|
88
|
+
|
|
89
|
+
manager = ComponentsManager.new
|
|
90
|
+
manager.add(component)
|
|
91
|
+
|
|
92
|
+
result = []
|
|
93
|
+
manager.each_nonfetchable_component { |c| result << c }
|
|
94
|
+
|
|
95
|
+
expect(result.count).to eq 1
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
context '#root_directory=' do
|
|
100
|
+
it 'marks the cache as dirty' do
|
|
101
|
+
cache = instance_double('Middleman::Presentation::Cache')
|
|
102
|
+
expect(cache).to receive(:mark_dirty)
|
|
103
|
+
|
|
104
|
+
manager = ComponentsManager.new(cache: cache)
|
|
105
|
+
manager.bower_directory = 'asdf'
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
context '#to_s' do
|
|
110
|
+
it 'returns a string representation of self' do
|
|
111
|
+
allow(component).to receive(:name).and_return('test.d/test1')
|
|
112
|
+
allow(component).to receive(:resource_locator).and_return('http://www.example.com')
|
|
113
|
+
allow(component).to receive(:version).and_return('0.0.1')
|
|
114
|
+
allow(component).to receive(:base_path).and_return('test.d')
|
|
115
|
+
allow(component).to receive(:path).and_return('test.d/test1')
|
|
116
|
+
allow(component).to receive(:importable_files).and_return([])
|
|
117
|
+
allow(component).to receive(:loadable_files).and_return([])
|
|
118
|
+
allow(component).to receive(:ignorable_files).and_return([])
|
|
119
|
+
allow(component).to receive(:output_paths).and_return([])
|
|
120
|
+
|
|
121
|
+
manager = ComponentsManager.new
|
|
122
|
+
manager.add(component)
|
|
123
|
+
|
|
124
|
+
# rubocop:disable Style/TrailingWhitespace
|
|
125
|
+
expect(manager.to_s).to eq <<-EOS.strip_heredoc.chomp
|
|
126
|
+
************************ 1. row ************************
|
|
127
|
+
Name: test.d/test1
|
|
128
|
+
Path: test.d/test1
|
|
129
|
+
Base path: test.d
|
|
130
|
+
Resource locator: http://www.example.com
|
|
131
|
+
Version: 0.0.1
|
|
132
|
+
Importable files:
|
|
133
|
+
Loadable files:
|
|
134
|
+
Ignorable files:
|
|
135
|
+
Output paths:
|
|
136
|
+
1 row in set
|
|
137
|
+
EOS
|
|
138
|
+
# rubocop:enable Style/TrailingWhitespace
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
RSpec.describe CssClassExtracter do
|
|
5
|
+
context '#extract' do
|
|
6
|
+
it 'extract classes' do
|
|
7
|
+
file = write_file 'index.html', <<-EOS.strip_heredoc
|
|
8
|
+
<html class="hello">
|
|
9
|
+
</html>
|
|
10
|
+
EOS
|
|
11
|
+
|
|
12
|
+
klasses = CssClassExtracter.new.extract([absolute_path(file)])
|
|
13
|
+
expect(klasses.size).to eq 1
|
|
14
|
+
expect(klasses.first.name).to eq 'hello'
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'ignores classes' do
|
|
18
|
+
file = write_file 'index.html', <<-EOS.strip_heredoc
|
|
19
|
+
<html class="hello test">
|
|
20
|
+
</html>
|
|
21
|
+
EOS
|
|
22
|
+
|
|
23
|
+
klasses = CssClassExtracter.new.extract([absolute_path(file)], ignore: ['test'])
|
|
24
|
+
expect(klasses.size).to eq 1
|
|
25
|
+
expect(klasses.first.name).to eq 'hello'
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
RSpec.describe ExistingSlide do
|
|
5
|
+
|
|
6
|
+
context '#file_name' do
|
|
7
|
+
it 'extracts file name' do
|
|
8
|
+
slide1 = ExistingSlide.new(absolute_path('source', 'slides', '01.html.md'))
|
|
9
|
+
expect(slide1.file_name).to eq Pathname.new('01.html.md')
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it 'extracts file name with group' do
|
|
13
|
+
slide1 = ExistingSlide.new(absolute_path('source', 'slides', 'group', '01.html.md'))
|
|
14
|
+
expect(slide1.file_name).to eq Pathname.new('01.html.md')
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
context '#group' do
|
|
19
|
+
it 'extracts group name' do
|
|
20
|
+
slide1 = ExistingSlide.new(absolute_path('source', 'slides', 'group', '01.html.md'), base_path: absolute_path('source'))
|
|
21
|
+
expect(slide1.group).to eq 'group'
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'returns nil if no group name is available' do
|
|
25
|
+
slide1 = ExistingSlide.new(absolute_path('source', 'slides', '01.html.md'), base_path: absolute_path('source'))
|
|
26
|
+
expect(slide1.group).to be_nil
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
context '#path' do
|
|
31
|
+
it 'has path' do
|
|
32
|
+
path = absolute_path('source', 'slides', 'group', '01.html.md')
|
|
33
|
+
slide1 = ExistingSlide.new(path)
|
|
34
|
+
expect(slide1.path).to eq Pathname.new(path)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
context '#<=>' do
|
|
39
|
+
it 'compares slides with same file name' do
|
|
40
|
+
slide1 = ExistingSlide.new('01.html.md')
|
|
41
|
+
slide2 = ExistingSlide.new('01.html.md')
|
|
42
|
+
|
|
43
|
+
expect(slide1).to eq slide2
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it 'compares slides with different file names' do
|
|
47
|
+
slide1 = ExistingSlide.new('01.html.erb')
|
|
48
|
+
slide2 = ExistingSlide.new('01.html.md')
|
|
49
|
+
|
|
50
|
+
expect(slide1).not_to eq slide2
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
context '#eql?' do
|
|
55
|
+
it 'succeeds on eqal file names' do
|
|
56
|
+
slide1 = ExistingSlide.new('01.html.erb')
|
|
57
|
+
slide2 = ExistingSlide.new('01.html.erb')
|
|
58
|
+
|
|
59
|
+
expect(slide1.eql?(slide2)).to be_truthy
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it 'fails on different names' do
|
|
63
|
+
slide1 = ExistingSlide.new('01.html.erb')
|
|
64
|
+
slide2 = ExistingSlide.new('02.html.erb')
|
|
65
|
+
|
|
66
|
+
expect(slide1.eql?(slide2)).to be_falsey
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
context '#similar?' do
|
|
71
|
+
it 'succeeds if both files share the same base name' do
|
|
72
|
+
slide1 = ExistingSlide.new('01.html.erb')
|
|
73
|
+
slide2 = ExistingSlide.new('01.html.md')
|
|
74
|
+
|
|
75
|
+
expect(slide1).to be_similar slide2
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it 'fails if both files do not share the same basename' do
|
|
79
|
+
slide1 = ExistingSlide.new('01.html.erb')
|
|
80
|
+
slide2 = ExistingSlide.new('02.html.erb')
|
|
81
|
+
|
|
82
|
+
expect(slide1).not_to be_similar slide2
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
context '#hash' do
|
|
87
|
+
it 'generates hash based on file name' do
|
|
88
|
+
slide = ExistingSlide.new('01.html.erb')
|
|
89
|
+
expect(slide).to respond_to :hash
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
context '#exist?' do
|
|
94
|
+
it 'succeeds if slide file exists in filesystem' do
|
|
95
|
+
file = touch_file '02.html.md'
|
|
96
|
+
slide = ExistingSlide.new(absolute_path(file))
|
|
97
|
+
|
|
98
|
+
expect(slide).to be_exist
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
it 'fails if slide file does not exists in filesystem' do
|
|
102
|
+
slide = ExistingSlide.new(SecureRandom.hex)
|
|
103
|
+
|
|
104
|
+
expect(slide).not_to be_exist
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
context '#to_s' do
|
|
109
|
+
it 'returns string representation of self' do
|
|
110
|
+
slide = ExistingSlide.new('02.html.md')
|
|
111
|
+
|
|
112
|
+
expect(slide.to_s).to eq '02.html.md'
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
context '#base_name' do
|
|
117
|
+
it 'reduces slide file name to minimum' do
|
|
118
|
+
slide = ExistingSlide.new(absolute_path('02.html.erb'))
|
|
119
|
+
expect(slide.base_name).to eq '02'
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
context '#ext_name' do
|
|
124
|
+
it 'reduces slide file name to minimum' do
|
|
125
|
+
slide = ExistingSlide.new(absolute_path('02.html.erb'))
|
|
126
|
+
expect(slide.ext_name).to eq '.html.erb'
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
context '#match?' do
|
|
131
|
+
it 'matches full path' do
|
|
132
|
+
slide = ExistingSlide.new(absolute_path('02.html.md'))
|
|
133
|
+
|
|
134
|
+
expect(slide).to be_match(/02/)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
it 'supports string' do
|
|
138
|
+
slide = ExistingSlide.new(absolute_path('02.html.md'))
|
|
139
|
+
|
|
140
|
+
expect(slide).to be_match('02')
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
context '#group?' do
|
|
145
|
+
it 'succeeds if slide has group' do
|
|
146
|
+
slide = ExistingSlide.new(absolute_path('source', 'slides', 'group', '02.html.md'), base_path: absolute_path('source'))
|
|
147
|
+
|
|
148
|
+
expect(slide).to be_group 'group'
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
it 'fails if slide has not group' do
|
|
152
|
+
slide = ExistingSlide.new(absolute_path('source', 'slides', '02.html.md'), base_path: absolute_path('source'))
|
|
153
|
+
|
|
154
|
+
expect(slide).not_to be_group 'group'
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
context '#partial_path' do
|
|
159
|
+
it 'returns path based on base without extensions' do
|
|
160
|
+
slide = ExistingSlide.new(absolute_path('slides', '02.html.md'), base_path: absolute_path('.'))
|
|
161
|
+
|
|
162
|
+
expect(slide.partial_path).to eq Pathname.new('slides/02')
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
context '#render' do
|
|
167
|
+
it 'passes the path to a render block' do
|
|
168
|
+
slide = ExistingSlide.new(absolute_path('slides', '02.html.md'), base_path: absolute_path('.'))
|
|
169
|
+
result = slide.render { |partial_path| partial_path }
|
|
170
|
+
|
|
171
|
+
expect(result).to eq <<-EOS.strip_heredoc.chomp
|
|
172
|
+
<!-- #{slide.relative_path} -->
|
|
173
|
+
#{slide.path}
|
|
174
|
+
EOS
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
end
|