Sha256: 5d1dfddbd2faecebc0faa34b72486bf66aad058eac185f21210ed6b65680cb6a

Contents?: true

Size: 1.33 KB

Versions: 11

Compression:

Stored size: 1.33 KB

Contents

# encoding: utf-8
module Middleman
  module Presentation
    module Cli
      # Bundle shared methods for all cli classes
      module Shared
        def self.included(base)
          base.extend ClassMethods
        end

        # Enable debug mode
        def enable_debug_mode
          Middleman::Presentation.enable_debug_mode if options[:debug_mode] == true
        end

        # Create bower directory
        def bower_path
          MiddlemanEnvironment.new.bower_path
        end

        # Create assets loader base on bower directory
        def assets_loader
          return @assets_loader if @assets_loader

          @assets_loader = Middleman::Presentation::AssetsLoader.new(bower_directory: bower_path)
        end

        def open_in_editor(paths)
          editor = []

          begin
            editor << Erubis::Eruby.new(options[:editor_command]).result(Middleman::Presentation.config.to_h)
          rescue NameError => e
            $stderr.puts Middleman::Presentation.t('errors.missing_data_attribute', message: e.message)
          end
          editor.concat paths

          Middleman::Presentation.logger.warn Middleman::Presentation.t('infos.open_slide_in_editor', editor: editor.first)
          system(editor.join(' '))
        end

        # The class methods
        module ClassMethods
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
middleman-presentation-core-0.17.7 lib/middleman-presentation-core/cli/shared.rb
middleman-presentation-core-0.17.6 lib/middleman-presentation-core/cli/shared.rb
middleman-presentation-core-0.17.5 lib/middleman-presentation-core/cli/shared.rb
middleman-presentation-core-0.17.2 lib/middleman-presentation-core/cli/shared.rb
middleman-presentation-core-0.17.1 lib/middleman-presentation-core/cli/shared.rb
middleman-presentation-core-0.17.0 lib/middleman-presentation-core/cli/shared.rb
middleman-presentation-core-0.16.3 lib/middleman-presentation-core/cli/shared.rb
middleman-presentation-core-0.16.2 lib/middleman-presentation-core/cli/shared.rb
middleman-presentation-core-0.16.0 lib/middleman-presentation-core/cli/shared.rb
middleman-presentation-core-0.16.0.rc2 lib/middleman-presentation-core/cli/shared.rb
middleman-presentation-core-0.16.0.rc1 lib/middleman-presentation-core/cli/shared.rb