Sha256: 3df54dd328ca22e632c39b4563c057a061679032d908a5200e563750df3d5d21

Contents?: true

Size: 1.13 KB

Versions: 4

Compression:

Stored size: 1.13 KB

Contents

require 'webrick'
module HighFive
  module Thor
    module Tasks
      class Development < ::HighFive::Thor::Task
        include ::Thor::Actions
        
        desc "server", "Run a web server for a specific environment or path"
        method_option :platform, :aliases => "-e", :desc => "Environemnt [production|development]", :default => "development"
        method_option :platform_path, :desc => "Path to ios or android directory for the platform we want to serve"
        def server(platform="web")
          root = nil
          if options[:platform_path]
            [File.join(options[:platform_path], 'www'), File.join(options[:platform_path], 'assets', 'www')].each do |path|
              if File.exist? path
                root = path
                break
              end
            end
          else
            root = base_config.build_platform_config(platform).destination_root
          end

          puts "Starting server with root=#{root}"

          server = WEBrick::HTTPServer.new(:Port => 3000, :DocumentRoot => root)
          trap 'INT' do server.shutdown end
          server.start
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
high_five-0.2.10 lib/high_five/thor/tasks/development.rb
high_five-0.2.9 lib/high_five/thor/tasks/development.rb
high_five-0.2.8 lib/high_five/thor/tasks/development.rb
high_five-0.2.7 lib/high_five/thor/tasks/development.rb