Class: Middleman::Presentation::Cli::ChangeSlide
- Defined in:
- lib/middleman-presentation-core/cli/change_slide.rb
Overview
Create slide
Instance Method Summary collapse
Methods included from Shared
#assets_loader, #bower_path, #enable_debug_mode, included, #open_in_editor
Instance Method Details
#change_slide ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/middleman-presentation-core/cli/change_slide.rb', line 19 def enable_debug_mode fail ArgumentError, Middleman::Presentation.t('errors.too_many_arguments', count: 1) if names.count > 1 && .key?('base_name') = SlideList.new( Dir.glob(File.join(@environment., '**', '*')), slide_builder: ExistingSlide, base_path: @environment.sources_directory ) do |l| l.transform_with Transformers::FileKeeper.new end = .select do |s| if names.blank? true else if [:regex] names.any? { |n| s.base_name =~ /#{n}/ } else names.any? { |n| s.base_name == n } end end end if .blank? Middleman::Presentation.logger.warn Middleman::Presentation.t('errors.slide_not_found', patterns: names.to_list) return end move_jobs = .sort.map do || = SlideName.new( , base_name: [:base_name], type: [:type] ) = NewSlide.new( File.join(@environment., .to_s), base_path: @environment. ) OpenStruct.new( source: , destination: ) end move_jobs.each do |j| if j.source == j.destination $stderr.puts format('%-20s %-s -> %-s', 'ignore'.colorize(color: :yellow, mode: :bold), j.source.relative_path, j.destination.relative_path) next end $stderr.puts format('%-20s %-s -> %-s', 'rename '.colorize(color: :green, mode: :bold), j.source.relative_path, j.destination.relative_path) FileUtils.mv j.source.path, j.destination.path, force: true end invoke 'middleman:presentation:cli:edit_slide', move_jobs.map(&:destination).map(&:base_name), .extract!('editor_command') if ['edit'] end |
#make_middleman_environment_available ⇒ Object
15 16 17 |
# File 'lib/middleman-presentation-core/cli/change_slide.rb', line 15 def make_middleman_environment_available @environment = MiddlemanEnvironment.new end |