Sha256: de0932cf3a5620f8fd2393310709fd3f07f9a5386b620830ab4be63df7f51652

Contents?: true

Size: 1.84 KB

Versions: 7

Compression:

Stored size: 1.84 KB

Contents

module RevealCK
  module Commands
    # This Command is responsible for implementing the idea behind
    # "reveal-ck serve."
    #
    # This includes taking an action and managing stdout
    class Serve
      include Retrieve
      attr_reader :doc_root, :port, :host
      attr_reader :slides_file, :user_dir, :gem_dir, :output_dir
      attr_reader :ui
      def initialize(args)
        @doc_root    = retrieve(:doc_root, args)
        @port        = retrieve(:port, args)
        @host        = retrieve(:host, args)
        @slides_file = retrieve(:slides_file, args)
        @gem_dir     = retrieve(:gem_dir, args)
        @output_dir  = retrieve(:output_dir, args)
        @user_dir    = retrieve(:user_dir, args)
        @ui          = ServeUI.new
      end

      def run
        print_banner
        listen_to_reload
        listen_to_rebuild
        start_web_server
      end

      def rebuild_slides
        RevealCK::Commands::Generate.new(rebuild_options).run
      rescue => error
        ui.problem('Failed to Generate Slides:', error)
      end

      private

      def print_banner
        PrintBanner.new(doc_root, port, host, slides_file, ui).run
      end

      def listen_to_reload
        ui.message('Getting Ready to Reload Browsers.')
        ListenToReloadBrowser.new(ui).run
      end

      def listen_to_rebuild
        ui.message('Getting Ready to Rebuild Slides.')
        ListenToRebuildSlides.new(ui) do
          rebuild_slides
        end.run
      end

      def start_web_server
        ui.message('Starting Webserver.')
        StartWebServer.new(doc_root, port, host).run
      end

      def rebuild_options
        {
          slides_file: @slides_file,
          gem_dir: @gem_dir,
          output_dir: @output_dir,
          user_dir: @user_dir,
          stdout_prefix: ui.prefix_for(:rebuild)
        }
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
reveal-ck-3.9.0 lib/reveal-ck/commands/serve.rb
reveal-ck-3.8.1 lib/reveal-ck/commands/serve.rb
reveal-ck-3.8.0 lib/reveal-ck/commands/serve.rb
reveal-ck-3.7.0 lib/reveal-ck/commands/serve.rb
reveal-ck-3.6.0 lib/reveal-ck/commands/serve.rb
reveal-ck-3.5.1 lib/reveal-ck/commands/serve.rb
reveal-ck-3.5.0 lib/reveal-ck/commands/serve.rb