Sha256: 316d124e3dcc93e75d6808b5e09bde556b9840e740677eac0f0997f46f4f1afb

Contents?: true

Size: 769 Bytes

Versions: 2

Compression:

Stored size: 769 Bytes

Contents

module EmberCli
  class Runner
    TRUE_PROC = ->(*){ true }

    attr_reader :app, :path

    def initialize(app, path)
      @app, @path = app, path
    end

    def process
      return if skip?

      if EmberCli.env.development?
        start_or_restart!
      else
        compile!
      end

      wait!
    end

    private

    def skip?
      invoker = app.options.fetch(:enable, TRUE_PROC)
      !invoker.call(path)
    end

    def start_or_restart!
      run! unless app.pid && still_running?
    end

    def still_running?
      Process.getpgid app.pid
      true
    rescue Errno::ESRCH # no such process
      false
    end

    def wait!
      app.wait
    end

    def compile!
      app.compile
    end

    def run!
      app.run
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ember-cli-rails-0.4.3 lib/ember-cli/runner.rb
ember-cli-rails-0.4.2 lib/ember-cli/runner.rb