Sha256: 8485787d04c4aacfb59f69f084b0f75d28d9db88496944ba1e378c734080ce55

Contents?: true

Size: 1.78 KB

Versions: 12

Compression:

Stored size: 1.78 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
      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)
        @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, 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).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

12 entries across 12 versions & 1 rubygems

Version Path
reveal-ck-3.4.0 lib/reveal-ck/commands/serve.rb
reveal-ck-3.3.1 lib/reveal-ck/commands/serve.rb
reveal-ck-3.3.0 lib/reveal-ck/commands/serve.rb
reveal-ck-3.2.0 lib/reveal-ck/commands/serve.rb
reveal-ck-3.1.0 lib/reveal-ck/commands/serve.rb
reveal-ck-3.0.1 lib/reveal-ck/commands/serve.rb
reveal-ck-3.0.0 lib/reveal-ck/commands/serve.rb
reveal-ck-0.6.2 lib/reveal-ck/commands/serve.rb
reveal-ck-0.6.1 lib/reveal-ck/commands/serve.rb
reveal-ck-0.6.0 lib/reveal-ck/commands/serve.rb
reveal-ck-0.5.1 lib/reveal-ck/commands/serve.rb
reveal-ck-0.5.0 lib/reveal-ck/commands/serve.rb